feat(ollama): improve configuration and dashboard integration
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

This commit is contained in:
2026-04-07 12:53:17 +00:00
parent 1b5cd2815e
commit 1e13b0376b
4 changed files with 197 additions and 7 deletions
+32 -1
View File
@@ -154,6 +154,7 @@ func (s *Server) RefreshProviders() error {
s.providers["grok"] = providers.NewGrokProvider(cfg, apiKey)
case "ollama":
cfg := s.cfg.Providers.Ollama
fmt.Printf("[DEBUG] Ollama config: Enabled=%v, BaseURL=%s, Models=%v\n", cfg.Enabled, baseURL, cfg.Models)
cfg.BaseURL = baseURL
s.providers["ollama"] = providers.NewOllamaProvider(cfg)
}
@@ -271,6 +272,28 @@ func (s *Server) handleListModels(c *gin.Context) {
}
}
// Add configured Ollama models
if s.cfg.Providers.Ollama.Enabled {
for _, mID := range s.cfg.Providers.Ollama.Models {
// Check if already added
exists := false
for _, d := range data {
if d.ID == mID {
exists = true
break
}
}
if !exists {
data = append(data, OpenAIModel{
ID: mID,
Object: "model",
Created: 1700000000,
OwnedBy: "ollama",
})
}
}
}
c.JSON(http.StatusOK, gin.H{
"object": "list",
"data": data,
@@ -305,9 +328,17 @@ func (s *Server) handleChatCompletions(c *gin.Context) {
return
}
// Strip common prefixes
modelID := req.Model
if strings.HasPrefix(modelID, "gemini/") {
modelID = strings.TrimPrefix(modelID, "gemini/")
} else if strings.HasPrefix(modelID, "google/") {
modelID = strings.TrimPrefix(modelID, "google/")
}
// Convert ChatCompletionRequest to UnifiedRequest
unifiedReq := &models.UnifiedRequest{
Model: req.Model,
Model: modelID,
Messages: []models.UnifiedMessage{},
Temperature: req.Temperature,
TopP: req.TopP,