From 7d6dc6c7d06b12c849291ed9b93a1c30f3eaf019 Mon Sep 17 00:00:00 2001 From: Yury Nevalenny Date: Thu, 23 May 2024 22:04:05 +0000 Subject: [PATCH] don't try to subscribe with endless query params --- backend/app/ai/chat.go | 3 +-- backend/app/ai/openai/threads.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/app/ai/chat.go b/backend/app/ai/chat.go index 654d1bc..b15db0c 100644 --- a/backend/app/ai/chat.go +++ b/backend/app/ai/chat.go @@ -18,7 +18,6 @@ import ( "time" "unicode/utf8" - "github.com/google/uuid" log "github.com/sirupsen/logrus" ) @@ -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)) diff --git a/backend/app/ai/openai/threads.go b/backend/app/ai/openai/threads.go index f96964f..fe8dfe0 100644 --- a/backend/app/ai/openai/threads.go +++ b/backend/app/ai/openai/threads.go @@ -16,7 +16,6 @@ import ( "talk2robots/m/v2/app/payments" "time" - "github.com/google/uuid" log "github.com/sirupsen/logrus" ) @@ -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