Skip to content

Commit

Permalink
don't try to subscribe with endless query params
Browse files Browse the repository at this point in the history
  • Loading branch information
radiantspace committed May 23, 2024
1 parent ce2abd0 commit 7d6dc6c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions backend/app/ai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"time"
"unicode/utf8"

"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -175,7 +174,7 @@ func (a *API) ChatCompleteStreaming(ctx context.Context, completion models.ChatM
config.CONFIG.DataDogClient.Timing("openai.chat_complete_streaming.latency", time.Since(timeNow), []string{"model:" + completion.Model}, 1)
config.CONFIG.DataDogClient.Timing("openai.chat_complete_streaming.latency_per_token", time.Since(timeNow), []string{"model:" + completion.Model}, float64(usage.Usage.CompletionTokens))
}()
err := client.SubscribeWithContext(ctx, uuid.New().String(), func(msg *sse.Event) {
err := client.SubscribeWithContext(ctx, "", func(msg *sse.Event) {
var response models.ChatResponse
if msg.Data != nil && len(msg.Data) > 2 && string(msg.Data[:1]) == "[" && string(msg.Data) == "[DONE]" {
log.Infof("ChatCompleteStreaming got [DONE] message for user id %s", ctx.Value(models.UserContext{}).(string))
Expand Down
3 changes: 1 addition & 2 deletions backend/app/ai/openai/threads.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"talk2robots/m/v2/app/payments"
"time"

"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -675,7 +674,7 @@ func subscribeAndProcess(
config.CONFIG.DataDogClient.Timing("openai.threads.latency", time.Since(timeNow), []string{status, "api:" + apiName}, 1)
}()

err := client.SubscribeWithContext(ctx, uuid.New().String(), func(msg *sse.Event) {
err := client.SubscribeWithContext(ctx, "", func(msg *sse.Event) {
var response models.StreamDataResponse
if msg.Event == nil || msg.Data == nil {
return
Expand Down

0 comments on commit 7d6dc6c

Please sign in to comment.