Skip to content

Commit 8c727b5

Browse files
committed
fix: chatbot max tokens
1 parent 2990f6a commit 8c727b5

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

depot.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"id":"du7O4b0e8P"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
export const EMBEDINGS_SEARCH_RESULT = 3;

packages/backend/src/app/chatbot/embedings/fais-embeddings.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import path from 'path'
55
import os from 'os'
66
import fs from 'fs/promises'
77
import { localFileStore } from '../../helper/store'
8+
import { EMBEDINGS_SEARCH_RESULT } from './embedings-settings'
89

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

@@ -42,7 +43,7 @@ export const faissEmbedding = ({ openAIApiKey, botId }: { botId: string, openAIA
4243
if (store.docstore._docs.size === 0) {
4344
return []
4445
}
45-
const similarDocuments = await store.similaritySearch(input, 5, botId)
46+
const similarDocuments = await store.similaritySearch(input, EMBEDINGS_SEARCH_RESULT, botId)
4647
return similarDocuments.map((doc) => doc.pageContent)
4748
},
4849
async addDocuments({

packages/backend/src/app/chatbot/framework/datasource.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export const datasources = {
88
}): Promise<Document[]> {
99
const blob = new Blob([buffer])
1010
const pdfLoader = new PDFLoader(blob, { splitPages: true })
11-
const splitter = new RecursiveCharacterTextSplitter({})
11+
const splitter = new RecursiveCharacterTextSplitter({
12+
chunkSize: 1300,
13+
})
1214
const documents = await pdfLoader.loadAndSplit(splitter)
1315
return documents
1416
},

0 commit comments

Comments
 (0)