Skip to content

Commit

Permalink
info sql tool remove whitespaces in table names (langchain-ai#13712)
Browse files Browse the repository at this point in the history
Remove whitespaces from the input of the ListSQLDatabaseTool for better
support.
for example, the input "table1,table2,table3" will throw an exception
whiteout the change although it's a valid input.

---------

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
  • Loading branch information
2 people authored and aymeric-roucher committed Dec 11, 2023
1 parent b60ebb7 commit 5a5994b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libs/langchain/langchain/tools/sql_database/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def _run(
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Get the schema for tables in a comma-separated list."""
return self.db.get_table_info_no_throw(table_names.split(", "))
return self.db.get_table_info_no_throw(
[t.strip() for t in table_names.split(",")]
)


class ListSQLDatabaseTool(BaseSQLDatabaseTool, BaseTool):
Expand Down

0 comments on commit 5a5994b

Please sign in to comment.