feat: AIOps智能助手对话历史持久化(按用户隔离,刷新后仍可见)
This commit is contained in:
1 parent
6321886b69
commit
32de3709ed
6 files changed
+109
-5
No files matched your search
@@ -653,6 +653,16 @@ export interface ChatResult {
|
||||
tokens_used: number;
|
||||
}
|
||||
|
||||
// 对话历史条目(后端 ChatHistory 序列化) // Logan.Li
|
||||
export interface ChatHistoryItem {
|
||||
id: number;
|
||||
user_id: number;
|
||||
role: 'user' | 'assistant';
|
||||
content: string;
|
||||
model?: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export const aiApi = {
|
||||
// 获取 LLM 配置(API Key 已脱敏)
|
||||
getConfig: () => http.get<LLMConfigData>('/aiops/llm-config'),
|
||||
@@ -663,4 +673,8 @@ export const aiApi = {
|
||||
// AI 对话(messages 含历史 + 当前用户消息)
|
||||
chat: (messages: { role: 'user' | 'assistant'; content: string }[]) =>
|
||||
http.post<ChatResult>('/aiops/chat', { messages }),
|
||||
// 获取当前用户对话历史(按时间正序,最近 100 条)
|
||||
getHistory: () => http.get<{ list: ChatHistoryItem[]; total: number }>('/aiops/chat-history'),
|
||||
// 清空当前用户对话历史
|
||||
clearHistory: () => http.delete('/aiops/chat-history'),
|
||||
};
|
||||
Reference in new issue
Block a user