# ๐ฎ Sibilla โ L'Oracolo AI > *Self-hosted Perplexity-like AI search engine.* > *Chiedi, cerca, sintetizza โ con fonti verificabili.* [](https://www.python.org/downloads/) [](https://flask.palletsprojects.com/) [](https://ai.google.dev/) [](https://github.com/tuo-user/sibilla) [](LICENSE) [](https://modelcontextprotocol.io/) --- **Sibilla** รจ un motore di ricerca AI self-hosted che combina: - ๐ง **Google Gemini** โ LLM per sintesi con citazioni inline [1], [2], ... - ๐ **Degoog** โ metasearch engine self-hosted (primary) con API nativa - ๐ **SearXNG + DuckDuckGo** โ fallback a cascata se il primary non risponde - ๐ **Interfaccia web** โ UI responsive, dark theme, mobile-first - ๐ก **API REST** โ endpoint per consumo programmatico e skill vocali (Alexa, Google Home) - ๐ง **MCP (Model Context Protocol)** โ server stdio per agent AI esterni - ๐ฃ๏ธ **TTS-ready** โ campo `speakable_text` ottimizzato per sintesi vocale ``` Tu chiedi โ Query expansion โ Ricerca multi-engine โ Fetch pagine โ Gemini sintesi โ Risposta con fonti ``` --- ## ๐ Documentazione | Documento | Descrizione | |-----------|-------------| | [Architettura](docs/ARCHITECTURE.md) | ๐๏ธ Visione d'insieme, stack tecnologico, componenti, modello dati | | [Diagramma di Flusso](docs/FLOW.md) | ๐ Pipeline di ricerca, flusso richieste, macchina a stati (Mermaid) | | [API REST](docs/API.md) | ๐ก Documentazione completa degli endpoint `/api/ask` e `/api/v1/query` | | [Wiki](docs/WIKI.md) | ๐ FAQ, glossario, confronto con Perplexity, roadmap | | [Deployment](docs/DEPLOYMENT.md) | ๐ Guida al deployment in produzione (Gunicorn, Nginx, Docker, systemd) | | [Contributing](docs/CONTRIBUTING.md) | ๐ค Guida per contribuire, convenzioni, test, struttura branch | --- ## ๐ Quick Start ```bash # 1. Clona e installa git clone https://github.com/tuo-user/sibilla.git cd sibilla python3 -m venv .venv source .venv/bin/activate pip install -e ".[dev]" # 2. Avvia Degoog (motore di ricerca primary, opzionale ma consigliato) docker run -d --name degoog -p 4444:4444 ghcr.io/degoog-org/degoog:latest # 3. Configura # Crea un file .env con la tua Google API Key: # GOOGLE_API_KEY=la-tua-api-key # 4. Avvia sibilla # โ http://127.0.0.1:5000 ``` ### Prerequisiti minimi - **Python 3.10+** - **Google API Key** โ [ottienila gratis](https://aistudio.google.com/apikey) - Almeno un motore di ricerca (Degoog, SearXNG, o DuckDuckGo automatico) --- ## ๐ API ### Ricerca via API (per skill Alexa, bot, app) ```bash # GET โ il piรน semplice curl "http://localhost:5000/api/v1/query?q=ultimo+film+sull%27Odissea" # POST โ per query lunghe curl -X POST http://localhost:5000/api/v1/query \ -H "Content-Type: application/json" \ -d '{"query": "quali sono i migliori ristoranti a Roma?"}' # Estrai solo il testo per TTS curl -s "http://localhost:5000/api/v1/query?q=raggi+cosmici" \ | python -c "import sys,json; print(json.load(sys.stdin)['speakable_text'])" ``` **Risposta:** ```json { "query": "ultimo film sull'Odissea", "answer": "L'ultimo adattamento รจ **The Return** (2024)...", "speakable_text": "L'ultimo adattamento รจ The Return del 2024...", "sources": [{"index": 1, "title": "...", "url": "..."}], "model": "gemini-2.5-flash", "search_engine": "degoog", "tokens_used": 1847 } ``` > **Documentazione completa:** [`docs/API.md`](docs/API.md) --- ## ๐๏ธ Architettura ``` sibilla/ โโโ docs/ # ๐ Documentazione โ โโโ ARCHITECTURE.md # Architettura di sistema โ โโโ FLOW.md # Diagramma di flusso (Mermaid) โ โโโ API.md # Documentazione API REST โ โโโ WIKI.md # Wiki + FAQ โ โโโ DEPLOYMENT.md # Guida al deployment โ โโโ CONTRIBUTING.md # Guida alla contribuzione โ โโโ src/sibilla/ # ๐ฆ Codice sorgente โ โโโ app.py # Flask app factory + pipeline condivisa โ โโโ search.py # Degoog, SearXNG, DuckDuckGo, PageFetcher โ โโโ ai.py # GeminiClient (sintesi + query rewriting) โ โโโ markdown.py # Markdown โ HTML + strip per TTS โ โโโ prompts.py # System prompt stile Perplexity โ โโโ mcp.py # MCP server stdio (per agent AI) โ โโโ cli.py # Entry point server โ โโโ templates/index.html # Interfaccia web โโโ static/ # CSS, JS, favicon โโโ tests/ # Test (pytest, 109 test) โโโ pyproject.toml # Configurazione progetto ``` --- ## ๐ Pipeline di Ricerca ``` POST /api/ask {query: "..."} โ โโ 1. ๐ฎ Gemini riscrive la query in 3 varianti (query expansion) โโ 2. ๐ Multi-engine search: Degoog โ SearXNG โ DuckDuckGo (cascading) โโ 3. ๐ฅ PageFetcher scarica il contenuto completo delle top pagine โโ 4. ๐ Prompt assembly con fonti numerate + data odierna โโ 5. ๐ง Gemini sintesi con citazioni inline [1], [2], ... โโ 6. โ JSON {answer, html_answer, speakable_text, sources[], metadata} ``` --- ## ๐ง MCP Server Sibilla espone le sue capacitร di ricerca come tool MCP (Model Context Protocol) su stdio: ```bash sibilla-mcp ``` **Tool disponibili:** - `web_search(query, num_results)` โ ricerca web con fallback Degoog โ SearXNG โ DuckDuckGo - `fetch_page(url)` โ estrai contenuto testuale da una pagina web Compatibile con client MCP come Claude Desktop, Gemini Desktop e altri agent AI. --- ## ๐งช Sviluppo ```bash # Installa dipendenze dev pip install -e ".[dev]" # Lint ruff check src tests # Test pytest tests/ -v # Coverage pip install pytest-cov pytest tests/ --cov=src/sibilla --cov-report=html ``` --- ## ๐ Deployment Per il deployment in produzione: ```bash # Con Gunicorn pip install gunicorn gunicorn -w 4 -b 0.0.0.0:5000 "sibilla.app:create_app()" # Con Docker Compose (Sibilla + Degoog + SearXNG) docker compose up -d ``` > **Guida completa:** [`docs/DEPLOYMENT.md`](docs/DEPLOYMENT.md) --- ## ๐ Configurazione Crea un file `.env`: ```env GOOGLE_API_KEY=la-tua-api-key SECRET_KEY=una-chiave-segreta-lunga-e-casuale SIBILLA_HOST=127.0.0.1 SIBILLA_PORT=5000 SIBILLA_DEBUG=1 DEGOOG_URL=http://localhost:4444 SEARXNG_URL=http://localhost:8080 SIBILLA_DDG_FALLBACK=1 ``` --- ## ๐ค Contribuire Contributi benvenuti! Vedi [`docs/CONTRIBUTING.md`](docs/CONTRIBUTING.md) per: - Setup dell'ambiente di sviluppo - Convenzioni di codice e commit - Come aggiungere search engine, endpoint, o tool MCP - Struttura dei test --- ## ๐ Licenza MIT โ vedi il file [LICENSE](LICENSE) per i dettagli. ---
Fatto con ๐ฎ da Sibilla Team ยท Architettura ยท API ยท Deployment