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) }