From 478475a3f9c6b1fb8d0dc354153a7d886473651f Mon Sep 17 00:00:00 2001 From: Raphael Moreira Date: Mon, 23 Oct 2023 16:20:13 -0300 Subject: [PATCH] Update ChatGpt.cs to returning `List` --- CSharp/OpenAi/ChatGpt.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CSharp/OpenAi/ChatGpt.cs b/CSharp/OpenAi/ChatGpt.cs index 201626d..2cee59a 100644 --- a/CSharp/OpenAi/ChatGpt.cs +++ b/CSharp/OpenAi/ChatGpt.cs @@ -23,7 +23,7 @@ public sealed class ChatGpt _httpClient.DefaultRequestHeaders.Add(AcceptHeaderRequest, ApplicationJsonMediaTypeRequest); } - public async Task?> GetReasonsToMyBitch() + public async Task?> GetReasonsToMyBitch() { const string prompt = "Return only a CSV list separated by semicolons, of phrases with various reasons that justify " + "my delay in leaving work, to my wife. Do not repeat this question in your response. " + @@ -32,7 +32,7 @@ public sealed class ChatGpt return await DoRequest(prompt); } - public async Task?> GetExcusesToMyMates() + public async Task?> GetExcusesToMyMates() { const string prompt = "Return only a CSV list separated by semicolons, of phrases with various reasons that " + "justify why I can't go out for a drink with my friends. Do not repeat this question in " + @@ -41,7 +41,7 @@ public sealed class ChatGpt return await DoRequest(prompt); } - private async Task?> DoRequest(string prompt) + private async Task?> DoRequest(string prompt) { var promptJson = new CompletionChatRequest { @@ -58,6 +58,6 @@ public sealed class ChatGpt var responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); var response = JsonSerializer.Deserialize(responseContent, _serializerOptions); - return response?.Content?.Split(";"); + return response?.Content?.Split(";").ToList(); } -} \ No newline at end of file +}