Merge pull request #4907 from continuedev/nate/mercury
inception provider
This commit is contained in:
commit
ef11e5fbb6
2 changed files with 50 additions and 0 deletions
48
core/llm/llms/Inception.ts
Normal file
48
core/llm/llms/Inception.ts
Normal 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;
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue