on main help sign in
fix retry warning
b3a8dbdKujtim Hoxha
internal/llm/provider/gemini.go+2−2
@@ -209,7 +209,7 @@ func (g *geminiClient) send(ctx context.Context, messages []message.Message, too
209 return nil, retryErr
209 return nil, retryErr
210 }
210 }
211 if retry {
211 if retry {
212− logging.WarnPersist("Retrying due to rate limit... attempt %d of %d", logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
212+ logging.WarnPersist(fmt.Sprintf("Retrying due to rate limit... attempt %d of %d", attempts, maxRetries), logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
213 select {
213 select {
214 case <-ctx.Done():
214 case <-ctx.Done():
215 return nil, ctx.Err()
215 return nil, ctx.Err()
@@ -308,7 +308,7 @@ func (g *geminiClient) stream(ctx context.Context, messages []message.Message, t
308 return
308 return
309 }
309 }
310 if retry {
310 if retry {
311− logging.WarnPersist("Retrying due to rate limit... attempt %d of %d", logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
311+ logging.WarnPersist(fmt.Sprintf("Retrying due to rate limit... attempt %d of %d", attempts, maxRetries), logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
312 select {
312 select {
313 case <-ctx.Done():
313 case <-ctx.Done():
314 if ctx.Err() != nil {
314 if ctx.Err() != nil {
internal/llm/provider/openai.go+5−5
@@ -8,13 +8,13 @@ import (
8 "io"
8 "io"
9 "time"
9 "time"
10
10
11+ "github.com/openai/openai-go"
12+ "github.com/openai/openai-go/option"
13+ "github.com/openai/openai-go/shared"
11 "github.com/opencode-ai/opencode/internal/config"
14 "github.com/opencode-ai/opencode/internal/config"
12 "github.com/opencode-ai/opencode/internal/llm/tools"
15 "github.com/opencode-ai/opencode/internal/llm/tools"
13 "github.com/opencode-ai/opencode/internal/logging"
16 "github.com/opencode-ai/opencode/internal/logging"
14 "github.com/opencode-ai/opencode/internal/message"
17 "github.com/opencode-ai/opencode/internal/message"
15− "github.com/openai/openai-go"
16− "github.com/openai/openai-go/option"
17− "github.com/openai/openai-go/shared"
18)
18)
19
19
20type openaiOptions struct {
20type openaiOptions struct {
@@ -188,7 +188,7 @@ func (o *openaiClient) send(ctx context.Context, messages []message.Message, too
188 return nil, retryErr
188 return nil, retryErr
189 }
189 }
190 if retry {
190 if retry {
191− logging.WarnPersist("Retrying due to rate limit... attempt %d of %d", logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
191+ logging.WarnPersist(fmt.Sprintf("Retrying due to rate limit... attempt %d of %d", attempts, maxRetries), logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
192 select {
192 select {
193 case <-ctx.Done():
193 case <-ctx.Done():
194 return nil, ctx.Err()
194 return nil, ctx.Err()
@@ -288,7 +288,7 @@ func (o *openaiClient) stream(ctx context.Context, messages []message.Message, t
288 return
288 return
289 }
289 }
290 if retry {
290 if retry {
291− logging.WarnPersist("Retrying due to rate limit... attempt %d of %d", logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
291+ logging.WarnPersist(fmt.Sprintf("Retrying due to rate limit... attempt %d of %d", attempts, maxRetries), logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
292 select {
292 select {
293 case <-ctx.Done():
293 case <-ctx.Done():
294 // context cancelled
294 // context cancelled