mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-26 04:32:50 +00:00
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;
|
||||
}
|
||||
const text = decoder.decode(value).replace(/<br\/>/g, '\n');
|
||||
|
||||
let text = decoder.decode(value).replace(/<br\/>/g, '\n');
|
||||
// check system prompt
|
||||
if (text.startsWith(SYSTEM_PROMPT_PREFIX)) {
|
||||
systemPrompt = text.replace(SYSTEM_PROMPT_PREFIX, '');
|
||||
} else {
|
||||
responseText += text;
|
||||
onMessage(text);
|
||||
if (text.includes(SYSTEM_PROMPT_PREFIX)) {
|
||||
const arr = text.split(SYSTEM_PROMPT_PREFIX);
|
||||
systemPrompt = arr.pop() || '';
|
||||
|
||||
text = arr.join('');
|
||||
}
|
||||
responseText += text;
|
||||
onMessage(text);
|
||||
|
||||
read();
|
||||
} catch (err: any) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue