feat: 添加AI问题生成功能,支持配置生成数量并在前端展示生成的问题
This commit is contained in:
@@ -123,6 +123,12 @@ type KBModelConfigRequest struct {
|
||||
Nodes []types.GraphNode `json:"nodes"`
|
||||
Relations []types.GraphRelation `json:"relations"`
|
||||
} `json:"nodeExtract"`
|
||||
|
||||
// 问题生成配置
|
||||
QuestionGeneration struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
QuestionCount int `json:"questionCount"`
|
||||
} `json:"questionGeneration"`
|
||||
}
|
||||
|
||||
// InitializationRequest 初始化请求结构
|
||||
@@ -192,6 +198,11 @@ type InitializationRequest struct {
|
||||
Type string `json:"type"`
|
||||
} `json:"relations"`
|
||||
} `json:"nodeExtract"`
|
||||
|
||||
QuestionGeneration struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
QuestionCount int `json:"questionCount"`
|
||||
} `json:"questionGeneration"`
|
||||
}
|
||||
|
||||
// UpdateKBConfig 根据知识库ID和模型ID更新配置(简化版)
|
||||
@@ -333,6 +344,23 @@ func (h *InitializationHandler) UpdateKBConfig(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 更新问题生成配置
|
||||
if req.QuestionGeneration.Enabled {
|
||||
questionCount := req.QuestionGeneration.QuestionCount
|
||||
if questionCount <= 0 {
|
||||
questionCount = 3
|
||||
}
|
||||
if questionCount > 10 {
|
||||
questionCount = 10
|
||||
}
|
||||
kb.QuestionGenerationConfig = &types.QuestionGenerationConfig{
|
||||
Enabled: true,
|
||||
QuestionCount: questionCount,
|
||||
}
|
||||
} else {
|
||||
kb.QuestionGenerationConfig = &types.QuestionGenerationConfig{Enabled: false}
|
||||
}
|
||||
|
||||
// 保存更新后的知识库
|
||||
if err := h.kbRepository.UpdateKnowledgeBase(ctx, kb); err != nil {
|
||||
logger.Error(ctx, "Failed to update knowledge base", err)
|
||||
|
||||
Reference in New Issue
Block a user