feat(openai-compat): enhance provider key handling and model resolution

- Introduced dynamic `providerKey` resolution for OpenAI-compatible providers, incorporating attributes like `provider_key` and `compat_name`.
- Implemented upstream model overrides via `resolveUpstreamModel` and `overrideModel` methods in the OpenAI executor.
- Updated registry logic to correctly store provider mappings and register clients using normalized keys.
- Ensured consistency in handling empty or default provider names across components.
This commit is contained in:
Luis Pater
2025-09-22 22:54:21 +08:00
parent f1c4caf14a
commit e41d127732
3 changed files with 106 additions and 14 deletions

View File

@@ -474,19 +474,24 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth {
}
for i := range cfg.OpenAICompatibility {
compat := &cfg.OpenAICompatibility[i]
providerName := strings.ToLower(strings.TrimSpace(compat.Name))
if providerName == "" {
providerName = "openai-compatibility"
}
base := compat.BaseURL
for j := range compat.APIKeys {
key := compat.APIKeys[j]
a := &coreauth.Auth{
ID: fmt.Sprintf("openai-compatibility:%s:%d", compat.Name, j),
Provider: "openai-compatibility",
Provider: providerName,
Label: compat.Name,
Status: coreauth.StatusActive,
Attributes: map[string]string{
"source": fmt.Sprintf("config:%s#%d", compat.Name, j),
"base_url": base,
"api_key": key,
"compat_name": compat.Name,
"source": fmt.Sprintf("config:%s#%d", compat.Name, j),
"base_url": base,
"api_key": key,
"compat_name": compat.Name,
"provider_key": providerName,
},
CreatedAt: now,
UpdatedAt: now,