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.1.tar.gz (5.8 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.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ailocalconnection-0.1.1.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

Hashes for ailocalconnection-0.1.1.tar.gz
Algorithm Hash digest
SHA256 62532fba14315f484314a235db02eebc166823355ba14a88ca927699ff6e9d3d
MD5 905bd3ea895a272bce69b595d7c4d12e
BLAKE2b-256 121ef46865cca53b5e9aac625e7774d7322b2b6ef6507797a16926457dc52f58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ailocalconnection-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b65f9cdf2ea66cf0f1da02fdd57b6e7cc4a953c4ad191acb7f7a7e6711066c7
MD5 e4a1a144f4c6dcdd5256460ee65a0a72
BLAKE2b-256 3c43a0bf601c2e2180d91bc977652a324558292b972661a2da4d0e7063551cfb

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