Use convertmodelname to avoid 422 errors

This commit is contained in:
Thibault Genaitay 2024-12-12 12:08:02 +01:00
parent 86b40c7d14
commit a3fc66b530

View file

@ -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;