| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import request from '@/utils/request'
- /**
- * AI对话API - 简化版
- *
- * 使用 serviceId 替代 configId
- * 向后兼容:后端同时支持 serviceId 和 configId
- */
- // 发送聊天消息(非流式)
- export function sendMessage(data) {
- return request({
- url: '/system/ai/chat/send',
- method: 'post',
- data: data,
- timeout: 60000 // 60秒超时
- })
- }
- // 获取会话历史
- export function getHistory(conversationId) {
- return request({
- url: '/system/ai/chat/history/' + conversationId,
- method: 'get'
- })
- }
- // 创建新会话
- export function createConversation(data) {
- return request({
- url: '/system/ai/chat/conversation',
- method: 'post',
- data: data
- })
- }
- // 获取用户的会话列表
- export function getConversations() {
- return request({
- url: '/system/ai/chat/conversations',
- method: 'get'
- })
- }
- // 删除会话
- export function deleteConversation(conversationId) {
- return request({
- url: '/system/ai/chat/conversation/' + conversationId,
- method: 'delete'
- })
- }
- // 流式发送消息(SSE)
- export function streamMessage(serviceId, message, conversationId) {
- const params = new URLSearchParams()
- params.append('serviceId', serviceId)
- params.append('message', message)
- if (conversationId) {
- params.append('conversationId', conversationId)
- }
-
- return `/system/ai/chat/stream?${params.toString()}`
- }
|