Spaces:
Sleeping
Sleeping
File size: 1,032 Bytes
9e95393 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | from __future__ import annotations
from pathlib import Path
from .kb_search import LocalHybridKnowledgeStore
from .schemas import GroundedFact, NeedTask
class EmptyLiveStateProvider:
async def current_facts(self, tasks: list[NeedTask]) -> list[GroundedFact]:
return []
class HybridLiveStateProvider:
"""NeedTask-scoped Current/Live fact retrieval using the same local hybrid index contract."""
def __init__(self, store: LocalHybridKnowledgeStore):
self.store = store
@classmethod
def from_jsonl(
cls,
path: str | Path,
*,
generation_id: str,
) -> "HybridLiveStateProvider":
return cls(
LocalHybridKnowledgeStore.from_jsonl(
path,
generation_id=generation_id,
)
)
async def current_facts(self, tasks: list[NeedTask]) -> list[GroundedFact]:
facts = await self.store.find_for_tasks(tasks)
return [fact for fact in facts if fact.authority in {"current", "live"}]
|