feat(prompt): enhance context and intent classification in templates

- Updated context template to include runtime metadata such as current time and week, improving contextual awareness in user queries.
- Enhanced rewrite template with critical instructions for intent classification, ensuring that rewritten questions preserve essential entities and keywords.
- Refined intent classification logic to prioritize user intents more effectively, improving the accuracy of responses based on user queries.
- Added examples to clarify expected input and output formats for intent classification, enhancing usability for developers.
This commit is contained in:
wizardchen
2026-03-26 16:45:51 +08:00
committed by lyingbug
parent 27d4525ba9
commit 72dfb9ce75
44 changed files with 451 additions and 135 deletions
+5 -2
View File
@@ -969,10 +969,13 @@ func (r *chunkRepository) ListRecentDocumentChunksWithQuestions(
Select("id, knowledge_base_id, chunk_type, metadata, updated_at").
Where("tenant_id = ? AND chunk_type = ? AND status IN ? AND is_enabled = ?",
tenantID, types.ChunkTypeText, []int{int(types.ChunkStatusIndexed), int(types.ChunkStatusDefault)}, true)
if len(knowledgeIDs) > 0 {
if len(kbIDs) > 0 && len(knowledgeIDs) > 0 {
baseQuery = baseQuery.Where("knowledge_base_id IN ? OR knowledge_id IN ?", kbIDs, knowledgeIDs)
} else if len(knowledgeIDs) > 0 {
// 指定了具体知识文档,直接按 knowledge_id 过滤(忽略 kbIDs)
baseQuery = baseQuery.Where("knowledge_id IN ?", knowledgeIDs)
} else {
} else if len(kbIDs) > 0 {
baseQuery = baseQuery.Where("knowledge_base_id IN ?", kbIDs)
}
@@ -245,6 +245,14 @@ func (r *messageRepository) UpdateMessageImages(ctx context.Context, sessionID,
Update("images", images).Error
}
// UpdateMessageRenderedContent updates only the rendered_content column for a message.
func (r *messageRepository) UpdateMessageRenderedContent(ctx context.Context, sessionID, messageID string, renderedContent string) error {
return r.db.WithContext(ctx).
Model(&types.Message{}).
Where("id = ? AND session_id = ?", messageID, sessionID).
Update("rendered_content", renderedContent).Error
}
// DeleteMessagesBySessionID deletes all messages belonging to a session (soft delete)
func (r *messageRepository) DeleteMessagesBySessionID(ctx context.Context, sessionID string) error {
return r.db.WithContext(ctx).Where("session_id = ?", sessionID).Delete(&types.Message{}).Error