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

49 lines
2.2 KiB
C#
Raw Normal View History

2024-01-30 11:04:22 +00:00
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
2023-11-13 15:11:49 +00:00
using Microsoft.SemanticKernel.Services;
2024-01-30 11:04:22 +00:00
using Microsoft.SemanticKernel.TextGeneration;
2023-11-13 15:11:49 +00:00
namespace BotSharp.Plugin.SemanticKernel.UnitTests.Helpers
{
2024-01-30 11:04:22 +00:00
internal class SemanticKernelHelper : IChatCompletionService, ITextGenerationService, IAIService
2023-11-13 15:11:49 +00:00
{
private Dictionary<string, string> _attributes = new();
2023-11-13 15:11:49 +00:00
private readonly string _excepted;
public SemanticKernelHelper(string excepted)
{
this._excepted = excepted;
}
public IReadOnlyDictionary<string, string> Attributes => _attributes;
2024-01-30 11:04:22 +00:00
IReadOnlyDictionary<string, object?> IAIService.Attributes => throw new NotImplementedException();
2023-11-13 15:11:49 +00:00
public ChatHistory CreateNewChat(string? instructions = null)
{
return new ChatHistory();
}
2024-01-30 11:04:22 +00:00
public Task<IReadOnlyList<ChatMessageContent>> GetChatMessageContentsAsync(ChatHistory chatHistory, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default)
2023-11-13 15:11:49 +00:00
{
2024-01-30 11:04:22 +00:00
return Task.FromResult<IReadOnlyList<ChatMessageContent>>(new List<ChatMessageContent> { new ChatMessageContent(AuthorRole.Assistant, _excepted) });
2023-11-13 15:11:49 +00:00
}
2024-01-30 11:04:22 +00:00
public IAsyncEnumerable<StreamingChatMessageContent> GetStreamingChatMessageContentsAsync(ChatHistory chatHistory, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default)
2023-11-13 15:11:49 +00:00
{
2024-01-30 11:04:22 +00:00
throw new NotImplementedException();
2023-11-13 15:11:49 +00:00
}
2024-01-30 11:04:22 +00:00
public Task<IReadOnlyList<TextContent>> GetTextContentsAsync(string prompt, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default)
2023-11-13 15:11:49 +00:00
{
2024-01-30 11:04:22 +00:00
return Task.FromResult<IReadOnlyList<TextContent>>(new List<TextContent> { new TextContent(_excepted) });
2023-11-13 15:11:49 +00:00
}
2024-01-30 11:04:22 +00:00
public IAsyncEnumerable<StreamingTextContent> GetStreamingTextContentsAsync(string prompt, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default)
2023-11-13 15:11:49 +00:00
{
throw new NotImplementedException();
}
}
}