feat(admin-brand): add question expansion service and related functionality

- Implemented QuestionExpansionService for generating and materializing questions based on combinations and AI distillation.
- Added question metadata classification logic to infer intent and layer of questions.
- Created API handlers for question expansion operations including combination preview, AI distillation, metadata classification, and materialization.
- Introduced database migrations to support new question-related fields and constraints in brand_questions and brand_keywords tables.
- Added caching mechanism for AI distillation results to improve performance.
- Defined JSON schemas for question distillation responses to ensure data integrity.
This commit is contained in:
2026-05-12 21:53:36 +08:00
parent 77d542c282
commit 37b0b32327
27 changed files with 4619 additions and 908 deletions
@@ -176,6 +176,7 @@ func RegisterRoutes(app *bootstrap.App) {
brands := tenantProtected.Group("/brands")
brandHandler := NewBrandHandler(app)
questionExpansionHandler := NewQuestionExpansionHandler(app)
brands.GET("", brandHandler.List)
brands.GET("/library-summary", brandHandler.Summary)
brands.POST("", brandHandler.Create)
@@ -188,6 +189,10 @@ func RegisterRoutes(app *bootstrap.App) {
brands.DELETE("/:id/keywords/:kid", brandHandler.DeleteKeyword)
brands.GET("/:id/questions", brandHandler.ListQuestions)
brands.POST("/:id/questions", brandHandler.CreateQuestion)
brands.POST("/:id/questions/combination-preview", questionExpansionHandler.CombinationPreview)
brands.POST("/:id/questions/ai-distill", questionExpansionHandler.AIDistill)
brands.POST("/:id/questions/classify-metadata", questionExpansionHandler.ClassifyMetadata)
brands.POST("/:id/questions/materialize", questionExpansionHandler.Materialize)
brands.PUT("/:id/questions/:qid", brandHandler.UpdateQuestion)
brands.DELETE("/:id/questions/:qid", brandHandler.DeleteQuestion)
brands.GET("/:id/competitors", brandHandler.ListCompetitors)