feat(suggested-questions): implement suggested questions feature for chat interface
- Added a new API endpoint to fetch suggested questions based on the agent's associated knowledge bases. - Implemented frontend components to display suggested questions in both chat and create chat views, enhancing user interaction. - Updated localization files to include translations for suggested questions in English, Korean, Russian, and Chinese. - Introduced debounce logic for fetching suggestions to optimize performance during knowledge base changes. - Enhanced backend services to support fetching and returning suggested questions, improving the overall chat experience.
This commit is contained in:
@@ -175,6 +175,10 @@ type CustomAgentConfig struct {
|
||||
FallbackResponse string `yaml:"fallback_response" json:"fallback_response"`
|
||||
// Fallback prompt (when FallbackStrategy is "model")
|
||||
FallbackPrompt string `yaml:"fallback_prompt" json:"fallback_prompt"`
|
||||
|
||||
// ===== Suggested Prompts =====
|
||||
// 推荐问题列表,用于在前端对话面板展示快捷提问
|
||||
SuggestedPrompts []string `yaml:"suggested_prompts" json:"suggested_prompts,omitempty"`
|
||||
}
|
||||
|
||||
// Value implements driver.Valuer interface for CustomAgentConfig
|
||||
@@ -255,6 +259,16 @@ func (a *CustomAgent) IsAgentMode() bool {
|
||||
return a.Config.AgentMode == AgentModeSmartReasoning
|
||||
}
|
||||
|
||||
// SuggestedQuestion 推荐问题
|
||||
type SuggestedQuestion struct {
|
||||
// 问题文本
|
||||
Question string `json:"question"`
|
||||
// 来源类型: "faq", "document", "agent_config"
|
||||
Source string `json:"source"`
|
||||
// 来源知识库ID(仅 faq/document 来源时有值)
|
||||
KnowledgeBaseID string `json:"knowledge_base_id,omitempty"`
|
||||
}
|
||||
|
||||
// BuiltinAgentRegistry provides a registry of all built-in agents.
|
||||
// It is initialised empty and populated by LoadBuiltinAgentsConfig from
|
||||
// config/builtin_agents.yaml at startup via rebuildRegistryFromConfig.
|
||||
|
||||
@@ -89,6 +89,16 @@ type ChunkRepository interface {
|
||||
// FAQChunkDiff compares FAQ chunks between two knowledge bases and returns the differences.
|
||||
// Returns: chunksToAdd (content_hash in src but not in dst), chunksToDelete (content_hash in dst but not in src)
|
||||
FAQChunkDiff(ctx context.Context, srcTenantID uint64, srcKBID string, dstTenantID uint64, dstKBID string) (chunksToAdd []string, chunksToDelete []string, err error)
|
||||
|
||||
// ListRecommendedFAQChunks lists FAQ chunks with the recommended flag set.
|
||||
// Filter by kbIDs and/or knowledgeIDs. At least one of them must be non-empty.
|
||||
// Returns up to `limit` chunks sorted by updated_at descending.
|
||||
ListRecommendedFAQChunks(ctx context.Context, tenantID uint64, kbIDs []string, knowledgeIDs []string, limit int) ([]*types.Chunk, error)
|
||||
|
||||
// ListRecentDocumentChunksWithQuestions lists recent document chunks that have generated questions.
|
||||
// Filter by kbIDs and/or knowledgeIDs. At least one of them must be non-empty.
|
||||
// Returns up to `limit` chunks sorted by updated_at descending.
|
||||
ListRecentDocumentChunksWithQuestions(ctx context.Context, tenantID uint64, kbIDs []string, knowledgeIDs []string, limit int) ([]*types.Chunk, error)
|
||||
}
|
||||
|
||||
// ChunkService defines the interface for chunk service operations
|
||||
|
||||
@@ -64,6 +64,20 @@ type CustomAgentService interface {
|
||||
// - The newly created agent copy
|
||||
// - Possible errors such as not existing, insufficient permissions, etc.
|
||||
CopyAgent(ctx context.Context, id string) (*types.CustomAgent, error)
|
||||
|
||||
// GetSuggestedQuestions returns suggested questions for the agent based on its
|
||||
// associated knowledge bases. When kbIDs or knowledgeIDs are provided, they override
|
||||
// the agent's default knowledge base selection.
|
||||
// Parameters:
|
||||
// - ctx: Context information
|
||||
// - agentID: Agent ID
|
||||
// - kbIDs: Optional knowledge base IDs to override agent config
|
||||
// - knowledgeIDs: Optional knowledge item IDs to further filter
|
||||
// - limit: Maximum number of questions to return
|
||||
// Returns:
|
||||
// - List of suggested questions
|
||||
// - Possible errors
|
||||
GetSuggestedQuestions(ctx context.Context, agentID string, kbIDs []string, knowledgeIDs []string, limit int) ([]types.SuggestedQuestion, error)
|
||||
}
|
||||
|
||||
// CustomAgentRepository defines the custom agent repository interface
|
||||
|
||||
Reference in New Issue
Block a user