more inception fixes
This commit is contained in:
parent
d1b0de1cbb
commit
2a41f95a93
6 changed files with 72 additions and 5 deletions
|
|
@ -23,7 +23,7 @@ class Inception extends OpenAI {
|
|||
completionOptions: {
|
||||
temperature: 0.0,
|
||||
presencePenalty: 1.5,
|
||||
stop: ["\n\n", "\n \n", "<|endoftext|>"],
|
||||
stop: ["<|endoftext|>"],
|
||||
model: "mercury-editor-small-experimental", // Added model to fix TypeScript error
|
||||
},
|
||||
};
|
||||
|
|
@ -50,7 +50,7 @@ class Inception extends OpenAI {
|
|||
top_p: options.topP,
|
||||
frequency_penalty: options.frequencyPenalty,
|
||||
presence_penalty: options.presencePenalty,
|
||||
stop: options.stop,
|
||||
stop: [...(options.stop ?? []), "\n\n", "\n \n"],
|
||||
stream: true,
|
||||
}),
|
||||
headers: {
|
||||
|
|
|
|||
4
packages/openai-adapters/package-lock.json
generated
4
packages/openai-adapters/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.0.20",
|
||||
"version": "1.0.21",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.0.20",
|
||||
"version": "1.0.21",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@azure/openai": "^1.0.0-beta.12",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.0.20",
|
||||
"version": "1.0.21",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
|||
58
packages/openai-adapters/src/apis/Inception.ts
Normal file
58
packages/openai-adapters/src/apis/Inception.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import { streamSse } from "@continuedev/fetch";
|
||||
import { ChatCompletionChunk, Model } from "openai/resources/index";
|
||||
import { InceptionConfig } from "../types.js";
|
||||
import { chatChunk, customFetch } from "../util.js";
|
||||
import { OpenAIApi } from "./OpenAI.js";
|
||||
import { FimCreateParamsStreaming } from "./base.js";
|
||||
|
||||
export class InceptionApi extends OpenAIApi {
|
||||
apiBase: string = "https://api.inceptionlabs.ai/v1/";
|
||||
constructor(config: InceptionConfig) {
|
||||
super({
|
||||
...config,
|
||||
provider: "openai",
|
||||
});
|
||||
}
|
||||
|
||||
async *fimStream(
|
||||
body: FimCreateParamsStreaming,
|
||||
signal: AbortSignal,
|
||||
): AsyncGenerator<ChatCompletionChunk, any, unknown> {
|
||||
const endpoint = new URL("completions", this.apiBase);
|
||||
const resp = await customFetch(this.config.requestOptions)(endpoint, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
model: body.model,
|
||||
prompt: body.prompt,
|
||||
suffix: body.suffix.trim() === "" ? "<|endoftext|>" : body.suffix,
|
||||
max_tokens: body.max_tokens ?? 150, // Only want this for /fim, not chat
|
||||
temperature: body.temperature,
|
||||
top_p: body.top_p,
|
||||
frequency_penalty: body.frequency_penalty,
|
||||
presence_penalty: body.presence_penalty,
|
||||
stop: [...(body.stop ?? []), "\n\n", "\n \n"],
|
||||
stream: true,
|
||||
}),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${this.config.apiKey}`,
|
||||
},
|
||||
signal,
|
||||
});
|
||||
for await (const chunk of streamSse(resp as any)) {
|
||||
if (!chunk.choices[0]) {
|
||||
continue;
|
||||
}
|
||||
yield chatChunk({
|
||||
content: chunk.choices[0].text,
|
||||
finish_reason: null,
|
||||
model: body.model,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
list(): Promise<Model[]> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import { BaseLlmApi } from "./apis/base.js";
|
|||
import { CohereApi } from "./apis/Cohere.js";
|
||||
import { DeepSeekApi } from "./apis/DeepSeek.js";
|
||||
import { GeminiApi } from "./apis/Gemini.js";
|
||||
import { InceptionApi } from "./apis/Inception.js";
|
||||
import { JinaApi } from "./apis/Jina.js";
|
||||
import { MockApi } from "./apis/Mock.js";
|
||||
import { MoonshotApi } from "./apis/Moonshot.js";
|
||||
|
|
@ -45,6 +46,8 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined {
|
|||
return new MoonshotApi(config);
|
||||
case "relace":
|
||||
return new RelaceApi(config);
|
||||
case "inception":
|
||||
return new InceptionApi(config);
|
||||
case "x-ai":
|
||||
return openAICompatible("https://api.x.ai/v1/", config);
|
||||
case "voyage":
|
||||
|
|
|
|||
|
|
@ -103,6 +103,11 @@ export const JinaConfigSchema = OpenAIConfigSchema.extend({
|
|||
});
|
||||
export type JinaConfig = z.infer<typeof JinaConfigSchema>;
|
||||
|
||||
export const InceptionConfigSchema = OpenAIConfigSchema.extend({
|
||||
provider: z.literal("inception"),
|
||||
});
|
||||
export type InceptionConfig = z.infer<typeof InceptionConfigSchema>;
|
||||
|
||||
// Discriminated union
|
||||
export const LLMConfigSchema = z.discriminatedUnion("provider", [
|
||||
OpenAIConfigSchema,
|
||||
|
|
@ -114,5 +119,6 @@ export const LLMConfigSchema = z.discriminatedUnion("provider", [
|
|||
AnthropicConfigSchema,
|
||||
JinaConfigSchema,
|
||||
MockConfigSchema,
|
||||
InceptionConfigSchema,
|
||||
]);
|
||||
export type LLMConfig = z.infer<typeof LLMConfigSchema>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue