ltcai 7.3.0 → 7.5.0
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.
- package/README.md +34 -30
- package/docs/CHANGELOG.md +50 -0
- package/docs/ROADMAP_RECOMMENDATIONS.md +31 -5
- package/lattice_brain/__init__.py +1 -1
- package/lattice_brain/quality.py +31 -4
- package/lattice_brain/retrieval_benchmark_fixtures.py +92 -0
- package/lattice_brain/runtime/agent_runtime.py +20 -4
- package/lattice_brain/runtime/contracts.py +293 -4
- package/lattice_brain/runtime/multi_agent.py +5 -2
- package/lattice_brain/workflow.py +11 -1
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/agents.py +3 -3
- package/latticeai/api/realtime.py +3 -1
- package/latticeai/core/audit.py +15 -1
- package/latticeai/core/marketplace.py +1 -1
- package/latticeai/core/realtime.py +3 -0
- package/latticeai/core/workspace_os.py +34 -1
- package/package.json +6 -3
- package/scripts/brain_quality_eval.py +55 -3
- package/src-tauri/Cargo.lock +626 -1089
- package/src-tauri/Cargo.toml +3 -6
- package/src-tauri/src/main.rs +1 -1
- package/src-tauri/tauri.conf.json +1 -1
- package/static/app/asset-manifest.json +1 -1
- package/static/app/assets/core-CwxXejkd.js.map +1 -1
|
@@ -12,8 +12,15 @@ import sys
|
|
|
12
12
|
import tempfile
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
16
|
+
if str(REPO_ROOT) not in sys.path:
|
|
17
|
+
sys.path.insert(0, str(REPO_ROOT))
|
|
18
|
+
|
|
19
|
+
from knowledge_graph import KnowledgeGraphStore # noqa: E402
|
|
20
|
+
from lattice_brain.quality import RetrievalBenchmarkRunner # noqa: E402
|
|
21
|
+
from latticeai.services.search_service import SearchService # noqa: E402
|
|
22
|
+
from latticeai.services.memory_service import MemoryService # noqa: E402
|
|
23
|
+
from lattice_brain.retrieval_benchmark_fixtures import DOCUMENTS, FIXTURE_NAME, QUERIES, TOP_K # noqa: E402
|
|
17
24
|
|
|
18
25
|
|
|
19
26
|
class _EvalStore:
|
|
@@ -81,6 +88,37 @@ def _fail(message: str) -> int:
|
|
|
81
88
|
return 1
|
|
82
89
|
|
|
83
90
|
|
|
91
|
+
def _corpus_scale_retrieval_metrics(tmp_path: Path) -> dict:
|
|
92
|
+
graph = KnowledgeGraphStore(tmp_path / "kg.sqlite", tmp_path / "blobs")
|
|
93
|
+
id_map = {}
|
|
94
|
+
for doc in DOCUMENTS:
|
|
95
|
+
result = graph.ingest_event(
|
|
96
|
+
doc["type"],
|
|
97
|
+
f"{doc['title']} {doc['content']}",
|
|
98
|
+
source="retrieval-benchmark-v740",
|
|
99
|
+
conversation_id="retrieval-benchmark-v740",
|
|
100
|
+
metadata={
|
|
101
|
+
"fixture_id": doc["id"],
|
|
102
|
+
"title": doc["title"],
|
|
103
|
+
"content": doc["content"],
|
|
104
|
+
"workspace_id": "personal",
|
|
105
|
+
},
|
|
106
|
+
)
|
|
107
|
+
id_map[doc["id"]] = result["node_id"]
|
|
108
|
+
service = SearchService(graph)
|
|
109
|
+
judged = []
|
|
110
|
+
for query in QUERIES:
|
|
111
|
+
payload = service.hybrid_search(query["query"], limit=TOP_K, keyword_limit=TOP_K, vector_limit=TOP_K, graph_limit=TOP_K)
|
|
112
|
+
retrieved = [item.get("node_id") or item.get("id") for item in payload.get("matches", [])]
|
|
113
|
+
judged.append({
|
|
114
|
+
"query": query["query"],
|
|
115
|
+
"relevant": [id_map[item] for item in query["relevant"]],
|
|
116
|
+
"must_include": [id_map[item] for item in query.get("must_include", [])],
|
|
117
|
+
"retrieved": retrieved,
|
|
118
|
+
})
|
|
119
|
+
return RetrievalBenchmarkRunner().run_fixture(FIXTURE_NAME, judged, top_k=TOP_K)
|
|
120
|
+
|
|
121
|
+
|
|
84
122
|
def main() -> int:
|
|
85
123
|
with tempfile.TemporaryDirectory() as tmp:
|
|
86
124
|
service = MemoryService(
|
|
@@ -133,7 +171,21 @@ def main() -> int:
|
|
|
133
171
|
if retrieval_metrics.get("precision@5", 0.0) < 0.4:
|
|
134
172
|
return _fail(f"hybrid precision regression below threshold: {retrieval_metrics}")
|
|
135
173
|
|
|
136
|
-
|
|
174
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
175
|
+
corpus_metrics = _corpus_scale_retrieval_metrics(Path(tmp))
|
|
176
|
+
recall_key = f"recall@{TOP_K}"
|
|
177
|
+
precision_key = f"precision@{TOP_K}"
|
|
178
|
+
ndcg_key = f"ndcg@{TOP_K}"
|
|
179
|
+
if corpus_metrics.get(recall_key, 0.0) < 0.80:
|
|
180
|
+
return _fail(f"corpus hybrid recall below threshold: {corpus_metrics}")
|
|
181
|
+
if corpus_metrics.get(precision_key, 0.0) < 0.25:
|
|
182
|
+
return _fail(f"corpus hybrid precision below threshold: {corpus_metrics}")
|
|
183
|
+
if corpus_metrics.get(ndcg_key, 0.0) < 0.70:
|
|
184
|
+
return _fail(f"corpus hybrid ndcg below threshold: {corpus_metrics}")
|
|
185
|
+
if corpus_metrics.get("must_include_hit_rate", 0.0) < 0.90:
|
|
186
|
+
return _fail(f"corpus must-include hit rate below threshold: {corpus_metrics}")
|
|
187
|
+
|
|
188
|
+
print(f"brain-quality-eval: OK small={retrieval_metrics} corpus={corpus_metrics}")
|
|
137
189
|
return 0
|
|
138
190
|
|
|
139
191
|
|