add vector to prompt

This commit is contained in:
Henry
2023-08-16 01:43:11 +01:00
parent af5efaa751
commit 94461025dc
11 changed files with 1194 additions and 40 deletions
+19
View File
@@ -520,3 +520,22 @@ export const mapChatHistory = (options: ICommonObject): ChatMessageHistory => {
}
return new ChatMessageHistory(chatHistory)
}
/**
* Convert incoming chat history to string
* @param {IMessage[]} chatHistory
* @returns {string}
*/
export const convertChatHistoryToText = (chatHistory: IMessage[]): string => {
return chatHistory
.map((chatMessage) => {
if (chatMessage.type === 'apiMessage') {
return `Assistant: ${chatMessage.message}`
} else if (chatMessage.type === 'userMessage') {
return `Human: ${chatMessage.message}`
} else {
return `${chatMessage.message}`
}
})
.join('\n')
}