Commit aa74625f by archer

fix: system prompt response

parent 9199e3e5
...@@ -39,15 +39,16 @@ export const streamFetch = ({ url, data, onMessage, abortSignal }: StreamFetchPr ...@@ -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() || '';
text = arr.join('');
}
responseText += text; responseText += text;
onMessage(text); onMessage(text);
}
read(); read();
} catch (err: any) { } catch (err: any) {
......
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