From f27f0d39585cae6d685ed167851e7fddcde6c2e9 Mon Sep 17 00:00:00 2001 From: Cole Lashley Date: Mon, 26 Feb 2024 22:21:28 -0800 Subject: [PATCH] upped timeout and changed error msg (#341) --- wavesrv/pkg/remote/openai/openai.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wavesrv/pkg/remote/openai/openai.go b/wavesrv/pkg/remote/openai/openai.go index ed3251721..038dd579b 100644 --- a/wavesrv/pkg/remote/openai/openai.go +++ b/wavesrv/pkg/remote/openai/openai.go @@ -24,7 +24,7 @@ const DefaultMaxTokens = 1000 const DefaultModel = "gpt-3.5-turbo" const DefaultStreamChanSize = 10 -const CloudWebsocketConnectTimeout = 5 * time.Second +const CloudWebsocketConnectTimeout = 1 * time.Minute func convertUsage(resp openaiapi.ChatCompletionResponse) *packet.OpenAIUsageType { if resp.Usage.TotalTokens == 0 { @@ -86,7 +86,9 @@ func RunCloudCompletionStream(ctx context.Context, clientId string, opts *sstore websocketContext, dialCancelFn := context.WithTimeout(context.Background(), CloudWebsocketConnectTimeout) defer dialCancelFn() conn, _, err := websocket.DefaultDialer.DialContext(websocketContext, pcloud.GetWSEndpoint(), nil) - if err != nil { + if err == context.DeadlineExceeded { + return nil, nil, fmt.Errorf("OpenAI request, timed out connected to cloud server: %v", err) + } else if err != nil { return nil, nil, fmt.Errorf("OpenAI request, websocket connect error: %v", err) } reqPk := packet.MakeOpenAICloudReqPacket()