Search-Engine-With-Longchain-Tools-And-Agents

https://github.com/user-attachments/assets/a9ff8e75-f7ca-44d5-86bb-004fbcc58007

Search-Engine-With-Longchain-Tools-And-Agents

This project demonstrates how to build a search-powered conversational AI agent using LangChain and Groq LLMs, wrapped in a clean Streamlit UI. The chatbot doesnโ€™t just generate answers from a single model โ€” instead, it uses LangChain Agents that can reason, choose tools, and act before responding.

๐Ÿ”ง How It Works

LLM Backbone (Groq LLM)

The core reasoning engine is powered by Groqโ€™s llama-3.1-8b-instant model. It interprets the userโ€™s queries and decides how to solve them.

LangChain Agent

The app uses ZERO_SHOT_REACT_DESCRIPTION agent type. This means the agent can โ€œthink step by step,โ€ deciding when to search and which tool to use โ€” without any predefined training examples.

Integrated Tools

๐Ÿ“ฐ Wikipedia Tool โ€“ fetches concise, reliable summaries for general knowledge queries. ๐Ÿ“š Arxiv Tool โ€“ retrieves abstracts of academic research papers, useful for technical/scientific queries. ๐Ÿ” DuckDuckGo Tool โ€“ performs real-time web searches for the latest information or broader topics.

Agent Execution Flow

User enters a query in the Streamlit chat. The agent analyzes the query and selects the most relevant tool (Wikipedia, Arxiv, or DuckDuckGo). The tool fetches external data. The agent integrates the results and responds conversationally.

Interactive UI

Powered by Streamlit, showing both the chat and the agentโ€™s thought process (via StreamlitCallbackHandler). Maintains chat history so the conversation feels natural and continuous.

โš™๏ธ Installation

Clone the repo

git clone https://github.com/your-username/Search-Engine-With-Langchain-Tools-And-Agents.git cd Search-Engine-With-Langchain-Tools-And-Agents

Create a virtual environment

python -m venv venv source venv/bin/activate # On Linux/Mac venv\Scripts\activate # On Windows

Install dependencies

pip install -r requirements.txt

If requirements.txt is not created yet, generate one:

pip freeze > requirements.txt

๐Ÿ”‘ Environment Variables

Create a .env file in the project root:

GROQ_API_KEY=your_groq_api_key_here HF_TOKEN=your_huggingface_token_here

โš ๏ธ Important: Do not commit .env to GitHub (already added to .gitignore).

โ–ถ๏ธ Usage Run the Streamlit app: streamlit run app.py

Open your browser at: ๐Ÿ‘‰ http://localhost:8501

Youโ€™ll see a chatbot interface where you can: Ask research-based queries โ†’ answered via Arxiv General knowledge โ†’ answered via Wikipedia Broader topics โ†’ answered via DuckDuckGo

๐Ÿ“ธ Demo (Screenshot/GIF) (Add a screenshot of your Streamlit app here)

๐Ÿ› ๏ธ Tech Stack

Python Streamlit LangChain Groq API Arxiv API Wikipedia API DuckDuckGo Search

๐Ÿง‘โ€๐Ÿ’ป Author Himanshu Lodha ๐Ÿ’ผ LinkedIn ๐Ÿ“‚ GitHub