Untitled
unknown
plain_text
2 years ago
888 B
13
Indexable
public static async Task<string> RequestChatCompletionWithRetry(ChatCompletionMessage[] messages) { int maxRetries = 6; float initialDelay = 3.0f; float delay = initialDelay; for (int i = 0; i < maxRetries; i++) { try { return await OpenAIAccessManager.RequestChatCompletion(messages); } catch (Exception ex) { Debug.LogWarning($"Error in RequestChatCompletion call, attempt {i + 1}: {ex.Message}"); if (i < maxRetries - 1) // Don't delay if we've reached the max retries { await Task.Delay(TimeSpan.FromSeconds(delay)); delay += initialDelay; } } } throw new Exception("Max retries reached for RequestChatCompletion call"); }
Editor is loading...