mirror of
https://github.com/hwchase17/langchain.git
synced 2026-04-07 21:13:28 +00:00
The `sql_database.py` is unnecessarily placed in the root code folder. A similar code is usually placed in the `utilities/`. As a byproduct of this placement, the sql_database is [placed on the top level of classes in the API Reference](https://api.python.langchain.com/en/latest/api_reference.html#module-langchain.sql_database) which is confusing and not correct. - moved the `sql_database.py` from the root code folder to the `utilities/` @baskaryan --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
19 lines
599 B
Python
19 lines
599 B
Python
from langchain.agents import create_sql_agent
|
|
from langchain.agents.agent_toolkits import SQLDatabaseToolkit
|
|
from langchain.utilities.sql_database import SQLDatabase
|
|
from tests.unit_tests.llms.fake_llm import FakeLLM
|
|
|
|
|
|
def test_create_sql_agent() -> None:
|
|
db = SQLDatabase.from_uri("sqlite:///:memory:")
|
|
queries = {"foo": "Final Answer: baz"}
|
|
llm = FakeLLM(queries=queries, sequential_responses=True)
|
|
toolkit = SQLDatabaseToolkit(db=db, llm=llm)
|
|
|
|
agent_executor = create_sql_agent(
|
|
llm=llm,
|
|
toolkit=toolkit,
|
|
)
|
|
|
|
assert agent_executor.run("hello") == "baz"
|