zhou zhou
19 小时以前 5d16d9a0e7240ff4e6346bfee4890159da5a764e
rsf-admin/src/api/ai/chat.js
@@ -13,9 +13,9 @@
    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) {
@@ -33,6 +33,42 @@
    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 clearAiSessionMemory = async (sessionId) => {
    const res = await request.post(`ai/chat/session/memory/clear/${sessionId}`);
    const { code, msg, data } = res.data;
    if (code === 200) {
        return data;
    }
    throw new Error(msg || "清空 AI 会话记忆失败");
};
export const retainAiSessionLatestRound = async (sessionId) => {
    const res = await request.post(`ai/chat/session/memory/retain-latest/${sessionId}`);
    const { code, msg, data } = res.data;
    if (code === 200) {
        return data;
    }
    throw new Error(msg || "仅保留当前轮记忆失败");
};
export const streamAiChat = async (payload, { signal, onEvent } = {}) => {
    const token = getToken();
    const response = await fetch(`${PREFIX_BASE_URL}ai/chat/stream`, {