feat(generation): persist summary outcomes without articles

Record generation outcomes and summaries for history while keeping article content transient.

Refs #7

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 21:20:35 +01:00
parent 9970b49746
commit 768c0fd7f5
26 changed files with 1657 additions and 438 deletions

View File

@ -9,7 +9,7 @@ import (
)
type reportRequest struct {
SummaryID string `json:"summary_id"`
SummaryID string `json:"summary_id" binding:"required,uuid"`
Excerpts []string `json:"excerpts" binding:"required,min=1"`
Question string `json:"question" binding:"required"`
}
@ -22,10 +22,22 @@ func (h *Handler) CreateReport(c *gin.Context) {
return
}
var summaryID *string
if req.SummaryID != "" {
summaryID = &req.SummaryID
summary, err := h.repo.GetOwnedSummary(req.SummaryID, userID)
if err != nil {
httputil.InternalError(c, err)
return
}
if summary == nil {
httputil.NotFound(c)
return
}
for _, excerpt := range req.Excerpts {
if strings.TrimSpace(excerpt) == "" || !strings.Contains(summary.Content, excerpt) {
c.JSON(http.StatusBadRequest, gin.H{"error": "excerpt must come from the summary"})
return
}
}
summaryID := &summary.ID
// Joindre les extraits avec un séparateur visuel
excerpt := buildExcerptContext(req.Excerpts)