From aaa9261ac5fcd7af69d99274c2150e9794cdf5cb Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Tue, 6 Jun 2023 20:08:25 -0500 Subject: [PATCH] Rename to TextGeneratives. --- .../IChatCompletionProvider.cs} | 4 ++-- .../BotSharpServiceCollectionExtensions.cs | 6 +++--- .../BotSharp.Core/Plugins/PlatformMidware.cs | 4 ++-- .../LLamaSharp/ChatCompletionProvider.cs} | 8 ++++---- .../LLamaSharp/LlamaSharpSettings.cs | 2 +- .../AzureAiServiceCollectionExtensions.cs | 5 +++-- .../ChatCompletionProvider.cs} | 11 ++++++----- 7 files changed, 21 insertions(+), 19 deletions(-) rename src/Infrastructure/BotSharp.Abstraction/{TextCompletions/ITextCompletionProvider.cs => TextGeneratives/IChatCompletionProvider.cs} (72%) rename src/Infrastructure/BotSharp.Core/Plugins/{TextCompletions/LLamaSharp/LlamaSharpCompletionProvider.cs => TextGeneratives/LLamaSharp/ChatCompletionProvider.cs} (90%) rename src/Infrastructure/BotSharp.Core/Plugins/{TextCompletions => TextGeneratives}/LLamaSharp/LlamaSharpSettings.cs (88%) rename src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/{Providers/ChatCompletionHandler.cs => TextGeneratives/ChatCompletionProvider.cs} (91%) diff --git a/src/Infrastructure/BotSharp.Abstraction/TextCompletions/ITextCompletionProvider.cs b/src/Infrastructure/BotSharp.Abstraction/TextGeneratives/IChatCompletionProvider.cs similarity index 72% rename from src/Infrastructure/BotSharp.Abstraction/TextCompletions/ITextCompletionProvider.cs rename to src/Infrastructure/BotSharp.Abstraction/TextGeneratives/IChatCompletionProvider.cs index a5e03bb0..344c0dce 100644 --- a/src/Infrastructure/BotSharp.Abstraction/TextCompletions/ITextCompletionProvider.cs +++ b/src/Infrastructure/BotSharp.Abstraction/TextGeneratives/IChatCompletionProvider.cs @@ -1,8 +1,8 @@ using BotSharp.Abstraction.Models; -namespace BotSharp.Abstraction.TextCompletions; +namespace BotSharp.Abstraction.TextGeneratives; -public interface ITextCompletionProvider +public interface IChatCompletionProvider { string GetInstruction(); List GetChatSamples(); diff --git a/src/Infrastructure/BotSharp.Core/BotSharpServiceCollectionExtensions.cs b/src/Infrastructure/BotSharp.Core/BotSharpServiceCollectionExtensions.cs index fd0b89d4..648f2156 100644 --- a/src/Infrastructure/BotSharp.Core/BotSharpServiceCollectionExtensions.cs +++ b/src/Infrastructure/BotSharp.Core/BotSharpServiceCollectionExtensions.cs @@ -1,7 +1,7 @@ using BotSharp.Abstraction.Conversations; -using BotSharp.Abstraction.TextCompletions; +using BotSharp.Abstraction.TextGeneratives; using BotSharp.Core.Conversations; -using BotSharp.Core.Plugins.TextCompletions.LLamaSharp; +using BotSharp.Core.Plugins.TextGeneratives.LLamaSharp; using BotSharp.Core.Repository; using BotSharp.Core.Services; using EntityFrameworkCore.BootKit; @@ -64,6 +64,6 @@ public static class BotSharpServiceCollectionExtensions config.Bind("LlamaSharp", settings); return settings; }); - services.AddSingleton(); + services.AddSingleton(); } } diff --git a/src/Infrastructure/BotSharp.Core/Plugins/PlatformMidware.cs b/src/Infrastructure/BotSharp.Core/Plugins/PlatformMidware.cs index 3ed40ee4..ee3c5459 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/PlatformMidware.cs +++ b/src/Infrastructure/BotSharp.Core/Plugins/PlatformMidware.cs @@ -1,6 +1,6 @@ using BotSharp.Abstraction.Conversations; using BotSharp.Abstraction.Models; -using BotSharp.Abstraction.TextCompletions; +using BotSharp.Abstraction.TextGeneratives; using Microsoft.Extensions.DependencyInjection; namespace BotSharp.Core.Services; @@ -21,7 +21,7 @@ public class PlatformMidware : IPlatformMidware public async Task GetChatCompletionsAsync(List conversations, Func onChunkReceived) { - var handlers = _services.GetServices().ToList(); + var handlers = _services.GetServices().ToList(); for (int i = 0; i < handlers.Count(); i++) { var handler = handlers[i]; diff --git a/src/Infrastructure/BotSharp.Core/Plugins/TextCompletions/LLamaSharp/LlamaSharpCompletionProvider.cs b/src/Infrastructure/BotSharp.Core/Plugins/TextGeneratives/LLamaSharp/ChatCompletionProvider.cs similarity index 90% rename from src/Infrastructure/BotSharp.Core/Plugins/TextCompletions/LLamaSharp/LlamaSharpCompletionProvider.cs rename to src/Infrastructure/BotSharp.Core/Plugins/TextGeneratives/LLamaSharp/ChatCompletionProvider.cs index 581c1c79..1550dd80 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/TextCompletions/LLamaSharp/LlamaSharpCompletionProvider.cs +++ b/src/Infrastructure/BotSharp.Core/Plugins/TextGeneratives/LLamaSharp/ChatCompletionProvider.cs @@ -1,17 +1,17 @@ using BotSharp.Abstraction.Models; using BotSharp.Abstraction.Plugins; -using BotSharp.Abstraction.TextCompletions; +using BotSharp.Abstraction.TextGeneratives; using LLama; using System.IO; -namespace BotSharp.Core.Plugins.TextCompletions.LLamaSharp; +namespace BotSharp.Core.Plugins.TextGeneratives.LLamaSharp; -public class LlamaSharpCompletionProvider : ITextCompletionProvider, IBotSharpPlugin +public class ChatCompletionProvider : IChatCompletionProvider, IBotSharpPlugin { private readonly IChatModel _model; private readonly LlamaSharpSettings _settings; - public LlamaSharpCompletionProvider(LlamaSharpSettings settings) + public ChatCompletionProvider(LlamaSharpSettings settings) { _settings = settings; _model = new LLamaModel(new LLamaParams(model: _settings.ModelPath, diff --git a/src/Infrastructure/BotSharp.Core/Plugins/TextCompletions/LLamaSharp/LlamaSharpSettings.cs b/src/Infrastructure/BotSharp.Core/Plugins/TextGeneratives/LLamaSharp/LlamaSharpSettings.cs similarity index 88% rename from src/Infrastructure/BotSharp.Core/Plugins/TextCompletions/LLamaSharp/LlamaSharpSettings.cs rename to src/Infrastructure/BotSharp.Core/Plugins/TextGeneratives/LLamaSharp/LlamaSharpSettings.cs index a69f446e..4720baf6 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/TextCompletions/LLamaSharp/LlamaSharpSettings.cs +++ b/src/Infrastructure/BotSharp.Core/Plugins/TextGeneratives/LLamaSharp/LlamaSharpSettings.cs @@ -1,4 +1,4 @@ -namespace BotSharp.Core.Plugins.TextCompletions.LLamaSharp; +namespace BotSharp.Core.Plugins.TextGeneratives.LLamaSharp; public class LlamaSharpSettings { diff --git a/src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/AzureAiServiceCollectionExtensions.cs b/src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/AzureAiServiceCollectionExtensions.cs index 822fa2bc..5e869745 100644 --- a/src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/AzureAiServiceCollectionExtensions.cs +++ b/src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/AzureAiServiceCollectionExtensions.cs @@ -1,5 +1,6 @@ -using BotSharp.Abstraction.TextCompletions; +using BotSharp.Abstraction.TextGeneratives; using BotSharp.Platform.AzureAi; +using BotSharp.Plugin.AzureOpenAI.TextGeneratives; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -15,7 +16,7 @@ public static class AzureAiServiceCollectionExtensions config.Bind("AzureAi", settings); return settings; }); - services.AddScoped(); + services.AddScoped(); return services; } } \ No newline at end of file diff --git a/src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/Providers/ChatCompletionHandler.cs b/src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/TextGeneratives/ChatCompletionProvider.cs similarity index 91% rename from src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/Providers/ChatCompletionHandler.cs rename to src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/TextGeneratives/ChatCompletionProvider.cs index 066e8db7..8018a6f1 100644 --- a/src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/Providers/ChatCompletionHandler.cs +++ b/src/Plugins/Platforms/BotSharp.Plugin.AureOpenAI/TextGeneratives/ChatCompletionProvider.cs @@ -1,19 +1,20 @@ using Azure; using Azure.AI.OpenAI; using BotSharp.Abstraction.Models; -using BotSharp.Abstraction.TextCompletions; +using BotSharp.Abstraction.TextGeneratives; +using BotSharp.Platform.AzureAi; using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; -namespace BotSharp.Platform.AzureAi; - -public class ChatCompletionHandler : ITextCompletionProvider +namespace BotSharp.Plugin.AzureOpenAI.TextGeneratives; + +public class ChatCompletionProvider : IChatCompletionProvider { private readonly AzureAiSettings _settings; - public ChatCompletionHandler(AzureAiSettings settings) + public ChatCompletionProvider(AzureAiSettings settings) { _settings = settings; }