Skip to main content

Web search and RAG capabilities for local AI models.

Project description

AILocalConnection 🌐

Give your local AI models the power to browse the internet.

AILocalConnection 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 ailocalmemory for a complete RAG + Chat History experience.

Installation 📦

You can install AILocalConnection using pip:

pip install ailocalconnection

Quick Start 🚀

1. Generating a Search Prompt

You can use AILocalConnection independently to just build the context prompt, then send it to any AI endpoint manually.

from ailocalconnection 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 ailocalconnection 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ailocalconnection-0.1.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ailocalconnection-0.1.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file ailocalconnection-0.1.2.tar.gz.

File metadata

  • Download URL: ailocalconnection-0.1.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for ailocalconnection-0.1.2.tar.gz
Algorithm Hash digest
SHA256 702692013e994b4ead49be13021cd134ee6291c9222f5033105490d747d9c7df
MD5 21bb9440b369904c3b8359fafeb56d90
BLAKE2b-256 004002380851dcd09c58735751138cfd253552aa728044781885f0d6e647654f

See more details on using hashes here.

File details

Details for the file ailocalconnection-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ailocalconnection-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea81930e9ad95b4a6640318b82d11df6020a132b98ae37c197001056f49f59be
MD5 bd43f86d471ed78e5a7039a855928d8d
BLAKE2b-256 eb53fbdc096feac72aae9416ddc2a1371450d2404873df3b9eef7768c30d230e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page