Skip to content

AgentReply

autogen.beta.agent.AgentReply #

AgentReply(response, *, context, client, agent)

Bases: Askable

Source code in autogen/beta/agent.py
def __init__(
    self,
    response: ModelResponse,
    *,
    context: "Context",
    client: "LLMClient",
    agent: "Agent",
) -> None:
    self.response = response
    self.context = context
    self.__client = client
    self.__agent = agent

response instance-attribute #

response = response

context instance-attribute #

context = context

content property #

content

Text content of the model's response for this turn.

history property #

history

ask async #

ask(msg, *, dependencies=None, variables=None, prompt=(), config=None, tools=(), middleware=())
Source code in autogen/beta/agent.py
async def ask(
    self,
    msg: str,
    *,
    dependencies: dict[Any, Any] | None = None,
    variables: dict[Any, Any] | None = None,
    prompt: Iterable[str] = (),
    config: ModelConfig | None = None,
    tools: Iterable[Tool] = (),
    middleware: Iterable["MiddlewareFactory"] = (),
) -> "AgentReply":
    initial_event = ModelRequest(content=msg)

    context = self.context
    if dependencies:
        context.dependencies.update(dependencies)
    if variables:
        context.variables.update(variables)
    if prompt:
        context.prompt = list(prompt)

    client = config.create() if config else self.__client

    return await self.__agent._execute(
        initial_event,
        context=context,
        client=client,
        additional_tools=tools,
        additional_middleware=middleware,
    )