continue proxy FIM support
This commit is contained in:
parent
f97573e77e
commit
c8709c299f
3 changed files with 37 additions and 39 deletions
|
|
@ -1,10 +1,4 @@
|
|||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
ModelProvider,
|
||||
} from "../../index.js";
|
||||
import { streamSse } from "../stream.js";
|
||||
import { ChatMessage, LLMOptions, ModelProvider } from "../../index.js";
|
||||
import { gptEditPrompt } from "../templates/edit.js";
|
||||
import OpenAI from "./OpenAI.js";
|
||||
|
||||
|
|
@ -47,38 +41,6 @@ class Mistral extends OpenAI {
|
|||
supportsFim(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async *_streamFim(
|
||||
prefix: string,
|
||||
suffix: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
const endpoint = new URL("fim/completions", this.apiBase);
|
||||
const resp = await this.fetch(endpoint, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
model: options.model,
|
||||
prompt: prefix,
|
||||
suffix,
|
||||
max_tokens: options.maxTokens,
|
||||
temperature: options.temperature,
|
||||
top_p: options.topP,
|
||||
frequency_penalty: options.frequencyPenalty,
|
||||
presence_penalty: options.presencePenalty,
|
||||
stop: options.stop,
|
||||
stream: true,
|
||||
}),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"x-api-key": this.apiKey ?? "",
|
||||
Authorization: `Bearer ${this.apiKey}`,
|
||||
},
|
||||
});
|
||||
for await (const chunk of streamSse(resp)) {
|
||||
yield chunk.choices[0].delta.content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Mistral;
|
||||
|
|
|
|||
|
|
@ -226,6 +226,38 @@ class OpenAI extends BaseLLM {
|
|||
}
|
||||
}
|
||||
|
||||
async *_streamFim(
|
||||
prefix: string,
|
||||
suffix: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
const endpoint = new URL("fim/completions", this.apiBase);
|
||||
const resp = await this.fetch(endpoint, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
model: options.model,
|
||||
prompt: prefix,
|
||||
suffix,
|
||||
max_tokens: options.maxTokens,
|
||||
temperature: options.temperature,
|
||||
top_p: options.topP,
|
||||
frequency_penalty: options.frequencyPenalty,
|
||||
presence_penalty: options.presencePenalty,
|
||||
stop: options.stop,
|
||||
stream: true,
|
||||
}),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"x-api-key": this.apiKey ?? "",
|
||||
Authorization: `Bearer ${this.apiKey}`,
|
||||
},
|
||||
});
|
||||
for await (const chunk of streamSse(resp)) {
|
||||
yield chunk.choices[0].delta.content;
|
||||
}
|
||||
}
|
||||
|
||||
async listModels(): Promise<string[]> {
|
||||
const response = await this.fetch(this._getEndpoint("models"), {
|
||||
method: "GET",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ class ContinueProxy extends OpenAI {
|
|||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "http://localhost:3000/proxy/v1",
|
||||
};
|
||||
|
||||
supportsFim(): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export default ContinueProxy;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue