Merge branch 'preview' of https://github.com/continuedev/continue into preview

This commit is contained in:
Nate Sesti 2023-12-25 22:18:45 -05:00
commit f044be3256
5 changed files with 47 additions and 3 deletions

View file

@ -301,6 +301,7 @@ declare global {
| "phind"
| "anthropic"
| "chatml"
| "none"
| "deepseek";
type ModelProvider =

1
core/index.d.ts vendored
View file

@ -299,6 +299,7 @@ type TemplateType =
| "phind"
| "anthropic"
| "chatml"
| "none"
| "deepseek";
type ModelProvider =

View file

@ -92,6 +92,7 @@ function autodetectTemplateFunction(
anthropic: anthropicTemplateMessages,
chatml: chatmlTemplateMessages,
deepseek: deepseekTemplateMessages,
none: null,
};
return mapping[templateType];
@ -262,9 +263,9 @@ export abstract class BaseLLM implements ILLM {
.join("\n");
return `Settings:
${settings}
############################################
${prompt}`;
}

View file

@ -46,6 +46,13 @@ class OpenAI extends BaseLLM {
return completion;
}
private _getCompletionUrl() {
if (this.apiType === "azure") {
return `${this.apiBase}/openai/deployments/${this.engine}/completions?api-version=${this.apiVersion}`;
} else {
return this.apiBase + "/v1/completions";
}
}
protected async *_streamComplete(
prompt: string,
@ -59,6 +66,39 @@ class OpenAI extends BaseLLM {
}
}
protected async *_legacystreamComplete(
prompt: string,
options: CompletionOptions
): AsyncGenerator<string> {
const response = await this.fetch(this._getCompletionUrl(), {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.apiKey}`,
"api-key": this.apiKey || "", // For Azure
},
body: JSON.stringify({
...{
prompt,
model: options.model,
max_tokens: options.maxTokens,
temperature: options.temperature,
top_p: options.topP,
frequency_penalty: options.frequencyPenalty,
presence_penalty: options.presencePenalty,
stop: options.stop,
},
stream: true,
}),
});
for await (const value of streamSse(response)) {
if (value.choices?.[0]?.text) {
yield value.choices[0].text;
}
}
}
private _getChatUrl() {
if (this.apiType === "azure") {
return `${this.apiBase}/openai/deployments/${this.engine}/chat/completions?api-version=${this.apiVersion}`;

View file

@ -135,7 +135,7 @@
},
"template": {
"title": "Template",
"description": "The chat template used to format messages. This is auto-detected for most models, but can be overridden here.",
"description": "The chat template used to format messages. This is auto-detected for most models, but can be overridden here. Choose none if you are using vLLM or another server that automatically handles prompting.",
"enum": [
"llama2",
"alpaca",
@ -143,6 +143,7 @@
"phind",
"anthropic",
"chatml",
"none",
"deepseek"
],
"type": "string"