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:
@@ -212,3 +212,26 @@ export function deleteIMChannel(id: string) {
|
||||
export function toggleIMChannel(id: string) {
|
||||
return post<{ data: IMChannel }>(`/api/v1/im-channels/${id}/toggle`);
|
||||
}
|
||||
|
||||
// ===== 推荐问题 =====
|
||||
|
||||
// 推荐问题
|
||||
export interface SuggestedQuestion {
|
||||
question: string;
|
||||
source: 'faq' | 'document' | 'agent_config';
|
||||
knowledge_base_id?: string;
|
||||
}
|
||||
|
||||
// 获取智能体推荐问题
|
||||
// 根据智能体关联的知识库范围返回推荐问题,用于前端对话面板快捷提问
|
||||
export function getSuggestedQuestions(
|
||||
agentId: string,
|
||||
params?: { knowledge_base_ids?: string[]; knowledge_ids?: string[]; limit?: number }
|
||||
) {
|
||||
const query = new URLSearchParams();
|
||||
if (params?.knowledge_base_ids?.length) query.set('knowledge_base_ids', params.knowledge_base_ids.join(','));
|
||||
if (params?.knowledge_ids?.length) query.set('knowledge_ids', params.knowledge_ids.join(','));
|
||||
if (params?.limit) query.set('limit', String(params.limit));
|
||||
const qs = query.toString();
|
||||
return get<{ data: { questions: SuggestedQuestion[] } }>(`/api/v1/agents/${agentId}/suggested-questions${qs ? '?' + qs : ''}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user