mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-12 12:59:07 +00:00
MRKL output parser no longer breaks well formed queries (#5432)
# Handles the edge scenario in which the action input is a well formed SQL query which ends with a quoted column There may be a cleaner option here (or indeed other edge scenarios) but this seems to robustly determine if the action input is likely to be a well formed SQL query in which we don't want to arbitrarily trim off `"` characters Fixes #5423 ## Who can review? Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested: For a quicker response, figure out the right person to tag with @ @hwchase17 - project lead Agents / Tools / Toolkits - @vowelparrot
This commit is contained in:
@@ -71,6 +71,23 @@ def test_get_action_and_input_newline_after_keyword() -> None:
|
||||
assert action_input == "ls -l ~/.bashrc.d/\n"
|
||||
|
||||
|
||||
def test_get_action_and_input_sql_query() -> None:
|
||||
"""Test getting the action and action input from the text
|
||||
when the LLM output is a well formed SQL query
|
||||
"""
|
||||
llm_output = """
|
||||
I should query for the largest single shift payment for every unique user.
|
||||
Action: query_sql_db
|
||||
Action Input: \
|
||||
SELECT "UserName", MAX(totalpayment) FROM user_shifts GROUP BY "UserName" """
|
||||
action, action_input = get_action_and_input(llm_output)
|
||||
assert action == "query_sql_db"
|
||||
assert (
|
||||
action_input
|
||||
== 'SELECT "UserName", MAX(totalpayment) FROM user_shifts GROUP BY "UserName"'
|
||||
)
|
||||
|
||||
|
||||
def test_get_final_answer() -> None:
|
||||
"""Test getting final answer."""
|
||||
llm_output = (
|
||||
|
Reference in New Issue
Block a user