From 1b2c5d25f75691dcd39e6ab267c7003b48869fd6 Mon Sep 17 00:00:00 2001 From: "devin.yf" Date: Fri, 8 Mar 2024 18:02:40 +0800 Subject: [PATCH] add streamimg finish reason check --- qwen/qwencli.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qwen/qwencli.go b/qwen/qwencli.go index a912775..a263778 100644 --- a/qwen/qwencli.go +++ b/qwen/qwencli.go @@ -87,6 +87,10 @@ func iterateStreamChannel[T IQwenContent](ctx context.Context, channel <-chan St choice.FinishReason = rspData.Output.Output.Choices[0].FinishReason outputMessage.Output.Choices[0] = choice + + if choice.FinishReason != "" && choice.FinishReason != "null" { + break + } } } @@ -101,7 +105,7 @@ func asyncChatStreaming[T IQwenContent]( cli httpclient.IHttpClient, url, token string, ) <-chan StreamOutput[T] { - chanBuffer := 100 + chanBuffer := 1000 _respChunkChannel := make(chan StreamOutput[T], chanBuffer) go func() {