-
-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
retry after #51
Comments
It was something I was thinking add a retry mechanism either. HTTP::retry() won't work because of package uses guzzle client not HTTP facade. Is there a retry-after param on response header in this sitution? I will open a pr for this feature. |
Until we get this feature (great feature request), do you have any suggestions to deal correctly with HTTP error codes or error messages like the model overload? |
I solved it by switching to Laravel's Http client which is built on top of Guzzle. Actually, you don't need a package for OpenAI, Guzzle is more than enough. Because OpenAI API is very easy to use. return Http::withToken($token)
->baseUrl('https://api.openai.com/v1/')
->retry(5, 500)
->post('https://api.openai.com/v1/chat/completions',
[
'model' => 'gpt-4',
'messages' => [
[
'role' => 'system',
'content' => 'You are a helpful assistant.',
],
[
'role' => 'user',
'content' => $prompt,
],
],
'functions' => [
[
'name' => $function, 'parameters' => config('schema.'.$function),
],
],
'function_call' => [
'name' => $function,
],
'temperature' => 0.6,
'top_p' => 1,
]
)
->throw()
->json(); That's it :-) |
At times, ChatGPT may display the following error message: "That model is currently overloaded with other requests." This issue arises due to the high volume of users attempting to access the API.
To address this problem, referring to the documentation, it is recommended to retry the request after a certain period of time. Adding a 'retryAfter' method, akin to Laravel's 'Http::retry()', could potentially resolve this issue.
The text was updated successfully, but these errors were encountered: