Spaces:
Running
Running
Commit ·
d0cb2c0
1
Parent(s): 6a0d2fb
feat(phase-32): add AliasGraph import and singleton to api/main.py
Browse filesAdded imports for AliasGraph and EntityResolverV2 after api.models import.
Added module-level singletons _alias_graph = AliasGraph() and
_resolver_v2 = EntityResolverV2(threshold=0.82) so they are created once
and reused across all requests rather than per-request instantiation.
- api/main.py +6 -0
api/main.py
CHANGED
|
@@ -13,6 +13,8 @@ from loguru import logger
|
|
| 13 |
from api.dependencies import get_driver, close_driver
|
| 14 |
from api.routes import search, profile, graph, risk, multilingual, export, admin, investigation, affidavit, biography, benami, sources, procurement, conflict, linguistic, policy, adversarial, debate, runtime, resolve
|
| 15 |
from api.models import HealthResponse, StatsResponse
|
|
|
|
|
|
|
| 16 |
from config.runtime_profile import PROFILE as _RUNTIME_PROFILE
|
| 17 |
|
| 18 |
|
|
@@ -134,6 +136,10 @@ _STATS_TTL = 60.0
|
|
| 134 |
import threading as _threading # B-01 FIX: was missing entirely
|
| 135 |
_stats_lock = _threading.Lock() # B-01 FIX: NameError on every GET /stats
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
@app.get("/stats", response_model=StatsResponse)
|
| 139 |
def get_stats():
|
|
|
|
| 13 |
from api.dependencies import get_driver, close_driver
|
| 14 |
from api.routes import search, profile, graph, risk, multilingual, export, admin, investigation, affidavit, biography, benami, sources, procurement, conflict, linguistic, policy, adversarial, debate, runtime, resolve
|
| 15 |
from api.models import HealthResponse, StatsResponse
|
| 16 |
+
from processing.alias_graph import AliasGraph # Phase 32
|
| 17 |
+
from processing.entity_resolver_v2 import EntityResolverV2 # Phase 32
|
| 18 |
from config.runtime_profile import PROFILE as _RUNTIME_PROFILE
|
| 19 |
|
| 20 |
|
|
|
|
| 136 |
import threading as _threading # B-01 FIX: was missing entirely
|
| 137 |
_stats_lock = _threading.Lock() # B-01 FIX: NameError on every GET /stats
|
| 138 |
|
| 139 |
+
# Phase 32: shared AliasGraph instance (loaded once at startup)
|
| 140 |
+
_alias_graph = AliasGraph()
|
| 141 |
+
_resolver_v2 = EntityResolverV2(threshold=0.82)
|
| 142 |
+
|
| 143 |
|
| 144 |
@app.get("/stats", response_model=StatsResponse)
|
| 145 |
def get_stats():
|