simplify parsing of the final answer (#621)

This commit is contained in:
Harrison Chase
2023-01-15 16:39:27 -08:00
committed by GitHub
parent 2a54e73fec
commit 1ac3319e45
2 changed files with 17 additions and 2 deletions

View File

@@ -34,6 +34,21 @@ def test_get_final_answer() -> None:
assert action_input == "1994"
def test_get_final_answer_new_line() -> None:
"""Test getting final answer."""
llm_output = (
"Thought: I need to search for NBA\n"
"Action: Search\n"
"Action Input: NBA\n"
"Observation: founded in 1994\n"
"Thought: I can now answer the question\n"
"Final Answer:\n1994"
)
action, action_input = get_action_and_input(llm_output)
assert action == "Final Answer"
assert action_input == "1994"
def test_get_final_answer_multiline() -> None:
"""Test getting final answer that is multiline."""
llm_output = (