Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add test for incomplete action parsing
Tomas Valentaa92f53fa212d
diff --git a/api-service/test/test_incomplete_action_parsing.py b/api-service/test/test_incomplete_action_parsing.pynew file mode 100644index 000000000..826443105--- /dev/null+++ b/api-service/test/test_incomplete_action_parsing.py@@ -0,0 +1,43 @@+"""Test LLM incomplete action parsing"""++# import pytest++from typing import Dict, List, NamedTuple, Any+from codegen.agent.base import (+ separate_thought_and_action,+ parse_action_string,+)+++class Action(NamedTuple):+ tool: str+ input: str+++llm_outputs: List[Dict[str, Any]] = [+ {+ "llm_output": """Action:+```+<action tool="AskHuman">+What should the post request handler do?+</+```""",+ "expected_actions": [+ Action("AskHuman", "What should the post request handler do?")+ ],+ },+]+++def test_parsing_llm_incomplete_action_output():+ """Test LLM action parsing."""++ for output in llm_outputs:+ _, action_string = separate_thought_and_action(output["llm_output"])+ parsed_actions = parse_action_string(action_string)++ for parsed_action, expected_action in zip(+ parsed_actions, output["expected_actions"]+ ):+ assert parsed_action.attrib["tool"] == expected_action.tool+ assert parsed_action.text.strip() == expected_action.input.strip()