fix: system prompt response
This commit is contained in:
parent
9199e3e57d
commit
aa74625f96
@ -39,15 +39,16 @@ export const streamFetch = ({ url, data, onMessage, abortSignal }: StreamFetchPr
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const text = decoder.decode(value).replace(/<br\/>/g, '\n');
|
let text = decoder.decode(value).replace(/<br\/>/g, '\n');
|
||||||
|
|
||||||
// check system prompt
|
// check system prompt
|
||||||
if (text.startsWith(SYSTEM_PROMPT_PREFIX)) {
|
if (text.includes(SYSTEM_PROMPT_PREFIX)) {
|
||||||
systemPrompt = text.replace(SYSTEM_PROMPT_PREFIX, '');
|
const arr = text.split(SYSTEM_PROMPT_PREFIX);
|
||||||
} else {
|
systemPrompt = arr.pop() || '';
|
||||||
responseText += text;
|
|
||||||
onMessage(text);
|
text = arr.join('');
|
||||||
}
|
}
|
||||||
|
responseText += text;
|
||||||
|
onMessage(text);
|
||||||
|
|
||||||
read();
|
read();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user