Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Cleanup
Tomas Valenta1f5773a4e846
diff --git a/api-service/.gitignore b/api-service/.gitignoreindex 671894279..69023ffbd 100644--- a/api-service/.gitignore+++ b/api-service/.gitignore@@ -1,3 +1,4 @@__pycache__dist.venv+out.txt\ No newline at end of filediff --git a/api-service/out.txt b/api-service/out.txtdeleted file mode 100644index e69de29bb..000000000diff --git a/api-service/test/test_simple_format_action_parsing.py b/api-service/test/test_simple_format_action_parsing.pynew file mode 100644index 000000000..51f8a34f4--- /dev/null+++ b/api-service/test/test_simple_format_action_parsing.py@@ -0,0 +1,104 @@+"""Test LLM incomplete action parsing"""++# import pytest++from typing import Dict, List, NamedTuple, Any+from codegen.agent.base import (+ parse_text,+ separate_thought_and_action,+ parse_action_string,+)+++class Action(NamedTuple):+ tool: str+ input: str+++llm_outputs: List[Dict[str, Any]] = [+ {+ "llm_output": """+This is a thought:+Action:+<action tool="AskHuman">+What should the post request handler do?+</+""",+ "expected_actions": [+ Action("AskHuman", "What should the post request handler do?")+ ],+ },+ {+ "llm_output": """+<action tool="AskHuman">+What should the post request handler do?+</action>+This is a thought:+Action:+""",+ "expected_actions": [+ Action("AskHuman", "What should the post request handler do?")+ ],+ },+ {+ "llm_output": """+<action tool="AskHuman">+What should the post request handler do?+</action>+This is a thought:++<?+<action tool="AskHuman">+What+</action>++This is a thought:++<?+""",+ "expected_actions": [+ Action("AskHuman", "What should the post request handler do?"),+ Action("AskHuman", "What"),+ ],+ },+ {+ "llm_output": """+This is a thought+Greater <?+And action:++<action tool="AskHuman">+What should the post request handler do?+</action>+<action tool="AskHuman">+What+</action>+thought after?+""",+ "expected_actions": [+ Action("AskHuman", "What should the post request handler do?"),+ Action("AskHuman", "What"),+ ],+ },+]+++def test_parsing_llm_simple_format_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(output["llm_output"])++ thought, parsed_actions = parse_text(output["llm_output"])++ # print("Thought", thought)++ for parsed_action, expected_action in zip(+ parsed_actions, output["expected_actions"]+ ):+ # print("Action", parsed_action.text.strip())+ assert parsed_action.attrib["tool"] == expected_action.tool+ assert parsed_action.text.strip().startswith(expected_action.input.strip())++ print("-----------")