autogen_agentchat.task#
- async autogen_agentchat.task.Console(stream: AsyncGenerator[TextMessage | MultiModalMessage | StopMessage | HandoffMessage | ToolCallMessage | ToolCallResultMessage | T, None], *, no_inline_images: bool = False) T [source]#
Consume the stream from
run_stream()
oron_messages_stream()
print the messages to the console and return the last processed TaskResult or Response.- Parameters:
stream (AsyncGenerator[AgentMessage | TaskResult, None] | AsyncGenerator[AgentMessage | Response, None]) – Stream to render
no_inline_images (bool, optional) – If terminal is iTerm2 will render images inline. Use this to disable this behavior. Defaults to False.
- Returns:
last_processed – The last processed TaskResult or Response.
- class autogen_agentchat.task.ExternalTermination[source]#
Bases:
TerminationCondition
A termination condition that is externally controlled by calling the
set()
method.Example:
termination = ExternalTermination() # Run the team in an asyncio task. ... # Set the termination condition externally termination.set()
- class autogen_agentchat.task.HandoffTermination(target: str)[source]#
Bases:
TerminationCondition
Terminate the conversation if a
HandoffMessage
with the given target is received.- Parameters:
target (str) – The target of the handoff message.
- class autogen_agentchat.task.MaxMessageTermination(max_messages: int)[source]#
Bases:
TerminationCondition
Terminate the conversation after a maximum number of messages have been exchanged.
- Parameters:
max_messages – The maximum number of messages allowed in the conversation.
- class autogen_agentchat.task.StopMessageTermination[source]#
Bases:
TerminationCondition
Terminate the conversation if a StopMessage is received.
- class autogen_agentchat.task.TextMentionTermination(text: str)[source]#
Bases:
TerminationCondition
Terminate the conversation if a specific text is mentioned.
- Parameters:
text – The text to look for in the messages.
- class autogen_agentchat.task.TimeoutTermination(timeout_seconds: float)[source]#
Bases:
TerminationCondition
Terminate the conversation after a specified duration has passed.
- Parameters:
timeout_seconds – The maximum duration in seconds before terminating the conversation.
- class autogen_agentchat.task.TokenUsageTermination(max_total_token: int | None = None, max_prompt_token: int | None = None, max_completion_token: int | None = None)[source]#
Bases:
TerminationCondition
Terminate the conversation if a token usage limit is reached.
- Parameters:
max_total_token – The maximum total number of tokens allowed in the conversation.
max_prompt_token – The maximum number of prompt tokens allowed in the conversation.
max_completion_token – The maximum number of completion tokens allowed in the conversation.
- Raises:
ValueError – If none of max_total_token, max_prompt_token, or max_completion_token is provided.