fix error result cache

This commit is contained in:
Zheng Kai
2023-06-25 18:49:24 +08:00
parent 05fe88de8b
commit 645873a6d1
4 changed files with 50 additions and 32 deletions

View File

@@ -11,14 +11,14 @@ import (
"time"
)
func (pr *row) fetchRemote() (ab []byte, ok bool, err error) {
func (pr *row) fetchRemote() (ab []byte, err error) {
r := pr.req
b := pr.log
u, err := url.Parse(config.OpenAIBase + r.Url)
if err != nil {
return nil, false, err
return nil, err
}
// zj.J(`real url`, u.String())
@@ -39,9 +39,7 @@ func (pr *row) fetchRemote() (ab []byte, ok bool, err error) {
return
}
if rsp.StatusCode >= 200 || rsp.StatusCode < 300 {
ok = true
} else {
if rsp.StatusCode < 200 || rsp.StatusCode >= 300 {
err = fmt.Errorf(`status code fail: %d`, rsp.StatusCode)
b.WriteString(err.Error())
}