Skip to content

LiveT3Backend

🛈 DocStrings

Adapter around :class:pyt3client.native.T3NativeClient.

Source code in src/acptui/t3/state.py
class LiveT3Backend:
    """Adapter around :class:`pyt3client.native.T3NativeClient`."""

    def __init__(self, client: T3NativeClient) -> None:
        self._client = client

    def subscribe_shell(
        self, *, after_sequence: int | None = None
    ) -> AsyncIterator[ShellStreamItem]:
        """Stream workspace projects and threads."""
        return self._client.subscribe_shell(after_sequence=after_sequence)

    def subscribe_thread(
        self, thread_id: str, *, after_sequence: int | None = None
    ) -> AsyncIterator[ThreadStreamItem]:
        """Stream a single thread's snapshot and live events."""
        return self._client.subscribe_thread(thread_id, after_sequence=after_sequence)

    async def send_message(
        self,
        thread_id: str,
        text: str,
        *,
        model_selection: Mapping[str, JsonValue] | None = None,
    ) -> int:
        """Send a user message to `thread_id`."""
        return await self._client.send_message(thread_id, text, model_selection=model_selection)

    async def stop_thread(self, thread_id: str) -> int:
        """Stop the active run on `thread_id`."""
        return await self._client.stop_thread(thread_id)

    async def visit_thread(self, thread_id: str) -> int:
        """Mark `thread_id` as visited."""
        return await self._client.visit_thread(thread_id)

    async def respond_to_request(
        self,
        thread_id: str,
        request_id: str,
        *,
        decision: ApprovalDecision | None = None,
        answers: Mapping[str, JsonValue] | None = None,
    ) -> int:
        """Respond to a pending approval or user-input request."""
        return await self._client.respond_to_request(
            thread_id, request_id, decision=decision, answers=answers
        )

    async def create_thread(
        self,
        project_id: str,
        title: str,
        *,
        model_selection: Mapping[str, JsonValue],
    ) -> tuple[str, int]:
        """Create a new thread in `project_id`."""
        return await self._client.create_thread(project_id, title, model_selection=model_selection)

create_thread async

create_thread(
    project_id: str, title: str, *, model_selection: Mapping[str, JsonValue]
) -> tuple[str, int]

Create a new thread in project_id.

Source code in src/acptui/t3/state.py
async def create_thread(
    self,
    project_id: str,
    title: str,
    *,
    model_selection: Mapping[str, JsonValue],
) -> tuple[str, int]:
    """Create a new thread in `project_id`."""
    return await self._client.create_thread(project_id, title, model_selection=model_selection)

respond_to_request async

respond_to_request(
    thread_id: str,
    request_id: str,
    *,
    decision: ApprovalDecision | None = None,
    answers: Mapping[str, JsonValue] | None = None,
) -> int

Respond to a pending approval or user-input request.

Source code in src/acptui/t3/state.py
async def respond_to_request(
    self,
    thread_id: str,
    request_id: str,
    *,
    decision: ApprovalDecision | None = None,
    answers: Mapping[str, JsonValue] | None = None,
) -> int:
    """Respond to a pending approval or user-input request."""
    return await self._client.respond_to_request(
        thread_id, request_id, decision=decision, answers=answers
    )

send_message async

send_message(
    thread_id: str, text: str, *, model_selection: Mapping[str, JsonValue] | None = None
) -> int

Send a user message to thread_id.

Source code in src/acptui/t3/state.py
async def send_message(
    self,
    thread_id: str,
    text: str,
    *,
    model_selection: Mapping[str, JsonValue] | None = None,
) -> int:
    """Send a user message to `thread_id`."""
    return await self._client.send_message(thread_id, text, model_selection=model_selection)

stop_thread async

stop_thread(thread_id: str) -> int

Stop the active run on thread_id.

Source code in src/acptui/t3/state.py
async def stop_thread(self, thread_id: str) -> int:
    """Stop the active run on `thread_id`."""
    return await self._client.stop_thread(thread_id)

subscribe_shell

subscribe_shell(*, after_sequence: int | None = None) -> AsyncIterator[ShellStreamItem]

Stream workspace projects and threads.

Source code in src/acptui/t3/state.py
def subscribe_shell(
    self, *, after_sequence: int | None = None
) -> AsyncIterator[ShellStreamItem]:
    """Stream workspace projects and threads."""
    return self._client.subscribe_shell(after_sequence=after_sequence)

subscribe_thread

subscribe_thread(
    thread_id: str, *, after_sequence: int | None = None
) -> AsyncIterator[ThreadStreamItem]

Stream a single thread's snapshot and live events.

Source code in src/acptui/t3/state.py
def subscribe_thread(
    self, thread_id: str, *, after_sequence: int | None = None
) -> AsyncIterator[ThreadStreamItem]:
    """Stream a single thread's snapshot and live events."""
    return self._client.subscribe_thread(thread_id, after_sequence=after_sequence)

visit_thread async

visit_thread(thread_id: str) -> int

Mark thread_id as visited.

Source code in src/acptui/t3/state.py
async def visit_thread(self, thread_id: str) -> int:
    """Mark `thread_id` as visited."""
    return await self._client.visit_thread(thread_id)

:fa-brands-github: Show source on GitHub