mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
fix: choices empty
This commit is contained in:
@@ -75,7 +75,7 @@ export const streamFetch = ({ data, onMessage, abortSignal }: StreamFetchProps)
|
||||
})();
|
||||
|
||||
if (item.event === sseResponseEventEnum.answer && data !== '[DONE]') {
|
||||
const answer: string = data?.choices[0].delta.content || '';
|
||||
const answer: string = data?.choices?.[0].delta.content || '';
|
||||
onMessage(answer);
|
||||
responseText += answer;
|
||||
} else if (item.event === sseResponseEventEnum.chatResponse) {
|
||||
|
@@ -57,7 +57,7 @@ export const chatResponse = async ({
|
||||
}
|
||||
);
|
||||
|
||||
const responseText = stream ? '' : response.data.choices[0].message?.content || '';
|
||||
const responseText = stream ? '' : response.data.choices?.[0].message?.content || '';
|
||||
const totalTokens = stream ? 0 : response.data.usage?.total_tokens || 0;
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user