From abce0ceae361bb388774210fea0b2c6ea8f5e57d Mon Sep 17 00:00:00 2001 From: x5iu Date: Fri, 23 Aug 2024 00:37:09 +0800 Subject: [PATCH] =?UTF-8?q?v0.9.8=20=E5=86=85=E9=83=A8=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 2 +- proxy.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index c83ec7d..0969845 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ func init() { var ( MoonPalace = &cobra.Command{ Use: "moonpalace", - Version: "v0.9.7", + Version: "v0.9.8", Short: "MoonPalace is a command-line tool for debugging the Moonshot AI HTTP API", SilenceErrors: true, SilenceUsage: true, diff --git a/proxy.go b/proxy.go index 3673e95..d062260 100644 --- a/proxy.go +++ b/proxy.go @@ -417,6 +417,10 @@ func buildProxy( chunk.Model, chunk.Object, )) + responseBody = append(responseBody, "data: "...) + responseBody = append(responseBody, finishChunk...) + responseBody = append(responseBody, "\n\n"...) + responseBody = append(responseBody, "data: [DONE]\n\n"...) if forceStream && !requestUseStream { mergeIn(completion, finishChunk) } else { @@ -427,7 +431,7 @@ func buildProxy( } } if !(forceStream && !requestUseStream) { - responseWriter.Write([]byte("[DONE]")) + responseWriter.Write([]byte("data: [DONE]")) } break READLINES } @@ -495,8 +499,9 @@ func buildProxy( if completion.Choices != nil && len(completion.Choices) > 0 { for _, choice := range completion.Choices { if choice.FinishReason != nil && *choice.FinishReason == "length" { - err = fmt.Errorf("it seems that your max_tokens value is too small, please set a value greater than %d", - completion.Usage.CompletionTokens) + warnings = append(warnings, + fmt.Errorf("it seems that your max_tokens value is too small, please set a value greater than %d", + completion.Usage.CompletionTokens)) } } }