mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Remove redundant error handling for action and final answer in CrewAgentParser. Update tests to reflect this change by deleting the corresponding test case.
This commit is contained in:
@@ -103,10 +103,6 @@ class CrewAgentParser:
|
|||||||
return AgentFinish(thought, final_answer, text)
|
return AgentFinish(thought, final_answer, text)
|
||||||
|
|
||||||
elif action_match:
|
elif action_match:
|
||||||
if includes_answer:
|
|
||||||
raise OutputParserException(
|
|
||||||
f"{FINAL_ANSWER_AND_PARSABLE_ACTION_ERROR_MESSAGE}"
|
|
||||||
)
|
|
||||||
action = action_match.group(1)
|
action = action_match.group(1)
|
||||||
clean_action = self._clean_action(action)
|
clean_action = self._clean_action(action)
|
||||||
|
|
||||||
|
|||||||
@@ -227,13 +227,6 @@ def test_missing_action_input_error(parser):
|
|||||||
assert "I missed the 'Action Input:' after 'Action:'." in str(exc_info.value)
|
assert "I missed the 'Action Input:' after 'Action:'." in str(exc_info.value)
|
||||||
|
|
||||||
|
|
||||||
def test_action_and_final_answer_error(parser):
|
|
||||||
text = "Thought: I found the information\nAction: search\nAction Input: what is the temperature in SF?\nFinal Answer: The temperature is 100 degrees"
|
|
||||||
with pytest.raises(OutputParserException) as exc_info:
|
|
||||||
parser.parse(text)
|
|
||||||
assert "both perform Action and give a Final Answer" in str(exc_info.value)
|
|
||||||
|
|
||||||
|
|
||||||
def test_safe_repair_json(parser):
|
def test_safe_repair_json(parser):
|
||||||
invalid_json = '{"task": "Research XAI", "context": "Explainable AI", "coworker": Senior Researcher'
|
invalid_json = '{"task": "Research XAI", "context": "Explainable AI", "coworker": Senior Researcher'
|
||||||
expected_repaired_json = '{"task": "Research XAI", "context": "Explainable AI", "coworker": "Senior Researcher"}'
|
expected_repaired_json = '{"task": "Research XAI", "context": "Explainable AI", "coworker": "Senior Researcher"}'
|
||||||
|
|||||||
Reference in New Issue
Block a user