Skip to content

Commit

Permalink
chore: #975 check choices available
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeis committed Sep 18, 2024
1 parent c2a15f6 commit 23cb9a9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vendors/openai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
ret = resp.Choices[0].Message.Content
if len(resp.Choices) > 0 {
ret = resp.Choices[0].Message.Content
}
return
}

Expand Down

0 comments on commit 23cb9a9

Please sign in to comment.