Skip to content

Commit

Permalink
info sql tool remove whitespaces in table names (#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
dudub12 and hwchase17 authored Dec 6, 2023
1 parent 64d5108 commit 8f403ea
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 8f403ea

Please sign in to comment.