{"id":14065010,"url":"https://github.com/cogitovirus/langchain-sql-agent-bootstrap","last_synced_at":"2025-07-29T19:34:00.024Z","repository":{"id":228617909,"uuid":"618548424","full_name":"cogitovirus/langchain-sql-agent-bootstrap","owner":"cogitovirus","description":"Langchain SQL Agent Boostrap application. Flask on the backend, React on the front.","archived":false,"fork":false,"pushed_at":"2023-03-31T23:24:54.000Z","size":2332,"stargazers_count":31,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-13T07:07:58.738Z","etag":null,"topics":["flask","langchain","openai","sql"],"latest_commit_sha":null,"homepage":"https://cogitovirus.com/posts/20230402-gpt-4-langchain-agent-bootstrap/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cogitovirus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-03-24T17:56:12.000Z","updated_at":"2024-06-24T15:51:39.000Z","dependencies_parsed_at":"2024-03-19T18:03:30.025Z","dependency_job_id":null,"html_url":"https://github.com/cogitovirus/langchain-sql-agent-bootstrap","commit_stats":null,"previous_names":["cogitovirus/langchain-sql-agent-bootstrap"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cogitovirus%2Flangchain-sql-agent-bootstrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cogitovirus%2Flangchain-sql-agent-bootstrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cogitovirus%2Flangchain-sql-agent-bootstrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cogitovirus%2Flangchain-sql-agent-bootstrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cogitovirus","download_url":"https://codeload.github.com/cogitovirus/langchain-sql-agent-bootstrap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228046012,"owners_count":17861077,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","langchain","openai","sql"],"created_at":"2024-08-13T07:04:14.206Z","updated_at":"2024-12-04T04:30:37.439Z","avatar_url":"https://github.com/cogitovirus.png","language":"Python","readme":"# Langchain SQL Agent Bootstap\nThis is a simple App for testing LLM to SQL commands on a sqlite database using [Langchain SQL Agent](https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html). The repo comes with a setup script that loads a sqlite database with some sample data.\n\n\u003e This repo is intended to be a starter for Langchain and also a starter for programming with co-pilot GPT-4. The scope is small enough that you can even get by with copying/pasting whole clases to GPT-4 and asking for explanations or improvemnts to the code.\n\u003eThere's a single important TODO item that is not and will not be ever completed, which is to implement the file upload functionality in the UI.  The backend is already setup to handle file uploads (csv). If you're interested you could probably also:\n\u003e - clean the ouput of the agent after each execution\n\u003e - add a auto-refresh or a refresh button to the tables\n\nBackend has several endpoints:\n- `/api/v1/tables` - returns a list of tables in the database\n- `/api/v1/tables/\u003ctable_name\u003e` - returns a list of columns in the table\n- `/api/v1/run-command` - takes a json payload with the command to execute and returns the results via a websocket\n- `/api/v1/upload` - takes a csv file and loads it into the database\n\n`run-command` is where all the fun is happening with the langchain sql agent.\n\n![Example 1](images/whisp_10.PNG)\n![Exampe 2](images/whisp_11.PNG)\n\n## Running locally\n\n### Pre-requisites\nBackend was setup with Python 3.10.10\n\nFrontend was setup with Node 18.15.0\n\nExperience may vary with other versions\n\nYou have to have an open-api-api-key to use the langchain sql agent.\n\nCopy the `.env.example` file to `.env` and add your key to the `OPENAI_API_KEY` variable. You can also change the model which is used to make predictions. In the time of writing, `gpt-4` is in closed beta, so the backend might not work if you select that model.\n\n### Backend\nCreate virtual environment (only need to do this once)\n```bash\npython3 -m venv data-whisperer-backend/myenv\n```\nactivate virtual environment\n```bash\nsource data-whisperer-backend/myenv/bin/activate\n# install dependencies\npip install -r data-whisperer-backend/requirements.txt\n```\n**seed the database**\n```bash\npython data-whisperer-backend/setup/create_and_seed_db.py\n```\nfinally, run the backend\n```bash\npython data-whisperer-backend/run.py\n```\n\n### Frontend\n```bash\ncd data-whisperer-frontend/\nnpm install # only need to do this once\nnpm start\n```\n\n## Teardown\n```bash\n# deactivate virtual environment after you are done\ndeactivate\n```\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcogitovirus%2Flangchain-sql-agent-bootstrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcogitovirus%2Flangchain-sql-agent-bootstrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcogitovirus%2Flangchain-sql-agent-bootstrap/lists"}