| 1 | import OpenAI from "./OpenAI"; |
| 2 | |
| 3 | import { LLMOptions, CompletionOptions, ChatMessage } from "../../index.js"; |
| 4 | import { ChatCompletionCreateParams } from "openai/resources/index"; |
| 5 | |
| 6 | |
| 7 | class Scaleway extends OpenAI { |
| 8 | static providerName = "scaleway"; |
| 9 | static defaultOptions: Partial<LLMOptions> = { |
| 10 | apiBase: "https://api.scaleway.ai/v1/", |
| 11 | model: "qwen2.5-coder-32b-instruct", |
| 12 | useLegacyCompletionsEndpoint: false, |
| 13 | }; |
| 14 | |
| 15 | private static MODEL_IDS: { [name: string]: string } = { |
| 16 | "llama3.1-8b": "llama-3.1-8b-instruct", |
| 17 | "llama3.1-70b": "llama-3.1-70b-instruct", |
| 18 | "mistral-nemo": "mistral-nemo-instruct-2407", |
| 19 | "qwen2.5-coder-32b": "qwen2.5-coder-32b-instruct", |
| 20 | "pixtral": "pixtral-12b-2409", |
| 21 | }; |
| 22 | |
| 23 | protected _convertModelName(model: string) { |
| 24 | return Scaleway.MODEL_IDS[model] || this.model; |
| 25 | } |
| 26 | protected _convertArgs(options: CompletionOptions, messages: ChatMessage[]): ChatCompletionCreateParams { |
| 27 | // Convert model name in the options before passing to parent |
| 28 | const modifiedOptions = { |
| 29 | ...options, |
| 30 | model: this._convertModelName(options.model) |
| 31 | }; |
| 32 | return super._convertArgs(modifiedOptions, messages); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | export default Scaleway; |