✨ config.ts
This commit is contained in:
parent
a51127acd3
commit
e1ed7ed0a2
73 changed files with 832 additions and 629 deletions
|
|
@ -1,24 +1,5 @@
|
|||
import { CustomCommand, SlashCommandDescription } from "../config";
|
||||
import { IDE } from "../ide/types";
|
||||
import { LLM } from "../llm";
|
||||
import { ChatMessage, ContextItem } from "../llm/types";
|
||||
import { CustomCommand, SlashCommand, SlashCommandDescription } from "..";
|
||||
import SlashCommands from "./slash";
|
||||
export interface ContinueSDK {
|
||||
ide: IDE;
|
||||
llm: LLM;
|
||||
addContextItem: (item: ContextItem) => void;
|
||||
history: ChatMessage[];
|
||||
input: string;
|
||||
params?: any;
|
||||
contextItems: ContextItem[];
|
||||
}
|
||||
|
||||
export interface SlashCommand {
|
||||
name: string;
|
||||
description: string;
|
||||
params?: { [key: string]: any };
|
||||
run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
|
||||
}
|
||||
|
||||
export function slashFromCustomCommand(
|
||||
customCommand: CustomCommand
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { SlashCommand } from "..";
|
||||
import { SlashCommand } from "../..";
|
||||
import { removeQuotesAndEscapes } from "../../util";
|
||||
|
||||
const GenerateTerminalCommand: SlashCommand = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { SlashCommand } from "..";
|
||||
import { SlashCommand } from "../..";
|
||||
import EditSlashCommand from "./edit";
|
||||
|
||||
const CommentSlashCommand: SlashCommand = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { SlashCommand } from "..";
|
||||
import { ChatMessage } from "../../llm/types";
|
||||
import { ChatMessage, SlashCommand } from "../..";
|
||||
import { removeQuotesAndEscapes } from "../../util";
|
||||
|
||||
const PROMPT = (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { SlashCommand } from "..";
|
||||
import { LLM } from "../../llm";
|
||||
import { ContextItem } from "../../llm/types";
|
||||
import { ContextItem, ILLM, SlashCommand } from "../..";
|
||||
import { dedentAndGetCommonWhitespace, renderPromptTemplate } from "../../util";
|
||||
|
||||
interface RangeInFileWithContents {
|
||||
|
|
@ -50,7 +48,7 @@ Main task:
|
|||
export async function getPromptParts(
|
||||
rif: RangeInFileWithContents,
|
||||
fullFileContents: string,
|
||||
model: LLM,
|
||||
model: ILLM,
|
||||
input: string
|
||||
) {
|
||||
let maxTokens = Math.floor(model.contextLength / 2);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { SlashCommand } from "..";
|
||||
import { SlashCommand } from "../..";
|
||||
|
||||
const ShareSlashCommand: SlashCommand = {
|
||||
name: "share",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { SlashCommand } from "..";
|
||||
import { ChatMessageRole, SlashCommand } from "../..";
|
||||
import { pruneStringFromBottom } from "../../llm/countTokens";
|
||||
import { ChatMessageRole } from "../../llm/types";
|
||||
|
||||
const SERVER_URL = "https://proxy-server-l6vsfbzhba-uw.a.run.app";
|
||||
const PROMPT = (
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { SerializedContinueConfig } from ".";
|
||||
import { SerializedContinueConfig } from "..";
|
||||
|
||||
const defaultConfig: SerializedContinueConfig = {
|
||||
models: [
|
||||
|
|
|
|||
207
core/config/index.d.ts
vendored
207
core/config/index.d.ts
vendored
|
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
|
||||
These are the types for the JSON config file, config.json.
|
||||
|
||||
**/
|
||||
|
||||
import { SlashCommand } from "../commands/index";
|
||||
import { ContextProvider } from "../context";
|
||||
import { LLM } from "../llm";
|
||||
|
||||
type StepName =
|
||||
| "AnswerQuestionChroma"
|
||||
| "GenerateShellCommandStep"
|
||||
| "EditHighlightedCodeStep"
|
||||
| "ShareSessionStep"
|
||||
| "CommentCodeStep"
|
||||
| "ClearHistoryStep"
|
||||
| "StackOverflowStep"
|
||||
| "OpenConfigStep"
|
||||
| "GenerateShellCommandStep"
|
||||
| "DraftIssueStep";
|
||||
|
||||
type ContextProviderName =
|
||||
| "diff"
|
||||
| "github"
|
||||
| "terminal"
|
||||
| "open"
|
||||
| "google"
|
||||
| "search"
|
||||
| "url"
|
||||
| "tree";
|
||||
|
||||
type TemplateType =
|
||||
| "llama2"
|
||||
| "alpaca"
|
||||
| "zephyr"
|
||||
| "phind"
|
||||
| "anthropic"
|
||||
| "chatml"
|
||||
| "deepseek";
|
||||
|
||||
type ModelProvider =
|
||||
| "openai"
|
||||
| "openai-free-trial"
|
||||
| "openai-aiohttp"
|
||||
| "anthropic"
|
||||
| "together"
|
||||
| "ollama"
|
||||
| "huggingface-tgi"
|
||||
| "huggingface-inference-api"
|
||||
| "llama.cpp"
|
||||
| "replicate"
|
||||
| "text-gen-webui"
|
||||
| "google-palm"
|
||||
| "google-palm-real"
|
||||
| "lmstudio"
|
||||
| "llamafile"
|
||||
| "gemini"
|
||||
| "mistral";
|
||||
|
||||
export type ModelName =
|
||||
// OpenAI
|
||||
| "gpt-3.5-turbo"
|
||||
| "gpt-3.5-turbo-16k"
|
||||
| "gpt-4"
|
||||
| "gpt-3.5-turbo-0613"
|
||||
| "gpt-4-32k"
|
||||
| "gpt-4-1106-preview"
|
||||
// Open Source
|
||||
| "mistral-7b"
|
||||
| "mistral-8x7b"
|
||||
| "llama2-7b"
|
||||
| "llama2-13b"
|
||||
| "codellama-7b"
|
||||
| "codellama-13b"
|
||||
| "codellama-34b"
|
||||
| "phind-codellama-34b"
|
||||
| "wizardcoder-7b"
|
||||
| "wizardcoder-13b"
|
||||
| "wizardcoder-34b"
|
||||
| "zephyr-7b"
|
||||
| "codeup-13b"
|
||||
| "deepseek-1b"
|
||||
| "deepseek-7b"
|
||||
| "deepseek-33b"
|
||||
// Anthropic
|
||||
| "claude-2"
|
||||
// Google PaLM
|
||||
| "chat-bison-001"
|
||||
// Gemini
|
||||
| "gemini-pro";
|
||||
|
||||
interface RequestOptions {
|
||||
timeout?: number;
|
||||
verifySsl?: boolean;
|
||||
caBundlePath: string;
|
||||
proxy?: string;
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
|
||||
interface StepWithParams {
|
||||
name: StepName;
|
||||
params: { [key: string]: any };
|
||||
}
|
||||
|
||||
interface ContextProviderWithParams {
|
||||
name: ContextProviderName;
|
||||
params: { [key: string]: any };
|
||||
}
|
||||
|
||||
interface SlashCommandDescription {
|
||||
name: string;
|
||||
description: string;
|
||||
step: StepName | string;
|
||||
params?: { [key: string]: any };
|
||||
}
|
||||
|
||||
interface CustomCommand {
|
||||
name: string;
|
||||
prompt: string;
|
||||
description: string;
|
||||
}
|
||||
interface RetrievalSettings {
|
||||
nRetrieve?: number;
|
||||
nFinal?: number;
|
||||
useReranking: boolean;
|
||||
rerankGroupSize: number;
|
||||
ignoreFiles: string[];
|
||||
openaiApiKey?: string;
|
||||
apiBase?: string;
|
||||
apiType?: string;
|
||||
apiVersion?: string;
|
||||
organizationId?: string;
|
||||
}
|
||||
|
||||
interface BaseCompletionOptions {
|
||||
temperature?: number;
|
||||
topP?: number;
|
||||
topK?: number;
|
||||
presencePenalty?: number;
|
||||
frequencyPenalty?: number;
|
||||
stop?: string[];
|
||||
maxTokens: number;
|
||||
}
|
||||
|
||||
interface ModelDescription {
|
||||
title: string;
|
||||
provider: ModelProvider;
|
||||
model: string;
|
||||
apiKey?: string;
|
||||
apiBase?: string;
|
||||
contextLength?: number;
|
||||
template?: TemplateType;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
systemMessage?: string;
|
||||
requestOptions?: RequestOptions;
|
||||
}
|
||||
|
||||
interface ModelRoles {
|
||||
default: string;
|
||||
chat?: string;
|
||||
edit?: string;
|
||||
summarize?: string;
|
||||
}
|
||||
|
||||
interface SerializedContinueConfig {
|
||||
disallowedSteps?: string[];
|
||||
allowAnonymousTelemetry?: boolean;
|
||||
models: ModelDescription[];
|
||||
modelRoles: ModelRoles;
|
||||
systemMessage?: string;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
slashCommands?: SlashCommandDescription[];
|
||||
customCommands?: CustomCommand[];
|
||||
contextProviders?: ContextProviderWithParams[];
|
||||
retrievalSettings?: RetrievalSettings;
|
||||
disableIndexing?: boolean;
|
||||
}
|
||||
|
||||
interface ContinueConfig {
|
||||
allowAnonymousTelemetry?: boolean;
|
||||
models: LLM[];
|
||||
systemMessage?: string;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
slashCommands?: SlashCommand[];
|
||||
contextProviders?: ContextProvider[];
|
||||
retrievalSettings?: RetrievalSettings;
|
||||
disableIndexing?: boolean;
|
||||
}
|
||||
|
||||
export {
|
||||
BaseCompletionOptions,
|
||||
ContextProviderName,
|
||||
ContextProviderWithParams,
|
||||
ContinueConfig,
|
||||
CustomCommand,
|
||||
ModelDescription,
|
||||
ModelProvider,
|
||||
ModelRoles,
|
||||
RequestOptions,
|
||||
RetrievalSettings,
|
||||
SerializedContinueConfig,
|
||||
SlashCommandDescription,
|
||||
StepName,
|
||||
StepWithParams,
|
||||
TemplateType,
|
||||
};
|
||||
|
|
@ -1,25 +1,28 @@
|
|||
import { ContinueConfig, SerializedContinueConfig } from ".";
|
||||
import {
|
||||
Config,
|
||||
ContextProviderWithParams,
|
||||
ContinueConfig,
|
||||
CustomContextProvider,
|
||||
CustomLLM,
|
||||
IContextProvider,
|
||||
ModelDescription,
|
||||
SerializedContinueConfig,
|
||||
SlashCommand,
|
||||
} from "..";
|
||||
import {
|
||||
slashCommandFromDescription,
|
||||
slashFromCustomCommand,
|
||||
} from "../commands";
|
||||
import { ContextProvider } from "../context";
|
||||
import { contextProviderClassFromName } from "../context/providers";
|
||||
import CustomContextProviderClass from "../context/providers/CustomContextProvider";
|
||||
import FileContextProvider from "../context/providers/FileContextProvider";
|
||||
import { LLM } from "../llm";
|
||||
import { BaseLLM } from "../llm";
|
||||
import { llmFromDescription } from "../llm/llms";
|
||||
import CustomLLMClass from "../llm/llms/CustomLLM";
|
||||
|
||||
function loadSerializedConfig(
|
||||
function serializedToIntermediateConfig(
|
||||
initial: SerializedContinueConfig
|
||||
): ContinueConfig {
|
||||
const models: LLM[] = [];
|
||||
for (const desc of initial.models) {
|
||||
const llm = llmFromDescription(desc, initial.completionOptions);
|
||||
if (!llm) continue;
|
||||
models.push(llm);
|
||||
}
|
||||
|
||||
): Config {
|
||||
const slashCommands: SlashCommand[] = [];
|
||||
for (const command of initial.slashCommands || []) {
|
||||
const newCommand = slashCommandFromDescription(command);
|
||||
|
|
@ -31,23 +34,13 @@ function loadSerializedConfig(
|
|||
slashCommands.push(slashFromCustomCommand(command));
|
||||
}
|
||||
|
||||
const contextProviders: ContextProvider[] = [new FileContextProvider({})];
|
||||
for (const provider of initial.contextProviders || []) {
|
||||
const cls = contextProviderClassFromName(provider.name) as any;
|
||||
if (!cls) {
|
||||
console.warn(`Unknown context provider ${provider.name}`);
|
||||
continue;
|
||||
}
|
||||
contextProviders.push(new cls(provider.params));
|
||||
}
|
||||
|
||||
const config: ContinueConfig = {
|
||||
const config: Config = {
|
||||
allowAnonymousTelemetry: initial.allowAnonymousTelemetry,
|
||||
models,
|
||||
models: initial.models,
|
||||
systemMessage: initial.systemMessage,
|
||||
completionOptions: initial.completionOptions,
|
||||
slashCommands,
|
||||
contextProviders,
|
||||
contextProviders: initial.contextProviders || [],
|
||||
retrievalSettings: initial.retrievalSettings,
|
||||
disableIndexing: initial.disableIndexing,
|
||||
};
|
||||
|
|
@ -55,4 +48,51 @@ function loadSerializedConfig(
|
|||
return config;
|
||||
}
|
||||
|
||||
export { loadSerializedConfig };
|
||||
function isModelDescription(
|
||||
llm: ModelDescription | CustomLLM
|
||||
): llm is ModelDescription {
|
||||
return (llm as ModelDescription).title !== undefined;
|
||||
}
|
||||
|
||||
function isContextProviderWithParams(
|
||||
contextProvider: CustomContextProvider | ContextProviderWithParams
|
||||
): contextProvider is ContextProviderWithParams {
|
||||
return (contextProvider as ContextProviderWithParams).name !== undefined;
|
||||
}
|
||||
|
||||
/** Only difference between intermediate and final configs is the `models` array */
|
||||
function intermediateToFinalConfig(config: Config): ContinueConfig {
|
||||
const models: BaseLLM[] = [];
|
||||
for (const desc of config.models) {
|
||||
let llm: BaseLLM | undefined;
|
||||
if (isModelDescription(desc)) {
|
||||
llm = llmFromDescription(desc, config.completionOptions);
|
||||
} else {
|
||||
llm = new CustomLLMClass(desc);
|
||||
}
|
||||
if (!llm) continue;
|
||||
models.push(llm);
|
||||
}
|
||||
|
||||
const contextProviders: IContextProvider[] = [new FileContextProvider({})];
|
||||
for (const provider of config.contextProviders || []) {
|
||||
if (isContextProviderWithParams(provider)) {
|
||||
const cls = contextProviderClassFromName(provider.name) as any;
|
||||
if (!cls) {
|
||||
console.warn(`Unknown context provider ${provider.name}`);
|
||||
continue;
|
||||
}
|
||||
contextProviders.push(new cls(provider.params));
|
||||
} else {
|
||||
contextProviders.push(new CustomContextProviderClass(provider));
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...config,
|
||||
contextProviders,
|
||||
models,
|
||||
};
|
||||
}
|
||||
|
||||
export { intermediateToFinalConfig, serializedToIntermediateConfig };
|
||||
|
|
|
|||
|
|
@ -1,15 +1,8 @@
|
|||
import { ContextItem } from "../llm/types";
|
||||
import { ContextItem, ContextProviderDescription, IContextProvider } from "..";
|
||||
|
||||
export interface ContextProviderDescription {
|
||||
title: string;
|
||||
displayTitle: string;
|
||||
description: string;
|
||||
dynamic: boolean;
|
||||
requiresQuery: boolean;
|
||||
}
|
||||
|
||||
export abstract class ContextProvider {
|
||||
export abstract class BaseContextProvider implements IContextProvider {
|
||||
options: Object;
|
||||
|
||||
constructor(options: Object) {
|
||||
this.options = options;
|
||||
}
|
||||
|
|
|
|||
30
core/context/providers/CustomContextProvider.ts
Normal file
30
core/context/providers/CustomContextProvider.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import {
|
||||
ContextItem,
|
||||
ContextProviderDescription,
|
||||
CustomContextProvider,
|
||||
IContextProvider,
|
||||
} from "../..";
|
||||
|
||||
class CustomContextProviderClass implements IContextProvider {
|
||||
custom: CustomContextProvider;
|
||||
constructor(custom: CustomContextProvider) {
|
||||
this.custom = custom;
|
||||
}
|
||||
|
||||
get description(): ContextProviderDescription {
|
||||
return {
|
||||
title: this.custom.title,
|
||||
displayTitle: this.custom.displayTitle || this.custom.title,
|
||||
description: this.custom.description || "",
|
||||
dynamic: true,
|
||||
requiresQuery: false,
|
||||
};
|
||||
}
|
||||
|
||||
async getContextItems(query: string): Promise<ContextItem[]> {
|
||||
return await this.custom.getContextItems(query);
|
||||
}
|
||||
async load(): Promise<void> {}
|
||||
}
|
||||
|
||||
export default CustomContextProviderClass;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
import { v4 } from "uuid";
|
||||
import { ContextProvider, ContextProviderDescription } from "..";
|
||||
import { BaseContextProvider } from "..";
|
||||
import { ContextItem, ContextProviderDescription } from "../..";
|
||||
import { ExtensionIde } from "../../ide";
|
||||
import { ContextItem } from "../../llm/types";
|
||||
|
||||
class DiffContextProvider extends ContextProvider {
|
||||
class DiffContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "diff",
|
||||
displayTitle: "Git Diff",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { ContextProvider, ContextProviderDescription } from "..";
|
||||
import { BaseContextProvider } from "..";
|
||||
import { ContextItem, ContextProviderDescription } from "../..";
|
||||
import { ExtensionIde } from "../../ide";
|
||||
import { ContextItem } from "../../llm/types";
|
||||
|
||||
class FileContextProvider extends ContextProvider {
|
||||
class FileContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "file",
|
||||
displayTitle: "Files",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { ContextProvider, ContextProviderDescription } from "..";
|
||||
import { BaseContextProvider } from "..";
|
||||
import { ContextItem, ContextProviderDescription } from "../..";
|
||||
import { ExtensionIde } from "../../ide";
|
||||
import { ContextItem } from "../../llm/types";
|
||||
|
||||
interface Directory {
|
||||
name: string;
|
||||
|
|
@ -31,7 +31,7 @@ function formatFileTree(tree: Directory, indentation: string = ""): string {
|
|||
return result;
|
||||
}
|
||||
|
||||
class FileTreeContextProvider extends ContextProvider {
|
||||
class FileTreeContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "tree",
|
||||
displayTitle: "File Tree",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ContextProvider, ContextProviderDescription } from "..";
|
||||
import { ExtensionIde } from "../../ide";
|
||||
import { ContextItem } from "../../llm/types";
|
||||
import { BaseContextProvider } from "..";
|
||||
import { ContextItem, ContextProviderDescription } from "../..";
|
||||
|
||||
class GitHubIssuesContextProvider extends ContextProvider {
|
||||
class GitHubIssuesContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "github",
|
||||
displayTitle: "GitHub Issues",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ContextProvider, ContextProviderDescription } from "..";
|
||||
import { ExtensionIde } from "../../ide";
|
||||
import { ContextItem } from "../../llm/types";
|
||||
import { BaseContextProvider } from "..";
|
||||
import { ContextItem, ContextProviderDescription } from "../..";
|
||||
|
||||
class GoogleContextProvider extends ContextProvider {
|
||||
class GoogleContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "google",
|
||||
displayTitle: "Google",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { v4 } from "uuid";
|
||||
import { ContextProvider, ContextProviderDescription } from "..";
|
||||
import { BaseContextProvider } from "..";
|
||||
import { ContextItem, ContextProviderDescription } from "../..";
|
||||
import { ExtensionIde } from "../../ide";
|
||||
import { ContextItem } from "../../llm/types";
|
||||
|
||||
class TerminalContextProvider extends ContextProvider {
|
||||
class TerminalContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "terminal",
|
||||
displayTitle: "Terminal",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ContextProvider, ContextProviderDescription } from "..";
|
||||
import { ContextItem } from "../../llm/types";
|
||||
import { BaseContextProvider } from "..";
|
||||
import { ContextItem, ContextProviderDescription } from "../..";
|
||||
|
||||
class URLContextProvider extends ContextProvider {
|
||||
class URLContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "url",
|
||||
displayTitle: "URL",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ContextProvider } from "..";
|
||||
import { ContextProviderName } from "../../config";
|
||||
import { BaseContextProvider } from "..";
|
||||
import { ContextProviderName } from "../..";
|
||||
import DiffContextProvider from "./DiffContextProvider";
|
||||
import FileTreeContextProvider from "./FileTreeContextProvider";
|
||||
import GitHubIssuesContextProvider from "./GitHubIssuesContextProvider";
|
||||
|
|
@ -7,7 +7,7 @@ import GoogleContextProvider from "./GoogleContextProvider";
|
|||
import TerminalContextProvider from "./TerminalContextProvider";
|
||||
import URLContextProvider from "./URLContextProvider";
|
||||
|
||||
const Providers: (typeof ContextProvider)[] = [
|
||||
const Providers: (typeof BaseContextProvider)[] = [
|
||||
DiffContextProvider,
|
||||
FileTreeContextProvider,
|
||||
GitHubIssuesContextProvider,
|
||||
|
|
@ -18,7 +18,7 @@ const Providers: (typeof ContextProvider)[] = [
|
|||
|
||||
export function contextProviderClassFromName(
|
||||
name: ContextProviderName
|
||||
): typeof ContextProvider | undefined {
|
||||
): typeof BaseContextProvider | undefined {
|
||||
const cls = Providers.find((cls) => cls.description.title === name);
|
||||
|
||||
if (!cls) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import * as fs from "fs";
|
||||
import { SerializedContinueConfig } from "../config";
|
||||
import { IDE, SerializedContinueConfig } from "..";
|
||||
import {
|
||||
getConfigJsonPath,
|
||||
getConfigTsPath,
|
||||
getContinueGlobalPath,
|
||||
} from "../util/paths";
|
||||
import { IDE } from "./types";
|
||||
|
||||
class FileSystemIde implements IDE {
|
||||
async getSerializedConfig(): Promise<SerializedContinueConfig> {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { IDE, SerializedContinueConfig } from "../index";
|
||||
import { ideRequest } from "./messaging";
|
||||
import { IDE } from "./types";
|
||||
async function r(messageType: string, options: any = {}) {
|
||||
return await ideRequest(messageType, options);
|
||||
}
|
||||
export class ExtensionIde implements IDE {
|
||||
async getSerializedConfig() {
|
||||
async getSerializedConfig(): Promise<SerializedContinueConfig> {
|
||||
return await r("getSerializedConfig");
|
||||
}
|
||||
|
||||
|
|
|
|||
24
core/ide/types.d.ts
vendored
24
core/ide/types.d.ts
vendored
|
|
@ -1,24 +0,0 @@
|
|||
import { SerializedContinueConfig } from "../config";
|
||||
|
||||
interface IDE {
|
||||
getSerializedConfig(): Promise<SerializedContinueConfig>;
|
||||
getConfigJsUrl(): Promise<string | undefined>;
|
||||
getDiff(): Promise<string>;
|
||||
getTerminalContents(): Promise<string>;
|
||||
listWorkspaceContents(): Promise<string[]>;
|
||||
getWorkspaceDir(): Promise<string>;
|
||||
writeFile(path: string, contents: string): Promise<void>;
|
||||
showVirtualFile(title: string, contents: string): Promise<void>;
|
||||
getContinueDir(): Promise<string>;
|
||||
openFile(path: string): Promise<void>;
|
||||
runCommand(command: string): Promise<void>;
|
||||
saveFile(filepath: string): Promise<void>;
|
||||
readFile(filepath: string): Promise<string>;
|
||||
showDiff(
|
||||
filepath: string,
|
||||
newContents: string,
|
||||
stepIndex: number
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
export { IDE };
|
||||
455
core/index.d.ts
vendored
Normal file
455
core/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,455 @@
|
|||
export interface ILLM extends LLMOptions {
|
||||
get providerName(): ModelProvider;
|
||||
|
||||
uniqueId: string;
|
||||
model: string;
|
||||
|
||||
title?: string;
|
||||
systemMessage?: string;
|
||||
contextLength: number;
|
||||
completionOptions: CompletionOptions;
|
||||
requestOptions?: RequestOptions;
|
||||
promptTemplates?: Record<string, string>;
|
||||
templateMessages?: (messages: ChatMessage[]) => string;
|
||||
writeLog?: (str: string) => Promise<void>;
|
||||
llmRequestHook?: (model: string, prompt: string) => any;
|
||||
apiKey?: string;
|
||||
apiBase?: string;
|
||||
|
||||
engine?: string;
|
||||
apiVersion?: string;
|
||||
apiType?: string;
|
||||
region?: string;
|
||||
projectId?: string;
|
||||
|
||||
complete(prompt: string, options?: LLMFullCompletionOptions): Promise<string>;
|
||||
|
||||
streamComplete(
|
||||
prompt: string,
|
||||
options?: LLMFullCompletionOptions
|
||||
): AsyncGenerator<string>;
|
||||
|
||||
streamChat(
|
||||
messages: ChatMessage[],
|
||||
options?: LLMFullCompletionOptions
|
||||
): AsyncGenerator<ChatMessage>;
|
||||
|
||||
countTokens(text: string): number;
|
||||
}
|
||||
|
||||
export interface ContextProviderDescription {
|
||||
title: string;
|
||||
displayTitle: string;
|
||||
description: string;
|
||||
dynamic: boolean;
|
||||
requiresQuery: boolean;
|
||||
}
|
||||
|
||||
export interface CustomContextProvider {
|
||||
title: string;
|
||||
displayTitle?: string;
|
||||
description?: string;
|
||||
getContextItems(query: string): Promise<ContextItem[]>;
|
||||
}
|
||||
|
||||
export interface IContextProvider {
|
||||
get description(): ContextProviderDescription;
|
||||
|
||||
getContextItems(query: string): Promise<ContextItem[]>;
|
||||
}
|
||||
|
||||
export interface PersistedSessionInfo {
|
||||
history: ChatHistory;
|
||||
title: string;
|
||||
workspaceDirectory: string;
|
||||
sessionId: string;
|
||||
}
|
||||
|
||||
export interface SessionInfo {
|
||||
sessionId: string;
|
||||
title: string;
|
||||
dateCreated: string;
|
||||
workspaceDirectory: string;
|
||||
}
|
||||
|
||||
export interface RangeInFile {
|
||||
filepath: string;
|
||||
range: Range;
|
||||
}
|
||||
|
||||
export interface Range {
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
export interface Position {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
export interface FileEdit {
|
||||
filepath: string;
|
||||
range: Range;
|
||||
replacement: string;
|
||||
}
|
||||
|
||||
export interface ContinueError {
|
||||
title: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface CompletionOptions {
|
||||
model: string;
|
||||
|
||||
maxTokens: number;
|
||||
temperature?: number;
|
||||
topP?: number;
|
||||
topK?: number;
|
||||
presencePenalty?: number;
|
||||
frequencyPenalty?: number;
|
||||
stop?: string[];
|
||||
}
|
||||
|
||||
export type ChatMessageRole = "user" | "assistant" | "system";
|
||||
|
||||
export interface ChatMessage {
|
||||
role: ChatMessageRole;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface ContextItemId {
|
||||
providerTitle: string;
|
||||
itemId: string;
|
||||
}
|
||||
|
||||
export interface ContextItem {
|
||||
content: string;
|
||||
name: string;
|
||||
description: string;
|
||||
id: ContextItemId;
|
||||
editing?: boolean;
|
||||
editable?: boolean;
|
||||
}
|
||||
|
||||
export interface ChatHistoryItem {
|
||||
message: ChatMessage;
|
||||
contextItems: ContextItem[];
|
||||
promptLogs?: [string, string][]; // [prompt, completion]
|
||||
}
|
||||
|
||||
export type ChatHistory = ChatHistoryItem[];
|
||||
|
||||
// LLM
|
||||
|
||||
export interface LLMFullCompletionOptions {
|
||||
raw?: boolean;
|
||||
log?: boolean;
|
||||
|
||||
model?: string;
|
||||
|
||||
temperature?: number;
|
||||
topP?: number;
|
||||
topK?: number;
|
||||
presencePenalty?: number;
|
||||
frequencyPenalty?: number;
|
||||
stop?: string[];
|
||||
maxTokens?: number;
|
||||
}
|
||||
export interface LLMOptions {
|
||||
model: string;
|
||||
|
||||
title?: string;
|
||||
uniqueId?: string;
|
||||
systemMessage?: string;
|
||||
contextLength?: number;
|
||||
completionOptions?: CompletionOptions;
|
||||
requestOptions?: RequestOptions;
|
||||
promptTemplates?: Record<string, string>;
|
||||
templateMessages?: (messages: ChatMessage[]) => string;
|
||||
writeLog?: (str: string) => Promise<void>;
|
||||
llmRequestHook?: (model: string, prompt: string) => any;
|
||||
apiKey?: string;
|
||||
apiBase?: string;
|
||||
|
||||
// Azure options
|
||||
engine?: string;
|
||||
apiVersion?: string;
|
||||
apiType?: string;
|
||||
|
||||
// GCP Options
|
||||
region?: string;
|
||||
projectId?: string;
|
||||
}
|
||||
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
|
||||
T,
|
||||
Exclude<keyof T, Keys>
|
||||
> &
|
||||
{
|
||||
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
||||
}[Keys];
|
||||
|
||||
export interface CustomLLMWithOptionals {
|
||||
options?: LLMOptions;
|
||||
streamCompletion?: (
|
||||
prompt: string,
|
||||
options: CompletionOptions
|
||||
) => AsyncGenerator<string>;
|
||||
streamChat?: (
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions
|
||||
) => AsyncGenerator<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The LLM interface requires you to specify either `streamCompletion` or `streamChat` (or both).
|
||||
*/
|
||||
export type CustomLLM = RequireAtLeastOne<
|
||||
CustomLLMWithOptionals,
|
||||
"streamCompletion" | "streamChat"
|
||||
>;
|
||||
|
||||
// IDE
|
||||
|
||||
export interface IDE {
|
||||
getSerializedConfig(): Promise<SerializedContinueConfig>;
|
||||
getConfigJsUrl(): Promise<string | undefined>;
|
||||
getDiff(): Promise<string>;
|
||||
getTerminalContents(): Promise<string>;
|
||||
listWorkspaceContents(): Promise<string[]>;
|
||||
getWorkspaceDir(): Promise<string>;
|
||||
writeFile(path: string, contents: string): Promise<void>;
|
||||
showVirtualFile(title: string, contents: string): Promise<void>;
|
||||
getContinueDir(): Promise<string>;
|
||||
openFile(path: string): Promise<void>;
|
||||
runCommand(command: string): Promise<void>;
|
||||
saveFile(filepath: string): Promise<void>;
|
||||
readFile(filepath: string): Promise<string>;
|
||||
showDiff(
|
||||
filepath: string,
|
||||
newContents: string,
|
||||
stepIndex: number
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
// Slash Commands
|
||||
|
||||
export interface ContinueSDK {
|
||||
ide: IDE;
|
||||
llm: ILLM;
|
||||
addContextItem: (item: ContextItem) => void;
|
||||
history: ChatMessage[];
|
||||
input: string;
|
||||
params?: any;
|
||||
contextItems: ContextItem[];
|
||||
}
|
||||
|
||||
export interface SlashCommand {
|
||||
name: string;
|
||||
description: string;
|
||||
params?: { [key: string]: any };
|
||||
run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
|
||||
}
|
||||
|
||||
// Config
|
||||
|
||||
type StepName =
|
||||
| "AnswerQuestionChroma"
|
||||
| "GenerateShellCommandStep"
|
||||
| "EditHighlightedCodeStep"
|
||||
| "ShareSessionStep"
|
||||
| "CommentCodeStep"
|
||||
| "ClearHistoryStep"
|
||||
| "StackOverflowStep"
|
||||
| "OpenConfigStep"
|
||||
| "GenerateShellCommandStep"
|
||||
| "DraftIssueStep";
|
||||
|
||||
type ContextProviderName =
|
||||
| "diff"
|
||||
| "github"
|
||||
| "terminal"
|
||||
| "open"
|
||||
| "google"
|
||||
| "search"
|
||||
| "url"
|
||||
| "tree";
|
||||
|
||||
type TemplateType =
|
||||
| "llama2"
|
||||
| "alpaca"
|
||||
| "zephyr"
|
||||
| "phind"
|
||||
| "anthropic"
|
||||
| "chatml"
|
||||
| "deepseek";
|
||||
|
||||
type ModelProvider =
|
||||
| "openai"
|
||||
| "openai-free-trial"
|
||||
| "openai-aiohttp"
|
||||
| "anthropic"
|
||||
| "together"
|
||||
| "ollama"
|
||||
| "huggingface-tgi"
|
||||
| "huggingface-inference-api"
|
||||
| "llama.cpp"
|
||||
| "replicate"
|
||||
| "text-gen-webui"
|
||||
| "google-palm"
|
||||
| "google-palm-real"
|
||||
| "lmstudio"
|
||||
| "llamafile"
|
||||
| "gemini"
|
||||
| "mistral";
|
||||
|
||||
export type ModelName =
|
||||
// OpenAI
|
||||
| "gpt-3.5-turbo"
|
||||
| "gpt-3.5-turbo-16k"
|
||||
| "gpt-4"
|
||||
| "gpt-3.5-turbo-0613"
|
||||
| "gpt-4-32k"
|
||||
| "gpt-4-1106-preview"
|
||||
// Open Source
|
||||
| "mistral-7b"
|
||||
| "mistral-8x7b"
|
||||
| "llama2-7b"
|
||||
| "llama2-13b"
|
||||
| "codellama-7b"
|
||||
| "codellama-13b"
|
||||
| "codellama-34b"
|
||||
| "phind-codellama-34b"
|
||||
| "wizardcoder-7b"
|
||||
| "wizardcoder-13b"
|
||||
| "wizardcoder-34b"
|
||||
| "zephyr-7b"
|
||||
| "codeup-13b"
|
||||
| "deepseek-1b"
|
||||
| "deepseek-7b"
|
||||
| "deepseek-33b"
|
||||
// Anthropic
|
||||
| "claude-2"
|
||||
// Google PaLM
|
||||
| "chat-bison-001"
|
||||
// Gemini
|
||||
| "gemini-pro";
|
||||
|
||||
export interface RequestOptions {
|
||||
timeout?: number;
|
||||
verifySsl?: boolean;
|
||||
caBundlePath: string;
|
||||
proxy?: string;
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface StepWithParams {
|
||||
name: StepName;
|
||||
params: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface ContextProviderWithParams {
|
||||
name: ContextProviderName;
|
||||
params: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface SlashCommandDescription {
|
||||
name: string;
|
||||
description: string;
|
||||
step: StepName | string;
|
||||
params?: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface CustomCommand {
|
||||
name: string;
|
||||
prompt: string;
|
||||
description: string;
|
||||
}
|
||||
export interface RetrievalSettings {
|
||||
nRetrieve?: number;
|
||||
nFinal?: number;
|
||||
useReranking: boolean;
|
||||
rerankGroupSize: number;
|
||||
ignoreFiles: string[];
|
||||
openaiApiKey?: string;
|
||||
apiBase?: string;
|
||||
apiType?: string;
|
||||
apiVersion?: string;
|
||||
organizationId?: string;
|
||||
}
|
||||
|
||||
interface BaseCompletionOptions {
|
||||
temperature?: number;
|
||||
topP?: number;
|
||||
topK?: number;
|
||||
presencePenalty?: number;
|
||||
frequencyPenalty?: number;
|
||||
stop?: string[];
|
||||
maxTokens: number;
|
||||
}
|
||||
|
||||
export interface ModelDescription {
|
||||
title: string;
|
||||
provider: ModelProvider;
|
||||
model: string;
|
||||
apiKey?: string;
|
||||
apiBase?: string;
|
||||
contextLength?: number;
|
||||
template?: TemplateType;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
systemMessage?: string;
|
||||
requestOptions?: RequestOptions;
|
||||
}
|
||||
|
||||
export interface ModelRoles {
|
||||
default: string;
|
||||
chat?: string;
|
||||
edit?: string;
|
||||
summarize?: string;
|
||||
}
|
||||
|
||||
export interface SerializedContinueConfig {
|
||||
disallowedSteps?: string[];
|
||||
allowAnonymousTelemetry?: boolean;
|
||||
models: ModelDescription[];
|
||||
modelRoles: ModelRoles;
|
||||
systemMessage?: string;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
slashCommands?: SlashCommandDescription[];
|
||||
customCommands?: CustomCommand[];
|
||||
contextProviders?: ContextProviderWithParams[];
|
||||
retrievalSettings?: RetrievalSettings;
|
||||
disableIndexing?: boolean;
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
/** If set to true, Continue will collect anonymous usage data to improve the product. If set to false, we will collect nothing. Read here to learn more: https://continue.dev/docs/telemetry */
|
||||
allowAnonymousTelemetry?: boolean;
|
||||
/** Each entry in this array will originally be a ModelDescription, the same object from your config.json, but you may add CustomLLMs.
|
||||
* A CustomLLM requires you only to define an AsyncGenerator that calls the LLM and yields string updates. You can choose to define either `streamCompletion` or `streamChat` (or both).
|
||||
* Continue will do the rest of the work to construct prompt templates, handle context items, prune context, etc.
|
||||
*/
|
||||
models: (CustomLLM | ModelDescription)[];
|
||||
/** A system message to be followed by all of your models */
|
||||
systemMessage?: string;
|
||||
/** The default completion options for all models */
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
/** The list of slash commands that will be available in the sidebar */
|
||||
slashCommands?: SlashCommand[];
|
||||
/** Each entry in this array will originally be a ContextProviderWithParams, the same object from your config.json, but you may add CustomContextProviders.
|
||||
* A CustomContextProvider requires you only to define a title and getContextItems function. When you type '@title <query>', Continue will call `getContextItems(query)`.
|
||||
*/
|
||||
contextProviders?: (CustomContextProvider | ContextProviderWithParams)[];
|
||||
/** Settings related to the /codebase retrieval feature */
|
||||
retrievalSettings?: RetrievalSettings;
|
||||
/** If set to true, Continue will not index your codebase for retrieval */
|
||||
disableIndexing?: boolean;
|
||||
}
|
||||
|
||||
export interface ContinueConfig {
|
||||
allowAnonymousTelemetry?: boolean;
|
||||
models: ILLM[];
|
||||
systemMessage?: string;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
slashCommands?: SlashCommand[];
|
||||
contextProviders?: IContextProvider[];
|
||||
retrievalSettings?: RetrievalSettings;
|
||||
disableIndexing?: boolean;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { ChatHistory, ChatMessage } from "./types";
|
||||
import { ChatHistory, ChatMessage } from "..";
|
||||
|
||||
export function constructMessages(history: ChatHistory): ChatMessage[] {
|
||||
const msgs: ChatMessage[] = [];
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import {
|
|||
Tiktoken,
|
||||
TiktokenModel,
|
||||
} from "js-tiktoken";
|
||||
import { ChatMessage } from "..";
|
||||
import { TOKEN_BUFFER_FOR_SAFETY } from "./constants";
|
||||
import { ChatMessage } from "./types";
|
||||
|
||||
function renderTemplatedString(template: string): string {
|
||||
// TODO
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
import { ModelProvider, RequestOptions, TemplateType } from "../config";
|
||||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
ILLM,
|
||||
LLMFullCompletionOptions,
|
||||
LLMOptions,
|
||||
ModelProvider,
|
||||
RequestOptions,
|
||||
TemplateType,
|
||||
} from "..";
|
||||
import { CONTEXT_LENGTH_FOR_MODEL, DEFAULT_ARGS } from "./constants";
|
||||
import {
|
||||
compileChatMessages,
|
||||
|
|
@ -22,7 +31,6 @@ import {
|
|||
simplestEditPrompt,
|
||||
zephyrEditPrompt,
|
||||
} from "./templates/edit";
|
||||
import { ChatMessage, CompletionOptions } from "./types";
|
||||
|
||||
function autodetectTemplateType(model: string): TemplateType | undefined {
|
||||
const lower = model.toLowerCase();
|
||||
|
|
@ -120,53 +128,12 @@ function autodetectPromptTemplates(
|
|||
return templates;
|
||||
}
|
||||
|
||||
export interface LLMOptions {
|
||||
model: string;
|
||||
|
||||
title?: string;
|
||||
uniqueId?: string;
|
||||
systemMessage?: string;
|
||||
contextLength?: number;
|
||||
completionOptions?: CompletionOptions;
|
||||
requestOptions?: RequestOptions;
|
||||
promptTemplates?: Record<string, string>;
|
||||
templateMessages?: (messages: ChatMessage[]) => string;
|
||||
writeLog?: (str: string) => Promise<void>;
|
||||
llmRequestHook?: (model: string, prompt: string) => any;
|
||||
apiKey?: string;
|
||||
apiBase?: string;
|
||||
|
||||
// Azure options
|
||||
engine?: string;
|
||||
apiVersion?: string;
|
||||
apiType?: string;
|
||||
|
||||
// GCP Options
|
||||
region?: string;
|
||||
projectId?: string;
|
||||
}
|
||||
|
||||
interface LLMFullCompletionOptions {
|
||||
raw?: boolean;
|
||||
log?: boolean;
|
||||
|
||||
model?: string;
|
||||
|
||||
temperature?: number;
|
||||
topP?: number;
|
||||
topK?: number;
|
||||
presencePenalty?: number;
|
||||
frequencyPenalty?: number;
|
||||
stop?: string[];
|
||||
maxTokens?: number;
|
||||
}
|
||||
|
||||
export abstract class LLM implements LLMOptions {
|
||||
export abstract class BaseLLM implements ILLM {
|
||||
static providerName: ModelProvider;
|
||||
static defaultOptions: Partial<LLMOptions> | undefined;
|
||||
static defaultOptions: Partial<LLMOptions> | undefined = undefined;
|
||||
|
||||
get providerName(): ModelProvider {
|
||||
return (this.constructor as typeof LLM).providerName;
|
||||
return (this.constructor as typeof BaseLLM).providerName;
|
||||
}
|
||||
|
||||
uniqueId: string;
|
||||
|
|
@ -193,8 +160,8 @@ export abstract class LLM implements LLMOptions {
|
|||
constructor(options: LLMOptions) {
|
||||
// Set default options
|
||||
options = {
|
||||
title: (this.constructor as typeof LLM).providerName,
|
||||
...(this.constructor as typeof LLM).defaultOptions,
|
||||
title: (this.constructor as typeof BaseLLM).providerName,
|
||||
...(this.constructor as typeof BaseLLM).defaultOptions,
|
||||
...options,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
// import AnthropicClient from "@anthropic-ai/sdk";
|
||||
// import { CompletionCreateParamsBase } from "@anthropic-ai/sdk/resources/completions";
|
||||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { BaseLLM } from "..";
|
||||
import { CompletionOptions, LLMOptions, ModelProvider } from "../..";
|
||||
import { anthropicTemplateMessages } from "../templates/chat";
|
||||
import { CompletionOptions } from "../types";
|
||||
|
||||
class Anthropic extends LLM {
|
||||
class Anthropic extends BaseLLM {
|
||||
static providerName: ModelProvider = "anthropic";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
model: "claude-2",
|
||||
|
|
|
|||
55
core/llm/llms/CustomLLM.ts
Normal file
55
core/llm/llms/CustomLLM.ts
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import { BaseLLM } from "..";
|
||||
import { ChatMessage, CompletionOptions, CustomLLM } from "../..";
|
||||
|
||||
class CustomLLMClass extends BaseLLM {
|
||||
private customStreamCompletion?: (
|
||||
prompt: string,
|
||||
options: CompletionOptions
|
||||
) => AsyncGenerator<string>;
|
||||
|
||||
private customStreamChat?: (
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions
|
||||
) => AsyncGenerator<string>;
|
||||
|
||||
constructor(custom: CustomLLM) {
|
||||
super(custom.options || { model: "custom" });
|
||||
this.customStreamCompletion = custom.streamCompletion;
|
||||
this.customStreamChat = custom.streamChat;
|
||||
}
|
||||
|
||||
protected async *_streamChat(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
if (this.customStreamChat) {
|
||||
for await (const content of this.customStreamChat(messages, options)) {
|
||||
yield { role: "assistant", content };
|
||||
}
|
||||
} else {
|
||||
for await (const update of super._streamChat(messages, options)) {
|
||||
yield update;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async *_streamComplete(
|
||||
prompt: string,
|
||||
options: CompletionOptions
|
||||
): AsyncGenerator<string> {
|
||||
if (this.customStreamCompletion) {
|
||||
for await (const content of this.customStreamCompletion(
|
||||
prompt,
|
||||
options
|
||||
)) {
|
||||
yield content;
|
||||
}
|
||||
} else {
|
||||
for await (const content of super._streamComplete(prompt, options)) {
|
||||
yield content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default CustomLLMClass;
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
import { LLM } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { ChatMessage, CompletionOptions } from "../types";
|
||||
import { BaseLLM } from "..";
|
||||
import { ChatMessage, CompletionOptions, ModelProvider } from "../..";
|
||||
|
||||
// const SERVER_URL = "http://localhost:8080";
|
||||
const SERVER_URL = "https://proxy-server-l6vsfbzhba-uw.a.run.app";
|
||||
|
||||
class FreeTrial extends LLM {
|
||||
class FreeTrial extends BaseLLM {
|
||||
static providerName: ModelProvider = "openai-free-trial";
|
||||
|
||||
private _getHeaders() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { ChatMessage, CompletionOptions } from "../types";
|
||||
import { BaseLLM } from "..";
|
||||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
ModelProvider,
|
||||
} from "../..";
|
||||
|
||||
class Gemini extends LLM {
|
||||
class Gemini extends BaseLLM {
|
||||
static providerName: ModelProvider = "gemini";
|
||||
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { ChatMessage, CompletionOptions } from "../types";
|
||||
import { BaseLLM } from "..";
|
||||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
ModelProvider,
|
||||
} from "../..";
|
||||
|
||||
class GooglePalm extends LLM {
|
||||
class GooglePalm extends BaseLLM {
|
||||
static providerName: ModelProvider = "google-palm-real";
|
||||
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { BaseLLM } from "..";
|
||||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
ModelProvider,
|
||||
} from "../..";
|
||||
import { ideRequest } from "../../ide/messaging";
|
||||
import { ChatMessage, CompletionOptions } from "../types";
|
||||
|
||||
class GooglePalmProxy extends LLM {
|
||||
class GooglePalmProxy extends BaseLLM {
|
||||
static providerName: ModelProvider = "google-palm";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
model: "chat-bison-001",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { LLM } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { ChatMessage, CompletionOptions } from "../types";
|
||||
import { BaseLLM } from "..";
|
||||
import { ChatMessage, CompletionOptions, ModelProvider } from "../..";
|
||||
|
||||
class HuggingFaceInferenceAPI extends LLM {
|
||||
class HuggingFaceInferenceAPI extends BaseLLM {
|
||||
static providerName: ModelProvider = "huggingface-inference-api";
|
||||
|
||||
private _convertArgs(options: CompletionOptions, prompt: string) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { CompletionOptions } from "../types";
|
||||
import { BaseLLM } from "..";
|
||||
import { CompletionOptions, LLMOptions, ModelProvider } from "../..";
|
||||
|
||||
class HuggingFaceTGI extends LLM {
|
||||
class HuggingFaceTGI extends BaseLLM {
|
||||
static providerName: ModelProvider = "huggingface-tgi";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "http://localhost:8080",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { LLMOptions, ModelProvider } from "../..";
|
||||
import OpenAI from "./OpenAI";
|
||||
|
||||
class LMStudio extends OpenAI {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { CompletionOptions } from "../types";
|
||||
import { BaseLLM } from "..";
|
||||
import { CompletionOptions, LLMOptions, ModelProvider } from "../..";
|
||||
|
||||
class LlamaCpp extends LLM {
|
||||
class LlamaCpp extends BaseLLM {
|
||||
static providerName: ModelProvider = "llama.cpp";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "http://127.0.0.1:8080",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ModelProvider } from "../../config";
|
||||
import { ModelProvider } from "../..";
|
||||
import LlamaCpp from "./LlamaCpp";
|
||||
|
||||
class Llamafile extends LlamaCpp {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { LLMOptions, ModelProvider } from "../..";
|
||||
import OpenAI from "./OpenAI";
|
||||
|
||||
class Mistral extends OpenAI {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { CompletionOptions } from "../types";
|
||||
import { BaseLLM } from "..";
|
||||
import { CompletionOptions, LLMOptions, ModelProvider } from "../..";
|
||||
|
||||
class Ollama extends LLM {
|
||||
class Ollama extends BaseLLM {
|
||||
static providerName: ModelProvider = "ollama";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "http://localhost:11434",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
import { ChatCompletionCreateParamsBase } from "openai/resources/chat/completions";
|
||||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { ChatMessage, CompletionOptions } from "../types";
|
||||
class OpenAI extends LLM {
|
||||
import { BaseLLM } from "..";
|
||||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
ModelProvider,
|
||||
} from "../..";
|
||||
|
||||
class OpenAI extends BaseLLM {
|
||||
static providerName: ModelProvider = "openai";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "https://api.openai.com",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { ChatMessage, CompletionOptions } from "../types";
|
||||
import ReplicateClient from "replicate";
|
||||
import { BaseLLM } from "..";
|
||||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
ModelProvider,
|
||||
} from "../..";
|
||||
|
||||
class Replicate extends LLM {
|
||||
class Replicate extends BaseLLM {
|
||||
private static MODEL_IDS: {
|
||||
[name: string]: `${string}/${string}:${string}`;
|
||||
} = {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { ChatMessage, CompletionOptions } from "../types";
|
||||
import { BaseLLM } from "..";
|
||||
import { CompletionOptions, LLMOptions, ModelProvider } from "../..";
|
||||
|
||||
class TextGenWebUI extends LLM {
|
||||
class TextGenWebUI extends BaseLLM {
|
||||
static providerName: ModelProvider = "text-gen-webui";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "http://localhost:5000",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { ModelProvider } from "../../config";
|
||||
import { CompletionOptions } from "../types";
|
||||
import { BaseLLM } from "..";
|
||||
import { CompletionOptions, LLMOptions, ModelProvider } from "../..";
|
||||
|
||||
class Together extends LLM {
|
||||
class Together extends BaseLLM {
|
||||
static providerName: ModelProvider = "together";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "https://api.together.xyz",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { LLM, LLMOptions } from "..";
|
||||
import { BaseCompletionOptions, ModelDescription } from "../../config";
|
||||
import { BaseLLM } from "..";
|
||||
import { BaseCompletionOptions, LLMOptions, ModelDescription } from "../..";
|
||||
import Anthropic from "./Anthropic";
|
||||
import FreeTrial from "./FreeTrial";
|
||||
import Gemini from "./Gemini";
|
||||
|
|
@ -37,7 +37,7 @@ const LLMs = [
|
|||
export function llmFromDescription(
|
||||
desc: ModelDescription,
|
||||
completionOptions?: BaseCompletionOptions
|
||||
): LLM | undefined {
|
||||
): BaseLLM | undefined {
|
||||
const cls = LLMs.find((llm) => llm.providerName === desc.provider);
|
||||
|
||||
if (!cls) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ChatMessage } from "../types";
|
||||
import { ChatMessage } from "../..";
|
||||
|
||||
function llama2TemplateMessages(msgs: ChatMessage[]): string {
|
||||
if (msgs.length === 0) {
|
||||
|
|
@ -160,11 +160,11 @@ function phindTemplateMessages(msgs: ChatMessage[]): string {
|
|||
}
|
||||
|
||||
export {
|
||||
llama2TemplateMessages,
|
||||
anthropicTemplateMessages,
|
||||
zephyrTemplateMessages,
|
||||
chatmlTemplateMessages,
|
||||
templateAlpacaMessages,
|
||||
deepseekTemplateMessages,
|
||||
llama2TemplateMessages,
|
||||
phindTemplateMessages,
|
||||
templateAlpacaMessages,
|
||||
zephyrTemplateMessages,
|
||||
};
|
||||
|
|
|
|||
50
core/llm/types.d.ts
vendored
50
core/llm/types.d.ts
vendored
|
|
@ -1,50 +0,0 @@
|
|||
interface CompletionOptions {
|
||||
model: string;
|
||||
|
||||
maxTokens: number;
|
||||
temperature?: number;
|
||||
topP?: number;
|
||||
topK?: number;
|
||||
presencePenalty?: number;
|
||||
frequencyPenalty?: number;
|
||||
stop?: string[];
|
||||
}
|
||||
|
||||
type ChatMessageRole = "user" | "assistant" | "system";
|
||||
|
||||
interface ChatMessage {
|
||||
role: ChatMessageRole;
|
||||
content: string;
|
||||
}
|
||||
|
||||
interface ContextItemId {
|
||||
providerTitle: string;
|
||||
itemId: string;
|
||||
}
|
||||
|
||||
interface ContextItem {
|
||||
content: string;
|
||||
name: string;
|
||||
description: string;
|
||||
id: ContextItemId;
|
||||
editing?: boolean;
|
||||
editable?: boolean;
|
||||
}
|
||||
|
||||
interface ChatHistoryItem {
|
||||
message: ChatMessage;
|
||||
contextItems: ContextItem[];
|
||||
promptLogs?: [string, string][]; // [prompt, completion]
|
||||
}
|
||||
|
||||
type ChatHistory = ChatHistoryItem[];
|
||||
|
||||
export {
|
||||
ChatHistory,
|
||||
ChatHistoryItem,
|
||||
ChatMessage,
|
||||
ChatMessageRole,
|
||||
CompletionOptions,
|
||||
ContextItem,
|
||||
ContextItemId,
|
||||
};
|
||||
39
core/types.d.ts
vendored
39
core/types.d.ts
vendored
|
|
@ -1,39 +0,0 @@
|
|||
import { ChatHistory } from "./llm/types";
|
||||
|
||||
export interface PersistedSessionInfo {
|
||||
history: ChatHistory;
|
||||
title: string;
|
||||
workspaceDirectory: string;
|
||||
sessionId: string;
|
||||
}
|
||||
|
||||
export interface SessionInfo {
|
||||
sessionId: string;
|
||||
title: string;
|
||||
dateCreated: string;
|
||||
workspaceDirectory: string;
|
||||
}
|
||||
|
||||
export interface RangeInFile {
|
||||
filepath: string;
|
||||
range: Range;
|
||||
}
|
||||
|
||||
export interface Range {
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
export interface Position {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
export interface FileEdit {
|
||||
filepath: string;
|
||||
range: Range;
|
||||
replacement: string;
|
||||
}
|
||||
|
||||
export interface ContinueError {
|
||||
title: string;
|
||||
message: string;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import Handlebars from "handlebars";
|
||||
import { ChatMessage } from "../llm/types";
|
||||
import { ChatMessage } from "..";
|
||||
|
||||
export function removeQuotesAndEscapes(output: string): string {
|
||||
output = output.trim();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { SerializedContinueConfig } from "../config";
|
||||
import { SerializedContinueConfig } from "..";
|
||||
import defaultConfig from "../config/default";
|
||||
|
||||
export function getContinueGlobalPath(): string {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ await esbuild.build({
|
|||
entryPoints: ["src/extension.ts"],
|
||||
bundle: true,
|
||||
outfile: "out/extension.js",
|
||||
external: ["vscode"],
|
||||
external: ["vscode", "esbuild"],
|
||||
format: "cjs",
|
||||
platform: "node",
|
||||
sourcemap: true,
|
||||
|
|
|
|||
|
|
@ -99,15 +99,6 @@ function showRefactorMigrationMessage() {
|
|||
|
||||
export async function activateExtension(context: vscode.ExtensionContext) {
|
||||
extensionContext = context;
|
||||
try {
|
||||
console.log(
|
||||
"In workspace: ",
|
||||
vscode.workspace.workspaceFolders?.[0].uri.fsPath
|
||||
);
|
||||
} catch (e) {
|
||||
console.log("Error getting workspace folder: ", e);
|
||||
}
|
||||
console.log("Window ID: ", windowId);
|
||||
|
||||
// Register commands and providers
|
||||
registerAllCodeLensProviders(context);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { FileEdit, RangeInFile } from "core/types";
|
||||
import { FileEdit, RangeInFile } from "core";
|
||||
import { getConfigJsonPath } from "core/util/paths";
|
||||
import { readFileSync } from "fs";
|
||||
import * as vscode from "vscode";
|
||||
|
|
@ -44,7 +44,9 @@ class IdeProtocolClient {
|
|||
|
||||
if (
|
||||
filepath.endsWith(".continue/config.json") ||
|
||||
filepath.endsWith(".continue\\config.json")
|
||||
filepath.endsWith(".continue\\config.json") ||
|
||||
filepath.endsWith(".continue/config.ts") ||
|
||||
filepath.endsWith(".continue\\config.ts")
|
||||
) {
|
||||
const config = readFileSync(getConfigJsonPath(), "utf8");
|
||||
const configJson = JSON.parse(config);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { ModelDescription } from "core/config";
|
||||
import { FileEdit, ModelDescription } from "core";
|
||||
import { llmFromDescription } from "core/llm/llms";
|
||||
import { FileEdit } from "core/types";
|
||||
import {
|
||||
editConfigJson,
|
||||
getConfigJsonPath,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { PersistedSessionInfo, SessionInfo } from "core/types";
|
||||
import { PersistedSessionInfo, SessionInfo } from "core";
|
||||
import { getSessionFilePath, getSessionsListPath } from "core/util/paths";
|
||||
import * as fs from "fs";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import defaultConfig from "core/config/default";
|
||||
import { SerializedContinueConfig } from "core/config/index";
|
||||
import { IDE } from "core/ide/types";
|
||||
|
||||
import {
|
||||
getConfigJsPath,
|
||||
getConfigJsonPath,
|
||||
getConfigTsPath,
|
||||
getContinueGlobalPath,
|
||||
|
|
@ -11,6 +11,9 @@ import * as fs from "fs";
|
|||
import * as vscode from "vscode";
|
||||
import { ideProtocolClient } from "./activation/activate";
|
||||
|
||||
import { IDE, SerializedContinueConfig } from "core";
|
||||
import esbuild from "esbuild";
|
||||
|
||||
class VsCodeIde implements IDE {
|
||||
async getSerializedConfig(): Promise<SerializedContinueConfig> {
|
||||
try {
|
||||
|
|
@ -57,18 +60,19 @@ class VsCodeIde implements IDE {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
// const result = await esbuild.build({
|
||||
// entryPoints: [getConfigTsPath()],
|
||||
// bundle: true,
|
||||
// platform: "browser",
|
||||
// outfile: getConfigJsPath(),
|
||||
// external: ["esbuild"],
|
||||
// });
|
||||
const result = await esbuild.build({
|
||||
entryPoints: [getConfigTsPath()],
|
||||
bundle: true,
|
||||
platform: "browser",
|
||||
format: "esm",
|
||||
outfile: getConfigJsPath(),
|
||||
external: ["fetch"],
|
||||
});
|
||||
|
||||
// const configJsString = fs.readFileSync(getConfigJsPath(), "utf8");
|
||||
const configJsString = fs.readFileSync(getConfigJsPath(), "utf8");
|
||||
|
||||
// var dataUrl = "data:text/javascript;base64," + btoa(configJsString);
|
||||
// return dataUrl;
|
||||
var dataUrl = "data:text/javascript;base64," + btoa(configJsString);
|
||||
return dataUrl;
|
||||
|
||||
// try {
|
||||
// // Use tsc to compile config.ts to config.js. Spawn a child process to do this
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContextItem } from "core/llm/types";
|
||||
import { ContextItem } from "core";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button, Input } from "..";
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { MinusCircleIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import { ContinueError } from "core/types";
|
||||
import { ContinueError } from "core";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, vscBackground } from "..";
|
||||
import HeaderButtonWithText from "../HeaderButtonWithText";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import {
|
|||
HandThumbDownIcon,
|
||||
HandThumbUpIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ChatHistoryItem } from "core/llm/types";
|
||||
import { ChatHistoryItem } from "core";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ChatBubbleOvalLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { ChatHistoryItem } from "core/llm/types";
|
||||
import { ChatHistoryItem } from "core";
|
||||
import styled from "styled-components";
|
||||
import { lightGray, vscBackground } from "..";
|
||||
import { getFontSize } from "../../util";
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import {
|
|||
SparklesIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ContextItem } from "core/llm/types";
|
||||
import { ContextItem } from "core";
|
||||
import { useCombobox } from "downshift";
|
||||
import React, {
|
||||
useCallback,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
PaintBrushIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ContextItem } from "core/llm/types";
|
||||
import { ContextItem } from "core";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
import React from "react";
|
||||
import { defaultBorderRadius, lightGray, secondaryDark } from "..";
|
||||
import styled from "styled-components";
|
||||
import { getFontSize, getMarkdownLanguageTagForFile } from "../../util";
|
||||
import FileIcon from "../FileIcon";
|
||||
import HeaderButtonWithText from "../HeaderButtonWithText";
|
||||
import { ContextItem } from "core/llm/types";
|
||||
import { postToIde } from "../../util/ide";
|
||||
import {
|
||||
ArrowUpLeftIcon,
|
||||
ChevronDownIcon,
|
||||
ChevronUpIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { deleteContextWithIds } from "../../redux/slices/stateSlice";
|
||||
import { ContextItem } from "core";
|
||||
import React from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray, secondaryDark } from "..";
|
||||
import { deleteContextWithIds } from "../../redux/slices/stateSlice";
|
||||
import { getFontSize, getMarkdownLanguageTagForFile } from "../../util";
|
||||
import { postToIde } from "../../util/ide";
|
||||
import FileIcon from "../FileIcon";
|
||||
import HeaderButtonWithText from "../HeaderButtonWithText";
|
||||
import StyledMarkdownPreview from "./StyledMarkdownPreview";
|
||||
|
||||
const PreviewMarkdownDiv = styled.div<{ scroll: boolean }>`
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { Dispatch } from "@reduxjs/toolkit";
|
||||
|
||||
import { SlashCommand } from "core/commands";
|
||||
import { ChatHistory, ChatHistoryItem, ChatMessage, SlashCommand } from "core";
|
||||
import { ExtensionIde } from "core/ide";
|
||||
import { constructMessages } from "core/llm/constructMessages";
|
||||
import { ChatHistory, ChatHistoryItem, ChatMessage } from "core/llm/types";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContextItem } from "core/llm/types";
|
||||
import { ContextItem } from "core";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootStore } from "../redux/store";
|
||||
import { errorPopup } from "../util/ide";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { PersistedSessionInfo, SessionInfo } from "core";
|
||||
import { ideRequest } from "core/ide/messaging";
|
||||
import { PersistedSessionInfo, SessionInfo } from "core/types";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootStore } from "../redux/store";
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import { useEffect } from "react";
|
|||
import { setServerStatusMessage } from "../redux/slices/miscSlice";
|
||||
import { errorPopup, postToIde } from "../util/ide";
|
||||
|
||||
import { loadSerializedConfig } from "core/config/load";
|
||||
import {
|
||||
intermediateToFinalConfig,
|
||||
serializedToIntermediateConfig,
|
||||
} from "core/config/load";
|
||||
import { ExtensionIde } from "core/ide/index";
|
||||
import { setVscMachineId } from "../redux/slices/configSlice";
|
||||
import {
|
||||
|
|
@ -17,25 +20,28 @@ function useSetup(dispatch: Dispatch<any>) {
|
|||
const loadConfig = async () => {
|
||||
try {
|
||||
const ide = new ExtensionIde();
|
||||
let config = loadSerializedConfig(await ide.getSerializedConfig());
|
||||
// const configJsUrl = await ide.getConfigJsUrl();
|
||||
// if (configJsUrl) {
|
||||
// try {
|
||||
// // Try config.ts first
|
||||
// const module = await import(configJsUrl);
|
||||
// if (!module.config) {
|
||||
// throw new Error("config.ts does not export a config object");
|
||||
// }
|
||||
// console.log("Loaded config.ts", module.config);
|
||||
// config = module.modifyConfig(config);
|
||||
// } catch (e) {
|
||||
// console.log("Error loading config.ts: ", e);
|
||||
// errorPopup(e.message);
|
||||
// }
|
||||
// }
|
||||
console.log("Loaded config.json", config);
|
||||
let serialized = await ide.getSerializedConfig();
|
||||
let intermediate = serializedToIntermediateConfig(serialized);
|
||||
|
||||
const configJsUrl = await ide.getConfigJsUrl();
|
||||
if (configJsUrl) {
|
||||
try {
|
||||
// Try config.ts first
|
||||
const module = await import(configJsUrl);
|
||||
if (!module.modifyConfig) {
|
||||
throw new Error(
|
||||
"config.ts does not export a modifyConfig function."
|
||||
);
|
||||
}
|
||||
intermediate = module.modifyConfig(intermediate);
|
||||
} catch (e) {
|
||||
console.log("Error loading config.ts: ", e);
|
||||
errorPopup(e.message);
|
||||
}
|
||||
}
|
||||
const finalConfig = intermediateToFinalConfig(intermediate);
|
||||
// Fall back to config.json
|
||||
dispatch(setConfig(config));
|
||||
dispatch(setConfig(finalConfig));
|
||||
} catch (e) {
|
||||
console.log("Error loading config.json: ", e);
|
||||
errorPopup(e.message);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ArrowLeftIcon, TrashIcon } from "@heroicons/react/24/outline";
|
||||
import { PersistedSessionInfo, SessionInfo } from "core/types";
|
||||
import { PersistedSessionInfo, SessionInfo } from "core";
|
||||
import React, { Fragment, useEffect, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { ContinueConfig } from "core/config";
|
||||
import { ContinueConfig } from "core";
|
||||
import { useEffect } from "react";
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { SerializedContinueConfig } from "core/config";
|
||||
import { loadSerializedConfig } from "core/config/load";
|
||||
import FreeTrial from "core/llm/llms/FreeTrial";
|
||||
import { RootStore } from "../store";
|
||||
|
||||
|
|
@ -54,13 +52,6 @@ export const serverStateSlice = createSlice({
|
|||
contextProviders: action.payload,
|
||||
};
|
||||
},
|
||||
setConfig: (state, { payload }: { payload: SerializedContinueConfig }) => {
|
||||
const config = loadSerializedConfig(payload);
|
||||
return {
|
||||
...state,
|
||||
config,
|
||||
};
|
||||
},
|
||||
setIndexingProgress: (state, { payload }: { payload: number }) => {
|
||||
return {
|
||||
...state,
|
||||
|
|
@ -70,10 +61,6 @@ export const serverStateSlice = createSlice({
|
|||
},
|
||||
});
|
||||
|
||||
export const {
|
||||
setContextProviders,
|
||||
setSlashCommands,
|
||||
setConfig,
|
||||
setIndexingProgress,
|
||||
} = serverStateSlice.actions;
|
||||
export const { setContextProviders, setSlashCommands, setIndexingProgress } =
|
||||
serverStateSlice.actions;
|
||||
export default serverStateSlice.reducer;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { ContinueConfig } from "core/config";
|
||||
import {
|
||||
ChatMessage,
|
||||
ContextItem,
|
||||
ContextItemId,
|
||||
ContinueConfig,
|
||||
PersistedSessionInfo,
|
||||
} from "core";
|
||||
import defaultConfig from "core/config/default";
|
||||
import { loadSerializedConfig } from "core/config/load";
|
||||
import { ChatMessage, ContextItem, ContextItemId } from "core/llm/types";
|
||||
import { PersistedSessionInfo } from "core/types";
|
||||
import {
|
||||
intermediateToFinalConfig,
|
||||
serializedToIntermediateConfig,
|
||||
} from "core/config/load";
|
||||
import { v4 } from "uuid";
|
||||
import { RootStore } from "../store";
|
||||
|
||||
|
|
@ -85,7 +92,9 @@ const initialState: RootStore["state"] = {
|
|||
history: [],
|
||||
contextItems: [],
|
||||
active: false,
|
||||
config: loadSerializedConfig(defaultConfig),
|
||||
config: intermediateToFinalConfig(
|
||||
serializedToIntermediateConfig(defaultConfig)
|
||||
),
|
||||
title: "New Session",
|
||||
sessionId: v4(),
|
||||
defaultModelTitle: "GPT-4",
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import { combineReducers, configureStore } from "@reduxjs/toolkit";
|
||||
import { SlashCommandDescription } from "core/config";
|
||||
import { ContextProviderDescription } from "core/context";
|
||||
import { ContextItem } from "core/llm/types";
|
||||
import configReducer from "./slices/configSlice";
|
||||
import miscReducer from "./slices/miscSlice";
|
||||
import serverStateReducer from "./slices/serverStateReducer";
|
||||
import stateReducer from "./slices/stateSlice";
|
||||
import uiStateReducer from "./slices/uiStateSlice";
|
||||
|
||||
import { ContinueConfig } from "core/config";
|
||||
import { ChatHistory } from "core/llm/types";
|
||||
import {
|
||||
ChatHistory,
|
||||
ContextItem,
|
||||
ContextProviderDescription,
|
||||
ContinueConfig,
|
||||
SlashCommandDescription,
|
||||
} from "core";
|
||||
import { createTransform } from "redux-persist";
|
||||
import storage from "redux-persist/lib/storage";
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
This is the data that populates the model selection page.
|
||||
*/
|
||||
|
||||
import { ModelName, ModelProvider } from "core/config";
|
||||
import { ModelName, ModelProvider } from "core";
|
||||
import _ from "lodash";
|
||||
|
||||
export function updatedObj(old: any, pathToValue: { [key: string]: any }) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue