From 8a25fe6c86a49fd9bcf156f6a9e885d03dcf5cb8 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Sat, 3 Jun 2023 12:01:38 -0500 Subject: [PATCH] test 13B --- .../AzureAiServiceCollectionExtensions.cs | 2 +- .../BotSharp.Platform.Native.csproj | 2 +- .../BotSharplServiceCollectionExtensions.cs | 2 +- .../Handlers/ChatCompletionHandler.cs | 7 ++++--- src/WebStarter/Program.cs | 4 ++-- src/WebStarter/appsettings.json | 3 ++- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Plugins/Platforms/BotSharp.Platform.AureAi/AzureAiServiceCollectionExtensions.cs b/src/Plugins/Platforms/BotSharp.Platform.AureAi/AzureAiServiceCollectionExtensions.cs index e9b4fb49..5d97f1de 100644 --- a/src/Plugins/Platforms/BotSharp.Platform.AureAi/AzureAiServiceCollectionExtensions.cs +++ b/src/Plugins/Platforms/BotSharp.Platform.AureAi/AzureAiServiceCollectionExtensions.cs @@ -7,7 +7,7 @@ namespace BotSharp.Core; public static class AzureAiServiceCollectionExtensions { - public static IServiceCollection AddAzureOpenAi(this IServiceCollection services, IConfiguration config) + public static IServiceCollection AddAzureOpenAiPlatform(this IServiceCollection services, IConfiguration config) { services.AddSingleton(x => { diff --git a/src/Plugins/Platforms/BotSharp.Platform.Native/BotSharp.Platform.Native.csproj b/src/Plugins/Platforms/BotSharp.Platform.Native/BotSharp.Platform.Native.csproj index ba00cb5c..38285e33 100644 --- a/src/Plugins/Platforms/BotSharp.Platform.Native/BotSharp.Platform.Native.csproj +++ b/src/Plugins/Platforms/BotSharp.Platform.Native/BotSharp.Platform.Native.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Plugins/Platforms/BotSharp.Platform.Native/BotSharplServiceCollectionExtensions.cs b/src/Plugins/Platforms/BotSharp.Platform.Native/BotSharplServiceCollectionExtensions.cs index cf32c3e8..6571e409 100644 --- a/src/Plugins/Platforms/BotSharp.Platform.Native/BotSharplServiceCollectionExtensions.cs +++ b/src/Plugins/Platforms/BotSharp.Platform.Native/BotSharplServiceCollectionExtensions.cs @@ -8,7 +8,7 @@ namespace BotSharp.Core; public static class BotSharplServiceCollectionExtensions { - public static IServiceCollection AddBotSharpCommunityPlatform(this IServiceCollection services, IConfiguration config) + public static IServiceCollection AddBotSharpPlatform(this IServiceCollection services, IConfiguration config) { services.AddSingleton(x => { diff --git a/src/Plugins/Platforms/BotSharp.Platform.Native/Handlers/ChatCompletionHandler.cs b/src/Plugins/Platforms/BotSharp.Platform.Native/Handlers/ChatCompletionHandler.cs index f03e264a..7c076bac 100644 --- a/src/Plugins/Platforms/BotSharp.Platform.Native/Handlers/ChatCompletionHandler.cs +++ b/src/Plugins/Platforms/BotSharp.Platform.Native/Handlers/ChatCompletionHandler.cs @@ -36,9 +36,10 @@ public class ChatCompletionHandler : IChatCompletionHandler Func onChunkReceived) { string totalResponse = ""; - // var prompt = GetInstruction(); - // var content = string.Join("\n", conversations.Select(x => $"\n{x.Content}")); - foreach (var response in _model.Chat(conversations.Last().Content, "", "UTF-8")) + var prompt = GetInstruction(); + var content = string.Join(". ", conversations.Select(x => $"{x.Role}: {x.Content.Replace("user:", "")}")).Trim(); + content += ". assistant: "; + foreach (var response in _model.Chat(content, prompt, "UTF-8")) { Console.Write(response); totalResponse += response; diff --git a/src/WebStarter/Program.cs b/src/WebStarter/Program.cs index 1cc3ca61..72b1fbdc 100644 --- a/src/WebStarter/Program.cs +++ b/src/WebStarter/Program.cs @@ -12,8 +12,8 @@ builder.Services.AddHttpContextAccessor(); // Add BotSharp builder.Services.AddBotSharp(builder.Configuration); -builder.Services.AddBotSharpCommunityPlatform(builder.Configuration); -// builder.Services.AddAzureOpenAi(builder.Configuration); +builder.Services.AddBotSharpPlatform(builder.Configuration); +// builder.Services.AddAzureOpenAiPlatform(builder.Configuration); builder.Services.AddCors(options => { diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json index 4a5ae1b7..72eb9980 100644 --- a/src/WebStarter/appsettings.json +++ b/src/WebStarter/appsettings.json @@ -17,7 +17,8 @@ "ModelPath": "C:\\Users\\haipi\\Downloads\\ggml-vic13b-q5_1.bin", "InstructionFile": "Prompts\\chat-with-bob.txt", "ChatSampleFile": "Prompts\\chat-samples.txt", - "MaxContextLength": 512 + "MaxContextLength": 2048, + "NumberOfGpuLayer": 10 }, "AzureAi": {