File size: 1,147 Bytes
5ec491a
 
1b0e328
 
ca7a659
 
ba9285c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca7a659
 
 
 
 
 
ba9285c
 
 
 
ca7a659
 
 
1b0e328
5ec491a
1b0e328
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { PrismaClient } from '@prisma/client';

declare global {
  var prisma: PrismaClient | undefined;
  namespace PrismaJson {
    // you can use classes, interfaces, types, etc.

    type StructuredResult = {
      logs: {
        stderr: string[];
        stdout: string[];
      };
      results: Array<{
        png?: string;
        mp4?: string;
        text: string;
        is_main_result: boolean;
      }>;
      error: {
        name: string;
        value: string;
        traceback_raw: string[];
      };
    };

    type FinalChatResult = {
      type: 'final_code';
      status: 'completed' | 'failed';
      payload: {
        code: string;
        test: string;
        // Change introduces https://github.com/landing-ai/vision-agent-ui/pull/86
        // 1. Backward compatibility, it could be stringified StructuredResult
        // 2. result not modified in stream server, could still be stringified StructuredResult
        result: string | StructuredResult;
      };
    };
  }
}

const db = globalThis.prisma || new PrismaClient();

if (process.env.NODE_ENV != 'production') globalThis.prisma = db;

export default db;