| 1 | import OpenAI from "./OpenAI.js"; |
| 2 | |
| 3 | import type { CompletionOptions, LLMOptions } from "../../index.js"; |
| 4 | |
| 5 | class Novita extends OpenAI { |
| 6 | static providerName = "novita"; |
| 7 | static defaultOptions: Partial<LLMOptions> = { |
| 8 | apiBase: "https://api.novita.ai/v3/openai/", |
| 9 | }; |
| 10 | |
| 11 | private static MODEL_IDS: { [name: string]: string } = { |
| 12 | "deepseek-r1": "deepseek/deepseek-r1", |
| 13 | deepseek_v3: "deepseek/deepseek_v3", |
| 14 | "llama3-8b": "meta-llama/llama-3-8b-instruct", |
| 15 | "llama3-70b": "meta-llama/llama-3-70b-instruct", |
| 16 | "llama3.1-8b": "meta-llama/llama-3.1-8b-instruct", |
| 17 | "llama3.1-70b": "meta-llama/llama-3.1-70b-instruct", |
| 18 | "llama3.1-405b": "meta-llama/llama-3.1-405b-instruct", |
| 19 | "llama3.2-1b": "meta-llama/llama-3.2-1b-instruct", |
| 20 | "llama3.2-3b": "meta-llama/llama-3.2-3b-instruct", |
| 21 | "llama3.2-11b": "meta-llama/llama-3.2-11b-vision-instruct", |
| 22 | "llama3.3-70b": "meta-llama/llama-3.3-70b-instruct", |
| 23 | "mistral-nemo": "mistralai/mistral-nemo", |
| 24 | "mistral-7b": "mistralai/mistral-7b-instruct", |
| 25 | }; |
| 26 | |
| 27 | protected _convertModelName(model: string) { |
| 28 | return Novita.MODEL_IDS[model] || this.model; |
| 29 | } |
| 30 | |
| 31 | protected async *_streamComplete( |
| 32 | prompt: string, |
| 33 | signal: AbortSignal, |
| 34 | options: CompletionOptions, |
| 35 | ): AsyncGenerator<string> { |
| 36 | for await (const chunk of this._legacystreamComplete( |
| 37 | prompt, |
| 38 | signal, |
| 39 | options, |
| 40 | )) { |
| 41 | yield chunk; |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export default Novita; |