How mhd-gdev/browsellama works
Project type and purpose
• BrowseLlama is an open-source Python-based CLI tool that augments a local LLM (via llama.cpp) with live web search. It ships two entry-points:
• online.py for quick search on the first few pages
• deep.py for multi-page, deeper scraping
• The goal is: take a user’s question, search the web, collect content, then feed that into a local LLM to generate an answer.
File structure
• Top level:
• README.md – project overview and install/usage instructions
• online.py – “quick” search + single-page pipeline
• deep.py – “deep” multi-page search + pipeline
• No subdirectories or microservices. All functionality lives in these two Python scripts.
• Dependencies: llama_cpp_python (wrapper for llama.cpp), beautifulsoup4, requests, duckduckgo-search – each plays a distinct architectural role.
Architecture gleaned from README
• Local model files (downloaded separately; loaded by llama_cpp_python)
• HTTP search (duckduckgo-search)
• HTTP fetch (requests)
• HTML parsing (BeautifulSoup)
• LLM inference (llama.cpp via llama_cpp_python)
• CLI orchestration
a. Main components
1. CLI Layer
• online.py / deep.py
2. Search Layer
• duckduckgo-search library → returns URLs
3. Fetch Layer
• requests library → downloads raw HTML
4. Parse Layer
• BeautifulSoup → extracts text
5. LLM Inference Layer
• llama_cpp_python → llama.cpp → local model files
6. Local Storage
• Model directory (user-specified)
b. Relationships & data flow
• User CLI input → Search Layer (queries DuckDuckGo)
• Search Layer → list of URLs → Fetch Layer
• Fetch Layer → raw HTML → Parse Layer
• Parse Layer → cleaned text → LLM Inference Layer
• LLM Inference Layer → generated answer → CLI output
c. Architectural patterns & design principles
• Pipeline pattern: each layer has a single responsibility
• Modular: search, fetch, parse, inference can be swapped or extended
• CLI orchestration: thin wrapper that chains stages
d. Key technologies & libraries
• Python 3.x
• llama_cpp_python (bridges to llama.cpp)
• duckduckgo-search (web search API)
• requests (HTTP client)
• BeautifulSoup4 (HTML parser)
Essential details without over-splitting
• Where the user must configure paths (the “model directory”).