feat(qa): add synthesis conversations with source retention (#52)
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user