From a3fc66b530e07318ea2b107b94bbb9a983ab2cd6 Mon Sep 17 00:00:00 2001 From: Thibault Genaitay Date: Thu, 12 Dec 2024 12:08:02 +0100 Subject: [PATCH] Use convertmodelname to avoid 422 errors --- core/llm/llms/Scaleway.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/llm/llms/Scaleway.ts b/core/llm/llms/Scaleway.ts index 95b8d6db3..aaee08bc2 100644 --- a/core/llm/llms/Scaleway.ts +++ b/core/llm/llms/Scaleway.ts @@ -1,6 +1,7 @@ import OpenAI from "./OpenAI"; -import { LLMOptions } from "../../index.js"; +import { LLMOptions, CompletionOptions, ChatMessage } from "../../index.js"; +import { ChatCompletionCreateParams } from "openai/resources/index"; class Scaleway extends OpenAI { @@ -22,6 +23,14 @@ class Scaleway extends OpenAI { protected _convertModelName(model: string) { return Scaleway.MODEL_IDS[model] || this.model; } + protected _convertArgs(options: CompletionOptions, messages: ChatMessage[]): ChatCompletionCreateParams { + // Convert model name in the options before passing to parent + const modifiedOptions = { + ...options, + model: this._convertModelName(options.model) + }; + return super._convertArgs(modifiedOptions, messages); + } } export default Scaleway;