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).
pipaggiornato.- Dipendenze principali (versioni minime consigliate):
langchain>=0.2.10langchain-communitylangchain-openai
langchain-text-splittersfaiss-cpupypdfflask
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
- Facoltativo: installa il pacchetto in modalità sviluppo.
pip install -e .
- (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
- Esegui il test end-to-end:
make test
Il target crea un PDF di prova, aggiornadatabase/db.json, indicizza i documenti intest/kb/ed esegue una domanda di esempio. - Verifica il log dettagliato in
test/logs/test.log. - L’output standard termina con
TEST OK: ingestion and prompting completed.
Test Web (Flask)
- Avvia il backend e l'interfaccia HTML di esempio:
make web - Apri http://127.0.0.1:5000 e prova l'input nella textarea.
- Il backend espone
POST /aske restituisceansweredocumentsin JSON. - Per eseguire una domanda rapida da CLI senza server:
python test/web/app.py --demo
- Per avviare il server caricando automaticamente la chiave da
.enve generareflask.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
- Aggiorna
setup.pycon la nuova versione (es. 3.5.0) e assegna un tag Git. - Esegui la pipeline locale (test + build) con
python publish.py --bumpper incrementare automaticamente la versione (patch) oppure separatamente conmake testemake package. - Crea una release GitHub (
git tag vX.Y.Z && git push --tags). - Il workflow Publish MaMa Package eseguirà build e
test/cli_test.py, quindi pubblicherà su PyPI usandoPYPI_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:
- Popola
database/db.jsonconconfig.model = "OpenAi"e i parametri necessari (openai_api_key, temperatura, ecc.). - Rimuovi
MAMA_EMBEDDINGS=simple(verranno usati gli embeddingsHuggingFaceEmbeddings). - Fornisci un prompt personalizzato nella sezione LLM del database o nella sessione utente.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mamai-3.5.1.tar.gz.
File metadata
- Download URL: mamai-3.5.1.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4d7be8946b884d8d26d8fb8d0dab1b09bd1f1d9a020f945de44c16ea922711f
|
|
| MD5 |
3adc22b911ca9a977cecb9933129c5c7
|
|
| BLAKE2b-256 |
35c9932b68916820f760fc9c6b7e0c7288f67bb0ab427e14ba2aa96f73fb6da5
|
File details
Details for the file mamai-3.5.1-py3-none-any.whl.
File metadata
- Download URL: mamai-3.5.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78e6b273dfe2ea8470ff77bc7d5ac049ef497021d9e6525f4581d5c9beca34b5
|
|
| MD5 |
29b8ebca77db982e88a7a38144b6790a
|
|
| BLAKE2b-256 |
8b59ad9f38c1e902a610a98c0cd24da45a8191fba3f33792bae9accdf584ca3f
|