ChatCompletionAgent Class

Definition

Represents a Agent specialization based on IChatCompletionService.

public sealed class ChatCompletionAgent : Microsoft.SemanticKernel.Agents.ChatHistoryAgent
type ChatCompletionAgent = class
    inherit ChatHistoryAgent
Public NotInheritable Class ChatCompletionAgent
Inherits ChatHistoryAgent
Inheritance
ChatCompletionAgent

Remarks

NOTE: Enable FunctionChoiceBehavior for agent plugins (Arguments).

Constructors

ChatCompletionAgent()

Initializes a new instance of the ChatCompletionAgent class.

ChatCompletionAgent(PromptTemplateConfig, IPromptTemplateFactory)

Initializes a new instance of the ChatCompletionAgent class from a PromptTemplateConfig.

Properties

ActiveLoggerFactory

Get the active logger factory, if defined; otherwise, provide the default.

(Inherited from Agent)
Arguments

Gets the arguments for the agent instruction parameters (optional).

(Inherited from Agent)
Description

Gets the description of the agent (optional).

(Inherited from Agent)
HistoryReducer

Gets an optional IChatHistoryReducer to reduce the history.

(Inherited from ChatHistoryAgent)
Id

Gets the identifier of the agent (optional).

(Inherited from Agent)
Instructions

Gets the instructions for the agent (optional).

(Inherited from Agent)
InstructionsRole

Gets the role used for agent instructions. Defaults to "system".

Kernel

Gets the Kernel containing services, plugins, and filters for use throughout the agent lifetime.

(Inherited from Agent)
Logger

The ILogger associated with this Agent.

(Inherited from Agent)
LoggerFactory

A ILoggerFactory for this Agent.

(Inherited from Agent)
Name

Gets the name of the agent (optional).

(Inherited from Agent)
Template

Gets or sets a prompt template based on the agent instructions.

(Inherited from Agent)

Methods

CreateChannelAsync(CancellationToken)

Produce an AgentChannel appropriate for the agent type.

(Inherited from ChatHistoryAgent)
EnsureThreadExistsWithMessagesAsync<TThreadType>(ICollection<ChatMessageContent>, AgentThread, Func<TThreadType>, CancellationToken)

Ensures that the thread exists, is of the expected type, and is active, plus adds the provided message to the thread.

(Inherited from Agent)
GetChannelKeys()

Set of keys to establish channel affinity. Minimum expected key-set: yield return typeof(YourAgentChannel).FullName;

(Inherited from ChatHistoryAgent)
InvokeAsync(AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with no message assuming that all required instructions are already provided to the agent or on the thread.

(Inherited from Agent)
InvokeAsync(ChatHistory, KernelArguments, Kernel, CancellationToken)
Obsolete.

Invokes the assistant to respond to the provided history.

InvokeAsync(ChatMessageContent, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

(Inherited from Agent)
InvokeAsync(ICollection<ChatMessageContent>, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

InvokeAsync(String, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

(Inherited from Agent)
InvokeStreamingAsync(AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with no message assuming that all required instructions are already provided to the agent or on the thread.

(Inherited from Agent)
InvokeStreamingAsync(ChatHistory, KernelArguments, Kernel, CancellationToken)
Obsolete.

Invokes the assistant to respond to the provided history with streaming response.

InvokeStreamingAsync(ChatMessageContent, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

(Inherited from Agent)
InvokeStreamingAsync(ICollection<ChatMessageContent>, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

InvokeStreamingAsync(String, AgentThread, AgentInvokeOptions, CancellationToken)

Invoke the agent with the provided message and arguments.

(Inherited from Agent)
NotifyThreadOfNewMessage(AgentThread, ChatMessageContent, CancellationToken)

Notfiy the given thread that a new message is available.

(Inherited from Agent)
ReduceAsync(ChatHistory, CancellationToken)

Reduces the provided history.

(Inherited from ChatHistoryAgent)
RenderInstructionsAsync(Kernel, KernelArguments, CancellationToken)

Formats the system instructions for the agent.

(Inherited from Agent)
RestoreChannelAsync(String, CancellationToken)

Produce an AgentChannel appropriate for the agent type based on the provided state.

(Inherited from Agent)

Applies to