Panic when running ExampleGenerativeModel_GenerateContentStream test
nullcache opened this issue · 3 comments
nullcache commented
Code
I just change the prompt text to "count 1 to 100.". The code is copied from ExampleGenerativeModel_GenerateContentStream in the file example_test.go
of this repository. I meet it everytime.
func TestExampleGenerativeModel_GenerateContentStream(t *testing.T) {
ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("API_KEY")))
if err != nil {
log.Fatal(err)
}
defer client.Close()
model := client.GenerativeModel("gemini-pro")
iter := model.GenerateContentStream(ctx, genai.Text("count 1 to 100."))
for {
resp, err := iter.Next()
if err == iterator.Done {
break
}
if err != nil {
log.Fatal(err)
}
printResponseV1(resp)
}
}
Test Result
1, 2, 3, 4, 5, 6
---
, 7, 8, 9, 10, 11, 12, 13, 14, 1
---
5, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 3
---
--- FAIL: TestExampleGenerativeModel_GenerateContentStream (4.49s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x104db8304]
goroutine 20 [running]:
testing.tRunner.func1.2({0x104f58140, 0x1054c4c00})
/opt/homebrew/opt/go/libexec/src/testing/testing.go:1545 +0x1c8
testing.tRunner.func1()
/opt/homebrew/opt/go/libexec/src/testing/testing.go:1548 +0x360
panic({0x104f58140?, 0x1054c4c00?})
/opt/homebrew/opt/go/libexec/src/runtime/panic.go:914 +0x218
github.com/google/generative-ai-go/genai.joinContent(...)
/Users/xxx/go/pkg/mod/github.com/google/generative-ai-go@v0.3.0/genai/client.go:298
github.com/google/generative-ai-go/genai.joinCandidateLists({0x1400006a148, 0x1, 0x1}, {0x1400006a158, 0x1, 0x105051800?})
/Users/xxx/go/pkg/mod/github.com/google/generative-ai-go@v0.3.0/genai/client.go:271 +0x144
github.com/google/generative-ai-go/genai.joinResponses(...)
/Users/xxx/go/pkg/mod/github.com/google/generative-ai-go@v0.3.0/genai/client.go:257
github.com/google/generative-ai-go/genai.(*GenerateContentResponseIterator).Next(0x1400009f710)
/Users/xxx/go/pkg/mod/github.com/google/generative-ai-go@v0.3.0/genai/client.go:178 +0x228
nullcache commented
Yes, it is actually resolved, but I think it is an exception of Gemini. When I use official web UI and ask the same question, it will stop unexpectedly. I don't know how to report this bug (maybe), can you help me?
eliben commented
zhu327 commented
I encountered the same issue.