fix: tool call anchor & wire format, streaming chunk passthrough, WebUI narrow-screen, docs bilingual

This commit is contained in:
root
2026-08-08 11:26:58 +08:00
parent 8e9de95274
commit 5d50b69153
18 changed files with 1119 additions and 42 deletions

View File

@ -100,6 +100,43 @@ func (p *Provider) ModelByID(id string) *config.Model {
return nil
}
// ModelFor resolves the model name this provider should send upstream.
// If the requested model is not owned by this provider (e.g. an AUTO chain
// fallback), it returns this provider's highest-priority chat model instead.
func (p *Provider) ModelFor(reqModel string) string {
if reqModel == "" || isAutoID(reqModel) {
return p.bestChatModel()
}
if p.ModelByID(reqModel) != nil {
return reqModel
}
return p.bestChatModel()
}
// bestChatModel returns the highest-priority chat-kind model of this source.
func (p *Provider) bestChatModel() string {
bestID, bestPrio := "", -1
for _, m := range p.cfg.Models {
if m.Kind != "" && m.Kind != "chat" {
continue
}
if m.Priority > bestPrio {
bestPrio = m.Priority
bestID = m.ID
}
}
if bestID == "" && len(p.cfg.Models) > 0 {
bestID = p.cfg.Models[0].ID
}
return bestID
}
// IsAutoID reports whether s is an AUTO routing placeholder.
func isAutoID(s string) bool {
s = strings.TrimSpace(s)
return s == "" || strings.EqualFold(s, "AUTO")
}
// Endpoint resolves the upstream chat path.
func (p *Provider) Endpoint() string {
if p.cfg.Endpoint != "" {