From d180d676027e980ac65698fa546d6fca7082bf8e Mon Sep 17 00:00:00 2001 From: geffzhang Date: Sat, 27 Jan 2024 15:57:56 +0800 Subject: [PATCH 1/7] feat: upgrade .NET 8 --- Directory.Build.props | 2 +- dockerfiles/Dockerfile | 49 +++++++++++++++++++ .../BotSharp.OpenAPI/BotSharp.OpenAPI.csproj | 6 +-- .../BotSharp.Plugin.ChatHub.csproj | 2 +- .../BotSharp.Plugin.ChatbotUI.csproj | 2 +- .../BotSharp.Plugin.PaddleSharp.csproj | 10 ++-- .../BotSharp.Plugin.RoutingSpeeder.csproj | 2 +- .../BotSharp.Plugin.SqlDriver.csproj | 4 +- .../BotSharp.Plugin.Twilio.csproj | 4 +- .../BotSharp.Plugin.WeChat.csproj | 4 +- .../BotSharp.Plugin.WebDriver.csproj | 2 +- src/WebStarter/WebStarter.csproj | 10 ++-- src/WebStarter/appsettings.json | 10 ++-- ...arp.Plugin.SemanticKernel.UnitTests.csproj | 4 +- 14 files changed, 81 insertions(+), 30 deletions(-) create mode 100644 dockerfiles/Dockerfile diff --git a/Directory.Build.props b/Directory.Build.props index b7011785..75814118 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - net6.0 + net8.0 10.0 0.22.0 false diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile new file mode 100644 index 00000000..856284a1 --- /dev/null +++ b/dockerfiles/Dockerfile @@ -0,0 +1,49 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER app +WORKDIR /app +EXPOSE 8080 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["Directory.Build.props", "."] +COPY ["src/WebStarter/WebStarter.csproj", "src/WebStarter/"] +COPY ["tests/BotSharp.Plugin.PizzaBot/BotSharp.Plugin.PizzaBot.csproj", "tests/BotSharp.Plugin.PizzaBot/"] +COPY ["src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj", "src/Infrastructure/BotSharp.Core/"] +COPY ["src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj", "src/Infrastructure/BotSharp.Abstraction/"] +COPY ["src/Infrastructure/BotSharp.Logger/BotSharp.Logger.csproj", "src/Infrastructure/BotSharp.Logger/"] +COPY ["src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj", "src/Infrastructure/BotSharp.OpenAPI/"] +COPY ["src/Plugins/BotSharp.Plugin.GoogleAI/BotSharp.Plugin.GoogleAI.csproj", "src/Plugins/BotSharp.Plugin.GoogleAI/"] +COPY ["src/Plugins/BotSharp.Plugin.MongoStorage/BotSharp.Plugin.MongoStorage.csproj", "src/Plugins/BotSharp.Plugin.MongoStorage/"] +COPY ["src/Plugins/BotSharp.Plugin.AzureOpenAI/BotSharp.Plugin.AzureOpenAI.csproj", "src/Plugins/BotSharp.Plugin.AzureOpenAI/"] +COPY ["src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj", "src/Plugins/BotSharp.Plugin.ChatbotUI/"] +COPY ["src/Plugins/BotSharp.Plugin.HuggingFace/BotSharp.Plugin.HuggingFace.csproj", "src/Plugins/BotSharp.Plugin.HuggingFace/"] +COPY ["src/Plugins/BotSharp.Plugin.KnowledgeBase/BotSharp.Plugin.KnowledgeBase.csproj", "src/Plugins/BotSharp.Plugin.KnowledgeBase/"] +COPY ["src/Plugins/BotSharp.Plugin.MetaAI/BotSharp.Plugin.MetaAI.csproj", "src/Plugins/BotSharp.Plugin.MetaAI/"] +COPY ["src/Plugins/BotSharp.Plugin.MetaMessenger/BotSharp.Plugin.MetaMessenger.csproj", "src/Plugins/BotSharp.Plugin.MetaMessenger/"] +COPY ["src/Plugins/BotSharp.Plugin.Qdrant/BotSharp.Plugin.Qdrant.csproj", "src/Plugins/BotSharp.Plugin.Qdrant/"] +COPY ["src/Plugins/BotSharp.Plugin.RoutingSpeeder/BotSharp.Plugin.RoutingSpeeder.csproj", "src/Plugins/BotSharp.Plugin.RoutingSpeeder/"] +COPY ["src/Plugins/BotSharp.Plugin.WeChat/BotSharp.Plugin.WeChat.csproj", "src/Plugins/BotSharp.Plugin.WeChat/"] +COPY ["src/Plugins/BotSharp.Plugin.SemanticKernel/BotSharp.Plugin.SemanticKernel.csproj", "src/Plugins/BotSharp.Plugin.SemanticKernel/"] +COPY ["src/Plugins/BotSharp.Plugin.Twilio/BotSharp.Plugin.Twilio.csproj", "src/Plugins/BotSharp.Plugin.Twilio/"] +COPY ["src/Plugins/BotSharp.Plugin.TelegramBots/BotSharp.Plugin.TelegramBots.csproj", "src/Plugins/BotSharp.Plugin.TelegramBots/"] +COPY ["src/Plugins/BotSharp.Plugin.ChatHub/BotSharp.Plugin.ChatHub.csproj", "src/Plugins/BotSharp.Plugin.ChatHub/"] +COPY ["src/Plugins/BotSharp.Plugin.HttpHandler/BotSharp.Plugin.HttpHandler.csproj", "src/Plugins/BotSharp.Plugin.HttpHandler/"] +COPY ["src/Plugins/BotSharp.Plugin.LLamaSharp/BotSharp.Plugin.LLamaSharp.csproj", "src/Plugins/BotSharp.Plugin.LLamaSharp/"] +COPY ["src/Plugins/BotSharp.Plugin.SqlDriver/BotSharp.Plugin.SqlDriver.csproj", "src/Plugins/BotSharp.Plugin.SqlDriver/"] +COPY ["src/Plugins/BotSharp.Plugin.WebDriver/BotSharp.Plugin.WebDriver.csproj", "src/Plugins/BotSharp.Plugin.WebDriver/"] +RUN dotnet restore "./src/WebStarter/./WebStarter.csproj" +COPY . . +WORKDIR "/src/src/WebStarter" +RUN dotnet build "./WebStarter.csproj" -c $BUILD_CONFIGURATION -o /app/build /p:SolutionName=BotSharp + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./WebStarter.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false /p:SolutionName=BotSharp + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "WebStarter.dll"] \ No newline at end of file diff --git a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj index 70c391ee..3223688a 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj +++ b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable $(LangVersion) @@ -19,9 +19,9 @@ - + - + diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/BotSharp.Plugin.ChatHub.csproj b/src/Plugins/BotSharp.Plugin.ChatHub/BotSharp.Plugin.ChatHub.csproj index 04d9b8fd..af5b2146 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/BotSharp.Plugin.ChatHub.csproj +++ b/src/Plugins/BotSharp.Plugin.ChatHub/BotSharp.Plugin.ChatHub.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable $(LangVersion) diff --git a/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj b/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj index 9e83b9a8..8f70adb1 100644 --- a/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj +++ b/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable $(LangVersion) $(BotSharpVersion) diff --git a/src/Plugins/BotSharp.Plugin.PaddleSharp/BotSharp.Plugin.PaddleSharp.csproj b/src/Plugins/BotSharp.Plugin.PaddleSharp/BotSharp.Plugin.PaddleSharp.csproj index fe8739a4..d6c862d4 100644 --- a/src/Plugins/BotSharp.Plugin.PaddleSharp/BotSharp.Plugin.PaddleSharp.csproj +++ b/src/Plugins/BotSharp.Plugin.PaddleSharp/BotSharp.Plugin.PaddleSharp.csproj @@ -12,14 +12,14 @@ - - - + + + - + - + diff --git a/src/Plugins/BotSharp.Plugin.RoutingSpeeder/BotSharp.Plugin.RoutingSpeeder.csproj b/src/Plugins/BotSharp.Plugin.RoutingSpeeder/BotSharp.Plugin.RoutingSpeeder.csproj index 4bc9a6af..857154cf 100644 --- a/src/Plugins/BotSharp.Plugin.RoutingSpeeder/BotSharp.Plugin.RoutingSpeeder.csproj +++ b/src/Plugins/BotSharp.Plugin.RoutingSpeeder/BotSharp.Plugin.RoutingSpeeder.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/BotSharp.Plugin.SqlDriver.csproj b/src/Plugins/BotSharp.Plugin.SqlDriver/BotSharp.Plugin.SqlDriver.csproj index 929d4d61..4f6f352c 100644 --- a/src/Plugins/BotSharp.Plugin.SqlDriver/BotSharp.Plugin.SqlDriver.csproj +++ b/src/Plugins/BotSharp.Plugin.SqlDriver/BotSharp.Plugin.SqlDriver.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/src/Plugins/BotSharp.Plugin.Twilio/BotSharp.Plugin.Twilio.csproj b/src/Plugins/BotSharp.Plugin.Twilio/BotSharp.Plugin.Twilio.csproj index 3a09e780..de9ea799 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/BotSharp.Plugin.Twilio.csproj +++ b/src/Plugins/BotSharp.Plugin.Twilio/BotSharp.Plugin.Twilio.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 $(LangVersion) $(BotSharpVersion) $(GeneratePackageOnBuild) @@ -9,7 +9,7 @@ - + diff --git a/src/Plugins/BotSharp.Plugin.WeChat/BotSharp.Plugin.WeChat.csproj b/src/Plugins/BotSharp.Plugin.WeChat/BotSharp.Plugin.WeChat.csproj index 1aff09b8..b2c19ae1 100644 --- a/src/Plugins/BotSharp.Plugin.WeChat/BotSharp.Plugin.WeChat.csproj +++ b/src/Plugins/BotSharp.Plugin.WeChat/BotSharp.Plugin.WeChat.csproj @@ -27,8 +27,8 @@ - - + + diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/BotSharp.Plugin.WebDriver.csproj b/src/Plugins/BotSharp.Plugin.WebDriver/BotSharp.Plugin.WebDriver.csproj index d78a7e12..205f32bf 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/BotSharp.Plugin.WebDriver.csproj +++ b/src/Plugins/BotSharp.Plugin.WebDriver/BotSharp.Plugin.WebDriver.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/WebStarter/WebStarter.csproj b/src/WebStarter/WebStarter.csproj index a4d90290..dec41bfb 100644 --- a/src/WebStarter/WebStarter.csproj +++ b/src/WebStarter/WebStarter.csproj @@ -1,11 +1,13 @@ - net6.0 + net8.0 enable enable OutOfProcess 4fb8c9df-7975-4926-ba73-46c8ca440691 + botsharpwebapi + Linux @@ -25,11 +27,11 @@ - + - + diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json index 66b92dc0..2f240b10 100644 --- a/src/WebStarter/appsettings.json +++ b/src/WebStarter/appsettings.json @@ -19,16 +19,16 @@ "Models": [ { "Name": "gpt-35-turbo", - "ApiKey": "", - "Endpoint": "https://gpt-35-turbo.openai.azure.com/", + "ApiKey": "c1cee6ddfb3d4f469587789efe7a2ba9", + "Endpoint": "https://ai4c-demo.openai.azure.com/", "Type": "chat", "PromptCost": 0.0015, "CompletionCost": 0.002 }, { - "Name": "gpt-35-turbo-instruct", - "ApiKey": "", - "Endpoint": "https://gpt-35-turbo-instruct.openai.azure.com/", + "Name": "gpt-35-turbo", + "ApiKey": "c1cee6ddfb3d4f469587789efe7a2ba9", + "Endpoint": "https://ai4c-demo.openai.azure.com/", "Type": "text", "PromptCost": 0.0015, "CompletionCost": 0.002 diff --git a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/BotSharp.Plugin.SemanticKernel.UnitTests.csproj b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/BotSharp.Plugin.SemanticKernel.UnitTests.csproj index 81e6d3b6..32781e0f 100644 --- a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/BotSharp.Plugin.SemanticKernel.UnitTests.csproj +++ b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/BotSharp.Plugin.SemanticKernel.UnitTests.csproj @@ -12,9 +12,9 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all From 9f71d8248e65becc5581b7b6a508ad1f023c334e Mon Sep 17 00:00:00 2001 From: geffzhang Date: Sat, 27 Jan 2024 20:24:57 +0800 Subject: [PATCH 2/7] feat: upgrade semantic kernel 1.2.0 --- .../BotSharp.Plugin.SemanticKernel.csproj | 10 +++- .../SemanticKernelChatCompletionProvider.cs | 19 +++--- .../SemanticKernelMemoryStoreProvider.cs | 6 ++ .../SemanticKernelTextCompletionProvider.cs | 11 ++-- .../SemanticKernelTextEmbeddingProvider.cs | 12 +++- src/WebStarter/WebStarter.csproj | 4 +- src/WebStarter/appsettings.json | 4 +- ...arp.Plugin.SemanticKernel.UnitTests.csproj | 2 +- .../Helpers/ResultHelper.cs | 59 +++++++++---------- .../Helpers/SemanticKernelHelper.cs | 34 +++++------ ...manticKernelChatCompletionProviderTests.cs | 29 +++++---- .../SemanticKernelPluginTests.cs | 10 +++- ...manticKernelTextCompletionProviderTests.cs | 17 +----- 13 files changed, 107 insertions(+), 110 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.SemanticKernel/BotSharp.Plugin.SemanticKernel.csproj b/src/Plugins/BotSharp.Plugin.SemanticKernel/BotSharp.Plugin.SemanticKernel.csproj index fe605288..bc0c0c2d 100644 --- a/src/Plugins/BotSharp.Plugin.SemanticKernel/BotSharp.Plugin.SemanticKernel.csproj +++ b/src/Plugins/BotSharp.Plugin.SemanticKernel/BotSharp.Plugin.SemanticKernel.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 @@ -11,8 +11,8 @@ - - + + @@ -24,4 +24,8 @@ + + + + diff --git a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelChatCompletionProvider.cs index bf7fbc42..22c7fc68 100644 --- a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelChatCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelChatCompletionProvider.cs @@ -6,7 +6,7 @@ using BotSharp.Abstraction.Conversations.Models; using BotSharp.Abstraction.Loggers; using BotSharp.Abstraction.MLTasks; using Microsoft.Extensions.DependencyInjection; -using Microsoft.SemanticKernel; +using Microsoft.SemanticKernel.ChatCompletion; using System; using System.Collections.Generic; using System.Linq; @@ -19,7 +19,7 @@ namespace BotSharp.Plugin.SemanticKernel /// public class SemanticKernelChatCompletionProvider : IChatCompletion { - private Microsoft.SemanticKernel.AI.ChatCompletion.IChatCompletion _kernelChatCompletion; + private Microsoft.SemanticKernel.ChatCompletion.IChatCompletionService _kernelChatCompletion; private IServiceProvider _services; private ITokenStatistics _tokenStatistics; private string? _model = null; @@ -33,7 +33,7 @@ namespace BotSharp.Plugin.SemanticKernel /// /// /// - public SemanticKernelChatCompletionProvider(Microsoft.SemanticKernel.AI.ChatCompletion.IChatCompletion chatCompletion, + public SemanticKernelChatCompletionProvider(IChatCompletionService chatCompletion, IServiceProvider services, ITokenStatistics tokenStatistics) { @@ -55,7 +55,7 @@ namespace BotSharp.Plugin.SemanticKernel var agentService = _services.GetRequiredService(); var instruction = agentService.RenderedInstruction(agent); - var chatHistory = completion.CreateNewChat(instruction); + ChatHistory chatHistory = new ChatHistory(instruction); foreach (var message in conversations) { @@ -69,14 +69,9 @@ namespace BotSharp.Plugin.SemanticKernel } } - var response = await completion.GetChatCompletionsAsync(chatHistory) - .ContinueWith(async t => - { - var result = await t; - var message = await result.First().GetChatMessageAsync(); - return message.Content; - }).ConfigureAwait(false).GetAwaiter().GetResult(); - + var ChatMessage = await completion.GetChatMessageContentsAsync(chatHistory); + var chatMessageContent = ChatMessage?.FirstOrDefault(); + var response = chatMessageContent != null ? chatMessageContent.Content :string.Empty; var msg = new RoleDialogModel(AgentRole.Assistant, response) { CurrentAgentId = agent.Id diff --git a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelMemoryStoreProvider.cs b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelMemoryStoreProvider.cs index 3f34e76b..444cab1e 100644 --- a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelMemoryStoreProvider.cs +++ b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelMemoryStoreProvider.cs @@ -9,9 +9,13 @@ namespace BotSharp.Plugin.SemanticKernel { internal class SemanticKernelMemoryStoreProvider : IVectorDb { +#pragma warning disable SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. private readonly IMemoryStore _memoryStore; +#pragma warning restore SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. +#pragma warning disable SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. public SemanticKernelMemoryStoreProvider(IMemoryStore memoryStore) +#pragma warning restore SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. { this._memoryStore = memoryStore; } @@ -46,7 +50,9 @@ namespace BotSharp.Plugin.SemanticKernel public async Task Upsert(string collectionName, int id, float[] vector, string text) { +#pragma warning disable SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. await _memoryStore.UpsertAsync(collectionName, MemoryRecord.LocalRecord(id.ToString(), text, null, vector)); +#pragma warning restore SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. } } } diff --git a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelTextCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelTextCompletionProvider.cs index 15791931..91dec640 100644 --- a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelTextCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelTextCompletionProvider.cs @@ -3,10 +3,7 @@ using BotSharp.Abstraction.Agents.Models; using BotSharp.Abstraction.Conversations; using BotSharp.Abstraction.Conversations.Models; using BotSharp.Abstraction.Loggers; -using Microsoft; using Microsoft.Extensions.DependencyInjection; -using Microsoft.SemanticKernel; -using Microsoft.SemanticKernel.AI.TextCompletion; using System; using System.Collections.Generic; using System.Linq; @@ -19,7 +16,7 @@ namespace BotSharp.Plugin.SemanticKernel /// public class SemanticKernelTextCompletionProvider : Abstraction.MLTasks.ITextCompletion { - private readonly Microsoft.SemanticKernel.AI.TextCompletion.ITextCompletion _kernelTextCompletion; + private readonly Microsoft.SemanticKernel.TextGeneration.ITextGenerationService _kernelTextCompletion; private readonly IServiceProvider _services; private readonly ITokenStatistics _tokenStatistics; private string? _model = null; @@ -33,7 +30,7 @@ namespace BotSharp.Plugin.SemanticKernel /// /// /// - public SemanticKernelTextCompletionProvider(Microsoft.SemanticKernel.AI.TextCompletion.ITextCompletion textCompletion, + public SemanticKernelTextCompletionProvider(Microsoft.SemanticKernel.TextGeneration.ITextGenerationService textCompletion, IServiceProvider services, ITokenStatistics tokenStatistics) { @@ -61,9 +58,11 @@ namespace BotSharp.Plugin.SemanticKernel var completion = this._kernelTextCompletion; _tokenStatistics.StartTimer(); - var result = await completion.CompleteAsync(text); + var textContent = await completion.GetTextContentsAsync(text); + var result = textContent.FirstOrDefault().Text; _tokenStatistics.StopTimer(); + // After chat completion hook Task.WaitAll(hooks.Select(hook => hook.AfterGenerated(new RoleDialogModel(AgentRole.Assistant, result), new TokenStatsModel diff --git a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelTextEmbeddingProvider.cs b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelTextEmbeddingProvider.cs index ef6efd49..66884ee8 100644 --- a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelTextEmbeddingProvider.cs +++ b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelTextEmbeddingProvider.cs @@ -1,6 +1,6 @@ using BotSharp.Abstraction.MLTasks; using Microsoft.Extensions.Configuration; -using Microsoft.SemanticKernel.AI.Embeddings; +using Microsoft.SemanticKernel.Embeddings; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -12,13 +12,17 @@ namespace BotSharp.Plugin.SemanticKernel /// public class SemanticKernelTextEmbeddingProvider : ITextEmbedding { - private readonly ITextEmbeddingGeneration _embedding; +#pragma warning disable SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. + private readonly ITextEmbeddingGenerationService _embedding; +#pragma warning restore SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. private readonly IConfiguration _configuration; /// /// Constructor of /// - public SemanticKernelTextEmbeddingProvider(ITextEmbeddingGeneration embedding, IConfiguration configuration) +#pragma warning disable SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. + public SemanticKernelTextEmbeddingProvider(ITextEmbeddingGenerationService embedding, IConfiguration configuration) +#pragma warning restore SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. { this._embedding = embedding; this._configuration = configuration; @@ -33,7 +37,9 @@ namespace BotSharp.Plugin.SemanticKernel /// public async Task GetVectorAsync(string text) { +#pragma warning disable SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. return (await this._embedding.GenerateEmbeddingAsync(text)).ToArray(); +#pragma warning restore SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. } /// diff --git a/src/WebStarter/WebStarter.csproj b/src/WebStarter/WebStarter.csproj index dec41bfb..02894f13 100644 --- a/src/WebStarter/WebStarter.csproj +++ b/src/WebStarter/WebStarter.csproj @@ -27,9 +27,9 @@ - + diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json index 244824c6..95eb7401 100644 --- a/src/WebStarter/appsettings.json +++ b/src/WebStarter/appsettings.json @@ -19,7 +19,7 @@ "Models": [ { "Name": "gpt-35-turbo", - "ApiKey": "c1cee6ddfb3d4f469587789efe7a2ba9", + "ApiKey": "", "Endpoint": "https://ai4c-demo.openai.azure.com/", "Type": "chat", "PromptCost": 0.0015, @@ -27,7 +27,7 @@ }, { "Name": "gpt-35-turbo", - "ApiKey": "c1cee6ddfb3d4f469587789efe7a2ba9", + "ApiKey": "", "Endpoint": "https://ai4c-demo.openai.azure.com/", "Type": "text", "PromptCost": 0.0015, diff --git a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/BotSharp.Plugin.SemanticKernel.UnitTests.csproj b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/BotSharp.Plugin.SemanticKernel.UnitTests.csproj index 32781e0f..a85f0dbc 100644 --- a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/BotSharp.Plugin.SemanticKernel.UnitTests.csproj +++ b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/BotSharp.Plugin.SemanticKernel.UnitTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/Helpers/ResultHelper.cs b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/Helpers/ResultHelper.cs index 4a818310..8acc4202 100644 --- a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/Helpers/ResultHelper.cs +++ b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/Helpers/ResultHelper.cs @@ -1,35 +1,34 @@ -using Microsoft.SemanticKernel.AI.ChatCompletion; -using Microsoft.SemanticKernel.AI.TextCompletion; -using Microsoft.SemanticKernel.Orchestration; +using Microsoft.SemanticKernel; +using Microsoft.SemanticKernel.ChatCompletion; -namespace BotSharp.Plugin.SemanticKernel.UnitTests.Helpers -{ - public class ResultHelper : IChatResult, ITextResult - { - public ModelResult ModelResult { get; set; } - private string _response; +//namespace BotSharp.Plugin.SemanticKernel.UnitTests.Helpers +//{ +// public class ResultHelper : KernelContent +// { +// public TextContent ModelResult { get; set; } +// private string _response; - public ResultHelper(string response) - { - ModelResult = new ModelResult(response); - _response = response; - } +// public ResultHelper(string response) +// { +// ModelResult = new TextContent(response); +// _response = response; +// } - public async Task GetChatMessageAsync(CancellationToken cancellationToken = default) - { - return await Task.FromResult(new MockModelResult(_response)); - } +// public async Task GetChatMessageAsync(CancellationToken cancellationToken = default) +// { +// return await Task.FromResult(new MockModelResult(_response)); +// } - public Task GetCompletionAsync(CancellationToken cancellationToken = default) - { - return Task.FromResult(_response); - } +// public Task GetCompletionAsync(CancellationToken cancellationToken = default) +// { +// return Task.FromResult(_response); +// } - public class MockModelResult : ChatMessage - { - public MockModelResult(string content) : base(AuthorRole.Assistant, content, null) - { - } - } - } -} \ No newline at end of file +// public class MockModelResult : ChatMessageContent +// { +// public MockModelResult(string content) : base(AuthorRole.Assistant, content, null) +// { +// } +// } +// } +//} \ No newline at end of file diff --git a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/Helpers/SemanticKernelHelper.cs b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/Helpers/SemanticKernelHelper.cs index 1245a4d2..4920460b 100644 --- a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/Helpers/SemanticKernelHelper.cs +++ b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/Helpers/SemanticKernelHelper.cs @@ -1,16 +1,11 @@ -using Microsoft.SemanticKernel.AI; -using Microsoft.SemanticKernel.AI.ChatCompletion; -using Microsoft.SemanticKernel.AI.TextCompletion; +using Microsoft.SemanticKernel; +using Microsoft.SemanticKernel.ChatCompletion; using Microsoft.SemanticKernel.Services; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.SemanticKernel.TextGeneration; namespace BotSharp.Plugin.SemanticKernel.UnitTests.Helpers { - internal class SemanticKernelHelper : IChatCompletion, ITextCompletion, IAIService + internal class SemanticKernelHelper : IChatCompletionService, ITextGenerationService, IAIService { private Dictionary _attributes = new(); private readonly string _excepted; @@ -22,27 +17,30 @@ namespace BotSharp.Plugin.SemanticKernel.UnitTests.Helpers public IReadOnlyDictionary Attributes => _attributes; + IReadOnlyDictionary IAIService.Attributes => throw new NotImplementedException(); + public ChatHistory CreateNewChat(string? instructions = null) { return new ChatHistory(); } - public Task> GetChatCompletionsAsync(ChatHistory chat, AIRequestSettings? requestSettings = null, CancellationToken cancellationToken = default) + public Task> GetChatMessageContentsAsync(ChatHistory chatHistory, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default) { - return Task.FromResult>(new List { new ResultHelper(_excepted) }); + return Task.FromResult>(new List { new ChatMessageContent(AuthorRole.Assistant, _excepted) }); + } - public Task> GetCompletionsAsync(string text, AIRequestSettings? requestSettings = null, CancellationToken cancellationToken = default) - { - return Task.FromResult>(new List { new ResultHelper(_excepted) }); - } - - public IAsyncEnumerable GetStreamingChatCompletionsAsync(ChatHistory chat, AIRequestSettings? requestSettings = null, CancellationToken cancellationToken = default) + public IAsyncEnumerable GetStreamingChatMessageContentsAsync(ChatHistory chatHistory, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } - public IAsyncEnumerable GetStreamingCompletionsAsync(string text, AIRequestSettings? requestSettings = null, CancellationToken cancellationToken = default) + public Task> GetTextContentsAsync(string prompt, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default) + { + return Task.FromResult>(new List { new TextContent(_excepted) }); + } + + public IAsyncEnumerable GetStreamingTextContentsAsync(string prompt, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } diff --git a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelChatCompletionProviderTests.cs b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelChatCompletionProviderTests.cs index 8c564a1a..caf4746e 100644 --- a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelChatCompletionProviderTests.cs +++ b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelChatCompletionProviderTests.cs @@ -1,26 +1,25 @@ using BotSharp.Abstraction.Agents; -using BotSharp.Abstraction.Conversations.Models; -using Moq; using BotSharp.Abstraction.Agents.Enums; using BotSharp.Abstraction.Agents.Models; using BotSharp.Abstraction.Conversations; -using Microsoft.SemanticKernel.AI.ChatCompletion; -using Microsoft.SemanticKernel.AI; -using BotSharp.Plugin.SemanticKernel.UnitTests.Helpers; +using BotSharp.Abstraction.Conversations.Models; using BotSharp.Abstraction.Loggers; +using Microsoft.SemanticKernel; +using Microsoft.SemanticKernel.ChatCompletion; +using Moq; namespace BotSharp.Plugin.SemanticKernel.Tests { public class SemanticKernelChatCompletionProviderTests { - private readonly Mock _chatCompletionMock; + private readonly Mock _chatCompletionMock; private readonly Mock _servicesMock; private readonly Mock _tokenStatisticsMock; private readonly SemanticKernelChatCompletionProvider _provider; public SemanticKernelChatCompletionProviderTests() { - _chatCompletionMock = new Mock(); + _chatCompletionMock = new Mock(); _servicesMock = new Mock(); _tokenStatisticsMock = new Mock(); _provider = new SemanticKernelChatCompletionProvider(_chatCompletionMock.Object, _servicesMock.Object, _tokenStatisticsMock.Object); @@ -39,18 +38,18 @@ namespace BotSharp.Plugin.SemanticKernel.Tests _servicesMock.Setup(x => x.GetService(typeof(IEnumerable))) .Returns(new List()); var agentService = new Mock(); - agentService.Setup(x => x.RenderedInstruction(agent)).Returns(""); + agentService.Setup(x => x.RenderedInstruction(agent)).Returns("How can I help you?"); _servicesMock.Setup(x => x.GetService(typeof(IAgentService))) .Returns(agentService.Object); var chatHistoryMock = new Mock(); - _chatCompletionMock.Setup(x => x.CreateNewChat(It.IsAny())).Returns(chatHistoryMock.Object); - _chatCompletionMock.Setup(x => x.GetChatCompletionsAsync(chatHistoryMock.Object, It.IsAny(), It.IsAny())) - .ReturnsAsync(new List - { - new ResultHelper("How can I help you?") - }); - + //_chatCompletionMock.Setup(x => new ChatHistory(It.IsAny())).Returns(chatHistoryMock.Object); + + _chatCompletionMock.Setup(x => x.GetChatMessageContentsAsync(chatHistoryMock.Object, It.IsAny(), It.IsAny(), It.IsAny())) + .ReturnsAsync(new List + { + new ChatMessageContent(AuthorRole.Assistant,"How can I help you?") + }); // Act var result = await _provider.GetChatCompletions(agent, conversations); diff --git a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelPluginTests.cs b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelPluginTests.cs index a1ac3963..99d41024 100644 --- a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelPluginTests.cs +++ b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelPluginTests.cs @@ -20,10 +20,14 @@ namespace BotSharp.Plugin.SemanticKernel.Tests services.AddSingleton(config); var plugin = new SemanticKernelPlugin(); - services.AddScoped(x => Mock.Of()); - services.AddScoped(x => Mock.Of()); + services.AddScoped(x => Mock.Of()); + services.AddScoped(x => Mock.Of()); +#pragma warning disable SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. services.AddScoped(x => Mock.Of()); - services.AddScoped(x => Mock.Of()); +#pragma warning restore SKEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. +#pragma warning disable SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. + services.AddScoped(x => Mock.Of()); +#pragma warning restore SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. services.AddScoped(x => Mock.Of()); diff --git a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelTextCompletionProviderTests.cs b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelTextCompletionProviderTests.cs index 89188973..3eb8f8b5 100644 --- a/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelTextCompletionProviderTests.cs +++ b/tests/BotSharp.Plugin.SemanticKernel.UnitTests/SemanticKernelTextCompletionProviderTests.cs @@ -1,20 +1,7 @@ -using BotSharp.Abstraction.Conversations.Models; -using BotSharp.Plugin.SemanticKernel; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.SemanticKernel; -using Microsoft.SemanticKernel.AI.TextCompletion; -using Moq; -using System.Collections.Generic; -using System.Threading.Tasks; -using Xunit; -using BotSharp.Abstraction.Agents.Enums; -using BotSharp.Abstraction.Agents.Models; using BotSharp.Abstraction.Conversations; -using System; -using System.Linq; -using Microsoft; -using Microsoft.SemanticKernel.AI; using BotSharp.Plugin.SemanticKernel.UnitTests.Helpers; +using Microsoft.Extensions.DependencyInjection; +using Moq; namespace BotSharp.Plugin.SemanticKernel.Tests { From 5904794d641c2fc30203f08a2d29d041d28991ca Mon Sep 17 00:00:00 2001 From: geffzhang Date: Sat, 27 Jan 2024 23:35:27 +0800 Subject: [PATCH 3/7] feat: dockerfile --- dockerfiles/.env | 7 + dockerfiles/ARTICULATE.Dockerfile | 16 -- dockerfiles/DIALOGFLOW.Dockerfile | 16 -- dockerfiles/RASA.Dockerfile | 16 -- .../{Dockerfile => WebStarter.Dockerfile} | 0 dockerfiles/appsettings.json | 158 ++++++++++++++++++ .../docker-compose-articulateui-0.1.0.yml | 17 -- dockerfiles/docker-compose-articulateui.yml | 24 --- dockerfiles/docker-compose-core.yml | 9 - dockerfiles/docker-compose-rasaui.yml | 17 -- dockerfiles/docker-compose.yml | 17 ++ .../BotSharp.OpenAPI/BotSharp.OpenAPI.csproj | 16 +- .../BotSharp.Plugin.ChatHub.csproj | 5 +- .../BotSharp.Plugin.ChatbotUI.csproj | 1 + src/WebStarter/Program.cs | 2 +- 15 files changed, 195 insertions(+), 126 deletions(-) create mode 100644 dockerfiles/.env delete mode 100644 dockerfiles/ARTICULATE.Dockerfile delete mode 100644 dockerfiles/DIALOGFLOW.Dockerfile delete mode 100644 dockerfiles/RASA.Dockerfile rename dockerfiles/{Dockerfile => WebStarter.Dockerfile} (100%) create mode 100644 dockerfiles/appsettings.json delete mode 100644 dockerfiles/docker-compose-articulateui-0.1.0.yml delete mode 100644 dockerfiles/docker-compose-articulateui.yml delete mode 100644 dockerfiles/docker-compose-core.yml delete mode 100644 dockerfiles/docker-compose-rasaui.yml create mode 100644 dockerfiles/docker-compose.yml diff --git a/dockerfiles/.env b/dockerfiles/.env new file mode 100644 index 00000000..9e5f5f8a --- /dev/null +++ b/dockerfiles/.env @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dockerfiles/ARTICULATE.Dockerfile b/dockerfiles/ARTICULATE.Dockerfile deleted file mode 100644 index e4c684f2..00000000 --- a/dockerfiles/ARTICULATE.Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -# stage 1: build -FROM microsoft/dotnet AS botsharp-articulate -WORKDIR /source - -# copies the rest of your code -COPY . . - -# RUN dotnet build -RUN dotnet publish BotSharp.WebHost/BotSharp.WebHost.csproj --configuration ARTICULATE --output /app - -# copy Settings folder -WORKDIR /app -RUN mkdir App_Data/Projects - -# stage 2: run -ENTRYPOINT [ "dotnet", "BotSharp.WebHost.dll" ] diff --git a/dockerfiles/DIALOGFLOW.Dockerfile b/dockerfiles/DIALOGFLOW.Dockerfile deleted file mode 100644 index 716defb9..00000000 --- a/dockerfiles/DIALOGFLOW.Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -# stage 1: build -FROM microsoft/dotnet AS botsharp-dialogflow -WORKDIR /source - -# copies the rest of your code -COPY . . - -# RUN dotnet build -RUN dotnet publish BotSharp.WebHost/BotSharp.WebHost.csproj --configuration DIALOGFLOW --output /app - -# copy Settings folder -WORKDIR /app -RUN mkdir App_Data/Projects - -# stage 2: run -ENTRYPOINT [ "dotnet", "BotSharp.WebHost.dll" ] diff --git a/dockerfiles/RASA.Dockerfile b/dockerfiles/RASA.Dockerfile deleted file mode 100644 index c9a5b707..00000000 --- a/dockerfiles/RASA.Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -# stage 1: build -FROM microsoft/dotnet AS botsharp-rasa -WORKDIR /source - -# copies the rest of your code -COPY . . - -# RUN dotnet build -RUN dotnet publish BotSharp.WebHost/BotSharp.WebHost.csproj --configuration RASA --output /app - -# copy Settings folder -WORKDIR /app -RUN mkdir App_Data/Projects - -# stage 2: run -ENTRYPOINT [ "dotnet", "BotSharp.WebHost.dll" ] diff --git a/dockerfiles/Dockerfile b/dockerfiles/WebStarter.Dockerfile similarity index 100% rename from dockerfiles/Dockerfile rename to dockerfiles/WebStarter.Dockerfile diff --git a/dockerfiles/appsettings.json b/dockerfiles/appsettings.json new file mode 100644 index 00000000..380008ef --- /dev/null +++ b/dockerfiles/appsettings.json @@ -0,0 +1,158 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + + "Jwt": { + "Issuer": "botsharp", + "Audience": "botsharp", + "Key": "31ba6052aa6f4569901facc3a41fcb4a" + }, + + "LlmProviders": [ + { + "Provider": "azure-openai", + "Models": [ + { + "Name": "gpt-35-turbo", + "ApiKey": "", + "Endpoint": "https://ai4c-demo.openai.azure.com/", + "Type": "chat", + "PromptCost": 0.0015, + "CompletionCost": 0.002 + }, + { + "Name": "gpt-35-turbo", + "ApiKey": "", + "Endpoint": "https://ai4c-demo.openai.azure.com/", + "Type": "text", + "PromptCost": 0.0015, + "CompletionCost": 0.002 + } + ] + } + ], + + "Router": { + }, + + "Evaluator": { + "AgentId": "dfd9b46d-d00c-40af-8a75-3fbdc2b89869" + }, + + "Agent": { + "DataDir": "agents", + "TemplateFormat": "liquid", + "HostAgentId": "01e2fc5c-2c89-4ec7-8470-7688608b496c", + "LlmConfig": { + "Provider": "azure-openai", + "Model": "gpt-35-turbo" + } + }, + + "Conversation": { + "DataDir": "conversations", + "ShowVerboseLog": false, + "EnableLlmCompletionLog": false, + "EnableExecutionLog": true + }, + + "LlamaSharp": { + "Interactive": true, + "ModelDir": "C:/Users/haipi/Downloads", + "DefaultModel": "llama-2-7b-chat.Q8_0.gguf", + "MaxContextLength": 1024, + "NumberOfGpuLayer": 20 + }, + + "AzureOpenAi": { + }, + + "GoogleAi": { + "PaLM": { + "Endpoint": "https://generativelanguage.googleapis.com", + "ApiKey": "" + } + }, + + "HuggingFace": { + "Endpoint": "https://api-inference.huggingface.co", + "Model": "tiiuae/falcon-180B-chat", + "Token": "" + }, + + "MetaAi": { + "fastText": { + "ModelPath": "dbpedia.ftz" + } + }, + + "RoutingSpeeder": { + }, + + "MetaMessenger": { + "Endpoint": "https://graph.facebook.com", + "ApiVersion": "v17.0", + "PageId": "", + "PageAccessToken": "" + }, + + "Twilio": { + "PhoneNumber": "+1", + "AccountSID": "", + "AuthToken": "", + "CallbackHost": "https://", + "AgentId": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a" + }, + + "Database": { + "Default": "FileRepository", + "TablePrefix": "BotSharp", + "BotSharpMongoDb": "", + "FileRepository": "data", + "Assemblies": [ "BotSharp.Core" ] + }, + + "Qdrant": { + "Url": "", + "ApiKey": "" + }, + + "WeChat": { + "AgentId": "437bed34-1169-4833-95ce-c24b8b56154a", + "Token": "#{Token}#", + "EncodingAESKey": "#{EncodingAESKey}#", + "WeixinAppId": "#{WeixinAppId}#", + "WeixinAppSecret": "#{WeixinAppSecret}#" + }, + + "KnowledgeBase": { + "VectorDb": "MemVectorDatabase", + "TextEmbedding": "fastTextEmbeddingProvider", + "TextCompletion": "AzureOpenAI.Providers.TextCompletionProvider", + "Pdf2TextConverter": "PigPdf2TextConverter" + }, + + "PluginLoader": { + "Assemblies": [ + "BotSharp.Plugin.MongoStorage", + "BotSharp.Core", + "BotSharp.Plugin.AzureOpenAI", + "BotSharp.Plugin.GoogleAI", + "BotSharp.Plugin.MetaAI", + "BotSharp.Plugin.MetaMessenger", + "BotSharp.Plugin.HuggingFace", + "BotSharp.Plugin.KnowledgeBase", + "BotSharp.Plugin.Qdrant", + "BotSharp.Plugin.ChatHub", + "BotSharp.Plugin.WeChat", + "BotSharp.Plugin.PizzaBot", + "BotSharp.Plugin.WebDriver", + "BotSharp.Plugin.LLamaSharp" + ] + } +} diff --git a/dockerfiles/docker-compose-articulateui-0.1.0.yml b/dockerfiles/docker-compose-articulateui-0.1.0.yml deleted file mode 100644 index 7e3c9142..00000000 --- a/dockerfiles/docker-compose-articulateui-0.1.0.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: '3.0' - -services: - ui: - image: botsharpdocker/botsharp-articulateui:0.1.0 - ports: ['0.0.0.0:3000:3000'] - networks: ['botsharp-network'] - environment: - - rasanluendpoint=http://botsharp:7500 - - botsharp: - image: botsharpdocker/botsharp-articulate:0.1.0 - ports: ['0.0.0.0:7500:7500'] - networks: ['botsharp-network'] - - -networks: {botsharp-network: {}} diff --git a/dockerfiles/docker-compose-articulateui.yml b/dockerfiles/docker-compose-articulateui.yml deleted file mode 100644 index 276c443f..00000000 --- a/dockerfiles/docker-compose-articulateui.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: '3.0' - -services: - ui: - image: samtecspg/articulate-ui:0.12.1 - ports: ['0.0.0.0:3000:3000'] - networks: ['botsharp-network'] - environment: - - API_URL - - api: - image: samtecspg/articulate-api:0.12.1 - ports: ['0.0.0.0:7500:7500'] - networks: ['botsharp-network'] - entrypoint: ['node', 'start.js'] - environment: - - SWAGGER_BASE_PATH - - botsharp: - image: botsharpdocker/botsharp-rasa:latest - ports: ['0.0.0.0:5000:5000'] - networks: ['botsharp-network'] - -networks: {botsharp-network: {}} diff --git a/dockerfiles/docker-compose-core.yml b/dockerfiles/docker-compose-core.yml deleted file mode 100644 index dc5c6c77..00000000 --- a/dockerfiles/docker-compose-core.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: '3.0' - -services: - botsharp: - image: botsharpdocker/botsharp-core:0.2.0 - ports: ['0.0.0.0:3112:3112'] - networks: ['botsharp-network'] - -networks: {botsharp-network: {}} diff --git a/dockerfiles/docker-compose-rasaui.yml b/dockerfiles/docker-compose-rasaui.yml deleted file mode 100644 index 8248c0d7..00000000 --- a/dockerfiles/docker-compose-rasaui.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: '3.0' - -services: - ui: - image: botsharpdocker/botsharp-rasaui:latest - ports: ['0.0.0.0:5001:5001'] - networks: ['botsharp-network'] - environment: - - rasanluendpoint=http://botsharp:5000 - - botsharp: - image: botsharpdocker/botsharp-rasa:latest - ports: ['0.0.0.0:5000:5000'] - networks: ['botsharp-network'] - - -networks: {botsharp-network: {}} diff --git a/dockerfiles/docker-compose.yml b/dockerfiles/docker-compose.yml new file mode 100644 index 00000000..983979a7 --- /dev/null +++ b/dockerfiles/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.0' + +services: + botsharp: + image: botsharpdocker/botsharp-core:0.23 + build: + context: ../ + dockerfile: dockerfiles/WebStarter.Dockerfile + ports: + - 5015:5015 + env_file: + - ./.env + volumes: + - ./appsettings.json:/app/appsettings.json + networks: ['botsharp-network'] + +networks: {botsharp-network: {}} diff --git a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj index 3223688a..e1bf2e4c 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj +++ b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj @@ -1,7 +1,7 @@ - net8.0 + net8.0 enable enable $(LangVersion) @@ -16,16 +16,20 @@ \ - - - - + + + + - + + + + + diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/BotSharp.Plugin.ChatHub.csproj b/src/Plugins/BotSharp.Plugin.ChatHub/BotSharp.Plugin.ChatHub.csproj index af5b2146..52358e1d 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/BotSharp.Plugin.ChatHub.csproj +++ b/src/Plugins/BotSharp.Plugin.ChatHub/BotSharp.Plugin.ChatHub.csproj @@ -16,12 +16,9 @@ \ - - - - + diff --git a/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj b/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj index 8f70adb1..4d529420 100644 --- a/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj +++ b/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj @@ -11,6 +11,7 @@ + diff --git a/src/WebStarter/Program.cs b/src/WebStarter/Program.cs index fbe924a5..0bd669ac 100644 --- a/src/WebStarter/Program.cs +++ b/src/WebStarter/Program.cs @@ -24,7 +24,7 @@ builder.Host.UseSerilog(); builder.Services.AddBotSharpCore(builder.Configuration) .AddBotSharpOpenAPI(builder.Configuration, new[] { - "http://localhost:5015", + "http://0.0.0.0:5015", "https://botsharp.scisharpstack.org", "https://chat.scisharpstack.org" }, builder.Environment, true) From 54dc4f136c9ab4d30c5608e1baa7e1f84566eda0 Mon Sep 17 00:00:00 2001 From: geffzhang Date: Sun, 28 Jan 2024 00:00:31 +0800 Subject: [PATCH 4/7] Update WebStarter.Dockerfile --- dockerfiles/WebStarter.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/WebStarter.Dockerfile b/dockerfiles/WebStarter.Dockerfile index 856284a1..3b74890c 100644 --- a/dockerfiles/WebStarter.Dockerfile +++ b/dockerfiles/WebStarter.Dockerfile @@ -1,6 +1,6 @@ #See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base USER app WORKDIR /app EXPOSE 8080 From 07afb00793a9a14fcee8f0bb88640f6b16cdc020 Mon Sep 17 00:00:00 2001 From: geffzhang Date: Sun, 28 Jan 2024 00:04:31 +0800 Subject: [PATCH 5/7] Update docker-compose.yml --- dockerfiles/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/docker-compose.yml b/dockerfiles/docker-compose.yml index 983979a7..c5a09350 100644 --- a/dockerfiles/docker-compose.yml +++ b/dockerfiles/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.0' services: botsharp: - image: botsharpdocker/botsharp-core:0.23 + image: botsharpdocker/botsharp-core:latest build: context: ../ dockerfile: dockerfiles/WebStarter.Dockerfile From d01c102e63328d78c0079f6372c7d091f6523716 Mon Sep 17 00:00:00 2001 From: geffzhang Date: Mon, 29 Jan 2024 22:03:51 +0800 Subject: [PATCH 6/7] Update docker-compose.yml --- dockerfiles/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/docker-compose.yml b/dockerfiles/docker-compose.yml index c5a09350..d2f660bd 100644 --- a/dockerfiles/docker-compose.yml +++ b/dockerfiles/docker-compose.yml @@ -7,7 +7,7 @@ services: context: ../ dockerfile: dockerfiles/WebStarter.Dockerfile ports: - - 5015:5015 + - 8080:8080 env_file: - ./.env volumes: From 7e5228ddcb7efe5a7b6f0e18966ddb19be6da051 Mon Sep 17 00:00:00 2001 From: geffzhang Date: Mon, 29 Jan 2024 23:04:06 +0800 Subject: [PATCH 7/7] Update appsettings.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit upgrade .net 8 error:IDX10720: Unable to create KeyedHashAlgorithm for algorithmHS256'. the key size must be greater than: '256' bits, key has '152' bits. Arg ParamName Name ,This means that the key needs to be more than 256 bits, that is, the set key is too short --- src/WebStarter/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json index 95eb7401..310d6908 100644 --- a/src/WebStarter/appsettings.json +++ b/src/WebStarter/appsettings.json @@ -10,7 +10,7 @@ "Jwt": { "Issuer": "botsharp", "Audience": "botsharp", - "Key": "31ba6052aa6f4569901facc3a41fcb4a" + "Key": "31ba6052aa6f4569901facc3a41fcb4adfd9b46dd00c40af8a753fbdc2b89869" }, "LlmProviders": [