1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-11-29 23:38:14 +02:00

сделал folders.go

This commit is contained in:
Nikitin Aleksandr
2023-07-20 15:54:11 +03:00
parent 71fc53b2f8
commit d86504a070
254 changed files with 11087 additions and 7197 deletions

View File

@@ -3,7 +3,6 @@ package openai
import (
"bufio"
"context"
"net/http"
utils "github.com/sashabaranov/go-openai/internal"
)
@@ -16,7 +15,7 @@ type ChatCompletionStreamChoiceDelta struct {
type ChatCompletionStreamChoice struct {
Index int `json:"index"`
Delta ChatCompletionStreamChoiceDelta `json:"delta"`
FinishReason string `json:"finish_reason"`
FinishReason FinishReason `json:"finish_reason"`
}
type ChatCompletionStreamResponse struct {
@@ -41,7 +40,7 @@ func (c *Client) CreateChatCompletionStream(
ctx context.Context,
request ChatCompletionRequest,
) (stream *ChatCompletionStream, err error) {
urlSuffix := "/chat/completions"
urlSuffix := chatCompletionsSuffix
if !checkEndpointSupportsModel(urlSuffix, request.Model) {
err = ErrChatCompletionInvalidModel
return
@@ -57,7 +56,7 @@ func (c *Client) CreateChatCompletionStream(
if err != nil {
return
}
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {
if isFailureStatusCode(resp) {
return nil, c.handleErrorResp(resp)
}
@@ -66,7 +65,7 @@ func (c *Client) CreateChatCompletionStream(
emptyMessagesLimit: c.config.EmptyMessagesLimit,
reader: bufio.NewReader(resp.Body),
response: resp,
errAccumulator: newErrorAccumulator(),
errAccumulator: utils.NewErrorAccumulator(),
unmarshaler: &utils.JSONUnmarshaler{},
},
}