Use getter/setter methods for API key access in ModelConfig
This commit is contained in:
parent
53c6dd3812
commit
2d9517c655
6 changed files with 10 additions and 10 deletions
|
|
@ -1199,11 +1199,11 @@ func TestModelConfig_ExtraBodyRoundTrip(t *testing.T) {
|
|||
cfgPath := filepath.Join(dir, "config.json")
|
||||
|
||||
cfg := &Config{
|
||||
ModelList: []ModelConfig{
|
||||
ModelList: []*ModelConfig{
|
||||
{
|
||||
ModelName: "test-model",
|
||||
Model: "openai/test",
|
||||
APIKey: "sk-test",
|
||||
apiKeys: []string{"sk-test"},
|
||||
ExtraBody: map[string]any{"custom_field": "value", "num_field": 42},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, err
|
|||
|
||||
case "minimax":
|
||||
// Minimax requires reasoning_split: true in the request body
|
||||
if cfg.APIKey == "" && cfg.APIBase == "" {
|
||||
if cfg.APIKey() == "" && cfg.APIBase == "" {
|
||||
return nil, "", fmt.Errorf("api_key or api_base is required for HTTP-based protocol %q", protocol)
|
||||
}
|
||||
apiBase := cfg.APIBase
|
||||
|
|
@ -153,7 +153,7 @@ func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, err
|
|||
extraBody["reasoning_split"] = true
|
||||
}
|
||||
return NewHTTPProviderWithMaxTokensFieldAndRequestTimeout(
|
||||
cfg.APIKey,
|
||||
cfg.APIKey(),
|
||||
apiBase,
|
||||
cfg.Proxy,
|
||||
cfg.MaxTokensField,
|
||||
|
|
|
|||
|
|
@ -622,9 +622,9 @@ func TestCreateProviderFromConfig_MinimaxInjectsReasoningSplit(t *testing.T) {
|
|||
cfg := &config.ModelConfig{
|
||||
ModelName: "test-minimax",
|
||||
Model: "minimax/MiniMax-M2.5",
|
||||
APIKey: "test-key",
|
||||
APIBase: server.URL,
|
||||
}
|
||||
cfg.SetAPIKey("test-key")
|
||||
|
||||
provider, modelID, err := CreateProviderFromConfig(cfg)
|
||||
if err != nil {
|
||||
|
|
@ -670,10 +670,10 @@ func TestCreateProviderFromConfig_MinimaxPreservesUserExtraBody(t *testing.T) {
|
|||
cfg := &config.ModelConfig{
|
||||
ModelName: "test-minimax-custom",
|
||||
Model: "minimax/MiniMax-M2.5",
|
||||
APIKey: "test-key",
|
||||
APIBase: server.URL,
|
||||
ExtraBody: map[string]any{"custom_field": "test"},
|
||||
}
|
||||
cfg.SetAPIKey("test-key")
|
||||
|
||||
provider, modelID, err := CreateProviderFromConfig(cfg)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export interface ModelInfo {
|
|||
max_tokens_field?: string
|
||||
request_timeout?: number
|
||||
thinking_level?: string
|
||||
extra_body?: Record<string, any>
|
||||
extra_body?: Record<string, unknown>
|
||||
// Meta
|
||||
configured: boolean
|
||||
is_default: boolean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue