feat(generation): score articles with selected relevance model (#48)
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tradarr/backend/internal/httputil"
|
||||
"github.com/tradarr/backend/internal/models"
|
||||
"github.com/tradarr/backend/internal/rankingcapability"
|
||||
"github.com/tradarr/backend/internal/summarybudget"
|
||||
)
|
||||
|
||||
@ -23,21 +24,31 @@ func catalogHTTPError(c *gin.Context, err error) {
|
||||
}
|
||||
}
|
||||
func (h *Handler) ListMySummaryModels(c *gin.Context) {
|
||||
role := c.Query("role")
|
||||
if role != "" && role != "summary" && role != "ranking" {
|
||||
c.JSON(400, gin.H{"error": "invalid model role"})
|
||||
return
|
||||
}
|
||||
|
||||
rows, err := h.repo.ListSummaryModels(true)
|
||||
if err != nil {
|
||||
catalogHTTPError(c, err)
|
||||
return
|
||||
}
|
||||
type option struct {
|
||||
PromptCapacity *summarybudget.Profile `json:"prompt_capacity"`
|
||||
ID string `json:"id"`
|
||||
Provider string `json:"provider"`
|
||||
Model string `json:"model"`
|
||||
Label string `json:"label"`
|
||||
RankingCapability rankingcapability.Capability `json:"ranking_capability"`
|
||||
PromptCapacity *summarybudget.Profile `json:"prompt_capacity"`
|
||||
ID string `json:"id"`
|
||||
Provider string `json:"provider"`
|
||||
Model string `json:"model"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
result := []option{}
|
||||
for _, row := range rows {
|
||||
result = append(result, option{row.PromptCapacity, row.ID, row.Provider, row.Model, row.Label})
|
||||
if role == "ranking" && !row.RankingCapability.Selectable {
|
||||
continue
|
||||
}
|
||||
result = append(result, option{RankingCapability: row.RankingCapability, PromptCapacity: row.PromptCapacity, ID: row.ID, Provider: row.Provider, Model: row.Model, Label: row.Label})
|
||||
}
|
||||
httputil.OK(c, result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user