Add protocol selection to Claude and Codex provider forms referencing CCSwitch
This commit is contained in:
1 parent
bae24cc439
commit
16957decb2
14 files changed
+274
-25
No files matched your search
@@ -104,10 +104,10 @@ func (s *Store) ActiveCodex() *Provider {
|
||||
}
|
||||
|
||||
// AddProvider validates and appends a provider for the given target.
|
||||
func (s *Store) AddProvider(name, preset, baseURL, apiKey string, models Models, target string) (*Provider, error) {
|
||||
func (s *Store) AddProvider(name, preset, baseURL, apiKey string, models Models, target string, protocol ...string) (*Provider, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
p, err := newProvider(name, preset, baseURL, apiKey, models, target)
|
||||
p, err := newProvider(name, preset, baseURL, apiKey, models, target, protocol...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func (s *Store) AddProvider(name, preset, baseURL, apiKey string, models Models,
|
||||
// UpdateProvider replaces a provider's editable fields. An empty apiKey
|
||||
// keeps the stored key so edits never wipe it by accident; an empty
|
||||
// target keeps the stored one.
|
||||
func (s *Store) UpdateProvider(id, name, preset, baseURL, apiKey string, models Models, target string) (*Provider, error) {
|
||||
func (s *Store) UpdateProvider(id, name, preset, baseURL, apiKey string, models Models, target string, protocol ...string) (*Provider, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
idx := -1
|
||||
@@ -141,7 +141,11 @@ func (s *Store) UpdateProvider(id, name, preset, baseURL, apiKey string, models
|
||||
if target == "" {
|
||||
target = existing.Target
|
||||
}
|
||||
updated, err := newProvider(name, preset, baseURL, apiKey, models, target)
|
||||
proto := existing.Protocol
|
||||
if len(protocol) > 0 && strings.TrimSpace(protocol[0]) != "" {
|
||||
proto = strings.TrimSpace(protocol[0])
|
||||
}
|
||||
updated, err := newProvider(name, preset, baseURL, apiKey, models, target, proto)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user