From ba8035887ce6ee73a9cebf2515c2f4b67e58be89 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Tue, 9 Jun 2026 09:57:24 +0200 Subject: [PATCH] chore: rimuove emoji da codice e output terminale Sostituisce tutti i simboli grafici con testo: - checkmark/cross -> OK / ERRORE: / AVVISO: - icone tema GUI -> testo Chiaro / Scuro Co-Authored-By: Claude Sonnet 4.6 --- gui/chat.html | 2 +- gui/chat_window.py | 14 +++++++------- ingestion/ingest.py | 28 ++++++++++++++-------------- rag/rag.py | 10 +++++----- rag/retrieve.py | 8 ++++---- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/gui/chat.html b/gui/chat.html index 7c48837..1454726 100644 --- a/gui/chat.html +++ b/gui/chat.html @@ -226,7 +226,7 @@ function addMessage(role, content, sources) { const doc = s.source || ''; const path = s.header_path || ''; chip.innerHTML = path - ? `${esc(doc)} β€Ί ${esc(path)}` + ? `${esc(doc)} > ${esc(path)}` : `${esc(doc)}`; srcDiv.appendChild(chip); }); diff --git a/gui/chat_window.py b/gui/chat_window.py index 20d1cd6..ae466f0 100644 --- a/gui/chat_window.py +++ b/gui/chat_window.py @@ -46,8 +46,8 @@ _THEMES = { padding:8px 12px; font-size:14px; } """, - "theme_btn": "background:#2a2a2a; color:#ececec; border:1px solid #3a3a3a; border-radius:6px; font-size:16px; padding:4px 8px;", - "icon": "β˜€οΈ", + "theme_btn": "background:#2a2a2a; color:#ececec; border:1px solid #3a3a3a; border-radius:6px; font-size:12px; font-weight:600; padding:4px 8px;", + "icon": "Chiaro", }, "light": { "topbar": "background:#f5f5f5; border-bottom:1px solid #e0e0e0;", @@ -72,8 +72,8 @@ _THEMES = { padding:8px 12px; font-size:14px; } """, - "theme_btn": "background:#fff; color:#1a1a1a; border:1px solid #ddd; border-radius:6px; font-size:16px; padding:4px 8px;", - "icon": "πŸŒ™", + "theme_btn": "background:#fff; color:#1a1a1a; border:1px solid #ddd; border-radius:6px; font-size:12px; font-weight:600; padding:4px 8px;", + "icon": "Scuro", }, } @@ -130,7 +130,7 @@ class ChatWindow(QMainWindow): tl.addStretch() self._theme_btn = QPushButton() - self._theme_btn.setFixedSize(36, 30) + self._theme_btn.setFixedSize(60, 30) self._theme_btn.setToolTip("Cambia tema") self._theme_btn.clicked.connect(self._toggle_theme) tl.addWidget(self._theme_btn) @@ -212,7 +212,7 @@ class ChatWindow(QMainWindow): if not question: return if not self._collection: - self._js("addMessage('assistant', '⚠️ Seleziona una collezione prima di inviare.', [])") + self._js("addMessage('assistant', 'Seleziona una collezione prima di inviare.', [])") return self._input.clear() @@ -236,7 +236,7 @@ class ChatWindow(QMainWindow): def _on_error(self, msg: str) -> None: self._js("removeThinking()") - self._js(f"addMessage('assistant', {json.dumps('❌ Errore: ' + msg)}, [])") + self._js(f"addMessage('assistant', {json.dumps('Errore: ' + msg)}, [])") self._set_enabled(True) # ── Helpers ─────────────────────────────────────────────────────────────── diff --git a/ingestion/ingest.py b/ingestion/ingest.py index d02383e..e68c673 100644 --- a/ingestion/ingest.py +++ b/ingestion/ingest.py @@ -83,13 +83,13 @@ def check_ollama(model: str) -> bool: for m in models ) if found: - print(f"βœ… Ollama OK β€” {model} disponibile") + print(f"Ollama OK β€” {model} disponibile") return True - print(f"❌ Modello {model} non trovato in Ollama") + print(f"ERRORE: Modello {model} non trovato in Ollama") print(f" β†’ ollama pull {model}") return False except (urllib.error.URLError, OSError): - print("❌ Ollama non raggiungibile β€” assicurati che sia in esecuzione") + print("ERRORE: Ollama non raggiungibile β€” assicurati che sia in esecuzione") print(" β†’ ollama serve") return False @@ -116,18 +116,18 @@ def _ingest_stem(stem: str, collection: chromadb.Collection, """ chunks_path = CHUNKS_DIR / stem / "chunks.json" if not chunks_path.exists(): - print(f"❌ File non trovato: {chunks_path}") + print(f"ERRORE: File non trovato: {chunks_path}") return 0 with open(chunks_path, encoding="utf-8") as f: chunks = json.load(f) if not chunks: - print(f"⚠️ {stem}: chunks.json Γ¨ vuoto β€” skip") + print(f"AVVISO: {stem}: chunks.json e' vuoto β€” skip") return 0 total = len(chunks) - print(f" πŸ“„ {stem}: {total} chunk\n") + print(f" {stem}: {total} chunk\n") ids = [] embeddings = [] @@ -167,7 +167,7 @@ def _ingest_stem(stem: str, collection: chromadb.Collection, eta = int(avg * (total - i)) done = f"[{offset + i:>6}/{offset + total}]" cid = chunk["chunk_id"][:40] - print(f" {done} βœ“ {stem}/{cid:<40} ETA: {eta}s", end="\r", flush=True) + print(f" {done} {stem}/{cid:<40} ETA: {eta}s", end="\r", flush=True) if len(ids) == 100: collection.add(ids=ids, embeddings=embeddings, @@ -180,7 +180,7 @@ def _ingest_stem(stem: str, collection: chromadb.Collection, elapsed = int(time.monotonic() - start) print() - print(f" βœ… {stem}: {total} chunk in {elapsed}s") + print(f" OK {stem}: {total} chunk in {elapsed}s") return total @@ -200,11 +200,11 @@ def ingest_multi(stems: list[str], collection_name: str, if collection_exists(client, collection_name): if not force: - print(f"⚠️ Collection '{collection_name}' giΓ  presente in ChromaDB β€” skip") + print(f"AVVISO: Collection '{collection_name}' gia' presente in ChromaDB β€” skip") print(f" β†’ usa --force per sovrascrivere") return True client.delete_collection(collection_name) - print(f"πŸ—‘οΈ Collection '{collection_name}' rimossa (--force)") + print(f"Collection '{collection_name}' rimossa (--force)") collection = client.create_collection( name=collection_name, @@ -218,7 +218,7 @@ def ingest_multi(stems: list[str], collection_name: str, return False total_chunks += n - print(f"\nβœ… Collection '{collection_name}': {total_chunks} chunk totali") + print(f"\nOK Collection '{collection_name}': {total_chunks} chunk totali") print(f" Documenti: {', '.join(stems)}") print(f" Percorso: {CHROMA_DIR}/") return True @@ -266,10 +266,10 @@ def main() -> int: # ── ModalitΓ  multi-documento ───────────────────────────────────────────── if args.stems or args.collection: if not args.stems: - print("❌ --collection richiede --stems (es. --stems doc1 doc2 doc3)") + print("ERRORE: --collection richiede --stems (es. --stems doc1 doc2 doc3)") return 1 if not args.collection: - print("❌ --stems richiede --collection (es. --collection archivio)") + print("ERRORE: --stems richiede --collection (es. --collection archivio)") return 1 print(f" Collection : {args.collection}") print(f" Documenti : {', '.join(args.stems)}\n") @@ -280,7 +280,7 @@ def main() -> int: # ── ModalitΓ  singolo / tutti ───────────────────────────────────────────── stems = [args.stem] if args.stem else find_stems() if not stems: - print("❌ Nessun chunks.json trovato in chunks/") + print("ERRORE: Nessun chunks.json trovato in chunks/") return 1 results = [] diff --git a/rag/rag.py b/rag/rag.py index 3c18e52..4eae5e6 100644 --- a/rag/rag.py +++ b/rag/rag.py @@ -133,7 +133,7 @@ def answer(question: str, collection: chromadb.Collection, verbose: bool) -> Non try: chunks = retrieve(collection, question) except (urllib.error.URLError, OSError) as e: - print(f"❌ Errore embedding: {e}") + print(f"ERRORE embedding: {e}") return if verbose: @@ -151,7 +151,7 @@ def answer(question: str, collection: chromadb.Collection, verbose: bool) -> Non try: response = call_ollama(prompt, system=system) except (urllib.error.URLError, OSError) as e: - print(f"❌ Errore generazione: {e}") + print(f"ERRORE generazione: {e}") return print(f"\n{response}\n") @@ -234,13 +234,13 @@ def main() -> int: print() if not CHROMA_DIR.exists(): - print("❌ chroma_db/ non trovata β€” esegui prima ingestion") + print("ERRORE: chroma_db/ non trovata β€” esegui prima ingestion") return 1 client = chromadb.PersistentClient(path=str(CHROMA_DIR)) collections = [c.name for c in client.list_collections()] if collection_name not in collections: - print(f"❌ Collection '{collection_name}' non trovata in chroma_db/") + print(f"ERRORE: Collection '{collection_name}' non trovata in chroma_db/") if args.stem: print(f" β†’ python ingestion/ingest.py --stem {collection_name}") else: @@ -248,7 +248,7 @@ def main() -> int: return 1 collection = client.get_collection(collection_name) - print(f"βœ… Collection '{collection_name}' caricata ({collection.count()} chunk)\n") + print(f"OK Collection '{collection_name}' caricata ({collection.count()} chunk)\n") run_loop(collection) return 0 diff --git a/rag/retrieve.py b/rag/retrieve.py index 3ebdc7d..866a8d8 100644 --- a/rag/retrieve.py +++ b/rag/retrieve.py @@ -134,7 +134,7 @@ def run_loop(collection: chromadb.Collection, top_k: int) -> None: try: chunks = retrieve(collection, query, top_k) except (urllib.error.URLError, OSError) as e: - print(f"❌ Errore embedding (Ollama raggiungibile?): {e}\n") + print(f"ERRORE embedding (Ollama raggiungibile?): {e}\n") continue print() @@ -204,13 +204,13 @@ def main() -> int: print() if not CHROMA_DIR.exists(): - print("❌ chroma_db/ non trovata β€” esegui prima ingestion", file=sys.stderr) + print("ERRORE: chroma_db/ non trovata β€” esegui prima ingestion", file=sys.stderr) return 1 client = chromadb.PersistentClient(path=str(CHROMA_DIR)) collections = [c.name for c in client.list_collections()] if collection_name not in collections: - print(f"❌ Collection '{collection_name}' non trovata in chroma_db/", file=sys.stderr) + print(f"ERRORE: Collection '{collection_name}' non trovata in chroma_db/", file=sys.stderr) if args.stem: print(f" β†’ python ingestion/ingest.py --stem {collection_name}", file=sys.stderr) else: @@ -218,7 +218,7 @@ def main() -> int: return 1 collection = client.get_collection(collection_name) - print(f"βœ… Collection '{collection_name}' caricata ({collection.count()} chunk)\n") + print(f"OK Collection '{collection_name}' caricata ({collection.count()} chunk)\n") run_loop(collection, args.top_k) return 0