diff --git a/core/llm/llms/Inception.ts b/core/llm/llms/Inception.ts new file mode 100644 index 000000000..3d9f992ad --- /dev/null +++ b/core/llm/llms/Inception.ts @@ -0,0 +1,48 @@ +import { CompletionOptions, LLMOptions } from "../../index.js"; +import { streamSse } from "../stream.js"; + +import OpenAI from "./OpenAI.js"; + +class Inception extends OpenAI { + static providerName = "inception"; + static defaultOptions: Partial = {}; + + supportsFim(): boolean { + return true; + } + + async *_streamFim( + prefix: string, + suffix: string, + signal: AbortSignal, + options: CompletionOptions, + ): AsyncGenerator { + const endpoint = new URL("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", + Authorization: `Bearer ${this.apiKey}`, + }, + signal, + }); + for await (const chunk of streamSse(resp)) { + yield chunk.choices[0].text; + } + } +} + +export default Inception; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index e27b78bcc..8e3f68b2e 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -27,6 +27,7 @@ import Gemini from "./Gemini"; import Groq from "./Groq"; import HuggingFaceInferenceAPI from "./HuggingFaceInferenceAPI"; import HuggingFaceTGI from "./HuggingFaceTGI"; +import Inception from "./Inception"; import Kindo from "./Kindo"; import LlamaCpp from "./LlamaCpp"; import Llamafile from "./Llamafile"; @@ -106,6 +107,7 @@ export const LLMClasses = [ SiliconFlow, Scaleway, Relace, + Inception, ]; export async function llmFromDescription(