mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-10-13 19:18:14 +00:00
37 lines
949 B
TypeScript
37 lines
949 B
TypeScript
import { sql } from 'drizzle-orm';
|
|
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';
|
|
import { Document } from 'langchain/document';
|
|
|
|
export const messages = sqliteTable('messages', {
|
|
id: integer('id').primaryKey(),
|
|
role: text('type', { enum: ['assistant', 'user', 'source'] }).notNull(),
|
|
chatId: text('chatId').notNull(),
|
|
createdAt: text('createdAt')
|
|
.notNull()
|
|
.default(sql`CURRENT_TIMESTAMP`),
|
|
messageId: text('messageId').notNull(),
|
|
|
|
content: text('content'),
|
|
|
|
sources: text('sources', {
|
|
mode: 'json',
|
|
})
|
|
.$type<Document[]>()
|
|
.default(sql`'[]'`),
|
|
});
|
|
|
|
interface File {
|
|
name: string;
|
|
fileId: string;
|
|
}
|
|
|
|
export const chats = sqliteTable('chats', {
|
|
id: text('id').primaryKey(),
|
|
title: text('title').notNull(),
|
|
createdAt: text('createdAt').notNull(),
|
|
focusMode: text('focusMode').notNull(),
|
|
files: text('files', { mode: 'json' })
|
|
.$type<File[]>()
|
|
.default(sql`'[]'`),
|
|
});
|