Skip to content

Commit ebecfe7

Browse files
committed
Rename GetResponseFromChatbot to GetResponseFromChatbotAsync
1 parent 1265387 commit ebecfe7

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

OpenAI_API/Chat/Conversation.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public OpenAI_API.Models.Model Model
4040
}
4141

4242
/// <summary>
43-
/// After calling <see cref="GetResponseFromChatbot"/>, this contains the full response object which can contain useful metadata like token usages, <see cref="ChatChoice.FinishReason"/>, etc. This is overwritten with every call to <see cref="GetResponseFromChatbot"/> and only contains the most recent result.
43+
/// After calling <see cref="GetResponseFromChatbotAsync"/>, this contains the full response object which can contain useful metadata like token usages, <see cref="ChatChoice.FinishReason"/>, etc. This is overwritten with every call to <see cref="GetResponseFromChatbotAsync"/> and only contains the most recent result.
4444
/// </summary>
4545
public ChatResult MostResentAPIResult { get; private set; }
4646

@@ -117,7 +117,7 @@ public void AppendMessage(ChatMessage message)
117117
/// Calls the API to get a response, which is appended to the current chat's <see cref="Messages"/> as an <see cref="ChatMessageRole.Assistant"/> <see cref="ChatMessage"/>.
118118
/// </summary>
119119
/// <returns>The string of the response from the chatbot API</returns>
120-
public async Task<string> GetResponseFromChatbot()
120+
public async Task<string> GetResponseFromChatbotAsync()
121121
{
122122
ChatRequest req = new ChatRequest(RequestParameters);
123123
req.Messages = _Messages.ToList();
@@ -134,6 +134,14 @@ public async Task<string> GetResponseFromChatbot()
134134
return null;
135135
}
136136

137+
/// <summary>
138+
/// OBSOLETE: GetResponseFromChatbot() has been renamed to <see cref="GetResponseFromChatbotAsync"/> to follow .NET naming guidelines. This alias will be removed in a future version.
139+
/// </summary>
140+
/// <returns>The string of the response from the chatbot API</returns>
141+
[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)]
142+
public Task<string> GetResponseFromChatbot() => GetResponseFromChatbotAsync();
143+
144+
137145
#endregion
138146

139147
#region Streaming

OpenAI_Tests/ChatEndpointTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ public void ChatBackAndForth(string model)
139139
chat.AppendUserInput("Is this an animal? House");
140140
chat.AppendExampleChatbotOutput("No");
141141
chat.AppendUserInput("Is this an animal? Dog");
142-
string res = chat.GetResponseFromChatbot().Result;
142+
string res = chat.GetResponseFromChatbotAsync().Result;
143143
Assert.NotNull(res);
144144
Assert.IsNotEmpty(res);
145145
Assert.AreEqual("Yes", res.Trim());
146146
chat.AppendUserInput("Is this an animal? Chair");
147-
res = chat.GetResponseFromChatbot().Result;
147+
res = chat.GetResponseFromChatbotAsync().Result;
148148
Assert.NotNull(res);
149149
Assert.IsNotEmpty(res);
150150
Assert.AreEqual("No", res.Trim());
@@ -164,12 +164,12 @@ public void ChatWithNames()
164164
chat.AppendUserInputWithName("Cindy", "Is John here? Answer yes or no.");
165165
chat.AppendExampleChatbotOutput("Yes");
166166
chat.AppendUserInputWithName("Cindy", "Is Monica here? Answer yes or no.");
167-
string res = chat.GetResponseFromChatbot().Result;
167+
string res = chat.GetResponseFromChatbotAsync().Result;
168168
Assert.NotNull(res);
169169
Assert.IsNotEmpty(res);
170170
Assert.That(res.ToLower().Contains("no"));
171171
chat.AppendUserInputWithName("Cindy", "Is Edward here? Answer yes or no.");
172-
res = chat.GetResponseFromChatbot().Result;
172+
res = chat.GetResponseFromChatbotAsync().Result;
173173
Assert.NotNull(res);
174174
Assert.IsNotEmpty(res);
175175
Assert.That(res.ToLower().Contains("yes"));

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Console.WriteLine(result);
3535

3636
Added support for GPT4, streaming conversations with ChatGPT, and supporting [`IHttpClientFactory`](#ihttpclientfactory).
3737

38-
Now also should work with the Azure OpenAI Service, although this is untested. See the [Azure](#azure) section for further details.
38+
Should work with the Azure OpenAI Service. See the [Azure](#azure) section for further details.
3939

4040
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!
4141

@@ -101,13 +101,13 @@ chat.AppendExampleChatbotOutput("No");
101101
// now let's ask it a question'
102102
chat.AppendUserInput("Is this an animal? Dog");
103103
// and get the response
104-
string response = await chat.GetResponseFromChatbot();
104+
string response = await chat.GetResponseFromChatbotAsync();
105105
Console.WriteLine(response); // "Yes"
106106
107107
// and continue the conversation by asking another
108108
chat.AppendUserInput("Is this an animal? Chair");
109109
// and get another response
110-
response = await chat.GetResponseFromChatbot();
110+
response = await chat.GetResponseFromChatbotAsync();
111111
Console.WriteLine(response); // "No"
112112
113113
// the entire chat history is available in chat.Messages

0 commit comments

Comments
 (0)