Skip to content

A Reflex web app that combines Serper Google Search with Ollama's language model to create an AI-powered search assistant. Features a clean, customizable interface, real-time query processing, and error handling. Built using Reflex, LangChain, and Ollama. Perfect for enhanced web searchingπŸ”πŸ€–

Notifications You must be signed in to change notification settings

bassemalyyy/LangChain-Search-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Search Agent with Ollama

A modern web application built with Reflex that combines Google Search with local Ollama LLM to provide AI-powered search responses. This app creates an intelligent search agent that can query Google for recent information and generate comprehensive responses using the Llama 3.2 model.

Features

  • πŸ” Google Search Integration - Real-time web search using Serper API
  • πŸ€– Local LLM Processing - Powered by Ollama and Llama 3.2 model
  • 🎨 Modern UI - Beautiful gradient design with responsive components
  • ⚑ Real-time Updates - Async processing with loading states
  • πŸ›‘οΈ Error Handling - Comprehensive error management and user feedback
  • πŸ“± Responsive Design - Works seamlessly across all devices

Prerequisites

Before running this application, make sure you have the following installed:

  • Python 3.10 or higher
  • Ollama installed and running
  • A Serper API key (get one from serper.dev)

Installation

  1. Clone the repository

    git clone https://github.com/bassemalyyy/LangChain-Search-Agent.git
    cd LangChain-Search-Agent
  2. Create a virtual environment

    python -m venv venv
    .\venv\Scripts\activate # On Windows
  3. Install dependencies

    pip install reflex langchain langchain-community langchain-ollama
  4. Install and setup Ollama

    Download and install Ollama from ollama.ai

    Then pull the Llama 3.2 model:

    ollama pull llama3.2

    Start Ollama service:

    ollama serve
  5. Configure API Key

    Replace the Serper API key in the code with your own:

    serper_search = GoogleSerperAPIWrapper(
    serper_api_key="serper_api_key")

Running the Application

  1. Initialize Reflex

    reflex init
  2. Run the development server

    reflex run
  3. Open your browser

    Navigate to http://localhost:3000 to access the application.

Project Structure

langchain_reflex_agent/
β”œβ”€β”€ assets/                     
β”œβ”€β”€ langchain_reflex_agent/     # Application package
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── langchain_reflex_agent.py # Main Reflex entrypoint
β”œβ”€β”€ rxconfig.py                 # Reflex build configuration
β”œβ”€β”€ requirements.txt            # Python dependencies
└── README.md                   # Project overview & setup instructions
β”œβ”€β”€ .gitignore                  # Ignored files

Configuration

Ollama Model Configuration

You can change the Ollama model by modifying this line in main.py:

ollama_llm = OllamaLLM(model="llama3.2")  # Change to any model you have installed

Available models can be listed with:

ollama list

Usage

  1. Enter your search query in the input field
  2. Click "Submit Query" or press Enter
  3. The application will:
    • Search Google for relevant information
    • Process the results using the local Llama 3.2 model
    • Generate a comprehensive AI-powered response

Dependencies

  • reflex - Web framework for Python
  • langchain - LLM application framework
  • langchain-community - Community integrations for LangChain
  • langchain-ollama - Ollama integration for LangChain

Acknowledgments

  • Reflex for the amazing Python web framework
  • Ollama for local LLM capabilities
  • LangChain for LLM orchestration
  • Serper for Google Search API

Support

If you encounter any issues or have questions, please:

  1. Check the troubleshooting section above
  2. Search existing GitHub Issues
  3. Create a new issue with detailed information about your problem

⭐ If you found this project helpful, please give it a star!

About

A Reflex web app that combines Serper Google Search with Ollama's language model to create an AI-powered search assistant. Features a clean, customizable interface, real-time query processing, and error handling. Built using Reflex, LangChain, and Ollama. Perfect for enhanced web searchingπŸ”πŸ€–

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages