mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
a40eda48f1
* Add Approval capabilities to FunctionInvokingChatClient * Address PR comments. * Address PR comments. * Address PR comments. * Address PR feedback, add sample, and fix bug plus unit test. * Address PR comments
33 lines
957 B
C#
33 lines
957 B
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Microsoft.Extensions.AI.Agents;
|
|
|
|
internal static class ChatClientExtensions
|
|
{
|
|
internal static IChatClient AsAgentInvokingChatClient(this IChatClient chatClient)
|
|
{
|
|
var chatBuilder = chatClient.AsBuilder();
|
|
|
|
if (chatClient is not AgentInvokingChatClient agentInvokingChatClient)
|
|
{
|
|
chatBuilder.UseAgentInvocation();
|
|
}
|
|
|
|
if (chatClient.GetService<NewFunctionInvokingChatClient>() is null)
|
|
{
|
|
chatBuilder.Use((IChatClient innerClient, IServiceProvider services) =>
|
|
{
|
|
var loggerFactory = services.GetService<ILoggerFactory>();
|
|
|
|
return new NewFunctionInvokingChatClient(innerClient, loggerFactory, services);
|
|
});
|
|
}
|
|
|
|
return chatBuilder.Build();
|
|
}
|
|
}
|