Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add adaptors for ollama and openai #117

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
"codellama/CodeLlama-13b-hf",
"Phind/Phind-CodeLlama-34B-v2",
"WizardLM/WizardCoder-Python-34B-V1.0",
"ollama/CodeLlama-7b-code",
"openai/chat-gpt-3.5-turbo",
"Custom"
],
"default": "bigcode/starcoder",
Expand Down Expand Up @@ -180,6 +182,22 @@
"default": null,
"description": "Tokenizer configuration for the model, check out the documentation for more details"
},
"llm.adaptor": {
"type": "string",
"enum": [
"huggingface",
"ollama",
"openai",
"tgi"
],
"default": "huggingface",
"desciption": "Completion provider to adapt to"
},
"llm.requestBody": {
"type": ["object", "null"],
"default": null,
"description": "Request body to be sent to the adaptor"
},
"llm.documentFilter": {
"type": [
"object",
Expand Down
38 changes: 36 additions & 2 deletions src/configTemplates.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const templateKeys = ["bigcode/starcoder", "codellama/CodeLlama-13b-hf", "Phind/Phind-CodeLlama-34B-v2", "WizardLM/WizardCoder-Python-34B-V1.0", "Custom"] as const;
const templateKeys = ["bigcode/starcoder", "codellama/CodeLlama-13b-hf", "Phind/Phind-CodeLlama-34B-v2", "WizardLM/WizardCoder-Python-34B-V1.0", "ollama/CodeLlama-7b-code", "openai/chat-gpt-3.5-turbo", "Custom"] as const;
export type TemplateKey = typeof templateKeys[number];

export interface TokenizerPathConfig {
Expand All @@ -24,6 +24,8 @@ export interface Config {
contextWindow: number;
tokensToClear: string[];
tokenizer: TokenizerPathConfig | TokenizerRepoConfig | TokenizerUrlConfig | null;
adaptor?: string;
requestBody?: object & { model?: string };
}

const StarCoderConfig: Config = {
Expand Down Expand Up @@ -67,9 +69,41 @@ const WizardCoderPython34Bv1Config: Config = {
}
}

const OllamaAdaptorDefaultConfig: Config = {
modelIdOrEndpoint: "http://localhost:11435/api/generate",
"fillInTheMiddle.enabled": true,
"fillInTheMiddle.prefix": "<PRE>",
"fillInTheMiddle.middle": "<MID>",
"fillInTheMiddle.suffix": "<SUF>",
temperature: 0.2,
contextWindow: 8192,
tokensToClear: ["<EOT>"],
tokenizer: {
repository: "codellama/CodeLlama-7b-hf",
},
adaptor: "ollama",
requestBody: { model: "codellama:7b-code" }
}

const OpenAIAdaptorDefaultConfig: Config = {
modelIdOrEndpoint: "https://api.openai.com/v1/chat/completions",
"fillInTheMiddle.enabled": true,
"fillInTheMiddle.prefix": "<im_start>",
"fillInTheMiddle.middle": "<im_end>",
"fillInTheMiddle.suffix": "<im_end>",
temperature: 0.2,
contextWindow: 8192,
tokensToClear: ["<endoftext>"],
tokenizer: null,
adaptor: "openai",
requestBody: { model: "gpt-3.5-turbo" }
}

export const templates: Partial<Record<TemplateKey, Config>> = {
"bigcode/starcoder": StarCoderConfig,
"codellama/CodeLlama-13b-hf": CodeLlama13BConfig,
"Phind/Phind-CodeLlama-34B-v2": PhindCodeLlama34Bv2Config,
"WizardLM/WizardCoder-Python-34B-V1.0": WizardCoderPython34Bv1Config,
}
"ollama/CodeLlama-7b-code": OllamaAdaptorDefaultConfig,
"openai/chat-gpt-3.5-turbo": OpenAIAdaptorDefaultConfig,
}
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export function activate(context: vscode.ExtensionContext) {
fim: config.get("fillInTheMiddle") as number,
context_window: config.get("contextWindow") as number,
tls_skip_verify_insecure: config.get("tlsSkipVerifyInsecure") as boolean,
adaptor: config.get("adaptor") as string,
request_body: config.get("requestBody") as object | null,
ide: "vscode",
tokenizer_config: config.get("tokenizer") as object | null,
};
Expand Down Expand Up @@ -329,4 +331,4 @@ async function delay(milliseconds: number, token: vscode.CancellationToken): Pro
resolve(token.isCancellationRequested)
}, milliseconds);
});
}
}