mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-12 06:13:36 +00:00
strip whitespace (#680)
This commit is contained in:
parent
2f57d18b25
commit
a2eeaf3d43
@ -41,7 +41,7 @@ def get_action_and_input(llm_output: str) -> Tuple[str, str]:
|
|||||||
match = re.search(regex, llm_output)
|
match = re.search(regex, llm_output)
|
||||||
if not match:
|
if not match:
|
||||||
raise ValueError(f"Could not parse LLM output: `{llm_output}`")
|
raise ValueError(f"Could not parse LLM output: `{llm_output}`")
|
||||||
action = match.group(1)
|
action = match.group(1).strip()
|
||||||
action_input = match.group(2)
|
action_input = match.group(2)
|
||||||
return action, action_input.strip(" ").strip('"')
|
return action, action_input.strip(" ").strip('"')
|
||||||
|
|
||||||
|
@ -19,6 +19,14 @@ def test_get_action_and_input() -> None:
|
|||||||
assert action_input == "NBA"
|
assert action_input == "NBA"
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_action_and_input_whitespace() -> None:
|
||||||
|
"""Test getting an action from text."""
|
||||||
|
llm_output = "Thought: I need to search for NBA\nAction: Search \nAction Input: NBA"
|
||||||
|
action, action_input = get_action_and_input(llm_output)
|
||||||
|
assert action == "Search"
|
||||||
|
assert action_input == "NBA"
|
||||||
|
|
||||||
|
|
||||||
def test_get_final_answer() -> None:
|
def test_get_final_answer() -> None:
|
||||||
"""Test getting final answer."""
|
"""Test getting final answer."""
|
||||||
llm_output = (
|
llm_output = (
|
||||||
|
Loading…
Reference in New Issue
Block a user