fix(server): add Ollama model detection and registry support

- Add Ollama to allowed providers in model list endpoint
- Add model pattern detection for Ollama models (glm-, qwen, gemma, llama, mistral, codellama)
- This fixes 500 errors when using Ollama models via /v1/chat/completions
This commit is contained in:
2026-04-06 14:45:57 -04:00
parent 2f6b7deb2c
commit cbc9eeb453
+3
View File
@@ -252,6 +252,7 @@ func (s *Server) handleListModels(c *gin.Context) {
"deepseek": true,
"moonshot": true,
"xai": true, // Models from models.dev use 'xai' ID for Grok
"ollama": true,
}
if s.registry != nil {
@@ -294,6 +295,8 @@ func (s *Server) handleChatCompletions(c *gin.Context) {
providerName = "moonshot"
} else if strings.Contains(req.Model, "grok") {
providerName = "grok"
} else if strings.Contains(req.Model, "glm-") || strings.Contains(req.Model, "qwen") || strings.Contains(req.Model, "gemma") || strings.Contains(req.Model, "llama") || strings.Contains(req.Model, "mistral") || strings.Contains(req.Model, "codellama") {
providerName = "ollama"
}
provider, ok := s.providers[providerName]