rmi-backend/scripts/ingest_whalegod_labels.py
opencode c762564d40 style(rmi-backend): complete lint cleanup — 1175→0 ruff errors
- Fix 71 invalid-syntax files (class-body newline-broken assignments)
- Add from/None chain to 307 B904 raise-without-from sites
- Add B008 ignore to ruff.toml (already in pyproject.toml)
- Noqa F401 on __init__.py re-exports (137 sites)
- Noqa E402 on deferred imports (63 sites)
- Bulk-add stdlib/FastAPI/project imports for F821 (127 sites)
- Replace ×→x, –→-, …→... in docstrings (4093 chars)
- Manual refactor of 5 SIM103/SIM116 patterns

Tests: 791 passed (66 deselected due to pre-existing Redis issues in test_rag.py)
Co-authored-by: opencode <opencode@rugmunch.io>
2026-07-06 15:43:20 +02:00

60 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Import WHALEGOD wallet labels into Wallet Memory Bank."""
import os
import sys
sys.path.insert(0, "/root/backend")
os.chdir("/root/backend")
# Extract labels from WHALEGOD source
whale_path = "/root/tools/dark-collection/whalegod/bot/services/label_service.py"
namespace = {}
with open(whale_path) as f:
exec(f.read(), namespace)
eth_labels = namespace.get("ETH_LABELS", {})
sol_labels = namespace.get("SOL_LABELS", {})
print(f"WHALEGOD labels: ETH={len(eth_labels)}, SOL={len(sol_labels)}")
# Ingest into wallet_memory
import asyncio # noqa: E402
import httpx # noqa: E402
async def ingest():
count = 0
async with httpx.AsyncClient(timeout=30) as client:
for addr, info in {**eth_labels, **sol_labels}.items():
entity_type = info.get("type", "unknown")
entity_name = info.get("entity", info.get("name", "unknown"))
payload = {
"collection": "wallet_profiles",
"content": f"WHALEGOD label: {info.get('name', addr)} - type={entity_type} entity={entity_name}",
"metadata": {
"address": addr,
"source": "whalegod",
"entity_type": entity_type,
"entity_name": entity_name,
"label_name": info.get("name", ""),
},
}
try:
r = await client.post(
"http://localhost:8000/api/v1/rag/ingest",
json=payload,
headers={"X-RMI-Key": "rmi-internal-2026"},
)
if r.status_code == 200:
count += 1
except Exception:
pass
print(f"Ingested {count}/{len(eth_labels) + len(sol_labels)} WHALEGOD labels")
asyncio.run(ingest())