From 1991bbc75a5c14f947afe2b99401f202061fb4db Mon Sep 17 00:00:00 2001 From: Bohan Cheng <47214785+cbh778899@users.noreply.github.com> Date: Thu, 15 Aug 2024 21:23:29 +1000 Subject: [PATCH] Update prompt format using template Signed-off-by: Bohan Cheng <47214785+cbh778899@users.noreply.github.com> --- tools/formatContext.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/formatContext.js b/tools/formatContext.js index c83a64d..b41f8e3 100644 --- a/tools/formatContext.js +++ b/tools/formatContext.js @@ -18,15 +18,15 @@ process.env.SYSTEM_INSTRUCTION && process.env.SYSTEM_INSTRUCTION !== '*' ? proce "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions." export function formatInferenceContext(history, question = null, system_included = false) { - let context = system_included ? "" : "<|system|>\n"+system_context+"\n"; + let context = system_included ? "" : "<|system|>\n"+system_context+"<|end|>\n"; context += history.map(({role, content}) => { - return `<|${role}|>\n${content || ''}` + return `<|${role}|>\n${content || ''}<|end|>` }).join('\n'); - if(question) context += `\n<|user|>\n${question}` + if(question) context += `\n<|user|>\n${question}<|end|>` context += "\n<|assistant|>\n"; return context; } export function formatOpenAIContext(messages) { return formatInferenceContext(messages, null, true); -} \ No newline at end of file +}