{"id":27979404,"url":"https://github.com/adadalshabab/orchestrating-multi-step-financial-sql-agent-using_langgraph_memory","last_synced_at":"2026-05-01T22:31:23.428Z","repository":{"id":291744775,"uuid":"978637612","full_name":"AdadAlShabab/Orchestrating-Multi-Step-Financial-SQL-Agent-Using_Langgraph_Memory","owner":"AdadAlShabab","description":"This repository demonstrates a production-ready architecture for a multi-step Financial SQL Agent using cutting-edge LLM tooling. It leverages a combination of","archived":false,"fork":false,"pushed_at":"2025-05-06T09:45:47.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T02:52:52.118Z","etag":null,"topics":["faiss","langchain","langgraph","llm","openai","python","sqlite"],"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/AdadAlShabab.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,"zenodo":null}},"created_at":"2025-05-06T09:40:27.000Z","updated_at":"2025-05-06T09:47:41.000Z","dependencies_parsed_at":"2025-05-06T11:00:01.027Z","dependency_job_id":null,"html_url":"https://github.com/AdadAlShabab/Orchestrating-Multi-Step-Financial-SQL-Agent-Using_Langgraph_Memory","commit_stats":null,"previous_names":["adadalshabab/orchestrating-multi-step-financial-sql-agent-using_langgraph_memory"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdadAlShabab%2FOrchestrating-Multi-Step-Financial-SQL-Agent-Using_Langgraph_Memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdadAlShabab%2FOrchestrating-Multi-Step-Financial-SQL-Agent-Using_Langgraph_Memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdadAlShabab%2FOrchestrating-Multi-Step-Financial-SQL-Agent-Using_Langgraph_Memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdadAlShabab%2FOrchestrating-Multi-Step-Financial-SQL-Agent-Using_Langgraph_Memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdadAlShabab","download_url":"https://codeload.github.com/AdadAlShabab/Orchestrating-Multi-Step-Financial-SQL-Agent-Using_Langgraph_Memory/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252989963,"owners_count":21836667,"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":["faiss","langchain","langgraph","llm","openai","python","sqlite"],"created_at":"2025-05-08T02:52:53.226Z","updated_at":"2026-05-01T22:31:23.394Z","avatar_url":"https://github.com/AdadAlShabab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Orchestrating Multi Step Financial SQL Agent Using Langgraph, LangChain, FAISS Memory, and SQLite\n\n## 🧠 Project Overview\n\nThis repository demonstrates a production-ready architecture for a **multi-step Financial SQL Agent** using cutting-edge LLM tooling. It leverages a combination of:\n\n- **[LangGraph](https://github.com/langchain-ai/langgraph)**: For orchestrating multi-step agent logic.\n- **[LangChain](https://www.langchain.com/)**: For creating SQL agents and handling database toolkits.\n- **OpenAI LLMs**: Used via `ChatOpenAI` to interpret user intent and generate SQL queries.\n- **FAISS-based Vector Store**: Stores and retrieves semantic memory to provide historical context.\n- **SQLite**: A lightweight SQL database backend with sample financial data.\n\n---\n\n## 🔍 What This Agent Can Do\n- Accept natural language questions about financial data (e.g., \"Show me total expenses in January\").\n- Retrieve contextual memory from a vector database to enrich SQL generation.\n- Use LangGraph to orchestrate query steps.\n- Translate the result into a clear and useful output.\n\n---\n\n## 🗂️ Project Structure\n\n```\nfinancial-sql-agent/\n├── agents/\n│   ├── query_agent.py       # Builds the SQL agent using LangChain + OpenAI + memory\n│   └── orchestrator.py      # Orchestrates query handling\n│\n├── data/\n│   ├── init_db.py           # Initializes SQLite with sample financial transactions\n│   └── sample_financial_data.db\n│\n├── memory/\n│   └── vector_store.py      # FAISS vector memory using OpenAI embeddings\n│\n├── prompts/\n│   └── financial_prompt.txt # System prompt that guides the agent\n│\n├── langgraph_app/\n│   └── langgraph_flow.py    # LangGraph setup for execution flow\n│\n├── main.py                 # CLI app entry point\n├── requirements.txt        # Dependencies\n└── README.md               # Project documentation\n```\n\n---\n\n## 🚀 How to Run This Project\n\n### 1. Clone the Repo\n```bash\ngit clone https://github.com/your-username/financial-sql-agent.git\ncd financial-sql-agent\n```\n\n### 2. Create a `.env` File\nCreate a `.env` file in the root folder:\n```\nOPENAI_API_KEY=your_openai_api_key\n```\n\n### 3. Install Dependencies\n```bash\npip install -r requirements.txt\n```\n\n### 4. Initialize the SQLite DB\n```bash\npython data/init_db.py\n```\nThis will create `sample_financial_data.db` with mock transactions.\n\n### 5. Run the App\n```bash\npython main.py\n```\nThen enter questions like:\n- \"What were my grocery expenses in January?\"\n- \"Total salary received in 2024?\"\n\n---\n\n## ⚙️ Key Components \u0026 Techniques\n\n### ✅ LangGraph (Multi-Step Workflow)\nLangGraph allows stateful orchestration between agents. Here it's used to:\n- Trigger the query agent\n- Manage memory and execution flow\n\n### ✅ LangChain SQL Agent\n- Automatically translates user queries into optimized SQL\n- Uses `SQLDatabaseToolkit` to explore schema and generate SQL\n- Uses `AgentType.ZERO_SHOT_REACT_DESCRIPTION` for efficiency\n\n### ✅ Memory with FAISS Vector Store\n- Stores and retrieves past context semantically\n- `OpenAIEmbeddings` + FAISS power fast and relevant memory lookup\n\n### ✅ OpenAI Chat Model\n- Uses `ChatOpenAI(temperature=0)` for deterministic query generation\n- Context is injected into the prompt dynamically\n\n### ✅ SQLite Backend\n- Lightweight and easy to explore\n- Schema:\n```sql\nCREATE TABLE transactions (\n  id INTEGER PRIMARY KEY,\n  date TEXT,\n  amount REAL,\n  category TEXT,\n  account TEXT\n);\n```\n\n---\n\n## 📌 Future Improvements\n- Add multi-table schema support\n- Integrate LangSmith for debugging\n- Expose via REST API or Streamlit UI\n- Add user authentication and persistent memory\n\n---\n\n## 🧑‍💻 Author\nCrafted by Adad — Machine Learning Engineer.\n  \nNeed help deploying this project or scaling it with real data? Feel free to ask!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadadalshabab%2Forchestrating-multi-step-financial-sql-agent-using_langgraph_memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadadalshabab%2Forchestrating-multi-step-financial-sql-agent-using_langgraph_memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadadalshabab%2Forchestrating-multi-step-financial-sql-agent-using_langgraph_memory/lists"}