Table of Contents

Class AgentExtension

Namespace
AutoGen.Core
Assembly
AutoGen.Core.dll
public static class AgentExtension
Inheritance
AgentExtension
Inherited Members

Methods

InitiateChatAsync(IAgent, IAgent, string?, int, CancellationToken)

Shortcut API to send message to another agent and get all responses. To iterate over the responses, use SendAsync(IAgent, IAgent, string, IEnumerable<IMessage>?, int, CancellationToken) or SendAsync(IAgent, IAgent, IEnumerable<IMessage>, int, CancellationToken)

public static Task<IEnumerable<IMessage>> InitiateChatAsync(this IAgent agent, IAgent receiver, string? message = null, int maxRound = 10, CancellationToken ct = default)

Parameters

agent IAgent

sender agent

receiver IAgent

receiver agent

message string

message to send

maxRound int

max round

ct CancellationToken

Returns

Task<IEnumerable<IMessage>>

SendAsync(IAgent, IAgent, IEnumerable<IMessage>, int, CancellationToken)

Send message to another agent and iterate over the responses.

public static IAsyncEnumerable<IMessage> SendAsync(this IAgent agent, IAgent receiver, IEnumerable<IMessage> chatHistory, int maxRound = 10, CancellationToken ct = default)

Parameters

agent IAgent

sender agent.

receiver IAgent

receiver agent.

chatHistory IEnumerable<IMessage>

chat history.

maxRound int

max conversation round.

ct CancellationToken

Returns

IAsyncEnumerable<IMessage>

conversation history

SendAsync(IAgent, IAgent, string, IEnumerable<IMessage>?, int, CancellationToken)

Send message to another agent and iterate over the responses.

public static IAsyncEnumerable<IMessage> SendAsync(this IAgent agent, IAgent receiver, string message, IEnumerable<IMessage>? chatHistory = null, int maxRound = 10, CancellationToken ct = default)

Parameters

agent IAgent

sender agent.

receiver IAgent

receiver agent.

message string

message to send. will be added to the end of chatHistory if provided

chatHistory IEnumerable<IMessage>

chat history.

maxRound int

max conversation round.

ct CancellationToken

Returns

IAsyncEnumerable<IMessage>

conversation history

SendAsync(IAgent, IMessage?, IEnumerable<IMessage>?, CancellationToken)

Send message to an agent.

public static Task<IMessage> SendAsync(this IAgent agent, IMessage? message = null, IEnumerable<IMessage>? chatHistory = null, CancellationToken ct = default)

Parameters

agent IAgent

sender agent.

message IMessage

message to send. will be added to the end of chatHistory if provided

chatHistory IEnumerable<IMessage>

chat history.

ct CancellationToken

Returns

Task<IMessage>

conversation history

SendAsync(IAgent, string, IEnumerable<IMessage>?, CancellationToken)

Send message to an agent.

public static Task<IMessage> SendAsync(this IAgent agent, string message, IEnumerable<IMessage>? chatHistory = null, CancellationToken ct = default)

Parameters

agent IAgent

sender agent.

message string

message to send. will be added to the end of chatHistory if provided

chatHistory IEnumerable<IMessage>

chat history.

ct CancellationToken

Returns

Task<IMessage>

conversation history

SendMessageToGroupAsync(IAgent, IGroupChat, IEnumerable<IMessage>?, int, CancellationToken)

[Obsolete("use GroupChatExtension.SendAsync")]
public static IAsyncEnumerable<IMessage> SendMessageToGroupAsync(this IAgent _, IGroupChat groupChat, IEnumerable<IMessage>? chatHistory = null, int maxRound = 10, CancellationToken ct = default)

Parameters

_ IAgent
groupChat IGroupChat
chatHistory IEnumerable<IMessage>
maxRound int
ct CancellationToken

Returns

IAsyncEnumerable<IMessage>

SendMessageToGroupAsync(IAgent, IGroupChat, string, IEnumerable<IMessage>?, int, CancellationToken)

[Obsolete("use GroupChatExtension.SendAsync")]
public static IAsyncEnumerable<IMessage> SendMessageToGroupAsync(this IAgent agent, IGroupChat groupChat, string msg, IEnumerable<IMessage>? chatHistory = null, int maxRound = 10, CancellationToken ct = default)

Parameters

agent IAgent
groupChat IGroupChat
msg string
chatHistory IEnumerable<IMessage>
maxRound int
ct CancellationToken

Returns

IAsyncEnumerable<IMessage>