Agent.respond()

Send a message and get a response from this agent.

Usage

Source

Agent.respond(
    message,
    *,
    conversation=None,
)

Uses the agent’s configured ChatBot to generate a response. If no conversation is provided, continues the agent’s internal conversation (or starts a new one).

The agent records prompts and responses in its capture and applies its retention policy (if the persona defines one) after each response.

Parameters

message: str

The user message to respond to.

conversation: Conversation | None = None
An existing conversation to continue. If None, uses the agent’s internal conversation state.

Returns

Conversation
The updated conversation with the response appended.

Examples

import talk_box as tb

agent = tb.Agent.from_persona("python_mentor")
convo = agent.respond("What are list comprehensions?")
convo = agent.respond("Show me an example", conversation=convo)