Table of Contents

Class GPTAgent

Namespace
AutoGen.OpenAI.V1
Assembly
AutoGen.OpenAI.V1.dll

GPT agent that can be used to connect to OpenAI chat models like GPT-3.5, GPT-4, etc.

GPTAgent supports the following message types as input:

- TextMessage

- ImageMessage

- MultiModalMessage

- ToolCallMessage

- ToolCallResultMessage

- Message

- IMessage<T> where T is ChatRequestMessage

- AggregateMessage<TMessage1, TMessage2> where TMessage1 is ToolCallMessage and TMessage2 is ToolCallResultMessage

GPTAgent returns the following message types:

- TextMessage

- ToolCallMessage

- AggregateMessage<TMessage1, TMessage2> where TMessage1 is ToolCallMessage and TMessage2 is ToolCallResultMessage

[Obsolete("Use OpenAIChatAgent instead")]
public class GPTAgent : IStreamingAgent, IAgent, IAgentMetaInformation
Inheritance
GPTAgent
Implements
Inherited Members
Extension Methods

Constructors

GPTAgent(string, string, ILLMConfig, float, int, int?, ChatCompletionsResponseFormat?, IEnumerable<FunctionDefinition>?, IDictionary<string, Func<string, Task<string>>>?)

public GPTAgent(string name, string systemMessage, ILLMConfig config, float temperature = 0.7, int maxTokens = 1024, int? seed = null, ChatCompletionsResponseFormat? responseFormat = null, IEnumerable<FunctionDefinition>? functions = null, IDictionary<string, Func<string, Task<string>>>? functionMap = null)

Parameters

name string
systemMessage string
config ILLMConfig
temperature float
maxTokens int
seed int?
responseFormat ChatCompletionsResponseFormat
functions IEnumerable<FunctionDefinition>
functionMap IDictionary<string, Func<string, Task<string>>>

GPTAgent(string, string, OpenAIClient, string, float, int, int?, ChatCompletionsResponseFormat?, IEnumerable<FunctionDefinition>?, IDictionary<string, Func<string, Task<string>>>?)

public GPTAgent(string name, string systemMessage, OpenAIClient openAIClient, string modelName, float temperature = 0.7, int maxTokens = 1024, int? seed = null, ChatCompletionsResponseFormat? responseFormat = null, IEnumerable<FunctionDefinition>? functions = null, IDictionary<string, Func<string, Task<string>>>? functionMap = null)

Parameters

name string
systemMessage string
openAIClient OpenAIClient
modelName string
temperature float
maxTokens int
seed int?
responseFormat ChatCompletionsResponseFormat
functions IEnumerable<FunctionDefinition>
functionMap IDictionary<string, Func<string, Task<string>>>

Properties

Name

public string Name { get; }

Property Value

string

Methods

GenerateReplyAsync(IEnumerable<IMessage>, GenerateReplyOptions?, CancellationToken)

Generate reply

public Task<IMessage> GenerateReplyAsync(IEnumerable<IMessage> messages, GenerateReplyOptions? options = null, CancellationToken cancellationToken = default)

Parameters

messages IEnumerable<IMessage>

conversation history

options GenerateReplyOptions

completion option. If provided, it should override existing option if there's any

cancellationToken CancellationToken

Returns

Task<IMessage>

GenerateStreamingReplyAsync(IEnumerable<IMessage>, GenerateReplyOptions?, CancellationToken)

public IAsyncEnumerable<IMessage> GenerateStreamingReplyAsync(IEnumerable<IMessage> messages, GenerateReplyOptions? options = null, CancellationToken cancellationToken = default)

Parameters

messages IEnumerable<IMessage>
options GenerateReplyOptions
cancellationToken CancellationToken

Returns

IAsyncEnumerable<IMessage>