Merge pull request #4907 from continuedev/nate/mercury

inception provider
This commit is contained in:
Nate Sesti 2025-04-02 18:29:45 -07:00 • committed by GitHub
commit ef11e5fbb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 50 additions and 0 deletions

View file

@ -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<LLMOptions> = {};
supportsFim(): boolean {
return true;
}
async *_streamFim(
prefix: string,
suffix: string,
signal: AbortSignal,
options: CompletionOptions,
): AsyncGenerator<string> {
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;

View file

@ -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(