import http from './axios'
|
|
/** 会话列表 */
|
export function listChats() {
|
return http.get('/chats')
|
}
|
|
/**
|
* 搜索历史对话。
|
*
|
* 后端同时匹配标题与消息内容,返回的每一项带:
|
* - matchSnippet:命中处的上下文片段
|
* - matchType:title / message / both
|
*/
|
export function searchChats(keyword, limit = 30) {
|
return http.get('/chats/search', { params: { q: keyword, limit } })
|
}
|
|
/** 新建会话 */
|
export function createChat(payload = {}) {
|
return http.post('/chats', payload)
|
}
|
|
/**
|
* 修改会话标题或模型参数。
|
* meta 是整体覆盖语义,请提交完整的参数对象。
|
*/
|
export function updateChat(chatId, payload) {
|
return http.put(`/chats/${chatId}`, payload)
|
}
|
|
/** 删除会话(级联删除消息) */
|
export function deleteChat(chatId) {
|
return http.delete(`/chats/${chatId}`)
|
}
|
|
/** 获取会话的消息树(根节点数组,节点内嵌 children) */
|
export function listMessages(chatId) {
|
return http.get(`/chats/${chatId}/messages`)
|
}
|
|
/** 编辑消息内容 */
|
export function updateMessage(chatId, messageId, payload) {
|
return http.put(`/chats/${chatId}/messages/${messageId}`, payload)
|
}
|
|
/** 删除消息及其全部子孙 */
|
export function deleteMessage(chatId, messageId) {
|
return http.delete(`/chats/${chatId}/messages/${messageId}`)
|
}
|