feat: implement chat history and retrieval settings

- Added new API endpoints for managing chat history configuration and retrieval settings, allowing tenants to enable message indexing and configure search parameters.
- Introduced new Vue components for ChatHistorySettings and RetrievalSettings, providing a user-friendly interface for managing these configurations.
- Updated localization files to include new settings descriptions and labels in multiple languages.
- Enhanced the KnowledgeSearch view to support searching across both knowledge bases and chat history, improving the overall search functionality.

These changes significantly enhance the application's capabilities in managing and retrieving chat history, contributing to a more robust user experience.
This commit is contained in:
wizardchen
2026-03-06 21:06:10 +08:00
committed by lyingbug
parent c516d1f9bd
commit 1fb2bedd2b
27 changed files with 2755 additions and 199 deletions
+65
View File
@@ -0,0 +1,65 @@
import { get, put, post } from '@/utils/request'
// ChatHistoryConfig represents the chat history KB configuration for a tenant.
// knowledge_base_id is auto-managed by the backend; frontend only sets other fields.
export interface ChatHistoryConfig {
enabled: boolean
embedding_model_id: string
knowledge_base_id?: string // read-only, auto-managed
}
// ChatHistoryKBStats represents statistics about the chat history knowledge base
export interface ChatHistoryKBStats {
enabled: boolean
embedding_model_id?: string
knowledge_base_id?: string
knowledge_base_name?: string
indexed_message_count: number
has_indexed_messages: boolean
}
// MessageSearchRequest defines search parameters for message search
export interface MessageSearchRequest {
query: string
mode?: 'keyword' | 'vector' | 'hybrid'
limit?: number
session_ids?: string[]
}
// MessageSearchGroupItem represents a merged Q&A pair in search results
export interface MessageSearchGroupItem {
request_id: string
session_id: string
session_title: string
query_content: string
answer_content: string
score: number
match_type: string
created_at: string
}
// MessageSearchResult represents the full search result
export interface MessageSearchResult {
items: MessageSearchGroupItem[]
total: number
}
// Get tenant chat history config via KV API
export function getTenantChatHistoryConfig() {
return get('/api/v1/tenants/kv/chat-history-config')
}
// Update tenant chat history config via KV API
export function updateTenantChatHistoryConfig(config: ChatHistoryConfig) {
return put('/api/v1/tenants/kv/chat-history-config', config)
}
// Get chat history KB statistics
export function getChatHistoryKBStats() {
return get('/api/v1/messages/chat-history-stats')
}
// Search messages across all sessions (keyword + vector hybrid search)
export function searchMessages(data: MessageSearchRequest) {
return post('/api/v1/messages/search', data)
}
+22
View File
@@ -0,0 +1,22 @@
import { get, put } from '@/utils/request'
// RetrievalConfig represents the global retrieval/search configuration for a tenant.
// Shared by knowledge search and message search.
export interface RetrievalConfig {
embedding_top_k: number
vector_threshold: number
keyword_threshold: number
rerank_top_k: number
rerank_threshold: number
rerank_model_id: string
}
// Get tenant retrieval config via KV API
export function getTenantRetrievalConfig() {
return get('/api/v1/tenants/kv/retrieval-config')
}
// Update tenant retrieval config via KV API
export function updateTenantRetrievalConfig(config: RetrievalConfig) {
return put('/api/v1/tenants/kv/retrieval-config', config)
}