From 34384f2fe86b90504c661f1a801fb11bfbc4a347 Mon Sep 17 00:00:00 2001 From: Christopher Petito Date: Mon, 29 Sep 2025 22:38:34 +0200 Subject: [PATCH] only replace colons in the azure model mapper func seems to come from the upstream library https://github.com/sashabaranov/go-openai/issues/978 fixes #211 Signed-off-by: Christopher Petito --- pkg/model/provider/openai/client.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/model/provider/openai/client.go b/pkg/model/provider/openai/client.go index 4d3fd776..bbf74c58 100644 --- a/pkg/model/provider/openai/client.go +++ b/pkg/model/provider/openai/client.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "log/slog" + "regexp" "strings" "github.com/sashabaranov/go-openai" @@ -54,6 +55,17 @@ func NewClient(ctx context.Context, cfg *latest.ModelConfig, env environment.Pro if cfg.Provider == "azure" { openaiConfig = openai.DefaultAzureConfig(authToken, cfg.BaseURL) + openaiConfig.AzureModelMapperFunc = func(model string) string { + // NOTE(krissetto): This is to preserve dots in deployment names. + // Only strip colons like the library already does to minimize code drift. + // Can be removed once fixed/changed upstream. See https://github.com/sashabaranov/go-openai/issues/978 + + // only 3.5 models have the "." stripped in their names + if strings.Contains(model, "3.5") { + return regexp.MustCompile(`[.:]`).ReplaceAllString(model, "") + } + return strings.ReplaceAll(model, ":", "") + } } else { openaiConfig = openai.DefaultConfig(authToken) }