# ๐Ÿ”ฎ Sibilla โ€” L'Oracolo AI > *Self-hosted Perplexity-like AI search engine.* > *Chiedi, cerca, sintetizza โ€” con fonti verificabili.* [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/) [![Flask](https://img.shields.io/badge/flask-3.x-green.svg)](https://flask.palletsprojects.com/) [![Gemini](https://img.shields.io/badge/LLM-Gemini%202.5%20Flash-purple.svg)](https://ai.google.dev/) [![Version](https://img.shields.io/badge/version-0.2.0-blue.svg)](https://github.com/tuo-user/sibilla) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) [![MCP](https://img.shields.io/badge/MCP-compatible-orange.svg)](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