Class GPTAgent
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:
- Message
- IMessage<T> where T is ChatRequestMessage
- AggregateMessage<TMessage1, TMessage2> where TMessage1 is ToolCallMessage and TMessage2 is ToolCallResultMessage
GPTAgent returns the following message types:
- 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
stringsystemMessage
stringconfig
ILLMConfigtemperature
floatmaxTokens
intseed
int?responseFormat
ChatCompletionsResponseFormatfunctions
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
stringsystemMessage
stringopenAIClient
OpenAIClientmodelName
stringtemperature
floatmaxTokens
intseed
int?responseFormat
ChatCompletionsResponseFormatfunctions
IEnumerable<FunctionDefinition>functionMap
IDictionary<string, Func<string, Task<string>>>
Properties
Name
public string Name { get; }
Property Value
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
GenerateReplyOptionscompletion option. If provided, it should override existing option if there's any
cancellationToken
CancellationToken
Returns
GenerateStreamingReplyAsync(IEnumerable<IMessage>, GenerateReplyOptions?, CancellationToken)
public IAsyncEnumerable<IMessage> GenerateStreamingReplyAsync(IEnumerable<IMessage> messages, GenerateReplyOptions? options = null, CancellationToken cancellationToken = default)
Parameters
messages
IEnumerable<IMessage>options
GenerateReplyOptionscancellationToken
CancellationToken