| 1 | import { ChatCompletionCreateParams } from "openai/resources/index"; |
| 2 | import { ChatMessage, CompletionOptions, LLMOptions } from "../../index.js"; |
| 3 | import OpenAI from "./OpenAI.js"; |
| 4 | |
| 5 | export class OVHcloud extends OpenAI { |
| 6 | static providerName = "ovhcloud"; |
| 7 | |
| 8 | static defaultOptions: Partial<LLMOptions> = { |
| 9 | apiBase: "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1/", |
| 10 | model: "Qwen2.5-Coder-32B-Instruct", |
| 11 | useLegacyCompletionsEndpoint: false, |
| 12 | }; |
| 13 | |
| 14 | private static MODEL_IDS: { [name: string]: string } = { |
| 15 | "llama3.1-8b": "Llama-3.1-8B-Instruct", |
| 16 | "llama3.1-70b": "Meta-Llama-3_1-70B-Instruct", |
| 17 | "llama3.3-70b": "Meta-Llama-3_3-70B-Instruct", |
| 18 | "qwen2.5-coder-32b": "Qwen2.5-Coder-32B-Instruct", |
| 19 | "codestral-mamba-latest": "mamba-codestral-7B-v0.1", |
| 20 | "mistral-7b": "Mistral-7B-Instruct-v0.3", |
| 21 | "mistral-8x7b": "Mixtral-8x7B-Instruct-v0.1", |
| 22 | "mistral-nemo": "Mistral-Nemo-Instruct-2407", |
| 23 | "DeepSeek-R1-Distill-Llama-70B": "DeepSeek-R1-Distill-Llama-70B", |
| 24 | }; |
| 25 | |
| 26 | protected _convertModelName(model: string) { |
| 27 | return OVHcloud.MODEL_IDS[model] || this.model; |
| 28 | } |
| 29 | |
| 30 | protected _convertArgs( |
| 31 | options: CompletionOptions, |
| 32 | messages: ChatMessage[], |
| 33 | ): ChatCompletionCreateParams { |
| 34 | const modifiedOptions = { |
| 35 | ...options, |
| 36 | model: this._convertModelName(options.model), |
| 37 | }; |
| 38 | return super._convertArgs(modifiedOptions, messages); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | export default OVHcloud; |