OpenAIChatClientExtensions.AsAIAgent Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| AsAIAgent(ChatClient, ChatClientAgentOptions, Func<IChatClient,IChatClient>, ILoggerFactory, IServiceProvider) |
Creates an AI agent from an OpenAI.Chat.ChatClient using the OpenAI Chat Completion API. |
| AsAIAgent(ChatClient, String, String, String, IList<AITool>, Func<IChatClient,IChatClient>, ILoggerFactory, IServiceProvider) |
Creates an AI agent from an OpenAI.Chat.ChatClient using the OpenAI Chat Completion API. |
AsAIAgent(ChatClient, ChatClientAgentOptions, Func<IChatClient,IChatClient>, ILoggerFactory, IServiceProvider)
Creates an AI agent from an OpenAI.Chat.ChatClient using the OpenAI Chat Completion API.
public static Microsoft.Agents.AI.ChatClientAgent AsAIAgent(this OpenAI.Chat.ChatClient client, Microsoft.Agents.AI.ChatClientAgentOptions options, Func<Microsoft.Extensions.AI.IChatClient,Microsoft.Extensions.AI.IChatClient>? clientFactory = default, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory = default, IServiceProvider? services = default);
static member AsAIAgent : OpenAI.Chat.ChatClient * Microsoft.Agents.AI.ChatClientAgentOptions * Func<Microsoft.Extensions.AI.IChatClient, Microsoft.Extensions.AI.IChatClient> * Microsoft.Extensions.Logging.ILoggerFactory * IServiceProvider -> Microsoft.Agents.AI.ChatClientAgent
<Extension()>
Public Function AsAIAgent (client As ChatClient, options As ChatClientAgentOptions, Optional clientFactory As Func(Of IChatClient, IChatClient) = Nothing, Optional loggerFactory As ILoggerFactory = Nothing, Optional services As IServiceProvider = Nothing) As ChatClientAgent
Parameters
- client
- OpenAI.Chat.ChatClient
The OpenAI OpenAI.Chat.ChatClient to use for the agent.
- options
- ChatClientAgentOptions
Full set of options to configure the agent.
- clientFactory
- Func<IChatClient,IChatClient>
Provides a way to customize the creation of the underlying IChatClient used by the agent.
- loggerFactory
- ILoggerFactory
Optional logger factory for enabling logging within the agent.
- services
- IServiceProvider
An optional IServiceProvider to use for resolving services required by the AIFunction instances being invoked.
Returns
An ChatClientAgent instance backed by the OpenAI Chat Completion service.
Exceptions
Thrown when client or options is null.
Applies to
AsAIAgent(ChatClient, String, String, String, IList<AITool>, Func<IChatClient,IChatClient>, ILoggerFactory, IServiceProvider)
Creates an AI agent from an OpenAI.Chat.ChatClient using the OpenAI Chat Completion API.
public static Microsoft.Agents.AI.ChatClientAgent AsAIAgent(this OpenAI.Chat.ChatClient client, string? instructions = default, string? name = default, string? description = default, System.Collections.Generic.IList<Microsoft.Extensions.AI.AITool>? tools = default, Func<Microsoft.Extensions.AI.IChatClient,Microsoft.Extensions.AI.IChatClient>? clientFactory = default, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory = default, IServiceProvider? services = default);
static member AsAIAgent : OpenAI.Chat.ChatClient * string * string * string * System.Collections.Generic.IList<Microsoft.Extensions.AI.AITool> * Func<Microsoft.Extensions.AI.IChatClient, Microsoft.Extensions.AI.IChatClient> * Microsoft.Extensions.Logging.ILoggerFactory * IServiceProvider -> Microsoft.Agents.AI.ChatClientAgent
<Extension()>
Public Function AsAIAgent (client As ChatClient, Optional instructions As String = Nothing, Optional name As String = Nothing, Optional description As String = Nothing, Optional tools As IList(Of AITool) = Nothing, Optional clientFactory As Func(Of IChatClient, IChatClient) = Nothing, Optional loggerFactory As ILoggerFactory = Nothing, Optional services As IServiceProvider = Nothing) As ChatClientAgent
Parameters
- client
- OpenAI.Chat.ChatClient
The OpenAI OpenAI.Chat.ChatClient to use for the agent.
- instructions
- String
Optional system instructions that define the agent's behavior and personality.
- name
- String
Optional name for the agent for identification purposes.
- description
- String
Optional description of the agent's capabilities and purpose.
- clientFactory
- Func<IChatClient,IChatClient>
Provides a way to customize the creation of the underlying IChatClient used by the agent.
- loggerFactory
- ILoggerFactory
Optional logger factory for enabling logging within the agent.
- services
- IServiceProvider
An optional IServiceProvider to use for resolving services required by the AIFunction instances being invoked.
Returns
An ChatClientAgent instance backed by the OpenAI Chat Completion service.
Exceptions
Thrown when client is null.