|
@@ -108,7 +108,10 @@ export class BigModelApi implements LLMApi {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
controller.signal.onabort = finish;
|
|
controller.signal.onabort = finish;
|
|
|
|
|
+
|
|
|
let start = true;
|
|
let start = true;
|
|
|
|
|
+ let sliceInfoPromise: Promise<void> | null = null;
|
|
|
|
|
+
|
|
|
fetchEventSource(chatPath, {
|
|
fetchEventSource(chatPath, {
|
|
|
...chatPayload,
|
|
...chatPayload,
|
|
|
async onopen(res: any) {
|
|
async onopen(res: any) {
|
|
@@ -168,17 +171,40 @@ export class BigModelApi implements LLMApi {
|
|
|
const chatMode = useChatStore.getState().chatMode;
|
|
const chatMode = useChatStore.getState().chatMode;
|
|
|
if (chatMode === 'LOCAL' && start) {// 切片
|
|
if (chatMode === 'LOCAL' && start) {// 切片
|
|
|
start = false;
|
|
start = false;
|
|
|
- const res: any = await api.get(`deepseek/api/slice/search/${info.id}`);
|
|
|
|
|
- const sliceInfo = {
|
|
|
|
|
- ...res.data,
|
|
|
|
|
- }
|
|
|
|
|
- delete sliceInfo.code;
|
|
|
|
|
- console.log(sliceInfo, 'sliceInfo');
|
|
|
|
|
|
|
+ sliceInfoPromise = (async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res: any = await api.get(`deepseek/api/slice/search/${info.id}`);
|
|
|
|
|
+ const sliceInfo = {
|
|
|
|
|
+ ...res.data,
|
|
|
|
|
+ };
|
|
|
|
|
+ delete sliceInfo.code;
|
|
|
|
|
+ useChatStore.getState().updateCurrentSession((session) => {
|
|
|
|
|
+ session.messages = session.messages.map((item, index) => {
|
|
|
|
|
+ if (index === session.messages.length - 1 && item.role !== 'user') {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ sliceInfo: sliceInfo,
|
|
|
|
|
+ };
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error(error);
|
|
|
|
|
+ }
|
|
|
|
|
+ })();
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
async onclose() {
|
|
async onclose() {
|
|
|
finish();
|
|
finish();
|
|
|
|
|
+ if (sliceInfoPromise) {
|
|
|
|
|
+ await sliceInfoPromise; // 等待 sliceInfo 加载完成
|
|
|
|
|
+ }
|
|
|
const session = useChatStore.getState().sessions[0];
|
|
const session = useChatStore.getState().sessions[0];
|
|
|
|
|
+
|
|
|
const item = session.messages.find(item => item.role === 'user');
|
|
const item = session.messages.find(item => item.role === 'user');
|
|
|
const dialogName = item ? item.content : '新的聊天';
|
|
const dialogName = item ? item.content : '新的聊天';
|
|
|
const data = {
|
|
const data = {
|
|
@@ -191,6 +217,7 @@ export class BigModelApi implements LLMApi {
|
|
|
date: item.date,
|
|
date: item.date,
|
|
|
role: item.role,
|
|
role: item.role,
|
|
|
content: item.content,
|
|
content: item.content,
|
|
|
|
|
+ sliceInfo: item.sliceInfo,
|
|
|
})),
|
|
})),
|
|
|
};
|
|
};
|
|
|
const messages = session.messages.slice();
|
|
const messages = session.messages.slice();
|