Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/model/provider/openai/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"log/slog"
"regexp"
"strings"

"github.com/sashabaranov/go-openai"
Expand Down Expand Up @@ -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)
}
Expand Down
Loading