feat(article): support regenerating failed articles
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user