Skip to main content

MaMa è un toolkit RAG modulare basato su LangChain per knowledge base locali e interfacce conversazionali.

Project description

MaMa

Toolkit modulare per costruire pipeline RAG (Retrieval-Augmented Generation) su documenti locali e interrogare un LLM tramite LangChain.

Panoramica

  • Indicizza PDF, CSV e pagine web in un vector store FAISS.
  • Recupera i documenti pertinenti e compone prompt personalizzati per il modello.
  • Gestisce sessioni, memoria conversazionale e configurazione tramite un file JSON.

Requisiti

  • Python 3.10+ (testato con 3.12).
  • pip aggiornato.
  • Dipendenze principali (versioni minime consigliate):
    • langchain>=0.2.10
    • langchain-community
    • langchain-openai
  • langchain-text-splitters
  • faiss-cpu
  • pypdf
  • flask

Installa tutto con:

pip install -U "langchain>=0.2.10" langchain-community langchain-openai \
  langchain-text-splitters faiss-cpu pypdf bs4 urllib3 requests

Configurazione Rapida

  1. Facoltativo: installa il pacchetto in modalità sviluppo.
    pip install -e .
    
  2. (Solo per test offline) usa embeddings locali e un LLM di test impostando:
    export MAMA_EMBEDDINGS=simple
    
    Con le variabili di configurazione predefinite il modello "Dummy" viene caricato automaticamente e non richiede chiavi API.

Test CLI di Ingestion & Prompt

  1. Esegui il test end-to-end:
    make test
    
    Il target crea un PDF di prova, aggiorna database/db.json, indicizza i documenti in test/kb/ ed esegue una domanda di esempio.
  2. Verifica il log dettagliato in test/logs/test.log.
  3. L’output standard termina con TEST OK: ingestion and prompting completed.

Test Web (Flask)

  1. Avvia il backend e l'interfaccia HTML di esempio:
    make web
    
  2. Apri http://127.0.0.1:5000 e prova l'input nella textarea.
  3. Il backend espone POST /ask e restituisce answer e documents in JSON.
  4. Per eseguire una domanda rapida da CLI senza server:
    python test/web/app.py --demo
    
  5. Per avviare il server caricando automaticamente la chiave da .env e generare flask.log:
    bash test/start_web_test.sh
    

Area Admin web

  • Naviga su http://127.0.0.1:5000/admin per consultare:
    • elenco documenti indicizzati (estratto e sorgente);
    • statistiche sull’indice FAISS (numero vettori, dimensione embedding, spazio su disco);
    • modulo di upload per ingestare un nuovo PDF di test.
  • I file caricati vengono processati con gli stessi helper di MaMa (split e inserimento in FAISS).

Rilasciare una nuova versione su PyPI

  1. Aggiorna setup.py con la nuova versione (es. 3.5.0) e assegna un tag Git.
  2. Esegui la pipeline locale (test + build) con python publish.py oppure separatamente con make test e make package.
  3. Crea una release GitHub (git tag vX.Y.Z && git push --tags).
  4. Il workflow Publish MaMa Package eseguirà build e test/cli_test.py, quindi pubblicherà su PyPI usando PYPI_API_TOKEN.

File Generati dal Test

  • database/db.json: database JSON temporaneo per configurazione/sessions.
  • test/kb/: archivio FAISS della knowledge base di prova.
  • test/pdf_src/: PDF generato per l’ingestion.
  • test/logs/test.log: log con esito e passaggi principali.
  • test/logs/web.log: log dell'applicazione web di esempio.

Puoi eliminare tutto con make clean (vedi Makefile).

Utilizzo con Modelli Reali

Per usare un modello OpenAI:

  1. Popola database/db.json con config.model = "OpenAi" e i parametri necessari (openai_api_key, temperatura, ecc.).
  2. Rimuovi MAMA_EMBEDDINGS=simple (verranno usati gli embeddings HuggingFaceEmbeddings).
  3. Fornisci un prompt personalizzato nella sezione LLM del database o nella sessione utente.

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

mamai-3.5.0.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

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

mamai-3.5.0-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file mamai-3.5.0.tar.gz.

File metadata

  • Download URL: mamai-3.5.0.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for mamai-3.5.0.tar.gz
Algorithm Hash digest
SHA256 be1a69da0e33230eccf00b8c60b84f790381f0194276857917a05182839a204e
MD5 0c887094970d12dc55c86f78ca11bb14
BLAKE2b-256 b309146b349f7dfc064fe7576e29977491cbd573524d98fb8cb1a704d7919b6c

See more details on using hashes here.

File details

Details for the file mamai-3.5.0-py3-none-any.whl.

File metadata

  • Download URL: mamai-3.5.0-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for mamai-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3cf460678c9a209642c2ba3b01d6b54e8fce15b76b3c6a1b72a9efef470f08fe
MD5 3b57d1e8e51e4ab484587267e06a5ccc
BLAKE2b-256 54a4c8049dcf6cf6fb61f623a2712c2984c8cf5ebe0a0593e89b837ec165be25

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