mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-08 22:50:44 +01:00
Add explicit handling for 429 error code from OpenAI
This commit is contained in:
parent
fc4eb6eb6b
commit
ae14d5dd7a
@ -97,6 +97,9 @@ func GetAiSuggestionsViaOpenAiApi(query, shellName, osName string, numberComplet
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, OpenAiUsage{}, fmt.Errorf("failed to read OpenAI API response: %w", err)
|
return nil, OpenAiUsage{}, fmt.Errorf("failed to read OpenAI API response: %w", err)
|
||||||
}
|
}
|
||||||
|
if resp.StatusCode == 429 {
|
||||||
|
return nil, OpenAiUsage{}, fmt.Errorf("received 429 error code from OpenAI (is your API key valid?)")
|
||||||
|
}
|
||||||
var apiResp openAiResponse
|
var apiResp openAiResponse
|
||||||
err = json.Unmarshal(bodyText, &apiResp)
|
err = json.Unmarshal(bodyText, &apiResp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user