mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-01-10 06:48:04 -05:00
chore: #975 check choices available
This commit is contained in:
7
vendors/openai/openai.go
vendored
7
vendors/openai/openai.go
vendored
@@ -82,7 +82,12 @@ func (o *Client) SendStream(
|
||||
for {
|
||||
var response openai.ChatCompletionStreamResponse
|
||||
if response, err = stream.Recv(); err == nil {
|
||||
channel <- response.Choices[0].Delta.Content
|
||||
if len(response.Choices) > 0 {
|
||||
channel <- response.Choices[0].Delta.Content
|
||||
} else {
|
||||
fmt.Printf("No response (choices) from stream\n")
|
||||
break
|
||||
}
|
||||
} else if errors.Is(err, io.EOF) {
|
||||
channel <- "\n"
|
||||
close(channel)
|
||||
|
||||
Reference in New Issue
Block a user