Skip to content

Commit

Permalink
fix: chatbot max tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed Sep 30, 2023
1 parent 2990f6a commit 8c727b5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions depot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"du7O4b0e8P"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

export const EMBEDINGS_SEARCH_RESULT = 3;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import path from 'path'
import os from 'os'
import fs from 'fs/promises'
import { localFileStore } from '../../helper/store'
import { EMBEDINGS_SEARCH_RESULT } from './embedings-settings'

const storeCache: Record<string, FaissStore> = {}

Expand Down Expand Up @@ -42,7 +43,7 @@ export const faissEmbedding = ({ openAIApiKey, botId }: { botId: string, openAIA
if (store.docstore._docs.size === 0) {
return []
}
const similarDocuments = await store.similaritySearch(input, 5, botId)
const similarDocuments = await store.similaritySearch(input, EMBEDINGS_SEARCH_RESULT, botId)
return similarDocuments.map((doc) => doc.pageContent)
},
async addDocuments({
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/src/app/chatbot/framework/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export const datasources = {
}): Promise<Document[]> {
const blob = new Blob([buffer])
const pdfLoader = new PDFLoader(blob, { splitPages: true })
const splitter = new RecursiveCharacterTextSplitter({})
const splitter = new RecursiveCharacterTextSplitter({
chunkSize: 1300,
})
const documents = await pdfLoader.loadAndSplit(splitter)
return documents
},
Expand Down

0 comments on commit 8c727b5

Please sign in to comment.