Skip to content

Commit

Permalink
fix: client
Browse files Browse the repository at this point in the history
Signed-off-by: zwwhdls <zww@hdls.me>
  • Loading branch information
zwwhdls committed Nov 19, 2023
1 parent ba85e69 commit 4428c31
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/llm/client/openai/v1/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (o *OpenAIV1) Chat(ctx context.Context, prompt prompts.PromptTemplate, para
if err != nil {
errMsg := err.Error()
if strings.Contains(errMsg, "rate_limit_exceeded") || strings.Contains(errMsg, "Rate limit reached") {
o.log.Warn("meets rate limit exceeded, sleep 30 second and retry")
o.log.Warn("meets rate limit exceeded, sleep 30 seconds and retry")
time.Sleep(time.Duration(30) * time.Second)
return o.chat(ctx, prompt, parameters)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/llm/client/openai/v1/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func (o *OpenAIV1) Completion(ctx context.Context, prompt prompts.PromptTemplate
if err != nil {
errMsg := err.Error()
if strings.Contains(errMsg, "rate_limit_exceeded") {
o.log.Warnf("meets rate limit exceeded, sleep %d second and retry", o.rateLimit)
time.Sleep(time.Duration(o.rateLimit) * time.Second)
o.log.Warn("meets rate limit exceeded, sleep 30 seconds and retry")
time.Sleep(time.Duration(30) * time.Second)
return o.completion(ctx, prompt, parameters)
}
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/llm/client/openai/v1/embedding.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (o *OpenAIV1) Embedding(ctx context.Context, doc string) (*EmbeddingResult,
if err != nil {
errMsg := err.Error()
if strings.Contains(errMsg, "rate_limit_exceeded") {
o.log.Warnf("meets rate limit exceeded, sleep %d second and retry", o.rateLimit)
time.Sleep(time.Duration(o.rateLimit) * time.Second)
o.log.Warn("meets rate limit exceeded, sleep 30 seconds and retry")
time.Sleep(time.Duration(30) * time.Second)
return o.embedding(ctx, doc)
}
return nil, err
Expand Down

0 comments on commit 4428c31

Please sign in to comment.