feat(article): support regenerating failed articles

This commit is contained in:
2026-05-07 10:55:44 +08:00
parent ff2bb77cdd
commit 7d82c5c193
21 changed files with 659 additions and 23 deletions
@@ -43,7 +43,16 @@ func NewArticleHandler(a *bootstrap.App) *ArticleHandler {
).WithConfigProvider(a.ConfigStore)
return &ArticleHandler{
svc: app.NewArticleService(a.DB, a.AuditLogs, a.ObjectStorage).WithCache(a.Cache),
svc: app.NewArticleService(a.DB, a.AuditLogs, a.ObjectStorage).
WithCache(a.Cache).
WithGenerationRuntime(
a.LLM,
a.RabbitMQ,
a.GenerationStreams,
a.Config().Generation,
a.Config().LLM.MaxOutputTokens,
).
WithConfigProvider(a.ConfigStore),
selectionOptimize: app.NewArticleSelectionOptimizeService(
a.DB,
a.LLM,
@@ -188,6 +197,22 @@ func (h *ArticleHandler) GenerateImitation(c *gin.Context) {
response.SuccessWithStatus(c, http.StatusCreated, data)
}
func (h *ArticleHandler) Regenerate(c *gin.Context) {
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
if err != nil {
response.Error(c, response.ErrBadRequest(40001, "invalid_id", "article id must be a number"))
return
}
data, err := h.svc.Regenerate(c.Request.Context(), id)
if err != nil {
response.Error(c, err)
return
}
response.SuccessWithStatus(c, http.StatusCreated, data)
}
func (h *ArticleHandler) Create(c *gin.Context) {
var req app.CreateArticleRequest
if err := c.ShouldBindJSON(&req); err != nil {