mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
Fix error retry
This commit is contained in:
@@ -86,7 +86,8 @@ class LlmCallBlock(Block):
|
||||
|
||||
parsed_dict, parsed_error = parse_response(response_text)
|
||||
if not parsed_error:
|
||||
yield "response", parsed_dict
|
||||
# convert parsed_dict into dict[str,str]
|
||||
yield "response", {k: json.dumps(v) for k, v in parsed_dict.items()}
|
||||
break
|
||||
|
||||
retry_prompt = f"""
|
||||
|
||||
@@ -161,17 +161,20 @@ async def validate_exec(node: Node, data: dict[str, Any]) -> tuple[bool, str]:
|
||||
if not node_block:
|
||||
return False, f"Block for {node.block_id} not found."
|
||||
|
||||
error_message = f"Input data missing for {node_block.name}:"
|
||||
|
||||
input_fields_from_schema = node_block.input_schema.get_required_fields()
|
||||
if not input_fields_from_schema.issubset(data):
|
||||
return False, f"Input data missing: {input_fields_from_schema - set(data)}"
|
||||
return False, f"{error_message} {input_fields_from_schema - set(data)}"
|
||||
|
||||
input_fields_from_nodes = {name for name, _ in node.input_nodes}
|
||||
if not input_fields_from_nodes.issubset(data):
|
||||
return False, f"Input data missing: {input_fields_from_nodes - set(data)}"
|
||||
return False, f"{error_message} {input_fields_from_nodes - set(data)}"
|
||||
|
||||
if error := node_block.input_schema.validate_data(data):
|
||||
logger.error("Input value doesn't match schema: %s", error)
|
||||
return False, f"Input data doesn't match {node_block.name}: {error}"
|
||||
error_message = f"Input data doesn't match {node_block.name}: {error}"
|
||||
logger.error(error_message)
|
||||
return False, error_message
|
||||
|
||||
return True, node_block.name
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ AutoGPT agent, a tool for automating a large language model (LLM) for solving ta
|
||||
llm_call_node.connect(text_matcher_node, "response", "data")
|
||||
llm_call_node.connect(text_matcher_node, "response_#_post_id", "text")
|
||||
|
||||
text_matcher_node.input_default = {"pattern": "true"}
|
||||
text_matcher_node.input_default = {"match": "true"}
|
||||
text_matcher_node.connect(reddit_comment_node, "data_#_post_id", "post_id")
|
||||
text_matcher_node.connect(reddit_comment_node, "data_#_marketing_text", "comment")
|
||||
|
||||
@@ -99,16 +99,24 @@ AutoGPT agent, a tool for automating a large language model (LLM) for solving ta
|
||||
async def wait_execution(test_manager, graph_id, graph_exec_id) -> list:
|
||||
async def is_execution_completed():
|
||||
execs = await AgentServer().get_executions(graph_id, graph_exec_id)
|
||||
return test_manager.queue.empty() and len(execs) == 4
|
||||
"""
|
||||
List of execution:
|
||||
reddit_get_post_node 1 (produced 3 posts)
|
||||
text_formatter_node 3
|
||||
llm_call_node 3 (produced 2 relevant posts, filter out 1)
|
||||
text_matcher_node 2
|
||||
reddit_comment_node 2
|
||||
Total: 11
|
||||
"""
|
||||
return test_manager.queue.empty() and len(execs) == 11
|
||||
|
||||
# Wait for the executions to complete
|
||||
for i in range(10):
|
||||
for i in range(30):
|
||||
if await is_execution_completed():
|
||||
break
|
||||
return await AgentServer().get_executions(graph_id, graph_exec_id)
|
||||
time.sleep(1)
|
||||
|
||||
return await AgentServer().get_executions(graph_id, graph_exec_id)
|
||||
|
||||
assert False, "Execution did not complete in time."
|
||||
|
||||
# Manual run
|
||||
@pytest.mark.asyncio(scope="session")
|
||||
|
||||
Reference in New Issue
Block a user