Commit 4dc0fd3c by archer

fix: completions delta

parent f70a9885
...@@ -74,7 +74,7 @@ export const streamFetch = ({ ...@@ -74,7 +74,7 @@ export const streamFetch = ({
if (!eventName || !data) return; if (!eventName || !data) return;
if (eventName === sseResponseEventEnum.answer && data !== '[DONE]') { if (eventName === sseResponseEventEnum.answer && data !== '[DONE]') {
const answer: string = data?.choices?.[0].delta.content || ''; const answer: string = data?.choices?.[0]?.delta?.content || '';
onMessage({ text: answer }); onMessage({ text: answer });
responseText += answer; responseText += answer;
} else if ( } else if (
......
...@@ -324,7 +324,7 @@ async function streamResponse({ ...@@ -324,7 +324,7 @@ async function streamResponse({
const { data } = parseData.parse(item); const { data } = parseData.parse(item);
if (!data || data === '[DONE]') return; if (!data || data === '[DONE]') return;
const content: string = data?.choices?.[0].delta.content || ''; const content: string = data?.choices?.[0]?.delta?.content || '';
error = data.error; error = data.error;
answer += content; answer += content;
......
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