功能更新

main
bicijinlian 1 month ago
parent 63057567be
commit 0925abe475

@ -22,6 +22,8 @@ global using Microsoft.Extensions.Options;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.AI;
global using Microsoft.SemanticKernel;
global using Microsoft.SemanticKernel.AudioToText;
global using Microsoft.SemanticKernel.ChatCompletion;
@ -46,3 +48,5 @@ global using Microsoft.SemanticKernel.Agents.Extensions;
global using Microsoft.SemanticKernel.Agents.Chat;
global using Microsoft.SemanticKernel.Agents.Serialization;
global using Microsoft.SemanticKernel.Agents.OpenAI;
global using Xunit.Abstractions;

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.AI;
namespace SemanticKernelStudy.Test
{
public class SemanticKernelTest
{
private readonly ITestOutputHelper _output;
public SemanticKernelTest(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public async Task Use_SemanticKernel_Test()
{
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();
FunctionResult d = await kernel.InvokePromptAsync("你好");
ChatResponse? dd = d.GetValue<ChatResponse>();
var t = dd?.Messages.First().Text;
_output.WriteLine(t);
}
}
}

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

@ -0,0 +1,6 @@
<LUTConfig Version="1.0">
<Repository />
<ParallelBuilds>true</ParallelBuilds>
<ParallelTestRuns>true</ParallelTestRuns>
<TestCaseTimeout>180000</TestCaseTimeout>
</LUTConfig>
Loading…
Cancel
Save