Unexpected Token Error: Handling 404 Response in NextJS Application
ajit gupta
1 min read
const page = async() => {
const session = await getServerSession(authOptions)
if(!session){
redirect("/")
}
const response = await checkPdf()
return (
<div>
<ChatComponent name={session.user.name} heading={response===true?true:false}/>
</div>
)
}
export default page
"use server"
import { getServerSession } from "next-auth"
import { authOptions } from "../lib/auth"
import fs from "fs";
import prisma from "@/db";
import { CloseVectorNode } from "@langchain/community/vectorstores/closevector/node";
import { embeddings } from "../constants/embeddings";
export async function checkPdf(){
const session = await getServerSession(authOptions)
if(session.user){
const user = await prisma.user.findUnique({
where: {
id: Number(session.user.id)
}
})
console.log("uuid: ",user?.uuid)
const loadedVectorStore = await CloseVectorNode.loadFromCloud({
uuid:user?.uuid || "",
embeddings,
credentials: {
key: process.env.VOYAGE_ACCESS_KEY,
secret: process.env.VOYAGE_SECRET,
},
});
// Check if the directory exists
if (user?.uuid && user.uuid.trim().length>0) {
return true
} else {
return false
}
}
return false
}
0
Subscribe to my newsletter
Read articles from ajit gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by