From 8f403ea2d76ae463f9971f097edeb4ac5aa2d8f2 Mon Sep 17 00:00:00 2001 From: dudub12 <70527423+dudub12@users.noreply.github.com> Date: Wed, 6 Dec 2023 06:07:38 +0200 Subject: [PATCH] info sql tool remove whitespaces in table names (#13712) 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 --- libs/langchain/langchain/tools/sql_database/tool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/langchain/langchain/tools/sql_database/tool.py b/libs/langchain/langchain/tools/sql_database/tool.py index c90186cfc64..97d45977e7f 100644 --- a/libs/langchain/langchain/tools/sql_database/tool.py +++ b/libs/langchain/langchain/tools/sql_database/tool.py @@ -60,7 +60,9 @@ class InfoSQLDatabaseTool(BaseSQLDatabaseTool, BaseTool): 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):