feat(qa): add synthesis conversations with source retention (#52)

This commit is contained in:
2026-11-25 19:46:06 +01:00
parent 90dd2a65d2
commit 287811184f
49 changed files with 2636 additions and 47 deletions

View File

@ -12,6 +12,10 @@ import (
)
func preferencesError(c *gin.Context, err error) {
if errors.Is(err, models.ErrInvalidRetention) {
c.JSON(400, gin.H{"error": "invalid_source_article_retention_days"})
return
}
if errors.Is(err, models.ErrRankingModelIncompatible) {
c.JSON(400, gin.H{"error": "ranking_model_incompatible", "reason": "ranking_structured_output_unsupported", "message": "Ce modèle reste disponible pour la synthèse mais sa sortie JSON structurée n’est pas prise en charge pour le classement."})
return
@ -51,6 +55,7 @@ func (h *Handler) GetMyPreferences(c *gin.Context) {
func (h *Handler) UpdateMyPreferences(c *gin.Context) {
var body struct {
Retention json.RawMessage `json:"source_article_retention_days"`
RankingModelID *string `json:"ranking_model_id" binding:"omitempty,uuid"`
Language string `json:"language" binding:"required,oneof=fr en"`
RankingMode string `json:"ranking_mode" binding:"required,oneof=title title_content"`
@ -66,6 +71,10 @@ func (h *Handler) UpdateMyPreferences(c *gin.Context) {
c.JSON(400, gin.H{"error": "invalid_prompt_budget"})
return
}
if len(body.Retention) > 0 && (string(body.Retention) == "null" || json.Unmarshal(body.Retention, &req.SourceArticleRetentionDays) != nil || req.SourceArticleRetentionDays < 1 || req.SourceArticleRetentionDays > 30) {
c.JSON(400, gin.H{"error": "invalid_source_article_retention_days"})
return
}
p, err := h.repo.UpdateUserPreferences(c.GetString("userID"), req)
if err != nil {
preferencesError(c, err)