https://github.com/ashutoshrajgupta/agentic-ai-chatbot-using-langgraph
A smart AI assistant powered by LangGraph and Groq LLM that answers queries and intelligently uses tools like Wikipedia, Arxiv, PDF Q&A, web search, joke generation, and CSV analytics. It logs tool usage, analyzes it, and offers a clean Streamlit interface for chatting and insights.
https://github.com/ashutoshrajgupta/agentic-ai-chatbot-using-langgraph
agentic-ai ai-agents api groq-ai langgraph langgraph-tools python3 streamlit
Last synced: 3 months ago
JSON representation
A smart AI assistant powered by LangGraph and Groq LLM that answers queries and intelligently uses tools like Wikipedia, Arxiv, PDF Q&A, web search, joke generation, and CSV analytics. It logs tool usage, analyzes it, and offers a clean Streamlit interface for chatting and insights.
- Host: GitHub
- URL: https://github.com/ashutoshrajgupta/agentic-ai-chatbot-using-langgraph
- Owner: AshutoshRajGupta
- Created: 2025-05-24T18:03:54.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-06-25T10:30:50.000Z (4 months ago)
- Last Synced: 2025-06-25T11:31:38.122Z (4 months ago)
- Topics: agentic-ai, ai-agents, api, groq-ai, langgraph, langgraph-tools, python3, streamlit
- Language: Python
- Homepage: https://agentic-ai-bot.streamlit.app/
- Size: 611 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π§ LangGraph AI Assistant - Askie
A powerful AI assistant built using **LangGraph** and **Groq LLM**, capable of answering user queries and intelligently invoking multiple tools like Wikipedia, Arxiv, PDF retrieval, web search, joke generation, and CSV data analytics. This assistant logs tool usage, performs in-depth analysis of usage data, and provides both a chatbot and analytics interface through **Streamlit**.
---
## π Table of Contents
* [π Introduction](#-introduction)
* [π― Scope](#-scope)
* [π§° Tech Stack](#-tech-stack)
* [π Project Structure](#-project-structure)
* [β¨ Features](#-features)
* [βοΈ How It Works](#-how-it-works)
* [π οΈ Tools Used](#-tools-used)
* [π Tool Usage Analytics](#-tool-usage-analytics)
* [π‘ Future Enhancements](#-future-enhancements)
* [π§ͺ Setup & Usage](#-setup--usage)---
## π Introduction
LangGraph AI Assistant is a conversational AI application designed to demonstrate the powerful capabilities of the LangGraph workflow engine, integrated with **Groq's Qwen-QWQ-32B LLM**. It supports natural language interaction and smart tool invocation with dynamic analytics and data visualizations.
---
## π― Scope
This project showcases:
* Integration of **LangGraph** for stateful tool-based conversation management.
* Use of **Streamlit** to provide an interactive and user-friendly UI.
* Real-time **tool usage tracking** and visualization.
* Dynamic CSV **data analysis** via an LLM-enabled tool.
* Seamless use of external resources (e.g., Wikipedia, Arxiv, Tavily search) to enhance query responses.---
## π§° Tech Stack
| Component | Technology |
| ----------------- | ------------------------------------------------------ |
| π§ LLM | [Groq Qwen-QWQ-32B](https://groq.com/) |
| π§ Framework | [LangGraph](https://github.com/langchain-ai/langgraph) |
| π¬ Language Agent | [LangChain](https://www.langchain.com/) |
| π UI | [Streamlit](https://streamlit.io/) |
| π Data Handling | Pandas, CSV, FAISS, HuggingFace |
| π External APIs | Wikipedia, Arxiv, Tavily, JokeAPI |---
## π Project Structure
```
βββ main.py # LangGraph workflow & LLM logic
βββ ui.py # Streamlit UI
βββ tool.py # Tool definitions and utilities
βββ tool_usage_log.csv # CSV log for tool usage
βββ dbms.pdf # Source file for PDF QA
βββ faiss_dbms_index/ # FAISS vector store (auto-generated)
βββ .env # API keys
βββ requirements.txt
βββ README.md
```---
## β¨ Features
* π¬ **Chatbot Interface** β Natural conversation with automatic tool invocation.
* π§ **Dynamic Tool Triggering** β Tools like Wikipedia, Arxiv, and Tavily Search are triggered based on intent.
* π **PDF Q\&A** β Ask domain-specific questions about the uploaded DBMS textbook.
* π€£ **Joke Generator** β Fetches a programming joke from JokeAPI.
* π **Usage Analytics** β Tracks tool usage over time and visualizes it with bar charts.
* π§ **CSV Data Analysis Tool** β Analyzes usage logs for statistical insights using Groq LLM.
* β± **Response Time Logging** β Tracks how long tools take to execute.---
π€ What is LangGraph?
LangGraph is a stateful, graph-based orchestration framework designed specifically for large language model (LLM) applications. It enables you to construct modular, reactive workflows using simple nodes (functions) and conditional flows between them.It extends the LangChain ecosystem, allowing you to build complex LLM agents with tool-use behavior, memory, retries, fallbacks, and moreβstructured like a flowchart.
## βοΈ How It Works
## π§© (Execution Flow)
```mermaid
graph TD
Start --> tool_calling_llm
tool_calling_llm -->|Tool Needed| tools
tool_calling_llm -->|No Tool| End
tools --> tool_calling_llm
tools --> End
```
| Node | Functionality |
| ---------------------- | ---------------------------------------------------------------------------------------------- |
| **Start** | Entry point to the workflow. |
| **tool\_calling\_llm** | The LLM node (Groq Qwen-QWQ-32B) generates a response and determines whether a tool is needed. |
| **tools** | Invokes the appropriate tool (e.g., joke, PDF, Wikipedia, CSV analysis). |
| **End** | Terminates the workflow when no tool is needed or after tool output is processed. |1. **User submits a query.**
2. The **LangGraph** workflow:* Adds user input to the state.
* Passes it to the Groq-powered LLM.
* If tools are needed, it invokes them via `ToolNode`.
3. Tool usage is logged to `tool_usage_log.csv`.
4. Results are returned and displayed in the UI.
5. On the analytics tab, CSV data is visualized and analyzed.---
## π οΈ Tools Used
### 1. π **Wikipedia Tool**
Fetches concise information using the Wikipedia API.
### 2. π **Arxiv Tool**
Searches academic papers from Arxiv related to the user query.
### 3. π **Tavily Web Search**
Retrieves current web results for real-time information.
### 4. π€£ **Programming Joke Tool**
Uses JokeAPI to deliver a random programming-related joke.
### 5. π **PDF Question Answering Tool**
* Reads a domain-specific textbook (`dbms.pdf`).
* Creates or loads FAISS vector index.
* Answers questions using RetrievalQA with Groq LLM.### 6. π **CSV Analysis Tool**
* Reads `tool_usage_log.csv`.
* Computes:* Total tool calls
* Most/least used tools
* Average, min, max, and std deviation of response time
* Displays an ASCII bar chart of tool usage.---
## π Tool Usage Analytics
> Automatically logs and analyzes tool invocations.
Logged fields:
* Timestamp
* Tool Name
* Query
* Response Time (sec)Visualization:
* Bar chart of tool usage frequency
* Raw data table
* Detailed LLM-based statistical summary (via analyze\_tool\_usage\_csv tool)---
### π **OUTPUT**






## π‘ Future Enhancements
* Upload and analyze any PDF.
* User authentication & session storage.
* Real-time web search fallback if tools fail.
* Scheduled analytics report via email.
* Admin dashboard for tool monitoring.---
## π§ͺ Setup & Usage
### π§ Prerequisites
* Python 3.9+
* Create a `.env` file:```env
TAVILY_API_KEY=your_tavily_api_key
GROQ_API_KEY=your_groq_api_key
```### π¦ Install Dependencies
```bash
pip install -r requirements.txt
```### π Run the App
```bash
streamlit run ui.py
```---
## π License
This project is licensed under the MIT License.