Browse Source

fix retry warning

Kujtim Hoxha 10 months ago
parent
commit
b3a8dbd0d9
2 changed files with 7 additions and 7 deletions
  1. 2 2
      internal/llm/provider/gemini.go
  2. 5 5
      internal/llm/provider/openai.go

+ 2 - 2
internal/llm/provider/gemini.go

@@ -209,7 +209,7 @@ func (g *geminiClient) send(ctx context.Context, messages []message.Message, too
 				return nil, retryErr
 				return nil, retryErr
 			}
 			}
 			if retry {
 			if retry {
-				logging.WarnPersist("Retrying due to rate limit... attempt %d of %d", logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
+				logging.WarnPersist(fmt.Sprintf("Retrying due to rate limit... attempt %d of %d", attempts, maxRetries), logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
 				select {
 				select {
 				case <-ctx.Done():
 				case <-ctx.Done():
 					return nil, ctx.Err()
 					return nil, ctx.Err()
@@ -308,7 +308,7 @@ func (g *geminiClient) stream(ctx context.Context, messages []message.Message, t
 						return
 						return
 					}
 					}
 					if retry {
 					if retry {
-						logging.WarnPersist("Retrying due to rate limit... attempt %d of %d", logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
+						logging.WarnPersist(fmt.Sprintf("Retrying due to rate limit... attempt %d of %d", attempts, maxRetries), logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
 						select {
 						select {
 						case <-ctx.Done():
 						case <-ctx.Done():
 							if ctx.Err() != nil {
 							if ctx.Err() != nil {

+ 5 - 5
internal/llm/provider/openai.go

@@ -8,13 +8,13 @@ import (
 	"io"
 	"io"
 	"time"
 	"time"
 
 
+	"github.com/openai/openai-go"
+	"github.com/openai/openai-go/option"
+	"github.com/openai/openai-go/shared"
 	"github.com/opencode-ai/opencode/internal/config"
 	"github.com/opencode-ai/opencode/internal/config"
 	"github.com/opencode-ai/opencode/internal/llm/tools"
 	"github.com/opencode-ai/opencode/internal/llm/tools"
 	"github.com/opencode-ai/opencode/internal/logging"
 	"github.com/opencode-ai/opencode/internal/logging"
 	"github.com/opencode-ai/opencode/internal/message"
 	"github.com/opencode-ai/opencode/internal/message"
-	"github.com/openai/openai-go"
-	"github.com/openai/openai-go/option"
-	"github.com/openai/openai-go/shared"
 )
 )
 
 
 type openaiOptions struct {
 type openaiOptions struct {
@@ -188,7 +188,7 @@ func (o *openaiClient) send(ctx context.Context, messages []message.Message, too
 				return nil, retryErr
 				return nil, retryErr
 			}
 			}
 			if retry {
 			if retry {
-				logging.WarnPersist("Retrying due to rate limit... attempt %d of %d", logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
+				logging.WarnPersist(fmt.Sprintf("Retrying due to rate limit... attempt %d of %d", attempts, maxRetries), logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
 				select {
 				select {
 				case <-ctx.Done():
 				case <-ctx.Done():
 					return nil, ctx.Err()
 					return nil, ctx.Err()
@@ -288,7 +288,7 @@ func (o *openaiClient) stream(ctx context.Context, messages []message.Message, t
 				return
 				return
 			}
 			}
 			if retry {
 			if retry {
-				logging.WarnPersist("Retrying due to rate limit... attempt %d of %d", logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
+				logging.WarnPersist(fmt.Sprintf("Retrying due to rate limit... attempt %d of %d", attempts, maxRetries), logging.PersistTimeArg, time.Millisecond*time.Duration(after+100))
 				select {
 				select {
 				case <-ctx.Done():
 				case <-ctx.Done():
 					// context cancelled
 					// context cancelled