Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anthropic does not handle null content elegantly (panics) #993

Open
rek7 opened this issue Aug 18, 2024 · 0 comments
Open

Anthropic does not handle null content elegantly (panics) #993

rek7 opened this issue Aug 18, 2024 · 0 comments

Comments

@rek7
Copy link

rek7 commented Aug 18, 2024

If attempts to anthropic fail or return no content, the generateMessagesContent function will die. This function should check result.Content to see if its nil, if it is an error should be returned an the request should be retried.

Crash:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x1034766c8]

goroutine 10 [running]:
github.com/tmc/langchaingo/llms/anthropic.generateMessagesContent({0x1039656f8, 0x103df40c0}, 0x1400031a9f0, {0x14000402d50?, 0x140003d5308?, 0x1032eacec?}, 0x1400040e1e0)
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/llms/anthropic/anthropicllm.go:155 +0x248
github.com/tmc/langchaingo/llms/anthropic.(*LLM).GenerateContent(0x1400031a9f0, {0x1039656f8, 0x103df40c0}, {0x14000402d50, 0x1, 0x1}, {0x140002fe5a0, 0x2, 0x140002e3000?})
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/llms/anthropic/anthropicllm.go:89 +0xe8
github.com/tmc/langchaingo/llms.GenerateFromSinglePrompt({0x1039656f8, 0x103df40c0}, {0x103962350, 0x1400031a9f0}, {0x1400046e000, 0x1554}, {0x140002fe5a0, 0x2, 0x2})
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/llms/llms.go:41 +0x148
github.com/tmc/langchaingo/chains.LLMChain.Call({{0x103962300, 0x140000201e0}, {0x103962350, 0x1400031a9f0}, {0x1039665a0, 0x103df40c0}, {0x103969b78, 0x140002fe240}, {0x1039657a0, 0x103df40c0}, ...}, ...)
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/chains/llm.go:59 +0xc8
github.com/tmc/langchaingo/chains.callChain({0x1039656f8, 0x103df40c0}, {0x103965768, 0x140001143c0}, 0x140004027b0, {0x140002fe3e0, 0x2, 0x2})
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/chains/chains.go:79 +0x74
github.com/tmc/langchaingo/chains.Call({0x1039656f8, 0x103df40c0}, {0x103965768, 0x140001143c0}, 0x14000402780, {0x140002fe3e0, 0x2, 0x2})
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/chains/chains.go:50 +0x268
github.com/tmc/langchaingo/chains.Predict({0x1039656f8?, 0x103df40c0?}, {0x103965768, 0x140001143c0}, 0x104113458?, {0x140002fe3e0?, 0x10?, 0x10?})
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/chains/chains.go:136 +0x30
github.com/tmc/langchaingo/agents.(*ConversationalAgent).Plan(0x14000020230, {0x1039656f8, 0x103df40c0}, {0x103df40c0, 0x0, 0x1030fe508?}, 0x14000402720)
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/agents/conversational.go:83 +0x320
github.com/tmc/langchaingo/agents.(*Executor).doIteration(0x14000020280, {0x1039656f8, 0x103df40c0}, {0x103df40c0, 0x0, 0x0}, 0x14000402750, 0x5?)
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/agents/executor.go:83 +0x54
github.com/tmc/langchaingo/agents.(*Executor).Call(0x14000020280, {0x1039656f8, 0x103df40c0}, 0x103910a60?, {0x1038b4d01?, 0x140004026f0?, 0x140004026f0?})
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/agents/executor.go:60 +0xd0
github.com/tmc/langchaingo/chains.callChain({0x1039656f8, 0x103df40c0}, {0x1039656c0, 0x14000020280}, 0x140004026c0, {0x0, 0x0, 0x0})
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/chains/chains.go:79 +0x74
github.com/tmc/langchaingo/chains.Call({0x1039656f8, 0x103df40c0}, {0x1039656c0, 0x14000020280}, 0x14000402690, {0x0, 0x0, 0x0})
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/chains/chains.go:50 +0x268
github.com/tmc/langchaingo/chains.Run({0x1039656f8, 0x103df40c0}, {0x1039656c0, 0x14000020280}, {0x103883be0, 0x140002fe370}, {0x0, 0x0, 0x0})
	/Users/r/go/pkg/mod/github.com/tmc/[email protected]/chains/chains.go:121 +0x21c
@rek7 rek7 changed the title Anthropic does not handle null content elegantly Anthropic does not handle null content elegantly (panics) Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant