AutoGPT/rnd/autogpt_server/schema.prisma

140 lines
4.4 KiB
Plaintext

datasource db {
provider = "sqlite"
url = "file:./database.db"
}
generator client {
provider = "prisma-client-py"
recursive_type_depth = 5
interface = "asyncio"
}
// This model describes the Agent Graph/Flow (Multi Agent System).
model AgentGraph {
id String @id @default(uuid())
name String?
description String?
AgentNodes AgentNode[]
AgentGraphExecution AgentGraphExecution[]
AgentGraphExecutionSchedule AgentGraphExecutionSchedule[]
}
// This model describes a single node in the Agent Graph/Flow (Multi Agent System).
model AgentNode {
id String @id @default(uuid())
agentBlockId String
AgentBlock AgentBlock @relation(fields: [agentBlockId], references: [id])
agentGraphId String
AgentGraph AgentGraph @relation(fields: [agentGraphId], references: [id])
// List of consumed input, that the parent node should provide.
Input AgentNodeLink[] @relation("AgentNodeSink")
// List of produced output, that the child node should be executed.
Output AgentNodeLink[] @relation("AgentNodeSource")
// JSON serialized dict[str, str] containing predefined input values.
constantInput String @default("{}")
// JSON serialized dict[str, str] containing the node metadata.
metadata String @default("{}")
ExecutionHistory AgentNodeExecution[]
}
// This model describes the link between two AgentNodes.
model AgentNodeLink {
id String @id @default(uuid())
// Output of a node is connected to the source of the link.
agentNodeSourceId String
AgentNodeSource AgentNode @relation("AgentNodeSource", fields: [agentNodeSourceId], references: [id])
sourceName String
// Input of a node is connected to the sink of the link.
agentNodeSinkId String
AgentNodeSink AgentNode @relation("AgentNodeSink", fields: [agentNodeSinkId], references: [id])
sinkName String
}
// This model describes a component that will be executed by the AgentNode.
model AgentBlock {
id String @id @default(uuid())
name String @unique
// We allow a block to have multiple types of input & output.
// Serialized object-typed `jsonschema` with top-level properties as input/output name.
inputSchema String
outputSchema String
// Prisma requires explicit back-references.
ReferencedByAgentNode AgentNode[]
}
// This model describes the execution of an AgentGraph.
model AgentGraphExecution {
id String @id @default(uuid())
agentGraphId String
AgentGraph AgentGraph @relation(fields: [agentGraphId], references: [id])
AgentNodeExecutions AgentNodeExecution[]
}
// This model describes the execution of an AgentNode.
model AgentNodeExecution {
id String @id @default(uuid())
agentGraphExecutionId String
AgentGraphExecution AgentGraphExecution @relation(fields: [agentGraphExecutionId], references: [id])
agentNodeId String
AgentNode AgentNode @relation(fields: [agentNodeId], references: [id])
Input AgentNodeExecutionInputOutput[] @relation("AgentNodeExecutionInput")
Output AgentNodeExecutionInputOutput[] @relation("AgentNodeExecutionOutput")
// sqlite does not support enum
// enum Status { INCOMPLETE, QUEUED, RUNNING, SUCCESS, FAILED }
executionStatus String
addedTime DateTime @default(now())
queuedTime DateTime?
startedTime DateTime?
endedTime DateTime?
}
// This model describes the output of an AgentNodeExecution.
model AgentNodeExecutionInputOutput {
id String @id @default(uuid())
name String
data String
time DateTime @default(now())
// Prisma requires explicit back-references.
referencedByInputExecId String?
ReferencedByInputExec AgentNodeExecution? @relation("AgentNodeExecutionInput", fields: [referencedByInputExecId], references: [id])
referencedByOutputExecId String?
ReferencedByOutputExec AgentNodeExecution? @relation("AgentNodeExecutionOutput", fields: [referencedByOutputExecId], references: [id])
}
// This model describes the recurring execution schedule of an Agent.
model AgentGraphExecutionSchedule {
id String @id
agentGraphId String
AgentGraph AgentGraph @relation(fields: [agentGraphId], references: [id])
schedule String // cron expression
isEnabled Boolean @default(true)
inputData String // JSON serialized object
// default and set the value on each update, lastUpdated field has no time zone.
lastUpdated DateTime @updatedAt
@@index([isEnabled])
}