| | |
| | | throw new Error(msg || "获取 AI 运行时信息失败"); |
| | | }; |
| | | |
| | | export const getAiSessions = async (promptCode = "home.default") => { |
| | | export const getAiSessions = async (promptCode = "home.default", keyword = "") => { |
| | | const res = await request.get("ai/chat/sessions", { |
| | | params: { promptCode }, |
| | | params: { promptCode, keyword }, |
| | | }); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | |
| | | throw new Error(msg || "删除 AI 会话失败"); |
| | | }; |
| | | |
| | | export const renameAiSession = async (sessionId, title) => { |
| | | const res = await request.post(`ai/chat/session/rename/${sessionId}`, { title }); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | return data; |
| | | } |
| | | throw new Error(msg || "重命名 AI 会话失败"); |
| | | }; |
| | | |
| | | export const pinAiSession = async (sessionId, pinned) => { |
| | | const res = await request.post(`ai/chat/session/pin/${sessionId}`, { pinned }); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | return data; |
| | | } |
| | | throw new Error(msg || "更新 AI 会话置顶状态失败"); |
| | | }; |
| | | |
| | | export const streamAiChat = async (payload, { signal, onEvent } = {}) => { |
| | | const token = getToken(); |
| | | const response = await fetch(`${PREFIX_BASE_URL}ai/chat/stream`, { |