generated from nhcarrigan/template
feat: use db for rag
This commit is contained in:
+13
-12
@@ -15,6 +15,7 @@ import path from "node:path";
|
||||
import matter from "gray-matter";
|
||||
import { promisify } from "node:util";
|
||||
import { exec } from "node:child_process";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
@@ -68,18 +69,18 @@ const results = await Promise.all(
|
||||
|
||||
const flat = results.flat();
|
||||
|
||||
const string = `/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
const db = new PrismaClient();
|
||||
|
||||
export const documentationData = ${JSON.stringify({ documents: flat }, null, 2)};
|
||||
`;
|
||||
|
||||
await fs.writeFile(
|
||||
path.resolve(process.cwd(), "src", "data", "docs.ts"),
|
||||
string
|
||||
);
|
||||
await db.documentation.deleteMany({});
|
||||
await db.documentation.createMany({
|
||||
data: flat.map((doc) => ({
|
||||
pageId: doc.id,
|
||||
title: doc.title,
|
||||
content: doc.content,
|
||||
file: doc.file,
|
||||
pageTitle: doc.metadata.title ?? doc.title,
|
||||
url: doc.url,
|
||||
})),
|
||||
});
|
||||
|
||||
await fs.rm(docsDirectory, { recursive: true, force: true });
|
||||
|
||||
Reference in New Issue
Block a user