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 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 09:57:24 +02:00
parent 91d20da120
commit ba8035887c
5 changed files with 31 additions and 31 deletions
+1 -1
View File
@@ -226,7 +226,7 @@ function addMessage(role, content, sources) {
const doc = s.source || ''; const doc = s.source || '';
const path = s.header_path || ''; const path = s.header_path || '';
chip.innerHTML = path chip.innerHTML = path
? `<span class="src-doc">${esc(doc)}</span> <span class="src-path">${esc(path)}</span>` ? `<span class="src-doc">${esc(doc)}</span> &gt; <span class="src-path">${esc(path)}</span>`
: `<span class="src-doc">${esc(doc)}</span>`; : `<span class="src-doc">${esc(doc)}</span>`;
srcDiv.appendChild(chip); srcDiv.appendChild(chip);
}); });
+7 -7
View File
@@ -46,8 +46,8 @@ _THEMES = {
padding:8px 12px; font-size:14px; 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;", "theme_btn": "background:#2a2a2a; color:#ececec; border:1px solid #3a3a3a; border-radius:6px; font-size:12px; font-weight:600; padding:4px 8px;",
"icon": "☀️", "icon": "Chiaro",
}, },
"light": { "light": {
"topbar": "background:#f5f5f5; border-bottom:1px solid #e0e0e0;", "topbar": "background:#f5f5f5; border-bottom:1px solid #e0e0e0;",
@@ -72,8 +72,8 @@ _THEMES = {
padding:8px 12px; font-size:14px; 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;", "theme_btn": "background:#fff; color:#1a1a1a; border:1px solid #ddd; border-radius:6px; font-size:12px; font-weight:600; padding:4px 8px;",
"icon": "🌙", "icon": "Scuro",
}, },
} }
@@ -130,7 +130,7 @@ class ChatWindow(QMainWindow):
tl.addStretch() tl.addStretch()
self._theme_btn = QPushButton() 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.setToolTip("Cambia tema")
self._theme_btn.clicked.connect(self._toggle_theme) self._theme_btn.clicked.connect(self._toggle_theme)
tl.addWidget(self._theme_btn) tl.addWidget(self._theme_btn)
@@ -212,7 +212,7 @@ class ChatWindow(QMainWindow):
if not question: if not question:
return return
if not self._collection: 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 return
self._input.clear() self._input.clear()
@@ -236,7 +236,7 @@ class ChatWindow(QMainWindow):
def _on_error(self, msg: str) -> None: def _on_error(self, msg: str) -> None:
self._js("removeThinking()") 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) self._set_enabled(True)
# ── Helpers ─────────────────────────────────────────────────────────────── # ── Helpers ───────────────────────────────────────────────────────────────
+14 -14
View File
@@ -83,13 +83,13 @@ def check_ollama(model: str) -> bool:
for m in models for m in models
) )
if found: if found:
print(f"Ollama OK — {model} disponibile") print(f"Ollama OK — {model} disponibile")
return True return True
print(f" Modello {model} non trovato in Ollama") print(f"ERRORE: Modello {model} non trovato in Ollama")
print(f" → ollama pull {model}") print(f" → ollama pull {model}")
return False return False
except (urllib.error.URLError, OSError): 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") print(" → ollama serve")
return False return False
@@ -116,18 +116,18 @@ def _ingest_stem(stem: str, collection: chromadb.Collection,
""" """
chunks_path = CHUNKS_DIR / stem / "chunks.json" chunks_path = CHUNKS_DIR / stem / "chunks.json"
if not chunks_path.exists(): if not chunks_path.exists():
print(f" File non trovato: {chunks_path}") print(f"ERRORE: File non trovato: {chunks_path}")
return 0 return 0
with open(chunks_path, encoding="utf-8") as f: with open(chunks_path, encoding="utf-8") as f:
chunks = json.load(f) chunks = json.load(f)
if not chunks: if not chunks:
print(f"⚠️ {stem}: chunks.json è vuoto — skip") print(f"AVVISO: {stem}: chunks.json e' vuoto — skip")
return 0 return 0
total = len(chunks) total = len(chunks)
print(f" 📄 {stem}: {total} chunk\n") print(f" {stem}: {total} chunk\n")
ids = [] ids = []
embeddings = [] embeddings = []
@@ -167,7 +167,7 @@ def _ingest_stem(stem: str, collection: chromadb.Collection,
eta = int(avg * (total - i)) eta = int(avg * (total - i))
done = f"[{offset + i:>6}/{offset + total}]" done = f"[{offset + i:>6}/{offset + total}]"
cid = chunk["chunk_id"][:40] 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: if len(ids) == 100:
collection.add(ids=ids, embeddings=embeddings, collection.add(ids=ids, embeddings=embeddings,
@@ -180,7 +180,7 @@ def _ingest_stem(stem: str, collection: chromadb.Collection,
elapsed = int(time.monotonic() - start) elapsed = int(time.monotonic() - start)
print() print()
print(f" {stem}: {total} chunk in {elapsed}s") print(f" OK {stem}: {total} chunk in {elapsed}s")
return total return total
@@ -200,11 +200,11 @@ def ingest_multi(stems: list[str], collection_name: str,
if collection_exists(client, collection_name): if collection_exists(client, collection_name):
if not force: 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") print(f" → usa --force per sovrascrivere")
return True return True
client.delete_collection(collection_name) client.delete_collection(collection_name)
print(f"🗑️ Collection '{collection_name}' rimossa (--force)") print(f"Collection '{collection_name}' rimossa (--force)")
collection = client.create_collection( collection = client.create_collection(
name=collection_name, name=collection_name,
@@ -218,7 +218,7 @@ def ingest_multi(stems: list[str], collection_name: str,
return False return False
total_chunks += n 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" Documenti: {', '.join(stems)}")
print(f" Percorso: {CHROMA_DIR}/") print(f" Percorso: {CHROMA_DIR}/")
return True return True
@@ -266,10 +266,10 @@ def main() -> int:
# ── Modalità multi-documento ───────────────────────────────────────────── # ── Modalità multi-documento ─────────────────────────────────────────────
if args.stems or args.collection: if args.stems or args.collection:
if not args.stems: 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 return 1
if not args.collection: if not args.collection:
print(" --stems richiede --collection (es. --collection archivio)") print("ERRORE: --stems richiede --collection (es. --collection archivio)")
return 1 return 1
print(f" Collection : {args.collection}") print(f" Collection : {args.collection}")
print(f" Documenti : {', '.join(args.stems)}\n") print(f" Documenti : {', '.join(args.stems)}\n")
@@ -280,7 +280,7 @@ def main() -> int:
# ── Modalità singolo / tutti ───────────────────────────────────────────── # ── Modalità singolo / tutti ─────────────────────────────────────────────
stems = [args.stem] if args.stem else find_stems() stems = [args.stem] if args.stem else find_stems()
if not stems: if not stems:
print(" Nessun chunks.json trovato in chunks/") print("ERRORE: Nessun chunks.json trovato in chunks/")
return 1 return 1
results = [] results = []
+5 -5
View File
@@ -133,7 +133,7 @@ def answer(question: str, collection: chromadb.Collection, verbose: bool) -> Non
try: try:
chunks = retrieve(collection, question) chunks = retrieve(collection, question)
except (urllib.error.URLError, OSError) as e: except (urllib.error.URLError, OSError) as e:
print(f"❌ Errore embedding: {e}") print(f"ERRORE embedding: {e}")
return return
if verbose: if verbose:
@@ -151,7 +151,7 @@ def answer(question: str, collection: chromadb.Collection, verbose: bool) -> Non
try: try:
response = call_ollama(prompt, system=system) response = call_ollama(prompt, system=system)
except (urllib.error.URLError, OSError) as e: except (urllib.error.URLError, OSError) as e:
print(f"❌ Errore generazione: {e}") print(f"ERRORE generazione: {e}")
return return
print(f"\n{response}\n") print(f"\n{response}\n")
@@ -234,13 +234,13 @@ def main() -> int:
print() print()
if not CHROMA_DIR.exists(): if not CHROMA_DIR.exists():
print(" chroma_db/ non trovata — esegui prima ingestion") print("ERRORE: chroma_db/ non trovata — esegui prima ingestion")
return 1 return 1
client = chromadb.PersistentClient(path=str(CHROMA_DIR)) client = chromadb.PersistentClient(path=str(CHROMA_DIR))
collections = [c.name for c in client.list_collections()] collections = [c.name for c in client.list_collections()]
if collection_name not in 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: if args.stem:
print(f" → python ingestion/ingest.py --stem {collection_name}") print(f" → python ingestion/ingest.py --stem {collection_name}")
else: else:
@@ -248,7 +248,7 @@ def main() -> int:
return 1 return 1
collection = client.get_collection(collection_name) 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) run_loop(collection)
return 0 return 0
+4 -4
View File
@@ -134,7 +134,7 @@ def run_loop(collection: chromadb.Collection, top_k: int) -> None:
try: try:
chunks = retrieve(collection, query, top_k) chunks = retrieve(collection, query, top_k)
except (urllib.error.URLError, OSError) as e: except (urllib.error.URLError, OSError) as e:
print(f"❌ Errore embedding (Ollama raggiungibile?): {e}\n") print(f"ERRORE embedding (Ollama raggiungibile?): {e}\n")
continue continue
print() print()
@@ -204,13 +204,13 @@ def main() -> int:
print() print()
if not CHROMA_DIR.exists(): 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 return 1
client = chromadb.PersistentClient(path=str(CHROMA_DIR)) client = chromadb.PersistentClient(path=str(CHROMA_DIR))
collections = [c.name for c in client.list_collections()] collections = [c.name for c in client.list_collections()]
if collection_name not in 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: if args.stem:
print(f" → python ingestion/ingest.py --stem {collection_name}", file=sys.stderr) print(f" → python ingestion/ingest.py --stem {collection_name}", file=sys.stderr)
else: else:
@@ -218,7 +218,7 @@ def main() -> int:
return 1 return 1
collection = client.get_collection(collection_name) 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) run_loop(collection, args.top_k)
return 0 return 0