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:
@@ -93,6 +93,7 @@ type PipelineState struct {
|
||||
EntityKnowledge map[string]string `json:"-"`
|
||||
GraphResult *GraphData `json:"-"`
|
||||
UserContent string `json:"-"`
|
||||
RenderedContexts string `json:"-"`
|
||||
ChatResponse *ChatResponse `json:"-"`
|
||||
ImageDescription string `json:"-"`
|
||||
SystemPromptOverride string `json:"-"`
|
||||
@@ -189,6 +190,7 @@ func (c *ChatManage) Clone() *ChatManage {
|
||||
Intent: c.Intent,
|
||||
ImageDescription: c.ImageDescription,
|
||||
SystemPromptOverride: c.SystemPromptOverride,
|
||||
RenderedContexts: c.RenderedContexts,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,9 +238,6 @@ func (a *CustomAgent) EnsureDefaults() {
|
||||
if a.Config.RerankTopK == 0 {
|
||||
a.Config.RerankTopK = 5
|
||||
}
|
||||
if a.Config.RerankThreshold == 0 {
|
||||
a.Config.RerankThreshold = 0.5
|
||||
}
|
||||
// Advanced settings defaults
|
||||
if a.Config.FallbackStrategy == "" {
|
||||
a.Config.FallbackStrategy = "model"
|
||||
|
||||
@@ -32,6 +32,9 @@ type MessageService interface {
|
||||
// UpdateMessageImages updates only the images JSONB column for a message.
|
||||
UpdateMessageImages(ctx context.Context, sessionID, messageID string, images types.MessageImages) error
|
||||
|
||||
// UpdateMessageRenderedContent updates the rendered_content column for a user message.
|
||||
UpdateMessageRenderedContent(ctx context.Context, sessionID, messageID string, renderedContent string) error
|
||||
|
||||
// DeleteMessage deletes a message
|
||||
DeleteMessage(ctx context.Context, sessionID string, id string) error
|
||||
|
||||
@@ -74,6 +77,8 @@ type MessageRepository interface {
|
||||
UpdateMessage(ctx context.Context, message *types.Message) error
|
||||
// UpdateMessageImages updates only the images JSONB column for a message
|
||||
UpdateMessageImages(ctx context.Context, sessionID, messageID string, images types.MessageImages) error
|
||||
// UpdateMessageRenderedContent updates the rendered_content column for a user message
|
||||
UpdateMessageRenderedContent(ctx context.Context, sessionID, messageID string, renderedContent string) error
|
||||
// DeleteMessage deletes a message
|
||||
DeleteMessage(ctx context.Context, sessionID string, id string) error
|
||||
// DeleteMessagesBySessionID deletes all messages belonging to a session
|
||||
|
||||
@@ -125,8 +125,12 @@ type Message struct {
|
||||
IsFallback bool `json:"is_fallback,omitempty"`
|
||||
// Agent total execution duration in milliseconds (from query start to answer start)
|
||||
AgentDurationMs int64 `json:"agent_duration_ms,omitempty" gorm:"column:agent_duration_ms;default:0"`
|
||||
// RenderedContent stores the full RAG-augmented user message (with retrieved context)
|
||||
// sent to the LLM. Used to preserve retrieval context across conversation turns.
|
||||
// Empty for non-retrieval intents or assistant messages.
|
||||
RenderedContent string `json:"-" gorm:"type:text;column:rendered_content;default:''"`
|
||||
// Channel indicates the source channel of this message (e.g., "web", "api", "im")
|
||||
Channel string `json:"channel,omitempty" gorm:"type:varchar(50);default:''"`
|
||||
Channel string `json:"channel,omitempty" gorm:"type:varchar(50);default:''"`
|
||||
// KnowledgeID links this message to a Knowledge entry in the chat history knowledge base
|
||||
// Used for vector search indexing: when set, the message content has been indexed as a Knowledge passage
|
||||
KnowledgeID string `json:"knowledge_id,omitempty" gorm:"type:varchar(36);index"`
|
||||
|
||||
@@ -20,7 +20,7 @@ type RetrievalConfig struct {
|
||||
KeywordThreshold float64 `json:"keyword_threshold"`
|
||||
// RerankTopK is the maximum number of results after reranking (default: 10)
|
||||
RerankTopK int `json:"rerank_top_k"`
|
||||
// RerankThreshold is the minimum rerank score (0-1, default: 0.2)
|
||||
// RerankThreshold is the minimum rerank score (-10 to 10, default: 0.2)
|
||||
RerankThreshold float64 `json:"rerank_threshold"`
|
||||
// RerankModelID is the ID of the rerank model to use (required for search)
|
||||
RerankModelID string `json:"rerank_model_id"`
|
||||
@@ -60,7 +60,7 @@ func (c *RetrievalConfig) GetEffectiveRerankTopK() int {
|
||||
|
||||
// GetEffectiveRerankThreshold returns RerankThreshold with a fallback default.
|
||||
func (c *RetrievalConfig) GetEffectiveRerankThreshold() float64 {
|
||||
if c == nil || c.RerankThreshold <= 0 {
|
||||
if c == nil {
|
||||
return 0.2
|
||||
}
|
||||
return c.RerankThreshold
|
||||
|
||||
@@ -130,6 +130,9 @@ type SearchResult struct {
|
||||
// For FAQ: this is the matched question text (standard or similar question)
|
||||
MatchedContent string `json:"matched_content,omitempty"`
|
||||
|
||||
// KnowledgeDescription is the description of the knowledge document
|
||||
KnowledgeDescription string `json:"knowledge_description,omitempty"`
|
||||
|
||||
// KnowledgeBaseID is the ID of the knowledge base this result belongs to
|
||||
KnowledgeBaseID string `json:"knowledge_base_id,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user