Skip to content

Commit

Permalink
Check if response has a choice before debug logging to prevent null r… (
Browse files Browse the repository at this point in the history
#117)

* Check if response has a choice before debug logging to prevent null reference.

Signed-off-by: Jeffrey Lee <[email protected]>
Co-authored-by: Nick Hale <[email protected]>
  • Loading branch information
darkthread and njhale authored Mar 6, 2024
1 parent 1fb78c2 commit a3cbe20
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/openai/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ func (c *Client) call(ctx context.Context, request openai.ChatCompletionRequest,
} else if err != nil {
return nil, err
}
slog.Debug("stream", "content", response.Choices[0].Delta.Content)
if len(response.Choices) > 0 {
slog.Debug("stream", "content", response.Choices[0].Delta.Content)
}
if partial != nil {
partialMessage = appendMessage(partialMessage, response)
partial <- types.CompletionStatus{
Expand Down

0 comments on commit a3cbe20

Please sign in to comment.