Commit 3b515c3c by archer

fix: choices empty

parent e95f83ec
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment