Skip to content

Commit

Permalink
DH-4779/handling the bug with malformed tool input
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadrezaPourreza committed Oct 3, 2023
1 parent e951afa commit c66cc14
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dataherald/sql_generator/dataherald_sqlagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,11 @@ def _run(
tool_input: str,
run_manager: CallbackManagerForToolRun | None = None, # noqa: ARG002
) -> str:
schema, entity = tool_input.split(",")
table_name, column_name = schema.split("->")
try:
schema, entity = tool_input.split(",")
table_name, column_name = schema.split("->")
except ValueError:
return "Invalid input format, use following format: table_name -> column_name, entity (entity should be a string without ',')"
search_pattern = f"%{entity.strip().lower()}%"
meta = MetaData(bind=self.db.engine)
table = sqlalchemy.Table(table_name.strip(), meta, autoload=True)
Expand Down

0 comments on commit c66cc14

Please sign in to comment.