Я пытаюсь использовать плагины семантического ядра через разъем Openai с DeepSeek-R1, развернутым на Locure Foundry.
Я могу подключиться к LLM и получить ответы. Плагины, кажется, игнорируются.
Например, в коде ниже, я объявил функцию DatePlugin < /code> с его функцией getCurrentDate < /code>, но спрашиваю: < /p>
Какова текущая дата? /> Привет! Я предлагаю получить онлайн, чтобы получить информацию в режиме реального времени. Если
у вас есть какие -либо другие вопросы, пожалуйста, не стесняйтесь сообщить мне! Возможно ли это достичь? < /P>
namespace DeepSeekR1Test
{
using System.ComponentModel;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
internal class Program
{
static async Task Main(string[] args)
{
var builder = Kernel.CreateBuilder();
#pragma warning disable SKEXP0010 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
builder.AddOpenAIChatCompletion(
modelId: "DeepSeek-R1",
new Uri(MY_AZURE_OPENAI_ENDPOINT),
MY_API_KEY
);
builder.Services.AddLogging(c => c.AddConsole().SetMinimumLevel(LogLevel.Trace));
builder.Plugins.AddFromType();
var kernel = builder.Build();
var chatAgent = new ChatCompletionAgent
{
Kernel = kernel,
LoggerFactory = kernel.LoggerFactory,
Arguments = new KernelArguments(
new OpenAIPromptExecutionSettings()
{
FunctionChoiceBehavior = FunctionChoiceBehavior.Auto()
}),
};
var history = new ChatHistory();
history.AddUserMessage("What is the current date ?");
await foreach (var t in chatAgent.InvokeAsync(history))
{
Console.WriteLine(t.Content);
}
}
public class DatePlugin
{
[KernelFunction()]
[Description("Returns the current date.")]
[return: Description("Current date.")]
public string GetCurrentDate() => DateOnly.FromDateTime(DateTime.UtcNow).ToString("D");
}
}
}
< /code>
my csproj: < /p>
Exe
net9.0
enable
enable
Подробнее здесь: https://stackoverflow.com/questions/795 ... ai-foundry