UNIVPLMDataIntegration/Admin.NET/Admin.NET.Application/Service/LLM/LLMChangeModelTestService.cs

30 lines
1.0 KiB
C#
Raw Normal View History

using Admin.NET.Core.Ai.Interface;
using Admin.NET.Core.Ai.Models;
namespace Admin.NET.Application.Service.LLM;
[ApiDescriptionSettings(Name = "LLMChangeModelTest", Description = "LLM测试,可以切换模型")]
public class LLMChangeModelTestService : IDynamicApiController, ITransient
{
private readonly ILLMFactory _llmFactory;
public LLMChangeModelTestService(ILLMFactory llmFactory)
{
_llmFactory = llmFactory;
}
/// <summary>
/// 演示大模型的使用,可以切换模型。
/// 例如可以切换到不同的模型OpenAI、Azure OpenAI、Google Gemini等。
/// </summary>
/// <param name="modelInput"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "TestSwitch", Description = "测试模型切换")]
public async Task<string> TestSwitchAsync(LLMModelInput modelInput)
{
var kernel = _llmFactory.CreateKernel(modelInput);
var result = await kernel.InvokePromptAsync("请介绍自己");
return result.ToString();
}
}