Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Nov 21, 2023
1 parent 210f19b commit 460f87b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions adapter/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@ package adapter

import (
"chat/globals"
"chat/utils"
)

func IsAvailableError(err error) bool {
return err != nil && err.Error() != "signal"
}

func getRetries(retries *int) int {
if retries == nil {
return defaultMaxRetries
}

return *retries
}

func NewChatRequest(props *ChatProps, hook globals.Hook) error {
err := createChatRequest(props, hook)

props.Current++
retries := utils.Multi(props.MaxRetries == nil, defaultMaxRetries, *props.MaxRetries)
retries := getRetries(props.MaxRetries)

if IsAvailableError(err) && props.Current < retries {
return NewChatRequest(props, hook)
Expand Down

0 comments on commit 460f87b

Please sign in to comment.