Skip to content

Commit 478475a

Browse files
Update ChatGpt.cs to returning List
1 parent 5737cb2 commit 478475a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

CSharp/OpenAi/ChatGpt.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public ChatGpt()
2323
_httpClient.DefaultRequestHeaders.Add(AcceptHeaderRequest, ApplicationJsonMediaTypeRequest);
2424
}
2525

26-
public async Task<IEnumerable<string>?> GetReasonsToMyBitch()
26+
public async Task<List<string>?> GetReasonsToMyBitch()
2727
{
2828
const string prompt = "Return only a CSV list separated by semicolons, of phrases with various reasons that justify " +
2929
"my delay in leaving work, to my wife. Do not repeat this question in your response. " +
@@ -32,7 +32,7 @@ public ChatGpt()
3232
return await DoRequest(prompt);
3333
}
3434

35-
public async Task<IEnumerable<string>?> GetExcusesToMyMates()
35+
public async Task<List<string>?> GetExcusesToMyMates()
3636
{
3737
const string prompt = "Return only a CSV list separated by semicolons, of phrases with various reasons that " +
3838
"justify why I can't go out for a drink with my friends. Do not repeat this question in " +
@@ -41,7 +41,7 @@ public ChatGpt()
4141
return await DoRequest(prompt);
4242
}
4343

44-
private async Task<IEnumerable<string>?> DoRequest(string prompt)
44+
private async Task<List<string>?> DoRequest(string prompt)
4545
{
4646
var promptJson = new CompletionChatRequest
4747
{
@@ -58,6 +58,6 @@ public ChatGpt()
5858
var responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
5959

6060
var response = JsonSerializer.Deserialize<CompletionChatResponse>(responseContent, _serializerOptions);
61-
return response?.Content?.Split(";");
61+
return response?.Content?.Split(";").ToList();
6262
}
63-
}
63+
}

0 commit comments

Comments
 (0)