mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 02:56:23 +08:00
@@ -30,6 +30,7 @@ model User {
|
||||
pagePermissions WorkspacePageUserPermission[]
|
||||
connectedAccounts ConnectedAccount[]
|
||||
sessions UserSession[]
|
||||
AiSession AiSession[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
@@ -96,6 +97,7 @@ model Workspace {
|
||||
permissions WorkspaceUserPermission[]
|
||||
pagePermissions WorkspacePageUserPermission[]
|
||||
features WorkspaceFeatures[]
|
||||
AiSession AiSession[]
|
||||
|
||||
@@map("workspaces")
|
||||
}
|
||||
@@ -321,6 +323,8 @@ model Snapshot {
|
||||
// but the created time of last seen update that has been merged into snapshot.
|
||||
updatedAt DateTime @map("updated_at") @db.Timestamptz(6)
|
||||
|
||||
AiSession AiSession[]
|
||||
|
||||
@@id([id, workspaceId])
|
||||
@@map("snapshots")
|
||||
}
|
||||
@@ -422,6 +426,47 @@ model UserInvoice {
|
||||
@@map("user_invoices")
|
||||
}
|
||||
|
||||
enum AiPromptRole {
|
||||
system
|
||||
assistant
|
||||
user
|
||||
}
|
||||
|
||||
model AiPrompt {
|
||||
id String @id @default(uuid()) @db.VarChar
|
||||
// prompt name
|
||||
name String @db.VarChar(20)
|
||||
// if a group of prompts contains multiple sentences, idx specifies the order of each sentence
|
||||
idx Int @db.Integer
|
||||
// system/assistant/user
|
||||
role AiPromptRole
|
||||
// prompt content
|
||||
content String @db.Text
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
|
||||
@@unique([name, idx])
|
||||
@@map("ai_prompts")
|
||||
}
|
||||
|
||||
model AiSession {
|
||||
id String @id @default(uuid()) @db.VarChar
|
||||
userId String @map("user_id") @db.VarChar
|
||||
workspaceId String @map("workspace_id") @db.VarChar
|
||||
docId String @map("doc_id") @db.VarChar
|
||||
promptName String @map("prompt_name") @db.VarChar
|
||||
action Boolean @db.Boolean
|
||||
model String @db.VarChar
|
||||
messages Json @db.Json
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||
doc Snapshot @relation(fields: [docId, workspaceId], references: [id, workspaceId], onDelete: Cascade)
|
||||
|
||||
@@map("ai_sessions")
|
||||
}
|
||||
|
||||
model DataMigration {
|
||||
id String @id @default(uuid()) @db.VarChar(36)
|
||||
name String @db.VarChar
|
||||
|
||||
Reference in New Issue
Block a user