【semantic Kernel】如何让其他模型也能在SemanticKernel中调用本地函数

参考:https://mp.weixin.qq.com/s/swPPTyIJa-2OJcyycBVJNQ

代码:

//接入星火AI
var httpClient = new HttpClient(new XinghuoOpenAIHttpClientHandler());
var builder = Kernel.CreateBuilder().AddOpenAIChatCompletion(modelId: "generalv3.5", "tHQoTStMXIMXmmFwrzSU:ioNfvqISnIPizlSccDdX", httpClient: httpClient);

var kernel = builder.Build();
kernel.ImportPluginFromType<FileIOPlugin>("FileIO");
kernel.ImportPluginFromType<TimePlugin>("Time");
kernel.ImportPluginFromType<MathPlugin>("Math");
kernel.ImportPluginFromType<EmailPluginFake>("Email");


UniversalLLMFunctionCaller planner = new(kernel);
//string ask = "What is the current hour number, plus 5?";
string ask = "帮我读取文件内容 c:\\1.txt";
Console.WriteLine(ask);

string result0 = await planner.RunAsync(ask);
Console.WriteLine(result0);
posted @ 2024-11-05 15:39  .Neterr  阅读(8)  评论(0编辑  收藏  举报