mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-09 15:17:59 -05:00
### Background
The current implementation of AgentServer doesn't allow for a single pin to be connected to multiple nodes, this will be problematic when you have a single output node that needs to be propagated into many nodes. Or multiple nodes that possibly feed the data into a single pin (first come first serve).
This infra change is also part of the preparation for changing the `block` interface to return a stream of output instead of a single output. Treating blocks as streams requires this capability.
### Changes 🏗️
* Update block run interface from returning `(output_name, output_data)` to `Generator[(output_name, output_data)]`
* Removed `agent` term in the API, replace it with `graph` for consistency.
* Reintroduced `AgentNodeExecutionInputOutput`. `AgentNodeExecution` input & output will be a list of `AgentNodeExecutionInputOutput` which describes the input & output data of its execution. Making an execution has 1-many relation to its input output data.
* Propagating the relation and block interface change into the execution engine.
140 lines
4.4 KiB
Plaintext
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])
|
|
}
|