Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jorgeandrespadilla/sql-agent
SQL Agent powered by LLMs
https://github.com/jorgeandrespadilla/sql-agent
langchain llm openai poetry python sql streamlit
Last synced: about 1 month ago
JSON representation
SQL Agent powered by LLMs
- Host: GitHub
- URL: https://github.com/jorgeandrespadilla/sql-agent
- Owner: jorgeandrespadilla
- Created: 2024-02-27T20:26:29.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-05T21:00:12.000Z (10 months ago)
- Last Synced: 2024-03-06T21:57:11.992Z (10 months ago)
- Topics: langchain, llm, openai, poetry, python, sql, streamlit
- Language: Python
- Homepage:
- Size: 286 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SQL Agent
This is a simple SQL Agent that can be used to run SQL queries against a database using LLMs. The main advantages of using the SQL Agent are:
- It can answer questions based on the databases’ schema as well as on the databases’ content (like describing a specific table).
- It can recover from errors by running a generated query, catching the traceback and regenerating it correctly.
- It can query the database as many times as needed to answer the user question.
- It will save tokens by only retrieving the schema from relevant tables.## Setup
> Before you start, you need to install `poetry`.
1. Clone the repository
2. Install the dependencies: `poetry install`
3. Activate the virtual environment: `poetry shell`
4. Configure the environment variables in the `.env` file (use the `.env.example` as a template)
5. Initialize the database: `python -m scripts.init_db`## Running the Agent
To run the agent in CLI, you can use the following command:
```bash
python main.py
```To run the agent in Streamlit, you can use the following command:
```bash
streamlit run main.py
```## Additional Information
For more information, please refer to the [Agents LangChain documentation](https://python.langchain.com/docs/use_cases/sql/agents).
For more information about using LLMs with Streamlit, please refer to the [Streamlit documentation](https://docs.streamlit.io/knowledge-base/tutorials/llm-quickstart).