Files
nextjs-rsc/app/api/chat/engine/loader.ts
T
Thuc Pham 4e1e986e79 feat: sync with latest CL (#2)
* feat: sync with latest CL

* declare use client
2024-11-14 13:25:48 +08:00

25 lines
560 B
TypeScript

import {
FILE_EXT_TO_READER,
SimpleDirectoryReader,
} from "llamaindex/readers/index";
export const DATA_DIR = "./data";
export function getExtractors() {
return FILE_EXT_TO_READER;
}
export async function getDocuments() {
const documents = await new SimpleDirectoryReader().loadData({
directoryPath: DATA_DIR,
});
// Set private=false to mark the document as public (required for filtering)
for (const document of documents) {
document.metadata = {
...document.metadata,
private: "false",
};
}
return documents;
}