mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +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]') {
|
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);
|
onMessage(answer);
|
||||||
responseText += answer;
|
responseText += answer;
|
||||||
} else if (item.event === sseResponseEventEnum.chatResponse) {
|
} 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;
|
const totalTokens = stream ? 0 : response.data.usage?.total_tokens || 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Reference in New Issue
Block a user