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 {
|
if len(response.Choices) > 0 {
|
||||||
channel <- response.Choices[0].Delta.Content
|
channel <- response.Choices[0].Delta.Content
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("No response (choices) from stream\n")
|
channel <- "\n"
|
||||||
|
close(channel)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if errors.Is(err, io.EOF) {
|
} 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 {
|
if resp, err = o.ApiClient.CreateChatCompletion(ctx, req); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(resp.Choices) > 0 {
|
||||||
ret = resp.Choices[0].Message.Content
|
ret = resp.Choices[0].Message.Content
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user