refactor: getConversationPairs and promptBase

This commit is contained in:
josc146
2023-04-05 15:31:55 +08:00
parent e598da51e4
commit 64fe14db79
4 changed files with 39 additions and 34 deletions
+7 -7
View File
@@ -1,16 +1,16 @@
export function getConversationPairs(records, isChatgpt) {
export function getConversationPairs(records, isCompletion) {
let pairs
if (isChatgpt) {
if (isCompletion) {
pairs = ''
for (const record of records) {
pairs += 'Human: ' + record.question + '\nAI: ' + record.answer + '\n'
}
} else {
pairs = []
for (const record of records) {
pairs.push({ role: 'user', content: record['question'] })
pairs.push({ role: 'assistant', content: record['answer'] })
}
} else {
pairs = ''
for (const record of records) {
pairs += 'Human:' + record.question + '\nAI:' + record.answer + '\n'
}
}
return pairs