Avoid misunderstanding LLMs about the numbers value (#4724)

Avoid misunderstanding LLMs about the numbers value
This commit is contained in:
so95 2025-02-06 09:17:56 +07:00 committed by GitHub
parent 6f2c3a3c3c
commit a3a70431f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -113,14 +113,14 @@ class ExeSQL(Generate, ABC):
logging.info("single_sql: ", single_sql)
cursor.execute(single_sql)
if cursor.rowcount == 0:
sql_res.append({"content": "\nTotal: 0\n No record in the database!"})
sql_res.append({"content": "No record in the database!"})
break
if self._param.db_type == 'mssql':
single_res = pd.DataFrame.from_records(cursor.fetchmany(self._param.top_n),columns = [desc[0] for desc in cursor.description])
else:
single_res = pd.DataFrame([i for i in cursor.fetchmany(self._param.top_n)])
single_res.columns = [i[0] for i in cursor.description]
sql_res.append({"content": "\nTotal: " + str(cursor.rowcount) + "\n" + single_res.to_markdown()})
sql_res.append({"content": single_res.to_markdown()})
break
except Exception as e:
single_sql = self._regenerate_sql(single_sql, str(e), **kwargs)