MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / init_signals

Function init_signals

uncommon_route/api_v2.py:20–53  ·  view source on GitHub ↗

Initialize signal singletons. Call once at proxy startup. If index_dir is not provided, auto-discovers the seed index from the standard user data directory (~/.uncommon-route/v2_splits/).

(index_dir=None)

Source from the content-addressed store, hash-verified

18
19
20def init_signals(index_dir=None):
21 """Initialize signal singletons. Call once at proxy startup.
22
23 If index_dir is not provided, auto-discovers the seed index
24 from the standard user data directory (~/.uncommon-route/v2_splits/).
25 """
26 global _sig_a, _sig_b, _sig_c
27 _sig_a = MetadataSignal()
28 _sig_b = StructuralSignal()
29
30 # Auto-discover seed index if not explicitly provided
31 if not index_dir:
32 try:
33 from uncommon_route.v2_assets import ensure_v2_assets_deployed
34 from uncommon_route.paths import data_dir
35 ensure_v2_assets_deployed()
36 candidate = data_dir() / "v2_splits"
37 if (candidate / "seed_embeddings.npy").exists():
38 index_dir = str(candidate)
39 except Exception:
40 pass
41
42 if index_dir:
43 from pathlib import Path
44 d = Path(index_dir)
45 # Unified hybrid: classifier when confident, KNN fallback when uncertain.
46 # Same behavior as production path — no more prod/preview split.
47 _sig_c = EmbeddingSignal(
48 index_path=d / "seed_embeddings.npy",
49 labels_path=d / "seed_labels.json",
50 model_name="BAAI/bge-small-en-v1.5",
51 )
52 else:
53 _sig_c = EmbeddingSignal(model_name=None)
54
55
56def route_preview(

Callers 1

route_previewFunction · 0.85

Calls 5

MetadataSignalClass · 0.90
StructuralSignalClass · 0.90
data_dirFunction · 0.90
EmbeddingSignalClass · 0.90

Tested by

no test coverage detected