knownledge preview

This commit is contained in:
n4ze3m
2024-04-06 20:18:46 +05:30
parent 0de5ea0b04
commit d6d2eae5ef
9 changed files with 147 additions and 42 deletions

View File

@@ -27,6 +27,10 @@ const formatChatHistoryAsString = (history: BaseMessage[]) => {
export const formatDocs = (docs: Document[]) => {
return docs
.filter(
(doc, i, self) =>
self.findIndex((d) => d.pageContent === doc.pageContent) === i
)
.map((doc, i) => `<doc id='${i}'>${doc.pageContent}</doc>`)
.join("\n")
}
@@ -145,7 +149,7 @@ export const createChatWithXChain = ({
runName: "Itemgetter:question"
}),
chat_history: RunnableLambda.from(serializeHistory).withConfig({
runName: "SerializeHistory",
runName: "SerializeHistory"
})
},
context,