Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions components/model/openai/chatmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ type ChatModelConfig struct {
// ExtraFields will override any existing fields with the same key.
// Optional. Useful for experimental features not yet officially supported.
ExtraFields map[string]any `json:"extra_fields,omitempty"`

// AzureModelMapperFunc is handling function for replacing model to azure deployment name func
// Optional. Set for lookup the model name with azure deployment name
AzureModelMapperFunc func(model string) string `json:"azure_model_mapper,omitempty"`
}

type ChatModel struct {
Expand Down Expand Up @@ -155,6 +159,7 @@ func NewChatModel(ctx context.Context, config *ChatModelConfig) (*ChatModel, err
LogitBias: config.LogitBias,
User: config.User,
ExtraFields: config.ExtraFields,
AzureModelMapperFunc: config.AzureModelMapperFunc,
}
}
cli, err := openai.NewClient(ctx, nConf)
Expand Down
8 changes: 8 additions & 0 deletions libs/acl/openai/chat_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ type Config struct {
// ExtraFields will override any existing fields with the same key.
// Optional. Useful for experimental features not yet officially supported.
ExtraFields map[string]any `json:"-"`

// AzureModelMapperFunc is handling function for replacing model to azure deployment name func
// Optional. Set for lookup the model name with azure deployment name
AzureModelMapperFunc func(model string) string `json:"azure_model_mapper,omitempty"`
}

type Client struct {
Expand All @@ -168,6 +172,10 @@ func NewClient(ctx context.Context, config *Config) (*Client, error) {
if config.APIVersion != "" {
clientConf.APIVersion = config.APIVersion
}

if config.AzureModelMapperFunc != nil {
clientConf.AzureModelMapperFunc = config.AzureModelMapperFunc
}
} else {
clientConf = openai.DefaultConfig(config.APIKey)
if len(config.BaseURL) > 0 {
Expand Down