feat: add model picker on non-ollama llm

This commit is contained in:
2026-04-21 09:17:48 +02:00
parent 2761282c0b
commit 985768f400
5 changed files with 82 additions and 10 deletions

View File

@ -174,6 +174,25 @@ func (h *Handler) DeleteAIProvider(c *gin.Context) {
httputil.NoContent(c)
}
func (h *Handler) ProbeAIModels(c *gin.Context) {
var req aiProviderRequest
if err := c.ShouldBindJSON(&req); err != nil {
httputil.BadRequest(c, err)
return
}
provider, err := h.pipeline.BuildProvider(req.Name, req.APIKey, req.Endpoint)
if err != nil {
httputil.InternalError(c, err)
return
}
models, err := provider.ListModels(c.Request.Context())
if err != nil {
httputil.InternalError(c, err)
return
}
httputil.OK(c, models)
}
func (h *Handler) ListAIModels(c *gin.Context) {
id := c.Param("id")
p, err := h.repo.GetAIProviderByID(id)

View File

@ -63,6 +63,7 @@ func SetupRouter(h *handlers.Handler, jwtSecret string) *gin.Engine {
admin.POST("/ai-providers/:id/activate", h.SetActiveAIProvider)
admin.DELETE("/ai-providers/:id", h.DeleteAIProvider)
admin.GET("/ai-providers/:id/models", h.ListAIModels)
admin.POST("/ai-providers/probe-models", h.ProbeAIModels)
admin.GET("/sources", h.ListSources)
admin.PUT("/sources/:id", h.UpdateSource)