Skip to content

Commit

Permalink
Fix langchain-ai#3365 + test
Browse files Browse the repository at this point in the history
Changed regex to cover new line before action serious.

regex101: https://regex101.com/r/CXl1kB/1
  • Loading branch information
msarskus committed Apr 22, 2023
1 parent 3a1bdce commit 9d17c72
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/unit_tests/agents/test_mrkl.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ def test_get_action_and_input_newline() -> None:
assert action_input == "```\nimport unittest\n\nunittest.main()\n```"


def test_get_action_and_input_newline_after_keyword() -> None:
"""Test getting an action and action input from the text
when there is a new line before the action (after the keywords "Action:" and "Action Input:") """
llm_output = """
I can use the `ls` command to list the contents of the directory and `grep` to search for the specific file.
Action:
Terminal
Action Input:
ls -l ~/.bashrc.d/
"""

action, action_input = get_action_and_input(llm_output)
assert action == "Terminal"
assert action_input == "ls -l ~/.bashrc.d/\n"


def test_get_final_answer() -> None:
"""Test getting final answer."""
llm_output = (
Expand Down

0 comments on commit 9d17c72

Please sign in to comment.