You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A null pointer exception occurs in the addToHistory method of the ChatSession struct. This issue is triggered when the Content field of a Candidate struct's first element is nil, and the method attempts to access its Role property (c.Role).
// github.com/google/generative-ai-go@v0.8.0/genai/client.go:183func (iter*GenerateContentResponseIterator) Next() (*GenerateContentResponse, error) {
...resp, err:=iter.sc.Recv()
iter.err=erriferr==io.EOF {
ifiter.cs!=nil&&iter.merged!=nil {
iter.cs.addToHistory(iter.merged.Candidates)
}
returnnil, iterator.Done
}
...
}
// cloud.google.com/go/ai@v0.3.0/generativelanguage/apiv1/generative_client.go:746func (c*streamGenerateContentRESTClient) Recv() (*generativelanguagepb.GenerateContentResponse, error) {
iferr:=c.ctx.Err(); err!=nil {
deferc.stream.Close()
returnnil, err
}
msg, err:=c.stream.Recv() // msg.Candidates[0].Content is niliferr!=nil {
deferc.stream.Close()
returnnil, err
}
res:=msg.(*generativelanguagepb.GenerateContentResponse)
returnres, nil
}
// Cause the following function to throw a NullPointerException// github.com/google/generative-ai-go@v0.8.0/genai/chat.go:63func (cs*ChatSession) addToHistory(cands []*Candidate) bool {
iflen(cands) >0 {
c:=cands[0].Content// c is nilc.Role=roleModelcs.History=append(cs.History, c)
returntrue
}
returnfalse
}
The text was updated successfully, but these errors were encountered:
This bug is fixed in the latest version of github.com/google/generative-ai-go (v0.11.0).
The fix for the vertex client is at googleapis/google-cloud-go#10057.
This bug is fixed in the latest version of github.com/google/generative-ai-go (v0.11.0). The fix for the vertex client is at googleapis/google-cloud-go#10057.
Thanks for the update. I've upgraded to the latest version and the issue has been resolved.
A null pointer exception occurs in the addToHistory method of the ChatSession struct. This issue is triggered when the Content field of a Candidate struct's first element is nil, and the method attempts to access its Role property (c.Role).
The text was updated successfully, but these errors were encountered: