Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update prompt format using template #52

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tools/formatContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading