feat(rnd): Add missing code on execution logic for AutoGPT Server (#7209)

Add missing changes from previous commit
This commit is contained in:
Zamil Majdy
2024-06-11 18:15:52 +04:00
committed by GitHub
parent 60e0d4c530
commit af3febd79f
3 changed files with 13 additions and 10 deletions

View File

@@ -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()

View File

@@ -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())

View File

@@ -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.