mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
feat(rnd): Add missing code on execution logic for AutoGPT Server (#7209)
Add missing changes from previous commit
This commit is contained in:
@@ -96,7 +96,6 @@ class Block(ABC, BaseModel):
|
||||
@classmethod
|
||||
@property
|
||||
@abstractmethod
|
||||
|
||||
def id(cls) -> str:
|
||||
"""
|
||||
The unique identifier for the block, this value will be persisted in the DB.
|
||||
@@ -136,7 +135,6 @@ class Block(ABC, BaseModel):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def name(cls):
|
||||
@@ -233,7 +231,6 @@ async def initialize_blocks() -> None:
|
||||
)
|
||||
|
||||
|
||||
|
||||
async def get_block(block_id: str) -> Block:
|
||||
if not AVAILABLE_BLOCKS:
|
||||
await initialize_blocks()
|
||||
|
||||
@@ -75,6 +75,11 @@ async def execute_node(data: Execution) -> Execution | None:
|
||||
next_node_input = await graph.get_node_input(next_node, run_id)
|
||||
next_node_block = await next_node.block
|
||||
|
||||
if not set(next_node.input_nodes).issubset(next_node_input):
|
||||
logger.warning(f"{prefix} Skipped {next_node_id}-{next_node_block.name}, "
|
||||
f"missing: {set(next_node.input_nodes) - set(next_node_input)}")
|
||||
return None
|
||||
|
||||
if error := next_node_block.input_schema.validate_data(next_node_input):
|
||||
logger.warning(
|
||||
f"{prefix} Skipped {next_node_id}-{next_node_block.name}, {error}")
|
||||
@@ -111,17 +116,17 @@ def start_executor(pool_size: int, queue: ExecutionQueue) -> None:
|
||||
return exception
|
||||
|
||||
execution = f.result()
|
||||
if execution:
|
||||
if execution:
|
||||
loop.run_until_complete(add_execution(execution, queue))
|
||||
return exception
|
||||
|
||||
|
||||
return None
|
||||
|
||||
logger.warning("Executor started!")
|
||||
|
||||
with ProcessPoolExecutor(
|
||||
max_workers=pool_size,
|
||||
initializer=db.connect_sync,
|
||||
max_workers=pool_size,
|
||||
initializer=db.connect_sync,
|
||||
) as executor:
|
||||
while True:
|
||||
future = executor.submit(execute_node_sync, queue.get())
|
||||
|
||||
@@ -22,8 +22,8 @@ model AgentGraph {
|
||||
model AgentNode {
|
||||
id String @id
|
||||
|
||||
agentBlockName String
|
||||
AgentBlock AgentBlock @relation(fields: [agentBlockName], references: [name])
|
||||
agentBlockId String
|
||||
AgentBlock AgentBlock @relation(fields: [agentBlockId], references: [id])
|
||||
|
||||
agentGraphId String
|
||||
AgentGraph AgentGraph @relation("AgentGraphNodes", fields: [agentGraphId], references: [id])
|
||||
@@ -57,7 +57,8 @@ model AgentNodeLink {
|
||||
|
||||
// This model describes a component that will be executed by the AgentNode.
|
||||
model AgentBlock {
|
||||
name String @id
|
||||
id String @id
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user