Python script for search-extract-summarize flow, like an AI search engine
Top 96.2% on sourcepulse
This Python program implements a search-extract-summarize pipeline, mimicking AI search engines like Perplexity. It's designed for developers and researchers to experiment with LLM-based search functionalities, offering flexibility in LLM endpoints, search parameters, and output formats, with both CLI and GradIO UI options.
How It Works
The core functionality follows a search-extract-summarize flow. Given a query, it searches Google (or a specified list of URLs), extracts text content from results, chunks it, and stores it in a vector database. It then performs a hybrid search (vector and BM25) to retrieve relevant chunks, optionally re-ranks them, and uses these as context for an LLM to generate an answer. This modular approach allows for customization of search scope (e.g., date restrictions, target sites) and LLM output (e.g., language, length).
Quick Start & Requirements
pip install -r requirements.txt
requirements.txt
dependencies. API keys for search (Google) and LLM (OpenAI default) are required, configurable via .env
file or environment variables.python ask.py -c -q "Your query"
python ask.py
Highlighted Details
data
directory.extract
output mode with Pydantic schema support for structured data extraction.Maintenance & Community
The project is actively updated, with recent additions including support for separate API endpoints for inference and embedding, .env
file switching, and Ollama integration. Community interaction is encouraged via the project's GitHub repository.
Licensing & Compatibility
Limitations & Caveats
The project explicitly states that performance and scalability are not primary concerns, focusing instead on illustrating core AI search engine concepts. A more robust, production-ready toolset is planned for future release.
1 month ago
1 day