BotSharp/tests/BotSharp.Plugin.SemanticKernel.UnitTests/Helpers/ResultHelper.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2023-11-12 14:04:00 +00:00
using Microsoft.SemanticKernel.AI.ChatCompletion;
2023-11-13 15:11:49 +00:00
using Microsoft.SemanticKernel.AI.TextCompletion;
2023-11-12 14:04:00 +00:00
using Microsoft.SemanticKernel.Orchestration;
namespace BotSharp.Plugin.SemanticKernel.UnitTests.Helpers
{
2023-11-13 15:11:49 +00:00
public class ResultHelper : IChatResult, ITextResult
2023-11-12 14:04:00 +00:00
{
public ModelResult ModelResult { get; set; }
private string _response;
2023-11-13 15:11:49 +00:00
public ResultHelper(string response)
2023-11-12 14:04:00 +00:00
{
ModelResult = new ModelResult(response);
_response = response;
}
public async Task<ChatMessageBase> GetChatMessageAsync(CancellationToken cancellationToken = default)
{
return await Task.FromResult(new MockModelResult(_response));
}
2023-11-13 15:11:49 +00:00
public Task<string> GetCompletionAsync(CancellationToken cancellationToken = default)
{
return Task.FromResult(_response);
}
2023-11-12 14:04:00 +00:00
public class MockModelResult : ChatMessageBase
{
public MockModelResult(string content) : base(AuthorRole.Assistant, content, null)
{
}
}
}
}