fix(thinking): improve model lookup and validation

This commit is contained in:
hkfires
2026-01-14 16:30:28 +08:00
parent 40ee065eff
commit 7f1b2b3f6e
13 changed files with 78 additions and 137 deletions

View File

@@ -132,6 +132,21 @@ func GetGlobalRegistry() *ModelRegistry {
return globalRegistry
}
// LookupModelInfo searches the dynamic registry first, then falls back to static model definitions.
//
// This helper exists because some code paths only have a model ID and still need Thinking and
// max completion token metadata even when the dynamic registry hasn't been populated.
func LookupModelInfo(modelID string) *ModelInfo {
modelID = strings.TrimSpace(modelID)
if modelID == "" {
return nil
}
if info := GetGlobalRegistry().GetModelInfo(modelID); info != nil {
return info
}
return LookupStaticModelInfo(modelID)
}
// SetHook sets an optional hook for observing model registration changes.
func (r *ModelRegistry) SetHook(hook ModelRegistryHook) {
if r == nil {