diff --git a/pages/api/chatbots/index.js b/pages/api/chatbots/index.js index 8d49205..fa3846e 100644 --- a/pages/api/chatbots/index.js +++ b/pages/api/chatbots/index.js @@ -2,8 +2,9 @@ import { PrismaClient } from "@prisma/client"; import { getServerSession } from "next-auth/next"; import { authOptions } from "../auth/[...nextauth]"; +const prismaClient = new PrismaClient(); + const chatbotsHandler = async (request, response) => { - const prismaClient = new PrismaClient(); const session = await getServerSession(request, response, authOptions); const user = await prismaClient.user.findUnique({ where: { email: session.user.email }, diff --git a/pages/api/v1/chatbots/[chatbotId]/index.js b/pages/api/v1/chatbots/[chatbotId]/index.js index 6c34fea..516075b 100644 --- a/pages/api/v1/chatbots/[chatbotId]/index.js +++ b/pages/api/v1/chatbots/[chatbotId]/index.js @@ -11,8 +11,9 @@ import { HumanChatMessage, AIChatMessage } from "langchain/schema"; import { PrismaClient } from "@prisma/client"; import { DEFAULT_PROMPT_TEMPLATE } from "@/lib/prompt-template"; +const prismaClient = new PrismaClient(); + const chatbotHandler = async (request, response) => { - const prismaClient = new PrismaClient(); const { chatbotId } = request.query; const { message } = request.body;