Web search and RAG capabilities for local AI models.
Project description
AILocalSearch 🌐
Give your local AI models the power to browse the internet.
AILocalSearch is a lightweight Python library that allows local Large Language Models (like Ollama, vLLM, LM Studio) to perform real-time web searches and use the internet as context to answer questions accurately. It acts as an instant Retrieval-Augmented Generation (RAG) agent.
Features ✨
- 100% Free Search: Uses DuckDuckGo under the hood. No API keys required.
- Smart Scraping: Fetches search results and scrapes the content of the pages, automatically removing ads, scripts, and navbars.
- Graceful Fallback: If a website blocks the scraper, it automatically falls back to the search engine's snippet.
- AILocalMemory Integration: Works flawlessly with
ailocalmemoryfor a complete RAG + Chat History experience.
Installation 📦
You can install AILocalSearch using pip:
pip install ailocalsearch
Quick Start 🚀
1. Generating a Search Prompt
You can use AILocalSearch independently to just build the context prompt, then send it to any AI endpoint manually.
from ailocalsearch import SearchAgent
agent = SearchAgent(max_results=3)
# Automatically searches the web, scrapes the top 3 links,
# and builds a comprehensive context prompt.
prompt = agent.build_prompt("Who won the UEFA Euro 2024?")
print(prompt)
2. Using with AILocalMemory (Recommended)
If you have ailocalmemory installed, you can combine internet searching with persistent chat history.
from ailocalsearch import SearchAgent
from ailocalmemory import ChatSession, OllamaAdapter
agent = SearchAgent(max_results=2)
with ChatSession(session_id="user_123", storage="memory") as session:
chat = OllamaAdapter(model="llama3", memory_session=session)
query = "What is the current price of Bitcoin?"
# 1. Search the web and build the RAG prompt
augmented_prompt = agent.build_prompt(query)
# 2. Send the augmented prompt to Ollama
response_stream = chat.send(augmented_prompt, stream=True)
for chunk in response_stream:
print(chunk, end="", flush=True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ailocalconnection-0.1.0.tar.gz.
File metadata
- Download URL: ailocalconnection-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5136145637eb0a00300492d4100a34e5b5f4fc4b74100d91b0ed50f72c734918
|
|
| MD5 |
e6a5853bb88732fb158f5c03c89a1f16
|
|
| BLAKE2b-256 |
371e90ce456d6ade360560304c078f38bc371627cdf0501f863168c5af3c3dcc
|
File details
Details for the file ailocalconnection-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ailocalconnection-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f13a937183bc6fac28b7cc57eaf0a2a602ab406c114a11677363735cfbcbf9f
|
|
| MD5 |
8d0006465598027716731b9488094daa
|
|
| BLAKE2b-256 |
11baeaaf935805f0c310dd7466f6cf4577617c34c8e75858774af181344834ec
|