tui: Add setting view with support for changing the current model
This commit is contained in:
@@ -31,6 +31,7 @@ type Config struct {
|
||||
} `yaml:"agents"`
|
||||
Providers []*struct {
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Display string `yaml:"display,omitempty"`
|
||||
Kind string `yaml:"kind"`
|
||||
BaseURL string `yaml:"baseUrl,omitempty"`
|
||||
APIKey string `yaml:"apiKey,omitempty"`
|
||||
|
||||
@@ -123,11 +123,10 @@ func (c *Context) DefaultSystemPrompt() string {
|
||||
return c.Config.Defaults.SystemPrompt
|
||||
}
|
||||
|
||||
func (c *Context) GetModelProvider(model string) (string, api.ChatCompletionProvider, error) {
|
||||
func (c *Context) GetModelProvider(model string, provider string) (string, string, api.ChatCompletionProvider, error) {
|
||||
parts := strings.Split(model, "@")
|
||||
|
||||
var provider string
|
||||
if len(parts) > 1 {
|
||||
if provider == "" && len(parts) > 1 {
|
||||
model = parts[0]
|
||||
provider = parts[1]
|
||||
}
|
||||
@@ -150,7 +149,7 @@ func (c *Context) GetModelProvider(model string) (string, api.ChatCompletionProv
|
||||
if p.BaseURL != "" {
|
||||
url = p.BaseURL
|
||||
}
|
||||
return model, &anthropic.AnthropicClient{
|
||||
return model, name, &anthropic.AnthropicClient{
|
||||
BaseURL: url,
|
||||
APIKey: p.APIKey,
|
||||
}, nil
|
||||
@@ -159,7 +158,7 @@ func (c *Context) GetModelProvider(model string) (string, api.ChatCompletionProv
|
||||
if p.BaseURL != "" {
|
||||
url = p.BaseURL
|
||||
}
|
||||
return model, &google.Client{
|
||||
return model, name, &google.Client{
|
||||
BaseURL: url,
|
||||
APIKey: p.APIKey,
|
||||
}, nil
|
||||
@@ -168,7 +167,7 @@ func (c *Context) GetModelProvider(model string) (string, api.ChatCompletionProv
|
||||
if p.BaseURL != "" {
|
||||
url = p.BaseURL
|
||||
}
|
||||
return model, &ollama.OllamaClient{
|
||||
return model, name, &ollama.OllamaClient{
|
||||
BaseURL: url,
|
||||
}, nil
|
||||
case "openai":
|
||||
@@ -176,18 +175,18 @@ func (c *Context) GetModelProvider(model string) (string, api.ChatCompletionProv
|
||||
if p.BaseURL != "" {
|
||||
url = p.BaseURL
|
||||
}
|
||||
return model, &openai.OpenAIClient{
|
||||
return model, name, &openai.OpenAIClient{
|
||||
BaseURL: url,
|
||||
APIKey: p.APIKey,
|
||||
Headers: p.Headers,
|
||||
}, nil
|
||||
default:
|
||||
return "", nil, fmt.Errorf("unknown provider kind: %s", p.Kind)
|
||||
return "", "", nil, fmt.Errorf("unknown provider kind: %s", p.Kind)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", nil, fmt.Errorf("unknown model: %s", model)
|
||||
return "", "", nil, fmt.Errorf("unknown model: %s", model)
|
||||
}
|
||||
|
||||
func configDir() string {
|
||||
|
||||
Reference in New Issue
Block a user