Source code for reli.runtime

"""Complete ReLI system from a configuration."""

from __future__ import annotations

from collections.abc import Callable
from dataclasses import dataclass

from .agent import ReLIAgent
from .camera import Camera
from .config import ReLIConfig
from .llm import LLMProvider, build_provider
from .perception import Grounder, build_grounder
from .robot import Robot, build_robot
from .types import Event


[docs] @dataclass class System: agent: ReLIAgent robot: Robot camera: Camera | None grounder: Grounder | None connection: object | None def close(self) -> None: self.agent.close() if self.camera is not None: self.camera.close() if self.connection is not None: self.connection.close() # type: ignore[attr-defined]
[docs] def build_system( cfg: ReLIConfig, on_event: Callable[[Event], None] = lambda e: None, provider: LLMProvider | None = None, ) -> System: bundle = build_robot(cfg) grounder = build_grounder(cfg, bundle.robot.pose, bundle.camera) agent = ReLIAgent(cfg, bundle.robot, provider or build_provider(cfg.llm), grounder, on_event) return System(agent, bundle.robot, bundle.camera, grounder, bundle.connection)