| title | emoji | colorFrom | colorTo | sdk | sdk_version | app_file | pinned |
|---|---|---|---|---|---|---|---|
Smart GPT with Tools |
๐ค |
blue |
green |
streamlit |
1.32.0 |
frontend.py |
false |
An intelligent chatbot built with LangGraph that uses conditional tool routing, reflection-based validation, and multi-tool reasoning for high-quality responses.
โจ Features โข ๐๏ธ Architecture โข ๐ Project Structure โข ๐ Quick Start โข ๐ฌ How It Works
Smart GPT with Tools is a LangGraph-powered conversational AI system that intelligently decides:
- when to answer directly,
- when to use external tools,
- and when to reflect and improve its own responses.
Unlike linear chat pipelines, this system uses graph-based control flow to route queries through tools, validation, and refinement stages before delivering the final answer.
The result is a chatbot that is faster, more accurate, and more reliable.
Traditional chatbots:
- Call tools unnecessarily
- Return unverified answers
- Lack self-correction
This project demonstrates how to build:
- conditional reasoning flows,
- reflection-based quality assurance,
- and tool-augmented intelligence
It closely resembles production-grade agent systems used in real-world GenAI applications.
- Conditional tool execution using LangGraph
- Direct LLM responses for simple questions
- Automatic decision-making by the model
- DuckDuckGo web search for real-time information
- Calculator for mathematical expressions
- Easily extensible tool interface
- Reflection node validates every response
- Improves clarity, correctness, and completeness
- Prevents low-quality or partial answers
- Conversation history with memory
- Multi-threaded chat sessions
- Persistent state using checkpointer
- Streaming token-by-token responses
User Query
โ
โผ
Chat Node
โ
โผ
Conditional Router
โ
โโโโบ Tool Execution (Search / Calculator)
โ โ
โ โผ
โ Chat Node
โ
โโโโบ Reflection Node
โ
โผ
Final Response
LangGraph enables:
- conditional edges
- tool-aware routing
- validation loops
- clean separation of responsibilities
Receives user input and invokes the LLM with tool bindings.
Inspects the LLM output:
- tool call detected โ route to tool execution
- no tool needed โ route directly to reflection
Executes requested tools such as:
- web search
- calculator
Evaluates the response for:
- correctness
- clarity
- completeness
Improves the answer if needed before returning it.
- Thread-based conversation separation
- Full chat history retained per session
- Supports multi-user and multi-chat workflows
| Component | Technology |
|---|---|
| Orchestration | LangGraph |
| LLM Framework | LangChain |
| LLM Provider | Groq |
| Web Search | DuckDuckGo |
| UI | Streamlit |
| Language | Python |
- Python 3.8+
- Groq API key
Create a .env file:
GROQ_API_KEY=your_groq_api_key
pip install -r requirements.txtstreamlit run frontend.pyThe app will open at http://localhost:8501.
Smart_Gpt_with_tools/
โโโ src/
โ โโโ states/
โ โ โโโ state.py # ChatState definition
โ โโโ llms/
โ โ โโโ llm.py # LLM + tool setup
โ โโโ nodes/
โ โ โโโ node.py # Chat, router, reflection nodes
โ โโโ graphs/
โ โโโ graph_builder.py # LangGraph construction
โโโ backend.py # Chatbot initialization
โโโ frontend.py # Streamlit UI
โโโ requirements.txt # Dependencies
โโโ pyproject.toml # Project config
โโโ README.md
Direct response:
- What is Python?
- Explain machine learning
Tool-based:
- What is 456 * 789?
- Latest news about AI
- Current weather in New York
Edit src/llms/llm.py:
llm = ChatGroq(model="your-model-name")@tool
def custom_tool(input: str) -> str:
return resultEdit route_tools() in src/nodes/node.py.
Customize prompts in reflect_node().
- Create a new Space โ SDK: Streamlit
- Upload this repository
- Add
GROQ_API_KEYin Space Secrets - App runs automatically using
frontend.py
- Not a basic chatbot
- Demonstrates agentic reasoning
- Uses reflection and validation
- Clean, scalable architecture
- Directly aligned with real-world GenAI systems
- Tool result caching
- More specialized tools
- Confidence-based refusal
- Evaluation metrics dashboard
- Multi-agent extensions
Vivek Kumar Gupta AI Engineering Student | GenAI & Agentic Systems Builder
GitHub: https://github.com/vivek34561 LinkedIn: https://linkedin.com/in/vivek-gupta-0400452b6 Portfolio: https://resume-sepia-seven.vercel.app/
MIT License ยฉ 2025 Vivek Kumar Gupta