Skip to content

Commit 8692cde

Browse files
authored
Merge pull request #358 from krissetto/fix-azure-model-mapper
Only replace colons in the azure model mapper func for non 3.5 models
2 parents 69e6544 + 34384f2 commit 8692cde

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/model/provider/openai/client.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"log/slog"
9+
"regexp"
910
"strings"
1011

1112
"github.com/sashabaranov/go-openai"
@@ -54,6 +55,17 @@ func NewClient(ctx context.Context, cfg *latest.ModelConfig, env environment.Pro
5455

5556
if cfg.Provider == "azure" {
5657
openaiConfig = openai.DefaultAzureConfig(authToken, cfg.BaseURL)
58+
openaiConfig.AzureModelMapperFunc = func(model string) string {
59+
// NOTE(krissetto): This is to preserve dots in deployment names.
60+
// Only strip colons like the library already does to minimize code drift.
61+
// Can be removed once fixed/changed upstream. See https://github.com/sashabaranov/go-openai/issues/978
62+
63+
// only 3.5 models have the "." stripped in their names
64+
if strings.Contains(model, "3.5") {
65+
return regexp.MustCompile(`[.:]`).ReplaceAllString(model, "")
66+
}
67+
return strings.ReplaceAll(model, ":", "")
68+
}
5769
} else {
5870
openaiConfig = openai.DefaultConfig(authToken)
5971
}

0 commit comments

Comments
 (0)