mirror of
https://github.com/hwchase17/langchain.git
synced 2025-10-28 06:10:30 +00:00
Currently the chain is getting the column names and types on the one side and the example rows on the other. It is easier for the llm to read the table information if the column name and examples are shown together so that it can easily understand to which columns do the examples refer to. For an instantiation of this, please refer to the changes in the `sqlite.ipynb` notebook. Also changed `eval` for `ast.literal_eval` when interpreting the results from the sample row query since it is a better practice. --------- Co-authored-by: Francisco Ingham <> --------- Co-authored-by: Francisco Ingham <fpingham@gmail.com>
This commit is contained in:
@@ -16,7 +16,7 @@ from sqlalchemy import (
|
||||
schema,
|
||||
)
|
||||
|
||||
from langchain.sql_database import SQLDatabase
|
||||
from langchain.sql_database import _TEMPLATE_PREFIX, SQLDatabase
|
||||
|
||||
metadata_obj = MetaData()
|
||||
|
||||
@@ -46,10 +46,11 @@ def test_table_info() -> None:
|
||||
metadata_obj.create_all(engine)
|
||||
db = SQLDatabase(engine, schema="schema_a")
|
||||
output = db.table_info
|
||||
output = output[len(_TEMPLATE_PREFIX) :]
|
||||
expected_output = (
|
||||
"Table 'user' has columns: user_id (INTEGER), user_name (VARCHAR).",
|
||||
"Table 'user' has columns: {'user_id': ['INTEGER'], 'user_name': ['VARCHAR']}"
|
||||
)
|
||||
assert sorted(output.split("\n")) == sorted(expected_output)
|
||||
assert output == expected_output
|
||||
|
||||
|
||||
def test_sql_database_run() -> None:
|
||||
|
||||
Reference in New Issue
Block a user