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.
- π Introduction
- π― Scope
- π§° Tech Stack
- π Project Structure
- β¨ Features
- βοΈ How It Works
- π οΈ Tools Used
- π Tool Usage Analytics
- π‘ Future Enhancements
- π§ͺ Setup & Usage
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.
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.
Component | Technology |
---|---|
π§ LLM | Groq Qwen-QWQ-32B |
π§ Framework | LangGraph |
π¬ Language Agent | LangChain |
π UI | Streamlit |
π Data Handling | Pandas, CSV, FAISS, HuggingFace |
π External APIs | Wikipedia, Arxiv, Tavily, JokeAPI |
βββ 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
- π¬ 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.
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. |
-
User submits a query.
-
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
.
-
Tool usage is logged to
tool_usage_log.csv
. -
Results are returned and displayed in the UI.
-
On the analytics tab, CSV data is visualized and analyzed.
Fetches concise information using the Wikipedia API.
Searches academic papers from Arxiv related to the user query.
Retrieves current web results for real-time information.
Uses JokeAPI to deliver a random programming-related joke.
- Reads a domain-specific textbook (
dbms.pdf
). - Creates or loads FAISS vector index.
- Answers questions using RetrievalQA with Groq LLM.
-
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.
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)
- 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.
- Python 3.9+
- Create a
.env
file:
TAVILY_API_KEY=your_tavily_api_key
GROQ_API_KEY=your_groq_api_key
pip install -r requirements.txt
streamlit run ui.py
This project is licensed under the MIT License.