Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
luoshengheng committed Nov 30, 2023
1 parent 167befa commit 976cfe2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type ChatCompletionRequest struct {
AllowFallback bool `json:"allow_fallback,omitempty"`
CaptchaToken string `json:"captchaToken,omitempty"` //easychat的额外参数
Token string `json:"token,omitempty"` //ylokh的额外参数
PlainText bool `json:"plainText,omitempty"` //用于标识响应的内容是否纯文本
}

type FunctionDefinition struct {
Expand Down
4 changes: 3 additions & 1 deletion chat_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func (c *Client) CreateChatCompletionStream(
urlSuffix := chatCompletionsSuffix
if len(extraHeaders) > 0 && extraHeaders[0] != nil && extraHeaders[0]["path"] != "" {
urlSuffix = extraHeaders[0]["path"]

}
if !checkEndpointSupportsModel(urlSuffix, request.Model) {
err = ErrChatCompletionInvalidModel
Expand All @@ -72,6 +71,9 @@ func (c *Client) CreateChatCompletionStream(
if err != nil {
return
}
if request.PlainText {
resp.ResponsePlainText = true
}
stream = &ChatCompletionStream{
StreamReader: resp,
}
Expand Down
2 changes: 1 addition & 1 deletion stream_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (stream *StreamReader[T]) processLines() (T, error) {
}

var response ChatCompletionStreamResponse
response.Choices = []ChatCompletionStreamChoice{{Index: 0, Delta: ChatCompletionStreamChoiceDelta{Content: string(totalBytes)}, FinishReason: "Completed"}}
response.Choices = []ChatCompletionStreamChoice{{Index: 0, Delta: ChatCompletionStreamChoiceDelta{Content: string(totalBytes)}, FinishReason: "PlainText"}}
bytes, _ := json.Marshal(response)

var t T
Expand Down

0 comments on commit 976cfe2

Please sign in to comment.