from __future__ import annotations

from rlm_core.protocols.subcall_client import SubcallClient

from .llm_orchestrator import LlmOrchestrator


class RclSubcallClient(SubcallClient):
    """Subcall client backed by the LlmOrchestrator."""

    def __init__(self, orchestrator: LlmOrchestrator) -> None:
        self._orchestrator = orchestrator

    def llm_query(self, prompt: str, context: str = "") -> str:
        return self._orchestrator.llm_query(prompt, context)

    def llm_batch(
        self,
        prompts: list[str],
        contexts: list[str] | None = None,
        *,
        max_concurrent: int | None = None,
        fail_fast: bool | None = None,
        timeout_ms: int | None = None,
    ) -> list[str]:
        return self._orchestrator.batch_llm_query(
            prompts,
            contexts,
            max_concurrent=max_concurrent,
            fail_fast=fail_fast,
            timeout_ms=timeout_ms,
        )

    def llm_batch_with_errors(
        self,
        prompts: list[str],
        contexts: list[str] | None = None,
    ) -> tuple[list[str], list[dict[str, object]]]:
        return self._orchestrator.llm_batch_with_errors(prompts, contexts)

    @property
    def chunk_data(self):
        return self._orchestrator.chunk_data
