chore: #975 check choices available

This commit is contained in:
Eugen Eisler 2024-09-18 14:19:00 +02:00
parent c2a15f6aa1
commit 23cb9a9ee8

View File

@ -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
}