Роутер работает нормально в process v2
This commit is contained in:
@@ -2,11 +2,12 @@ from __future__ import annotations
|
||||
|
||||
|
||||
class InMemoryDocsRetrievalAdapter:
|
||||
def __init__(self, rows: list[dict]) -> None:
|
||||
def __init__(self, rows: list[dict], materialized_rows: list[dict] | None = None) -> None:
|
||||
self._rows = list(rows)
|
||||
self._materialized_rows = list(materialized_rows or [])
|
||||
self._report: dict = {}
|
||||
|
||||
def retrieve_with_plan(self, rag_session_id: str, query: str, retrieval_spec, retrieval_constraints=None, *, query_plan=None) -> list[dict]:
|
||||
def retrieve_with_plan(self, rag_session_id: str, query: str, retrieval_spec, retrieval_constraints=None, *, query_plan=None, trace=None) -> list[dict]:
|
||||
planned_layers = [str(item.layer_id) for item in retrieval_spec.layer_queries]
|
||||
query_sub_intent = str(getattr(query_plan, "sub_intent", "") or "")
|
||||
relation_rows = [row for row in self._rows if str(row.get("layer") or "") == "D5_RELATION_GRAPH"]
|
||||
@@ -60,6 +61,25 @@ class InMemoryDocsRetrievalAdapter:
|
||||
def retrieve_exact_files(self, rag_session_id: str, *, repo_id=None, paths: list[str], layers=None, limit: int = 200, query: str = "", ranking_profile: str = "") -> list[dict]:
|
||||
return []
|
||||
|
||||
def materialize_document_ids(self, rag_session_id: str, *, document_ids: list[str], layers=None, limit: int = 200) -> list[dict]:
|
||||
allowed_ids = {str(item).strip() for item in document_ids if str(item).strip()}
|
||||
if not allowed_ids:
|
||||
return []
|
||||
allowed_layers = {str(item).strip() for item in list(layers or []) if str(item).strip()}
|
||||
result = []
|
||||
for row in [*self._rows, *self._materialized_rows]:
|
||||
if allowed_layers and str(row.get("layer") or "") not in allowed_layers:
|
||||
continue
|
||||
metadata = dict(row.get("metadata") or {})
|
||||
candidates = {
|
||||
str(metadata.get("document_id") or "").strip(),
|
||||
str(metadata.get("doc_id") or "").strip(),
|
||||
str(metadata.get("subject_id") or "").strip(),
|
||||
}
|
||||
if candidates & allowed_ids:
|
||||
result.append(row)
|
||||
return self._dedupe(result)[: max(1, int(limit))]
|
||||
|
||||
def hydrate_resolved_symbol_sources(self, rag_session_id: str, base_query: str, rag_rows: list[dict], symbol_resolution: dict, retrieval_spec, retrieval_constraints=None) -> list[dict]:
|
||||
return list(rag_rows)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user