Skip to content

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.

Notifications You must be signed in to change notification settings

AshutoshRajGupta/Agentic-ai-chatbot-using-LangGraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 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

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
πŸ”§ Framework LangGraph
πŸ’¬ Language Agent LangChain
🌐 UI Streamlit
πŸ“Š 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)

graph TD
    Start --> tool_calling_llm
    tool_calling_llm -->|Tool Needed| tools
    tool_calling_llm -->|No Tool| End
    tools --> tool_calling_llm
    tools --> End
Loading
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

WhatsApp Image 2025-05-28 at 00 26 49_0097ab59 WhatsApp Image 2025-05-28 at 00 26 23_37e5fa86 WhatsApp Image 2025-05-28 at 00 26 00_a75f4049 WhatsApp Image 2025-05-28 at 00 27 40_a2b1bafb WhatsApp Image 2025-05-28 at 00 28 19_56beee53 WhatsApp Image 2025-05-28 at 00 27 56_eb78d001 WhatsApp Image 2025-05-28 at 00 27 14_dbfdd0d8

πŸ’‘ 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:
TAVILY_API_KEY=your_tavily_api_key
GROQ_API_KEY=your_groq_api_key

πŸ“¦ Install Dependencies

pip install -r requirements.txt

πŸš€ Run the App

streamlit run ui.py

πŸ“ License

This project is licensed under the MIT License.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages