File tree Expand file tree Collapse file tree
api/get-next-completion-stream-promise Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"use server" ;
22
3- import prisma from "@/lib/prisma" ;
3+ import { PrismaClient } from "@prisma/client" ;
4+ import { PrismaNeon } from "@prisma/adapter-neon" ;
5+ import { Pool } from "@neondatabase/serverless" ;
46import { notFound } from "next/navigation" ;
57import Together from "together-ai" ;
68import {
@@ -15,7 +17,9 @@ export async function createChat(
1517 quality : "high" | "low" ,
1618 screenshotUrl : string | undefined ,
1719) {
18- console . log ( "--- createChat" ) ;
20+ const neon = new Pool ( { connectionString : process . env . DATABASE_URL } ) ;
21+ const adapter = new PrismaNeon ( neon ) ;
22+ const prisma = new PrismaClient ( { adapter } ) ;
1923 let chat ;
2024 try {
2125 chat = await prisma . chat . create ( {
@@ -191,6 +195,9 @@ export async function createMessage(
191195 text : string ,
192196 role : "assistant" | "user" ,
193197) {
198+ const neon = new Pool ( { connectionString : process . env . DATABASE_URL } ) ;
199+ const adapter = new PrismaNeon ( neon ) ;
200+ const prisma = new PrismaClient ( { adapter } ) ;
194201 const chat = await prisma . chat . findUnique ( {
195202 where : { id : chatId } ,
196203 include : { messages : true } ,
Original file line number Diff line number Diff line change 1- import client from "@/lib/prisma" ;
1+ // import client from "@/lib/prisma";
22import PageClient from "./page.client" ;
33import { notFound } from "next/navigation" ;
44import { cache } from "react" ;
5+ import { PrismaClient } from "@prisma/client" ;
6+ import { PrismaNeon } from "@prisma/adapter-neon" ;
7+ import { Pool } from "@neondatabase/serverless" ;
58
69export default async function Page ( {
710 params,
@@ -17,7 +20,10 @@ export default async function Page({
1720}
1821
1922const getChatById = cache ( async ( id : string ) => {
20- return await client . chat . findFirst ( {
23+ const neon = new Pool ( { connectionString : process . env . DATABASE_URL } ) ;
24+ const adapter = new PrismaNeon ( neon ) ;
25+ const prisma = new PrismaClient ( { adapter } ) ;
26+ return await prisma . chat . findFirst ( {
2127 where : { id } ,
2228 include : { messages : { orderBy : { position : "asc" } } } ,
2329 } ) ;
Original file line number Diff line number Diff line change 1- import prisma from "@/lib/prisma" ;
1+ import { PrismaClient } from "@prisma/client" ;
2+ import { PrismaNeon } from "@prisma/adapter-neon" ;
3+ import { Pool } from "@neondatabase/serverless" ;
24import { z } from "zod" ;
35import Together from "together-ai" ;
46
57export async function POST ( req : Request ) {
8+ const neon = new Pool ( { connectionString : process . env . DATABASE_URL } ) ;
9+ const adapter = new PrismaNeon ( neon ) ;
10+ const prisma = new PrismaClient ( { adapter } ) ;
611 const { messageId, model } = await req . json ( ) ;
712
813 const message = await prisma . message . findUnique ( {
Original file line number Diff line number Diff line change @@ -11,8 +11,6 @@ const adapter = new PrismaNeon(neon);
1111
1212let client : PrismaClient ;
1313
14- console . log ( "NODE_ENV IS: " ) ;
15- console . log ( process . env . NODE_ENV ) ;
1614if ( process . env . NODE_ENV !== "production" ) {
1715 client = globalThis . prisma || new PrismaClient ( { adapter } ) ;
1816 globalThis . prisma = client ;
You can’t perform that action at this time.
0 commit comments