fix chat history

This commit is contained in:
Henry
2023-11-30 16:01:16 +00:00
parent 5a5097e997
commit 4b5f7028e3
12 changed files with 262 additions and 98 deletions
+12
View File
@@ -549,6 +549,18 @@ export const convertChatHistoryToText = (chatHistory: IMessage[] = []): string =
.join('\n')
}
/**
* Serialize array chat history to string
* @param {IMessage[]} chatHistory
* @returns {string}
*/
export const serializeChatHistory = (chatHistory: string | Array<string>) => {
if (Array.isArray(chatHistory)) {
return chatHistory.join('\n')
}
return chatHistory
}
/**
* Convert schema to zod schema
* @param {string | object} schema