| 1 | import OpenAI from "./OpenAI"; |
| 2 | |
| 3 | import { LLMOptions, CompletionOptions, ChatMessage } from "../../index.js"; |
| 4 | import { ChatCompletionCreateParams } from "openai/resources/index"; |
| 5 | |
| 6 | class Scaleway extends OpenAI { |
| 7 | static providerName = "scaleway"; |
| 8 | static defaultOptions: Partial<LLMOptions> = { |
| 9 | apiBase: "https://api.scaleway.ai/v1/", |
| 10 | model: "qwen3-coder-30b-a3b-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.3-70b": "llama-3.3-70b-instruct", |
| 17 | "pixtral-12b": "pixtral-12b-2409", |
| 18 | "mistral-small3.1": "mistral-small-3.1-24b-instruct-2503", |
| 19 | "mistral-small3.2": "mistral-small-3.2-24b-instruct-2506", |
| 20 | "devstral-small": "devstral-small-2505", |
| 21 | "deepseek-r1-distill-llama-70b": "deepseek-r1-distill-llama-70b", |
| 22 | "qwen2.5-coder-32b": "qwen2.5-coder-32b-instruct", |
| 23 | "qwen3-coder-30b-a3b": "qwen3-coder-30b-a3b-instruct", |
| 24 | "qwen3-235b-a22b": "qwen3-235b-a22b-instruct-2507", |
| 25 | "gemma-3-27b": "gemma-3-27b-it", |
| 26 | "gpt-oss-120b": "gpt-oss-120b", |
| 27 | }; |
| 28 | |
| 29 | protected _convertModelName(model: string) { |
| 30 | return Scaleway.MODEL_IDS[model] || this.model; |
| 31 | } |
| 32 | protected _convertArgs( |
| 33 | options: CompletionOptions, |
| 34 | messages: ChatMessage[], |
| 35 | ): ChatCompletionCreateParams { |
| 36 | // Convert model name in the options before passing to parent |
| 37 | const modifiedOptions = { |
| 38 | ...options, |
| 39 | model: this._convertModelName(options.model), |
| 40 | }; |
| 41 | return super._convertArgs(modifiedOptions, messages); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | export default Scaleway; |