Skip to content

Commit 0818839

Browse files
author
Tomasz Juszczak
committed
Added more options that repeat on error from OpenAI
1 parent 56d4217 commit 0818839

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Slack-GPT-Socket/SlackHandlers/SlackMentionHandler.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,14 @@ private async Task<GptResponse> GeneratePromptRetry(AppMention slackEvent, List<
225225
{
226226
var result = await _gptClient.GeneratePrompt(context, userId);
227227

228-
if (HasError(result) && result.Error!.Contains("The server had an error while processing your request. Sorry about that"))
228+
var repeatOnErrorsArray = new string[]
229+
{
230+
"The server had an error while processing your request",
231+
"That model is currently overloaded with other requests",
232+
"The server is currently overloaded with other requests",
233+
};
234+
235+
if (HasError(result) && result.Error!.Contains(repeatOnErrorsArray))
229236
{
230237
if (errorsCount == 0)
231238
{

Slack-GPT-Socket/Utilities/StringUtils.cs

+10
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,14 @@ public static string SanitizeNumber(this string input)
7474
|| char.IsPunctuation(x) || char.IsSeparator(x))).Replace(",", ".");
7575
}
7676

77+
/// <summary>
78+
/// Checks if a string contains any of the given values.
79+
/// </summary>
80+
/// <param name="input"></param>
81+
/// <param name="values"></param>
82+
/// <returns></returns>
83+
public static bool Contains(this string input, IEnumerable<string> values)
84+
{
85+
return values.Any(input.Contains);
86+
}
7787
}

0 commit comments

Comments
 (0)