From 796bff8e494356e8ffcbf843f2cf6076ebaf34f5 Mon Sep 17 00:00:00 2001 From: zpc Date: Sat, 29 Jun 2024 10:43:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HuanMengProject.sln | 9 ++++++++- .../HuanMnegopneaiTest/HuanMnegopneaiTest.csproj | 14 ++++++++++++++ src/5-console/HuanMnegopneaiTest/Program.cs | 14 ++++++++++++++ .../api/TextGenerationRequestHttpApiTests.cs | 8 +++++--- 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 src/5-console/HuanMnegopneaiTest/HuanMnegopneaiTest.csproj create mode 100644 src/5-console/HuanMnegopneaiTest/Program.cs diff --git a/HuanMengProject.sln b/HuanMengProject.sln index 2ea6513..1ca6d3d 100644 --- a/HuanMengProject.sln +++ b/HuanMengProject.sln @@ -29,7 +29,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMeng.StableDiffusion.Te EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMeng.StableDiffusion.TextGenerationTests", "src\9-test\HuanMeng.StableDiffusion.TextGenerationTests\HuanMeng.StableDiffusion.TextGenerationTests.csproj", "{054AFFF5-D25E-4EC7-A135-050EEE7F7FA0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextGenerationApi", "src\2-api\TextGenerationApi\TextGenerationApi.csproj", "{A9C5939E-D239-4AB8-9380-7E76166326D9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TextGenerationApi", "src\2-api\TextGenerationApi\TextGenerationApi.csproj", "{A9C5939E-D239-4AB8-9380-7E76166326D9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HuanMnegopneaiTest", "src\5-console\HuanMnegopneaiTest\HuanMnegopneaiTest.csproj", "{D2A74CFA-8A03-4272-89C7-C01830D183F1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -61,6 +63,10 @@ Global {A9C5939E-D239-4AB8-9380-7E76166326D9}.Debug|Any CPU.Build.0 = Debug|Any CPU {A9C5939E-D239-4AB8-9380-7E76166326D9}.Release|Any CPU.ActiveCfg = Release|Any CPU {A9C5939E-D239-4AB8-9380-7E76166326D9}.Release|Any CPU.Build.0 = Release|Any CPU + {D2A74CFA-8A03-4272-89C7-C01830D183F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2A74CFA-8A03-4272-89C7-C01830D183F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2A74CFA-8A03-4272-89C7-C01830D183F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2A74CFA-8A03-4272-89C7-C01830D183F1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -79,6 +85,7 @@ Global {CFE784F8-3889-4698-8719-55BAB1724486} = {DD14191F-22CE-48D8-A944-B8A41C97ACD4} {054AFFF5-D25E-4EC7-A135-050EEE7F7FA0} = {8D39E84B-2810-41D7-AFE6-0A58E09E34C3} {A9C5939E-D239-4AB8-9380-7E76166326D9} = {0C0B6EB5-E41D-46D9-9F60-90D320A2EEF3} + {D2A74CFA-8A03-4272-89C7-C01830D183F1} = {F34C5BC4-8810-4D6A-B003-AFE12D7ED4BA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4A1DC406-AFAA-4884-859C-51B9B26E37FC} diff --git a/src/5-console/HuanMnegopneaiTest/HuanMnegopneaiTest.csproj b/src/5-console/HuanMnegopneaiTest/HuanMnegopneaiTest.csproj new file mode 100644 index 0000000..c6ef519 --- /dev/null +++ b/src/5-console/HuanMnegopneaiTest/HuanMnegopneaiTest.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/src/5-console/HuanMnegopneaiTest/Program.cs b/src/5-console/HuanMnegopneaiTest/Program.cs new file mode 100644 index 0000000..b787cf0 --- /dev/null +++ b/src/5-console/HuanMnegopneaiTest/Program.cs @@ -0,0 +1,14 @@ +// See https://aka.ms/new-console-template for more information +using OpenAI_API.Models; +using System; + +Console.WriteLine("Hello, World!"); +//var api = new OpenAI_API.OpenAIAPI("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"); +var api = new OpenAI_API.OpenAIAPI("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"); +//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 +var chat = api.Chat.CreateConversation(); +chat.Model = Model.Davinci; +chat.RequestParameters.Temperature = 0; +chat.AppendUserInput("哈喽"); +var result = await chat.GetResponseFromChatbotAsync(); +Console.WriteLine(result); \ No newline at end of file diff --git a/src/9-test/HuanMeng.StableDiffusion.TextGenerationTests/api/TextGenerationRequestHttpApiTests.cs b/src/9-test/HuanMeng.StableDiffusion.TextGenerationTests/api/TextGenerationRequestHttpApiTests.cs index 59d8332..b3a2ed8 100644 --- a/src/9-test/HuanMeng.StableDiffusion.TextGenerationTests/api/TextGenerationRequestHttpApiTests.cs +++ b/src/9-test/HuanMeng.StableDiffusion.TextGenerationTests/api/TextGenerationRequestHttpApiTests.cs @@ -1,4 +1,6 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using HuanMeng.StableDiffusion.TextGeneration.Abstractions; + +using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; @@ -14,12 +16,12 @@ namespace HuanMeng.StableDiffusion.TextGeneration.api.Tests [TestMethod()] public async Task SendMessageAsyncTest() { - TextGenerationRequestHttpApiStream textGenerationRequestHttpApi = new TextGenerationRequestHttpApi(); + TextGenerationRequestAbstract textGenerationRequestHttpApi = new TextGenerationRequestHttpApi(""); await foreach (var item in textGenerationRequestHttpApi.SendMessageAsync()) { Console.WriteLine(item); } - Console.WriteLine(textGenerationRequestHttpApi.textGenerationRequestHttpModel.Choices[0].Delta.Content); + Console.WriteLine(textGenerationRequestHttpApi.textGenerationModel.Model); } } } \ No newline at end of file