chore: #975 check choices available
This commit is contained in:
parent
c2a15f6aa1
commit
23cb9a9ee8
5
vendors/openai/openai.go
vendored
5
vendors/openai/openai.go
vendored
@ -85,7 +85,8 @@ func (o *Client) SendStream(
|
||||
if len(response.Choices) > 0 {
|
||||
channel <- response.Choices[0].Delta.Content
|
||||
} else {
|
||||
fmt.Printf("No response (choices) from stream\n")
|
||||
channel <- "\n"
|
||||
close(channel)
|
||||
break
|
||||
}
|
||||
} else if errors.Is(err, io.EOF) {
|
||||
@ -108,7 +109,9 @@ func (o *Client) Send(ctx context.Context, msgs []*common.Message, opts *common.
|
||||
if resp, err = o.ApiClient.CreateChatCompletion(ctx, req); err != nil {
|
||||
return
|
||||
}
|
||||
if len(resp.Choices) > 0 {
|
||||
ret = resp.Choices[0].Message.Content
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user