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:
@@ -252,6 +252,7 @@ func (s *Server) handleListModels(c *gin.Context) {
|
|||||||
"deepseek": true,
|
"deepseek": true,
|
||||||
"moonshot": true,
|
"moonshot": true,
|
||||||
"xai": true, // Models from models.dev use 'xai' ID for Grok
|
"xai": true, // Models from models.dev use 'xai' ID for Grok
|
||||||
|
"ollama": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.registry != nil {
|
if s.registry != nil {
|
||||||
@@ -294,6 +295,8 @@ func (s *Server) handleChatCompletions(c *gin.Context) {
|
|||||||
providerName = "moonshot"
|
providerName = "moonshot"
|
||||||
} else if strings.Contains(req.Model, "grok") {
|
} else if strings.Contains(req.Model, "grok") {
|
||||||
providerName = "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]
|
provider, ok := s.providers[providerName]
|
||||||
|
|||||||
Reference in New Issue
Block a user