Skip to content

Commit

Permalink
v0.9.8 内部代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
x5iu committed Aug 22, 2024
1 parent 35e85c3 commit abce0ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -427,7 +431,7 @@ func buildProxy(
}
}
if !(forceStream && !requestUseStream) {
responseWriter.Write([]byte("[DONE]"))
responseWriter.Write([]byte("data: [DONE]"))
}
break READLINES
}
Expand Down Expand Up @@ -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))
}
}
}
Expand Down

0 comments on commit abce0ce

Please sign in to comment.