amfs-http-server 0.3.7__tar.gz → 0.3.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/PKG-INFO +1 -1
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/pyproject.toml +1 -1
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/src/amfs_http/server.py +38 -18
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/.gitignore +0 -0
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/src/amfs_http/__init__.py +0 -0
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/src/amfs_http/auth.py +0 -0
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/src/amfs_http/models.py +0 -0
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/src/amfs_http/openrouter_proxy.py +0 -0
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/src/amfs_http/pro_provider.py +0 -0
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/src/amfs_http/pro_proxy.py +0 -0
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/src/amfs_http/sse.py +0 -0
- {amfs_http_server-0.3.7 → amfs_http_server-0.3.8}/src/amfs_http/tenant_middleware.py +0 -0
|
@@ -989,28 +989,48 @@ async def get_stats(
|
|
|
989
989
|
|
|
990
990
|
vis = _get_visibility_filter(request)
|
|
991
991
|
if vis is not None and vis.should_filter():
|
|
992
|
+
# Visibility-scoped stats. This branch must return the SAME shape as
|
|
993
|
+
# MemoryStats (which mem.stats() below produces), because the client
|
|
994
|
+
# parses /stats via MemoryStats.model_validate — any missing field
|
|
995
|
+
# silently defaults (confidence→0.0, outcome→0) and any mis-named key
|
|
996
|
+
# (e.g. "oldest_entry" vs "oldest_entry_at") is dropped to None. The
|
|
997
|
+
# earlier partial dict caused exactly that: correct counts but zeroed
|
|
998
|
+
# confidence/outcome and null timestamps.
|
|
999
|
+
from amfs_core.models import MemoryStats
|
|
1000
|
+
|
|
992
1001
|
entries = mem.list()
|
|
993
1002
|
entries = vis.filter_entries(entries)
|
|
994
1003
|
|
|
995
|
-
|
|
996
|
-
|
|
1004
|
+
agents: dict[str, int] = {}
|
|
1005
|
+
entities: dict[str, int] = {}
|
|
1006
|
+
confidences: list[float] = []
|
|
1007
|
+
written_ats: list[Any] = []
|
|
1008
|
+
outcome_linked = 0
|
|
997
1009
|
for e in entries:
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
"
|
|
1003
|
-
|
|
1004
|
-
"
|
|
1005
|
-
|
|
1006
|
-
(
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1010
|
+
entities[e.entity_path] = entities.get(e.entity_path, 0) + 1
|
|
1011
|
+
aid = e.provenance.agent_id
|
|
1012
|
+
agents[aid] = agents.get(aid, 0) + 1
|
|
1013
|
+
confidences.append(float(e.confidence))
|
|
1014
|
+
if getattr(e, "outcome_count", 0):
|
|
1015
|
+
outcome_linked += 1
|
|
1016
|
+
wa = getattr(e.provenance, "written_at", None)
|
|
1017
|
+
if wa is not None:
|
|
1018
|
+
written_ats.append(wa)
|
|
1019
|
+
|
|
1020
|
+
scoped = MemoryStats(
|
|
1021
|
+
total_entries=len(entries),
|
|
1022
|
+
total_entities=len(entities),
|
|
1023
|
+
total_agents=len(agents),
|
|
1024
|
+
agents=agents,
|
|
1025
|
+
entities=entities,
|
|
1026
|
+
confidence_avg=(sum(confidences) / len(confidences)) if confidences else 0.0,
|
|
1027
|
+
confidence_min=min(confidences) if confidences else 0.0,
|
|
1028
|
+
confidence_max=max(confidences) if confidences else 0.0,
|
|
1029
|
+
outcome_linked_count=outcome_linked,
|
|
1030
|
+
oldest_entry_at=min(written_ats) if written_ats else None,
|
|
1031
|
+
newest_entry_at=max(written_ats) if written_ats else None,
|
|
1032
|
+
)
|
|
1033
|
+
return json.loads(json.dumps(scoped.model_dump(mode="json"), default=str))
|
|
1014
1034
|
|
|
1015
1035
|
stats = mem.stats()
|
|
1016
1036
|
return json.loads(json.dumps(stats.model_dump(mode="json"), default=str))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|