{"id":27100614,"url":"https://github.com/notyusheng/query-agent","last_synced_at":"2025-04-06T13:20:09.206Z","repository":{"id":285752345,"uuid":"959223617","full_name":"NotYuSheng/query-agent","owner":"NotYuSheng","description":"Query Agent is an AI-powered natural language interface for PostgreSQL databases. It allows users to explore and query structured data using plain English, powered by Qwen 2.5 running via LM Studio.","archived":false,"fork":false,"pushed_at":"2025-04-02T13:07:51.000Z","size":8,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T14:22:29.178Z","etag":null,"topics":["docker","docker-compose","fastapi","lm-studio","postgres","qwen2-5","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NotYuSheng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2025-04-02T13:01:48.000Z","updated_at":"2025-04-02T13:09:11.000Z","dependencies_parsed_at":"2025-04-02T14:22:34.062Z","dependency_job_id":"91f386c7-e1cc-40f8-990a-44161851d5f8","html_url":"https://github.com/NotYuSheng/query-agent","commit_stats":null,"previous_names":["notyusheng/query-agent"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotYuSheng%2Fquery-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotYuSheng%2Fquery-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotYuSheng%2Fquery-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotYuSheng%2Fquery-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NotYuSheng","download_url":"https://codeload.github.com/NotYuSheng/query-agent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485662,"owners_count":20946451,"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":["docker","docker-compose","fastapi","lm-studio","postgres","qwen2-5","streamlit"],"created_at":"2025-04-06T13:20:08.625Z","updated_at":"2025-04-06T13:20:09.190Z","avatar_url":"https://github.com/NotYuSheng.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 Query Agent\n\n**Query Agent** is an AI-powered natural language interface for PostgreSQL databases. It allows users to explore and query structured data using plain English, powered by [Qwen 2.5](https://huggingface.co/Qwen/Qwen1.5-72B-Chat) running via [LM Studio](https://lmstudio.ai/).\n\nBuilt with:\n- 🐍 FastAPI backend\n- 📈 Streamlit frontend\n- 🐘 PostgreSQL database\n- 🧠 LLM-powered SQL generation\n- 🐳 Docker \u0026 Docker Compose\n\n---\n\n## 🚀 Features\n\n- Auto-discovers tables in your PostgreSQL database\n- Click-to-select table interface\n- LLM-generated data dictionary for any table\n- Preview top 5 sample rows from selected table\n- Natural language-to-SQL translation using Qwen 2.5\n- Fully containerized setup for local development\n\n---\n\n## 🧱 Project Structure\n\n```\nquery-agent/\n├── backend/            # FastAPI server\n│   ├── main.py\n│   ├── db.py\n│   ├── prompt.py\n│   └── requirements.txt\n├── frontend/           # Streamlit interface\n│   ├── streamlit_app.py\n│   └── requirements.txt\n├── postgres/           # Sample DB seed\n│   └── init.sql\n├── docker-compose.yml\n└── README.md\n```\n\n---\n\n## 🛠️ Getting Started\n\n### 1. Clone the repository\n\n```bash\ngit clone https://github.com/notyusheng/query-agent.git\ncd query-agent\n```\n\n### 2. Start the app\n\n```bash\ndocker-compose up --build -d\n```\n\n- Frontend (Streamlit): [http://localhost:8080](http://localhost:8080)\n- Backend (FastAPI): [http://localhost:3000/docs](http://localhost:3000/docs)\n- Database (PostgreSQL): Port `5432` exposed locally\n\n---\n\n## 🧠 LLM Setup (Qwen 2.5 via LM Studio)\n\nMake sure LM Studio is running locally or on your network with the following:\n- Model: Qwen 2.5 (or any OpenAI-compatible LLM)\n- Server URL: `http://192.168.1.130:1234/v1/chat/completions`\n\nThis is hardcoded in `backend/main.py`—update `LLM_URL` if needed.\n\n---\n\n## 🧰 Example Table Included\n\nA sample `devices` table is loaded on first run via `postgres/init.sql`:\n\n```sql\nCREATE TABLE devices (\n    device_id SERIAL PRIMARY KEY,\n    model_name TEXT,\n    os_version TEXT,\n    release_year INTEGER\n);\n```\n\n---\n\n## 📸 Screenshots\n\n_coming soon..._\n\n---\n\n## 📌 To-Do / Ideas\n\n- [ ] Add support for multiple-table joins\n- [ ] Semantic search across column descriptions\n- [ ] Export SQL results as CSV\n- [ ] Admin interface to manage metadata\n\n---\n\n## 📄 License\n\nMIT License — free for personal and commercial use.\n\n---\n\n## 💬 Feedback / Contributions\n\nOpen an issue, submit a PR, or reach out if you want to collaborate. This is an ongoing project and evolving rapidly.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotyusheng%2Fquery-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotyusheng%2Fquery-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotyusheng%2Fquery-agent/lists"}