mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-14 05:03:43 +08:00
fix: docker rag bug
This commit is contained in:
@@ -13,6 +13,7 @@ const DANGER_CONFIG = {
|
||||
hideBalanceQuery: serverConfig.hideBalanceQuery,
|
||||
disableFastLink: serverConfig.disableFastLink,
|
||||
customModels: serverConfig.customModels,
|
||||
isEnableRAG: serverConfig.isEnableRAG,
|
||||
};
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -21,14 +21,9 @@ async function handle(req: NextRequest) {
|
||||
try {
|
||||
const formData = await req.formData();
|
||||
const file = formData.get("file") as File;
|
||||
const fileData = await file.arrayBuffer();
|
||||
const originalFileName = file?.name;
|
||||
|
||||
let fileData: ArrayBuffer | undefined;
|
||||
for (const [key, value] of formData.entries()) {
|
||||
if (value instanceof File) {
|
||||
fileData = await value.arrayBuffer();
|
||||
}
|
||||
}
|
||||
if (!fileData) throw new Error("Get file buffer error");
|
||||
const buffer = Buffer.from(fileData);
|
||||
const fileType = path.extname(originalFileName).slice(1);
|
||||
|
||||
@@ -60,7 +60,7 @@ export class NodeJSTool {
|
||||
wolframAlphaTool,
|
||||
pdfBrowserTool,
|
||||
];
|
||||
if (!!process.env.NEXT_PUBLIC_ENABLE_RAG) {
|
||||
if (!!process.env.ENABLE_RAG) {
|
||||
tools.push(new RAGSearch(this.sessionId, this.model, this.ragEmbeddings));
|
||||
}
|
||||
return tools;
|
||||
|
||||
@@ -37,6 +37,8 @@ export class RAGSearch extends Tool {
|
||||
/** @ignore */
|
||||
async _call(inputs: string, runManager?: CallbackManagerForToolRun) {
|
||||
const serverConfig = getServerSideConfig();
|
||||
if (!serverConfig.isEnableRAG)
|
||||
throw new Error("env ENABLE_RAG not configured");
|
||||
// const pinecone = new Pinecone();
|
||||
// const pineconeIndex = pinecone.Index(serverConfig.pineconeIndex!);
|
||||
// const vectorStore = await PineconeStore.fromExistingIndex(this.embeddings, {
|
||||
|
||||
Reference in New Issue
Block a user