From ebecfe7afe4ba46d84785be010a268131f060033 Mon Sep 17 00:00:00 2001 From: Roger Date: Sun, 2 Apr 2023 02:21:19 -0700 Subject: [PATCH] Rename GetResponseFromChatbot to GetResponseFromChatbotAsync --- OpenAI_API/Chat/Conversation.cs | 12 ++++++++++-- OpenAI_Tests/ChatEndpointTests.cs | 8 ++++---- README.md | 6 +++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/OpenAI_API/Chat/Conversation.cs b/OpenAI_API/Chat/Conversation.cs index f47b8ba..babc9b1 100644 --- a/OpenAI_API/Chat/Conversation.cs +++ b/OpenAI_API/Chat/Conversation.cs @@ -40,7 +40,7 @@ public OpenAI_API.Models.Model Model } /// - /// After calling , this contains the full response object which can contain useful metadata like token usages, , etc. This is overwritten with every call to and only contains the most recent result. + /// After calling , this contains the full response object which can contain useful metadata like token usages, , etc. This is overwritten with every call to and only contains the most recent result. /// public ChatResult MostResentAPIResult { get; private set; } @@ -117,7 +117,7 @@ public void AppendMessage(ChatMessage message) /// Calls the API to get a response, which is appended to the current chat's as an . /// /// The string of the response from the chatbot API - public async Task GetResponseFromChatbot() + public async Task GetResponseFromChatbotAsync() { ChatRequest req = new ChatRequest(RequestParameters); req.Messages = _Messages.ToList(); @@ -134,6 +134,14 @@ public async Task GetResponseFromChatbot() return null; } + /// + /// OBSOLETE: GetResponseFromChatbot() has been renamed to to follow .NET naming guidelines. This alias will be removed in a future version. + /// + /// The string of the response from the chatbot API + [Obsolete("Conversation.GetResponseFromChatbot() has been renamed to GetResponseFromChatbotAsync to follow .NET naming guidelines. Please update any references to GetResponseFromChatbotAsync(). This alias will be removed in a future version.", false)] + public Task GetResponseFromChatbot() => GetResponseFromChatbotAsync(); + + #endregion #region Streaming diff --git a/OpenAI_Tests/ChatEndpointTests.cs b/OpenAI_Tests/ChatEndpointTests.cs index d4652d4..0c5f1bb 100644 --- a/OpenAI_Tests/ChatEndpointTests.cs +++ b/OpenAI_Tests/ChatEndpointTests.cs @@ -139,12 +139,12 @@ public void ChatBackAndForth(string model) chat.AppendUserInput("Is this an animal? House"); chat.AppendExampleChatbotOutput("No"); chat.AppendUserInput("Is this an animal? Dog"); - string res = chat.GetResponseFromChatbot().Result; + string res = chat.GetResponseFromChatbotAsync().Result; Assert.NotNull(res); Assert.IsNotEmpty(res); Assert.AreEqual("Yes", res.Trim()); chat.AppendUserInput("Is this an animal? Chair"); - res = chat.GetResponseFromChatbot().Result; + res = chat.GetResponseFromChatbotAsync().Result; Assert.NotNull(res); Assert.IsNotEmpty(res); Assert.AreEqual("No", res.Trim()); @@ -164,12 +164,12 @@ public void ChatWithNames() chat.AppendUserInputWithName("Cindy", "Is John here? Answer yes or no."); chat.AppendExampleChatbotOutput("Yes"); chat.AppendUserInputWithName("Cindy", "Is Monica here? Answer yes or no."); - string res = chat.GetResponseFromChatbot().Result; + string res = chat.GetResponseFromChatbotAsync().Result; Assert.NotNull(res); Assert.IsNotEmpty(res); Assert.That(res.ToLower().Contains("no")); chat.AppendUserInputWithName("Cindy", "Is Edward here? Answer yes or no."); - res = chat.GetResponseFromChatbot().Result; + res = chat.GetResponseFromChatbotAsync().Result; Assert.NotNull(res); Assert.IsNotEmpty(res); Assert.That(res.ToLower().Contains("yes")); diff --git a/README.md b/README.md index c22dc3a..eb34df6 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Console.WriteLine(result); Added support for GPT4, streaming conversations with ChatGPT, and supporting [`IHttpClientFactory`](#ihttpclientfactory). -Now also should work with the Azure OpenAI Service, although this is untested. See the [Azure](#azure) section for further details. +Should work with the Azure OpenAI Service. See the [Azure](#azure) section for further details. Thank you [@babrekel](https://github.com/babrekel), [@JasonWei512](https://github.com/JasonWei512), [@GotMike](https://github.com/gotmike), [@megalon](https://github.com/megalon), [@stonelv](https://github.com/stonelv), [@ncface](https://github.com/ncface), [@KeithHenry](https://github.com/KeithHenry), [@gmilano](https://github.com/gmilano), [@metjuperry](https://github.com/metjuperry), [@pandapknaepel](https://github.com/pandapknaepel), and [@Alexei000](https://github.com/Alexei000) for your contributions! @@ -101,13 +101,13 @@ chat.AppendExampleChatbotOutput("No"); // now let's ask it a question' chat.AppendUserInput("Is this an animal? Dog"); // and get the response -string response = await chat.GetResponseFromChatbot(); +string response = await chat.GetResponseFromChatbotAsync(); Console.WriteLine(response); // "Yes" // and continue the conversation by asking another chat.AppendUserInput("Is this an animal? Chair"); // and get another response -response = await chat.GetResponseFromChatbot(); +response = await chat.GetResponseFromChatbotAsync(); Console.WriteLine(response); // "No" // the entire chat history is available in chat.Messages