|
|
|
@ -1,37 +1,20 @@
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
namespace SemanticKernelStudy.Test;
|
|
|
|
|
|
|
|
|
|
using Microsoft.Extensions.AI;
|
|
|
|
|
|
|
|
|
|
namespace SemanticKernelStudy.Test
|
|
|
|
|
public class UseXunit
|
|
|
|
|
{
|
|
|
|
|
public class UseXunit
|
|
|
|
|
private readonly ITestOutputHelper _output;
|
|
|
|
|
public UseXunit(ITestOutputHelper output)
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Test1()
|
|
|
|
|
{
|
|
|
|
|
Assert.True(true,"使用 xUnit 2 框架!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Test2()
|
|
|
|
|
{
|
|
|
|
|
var kernelBuilder = Kernel.CreateBuilder();
|
|
|
|
|
|
|
|
|
|
//添加AI服务
|
|
|
|
|
kernelBuilder.AddOllamaChatClient("qwen3:0.6b", new Uri("http://localhost:11434/v1"), "ollamaService");
|
|
|
|
|
|
|
|
|
|
kernelBuilder.Plugins.AddFromType<TimePlugin>();
|
|
|
|
|
|
|
|
|
|
//添加企业级服务(日志、过滤器等)
|
|
|
|
|
kernelBuilder.Services.AddLogging(services => services.AddConsole().SetMinimumLevel(LogLevel.Trace));
|
|
|
|
|
|
|
|
|
|
Kernel kernel = kernelBuilder.Build();
|
|
|
|
|
_output = output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FunctionResult d = await kernel.InvokePromptAsync("你好");
|
|
|
|
|
[Fact]
|
|
|
|
|
public void UseXunitFramwork_Test()
|
|
|
|
|
{
|
|
|
|
|
var msg = "使用 xUnit 2 单元测试框架!";
|
|
|
|
|
|
|
|
|
|
ChatResponse? dd = d.GetValue<ChatResponse>();
|
|
|
|
|
_output.WriteLine(msg);
|
|
|
|
|
|
|
|
|
|
var t = dd?.Messages.First().Text;
|
|
|
|
|
}
|
|
|
|
|
Assert.True(true,msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|