perf: response store

This commit is contained in:
archer
2023-07-23 21:04:57 +08:00
parent ba965320d5
commit 1ffe1be562
20 changed files with 227 additions and 145 deletions

View File

@@ -60,7 +60,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
const prompts = messages.slice(-2);
const completionChatId = chatId ? chatId : nanoid();
const { responseText } = await streamFetch({
const { responseText, responseData } = await streamFetch({
data: {
messages: prompts,
variables,
@@ -106,7 +106,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
history: ChatBoxRef.current?.getChatHistory() || state.history
}));
return { responseText };
return { responseText, responseData };
},
[appId, chatId, history, router, setChatData, updateHistory]
);

View File

@@ -46,7 +46,7 @@ const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) =>
const prompts = messages.slice(-2);
const completionChatId = chatId ? chatId : nanoid();
const { responseText } = await streamFetch({
const { responseText, responseData } = await streamFetch({
data: {
messages: prompts,
variables,
@@ -91,7 +91,7 @@ const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) =>
'*'
);
return { responseText };
return { responseText, responseData };
},
[chatId, router, saveChatResponse, shareId]
);