langchaingo
langchaingo copied to clipboard
When I want to define two tools, I will get an error empty response
When I want to define two tools, I will get an error empty response
toolList := []tools.Tool{nex_tools.ProductAnalysis{}, nex_tools.SearchKeywords{}}
a := NewOpenAIFunctionsAgent(llm,
toolList,
NewOpenAIOption().WithSystemMessage("you are a helpful assistant"),
NewOpenAIOption().WithExtraMessages([]prompts.MessageFormatter{
prompts.NewHumanMessagePromptTemplate("please be strict", nil),
}),
)
executor := NewExecutor(a, toolList)
if err != nil {
t.Errorf("initialize error: %s", err)
return
}
res, err := chains.Run(context.Background(), executor, "Recommend some products and analyze the first product")
if err != nil {
t.Errorf("run error: %s", err)
return
}
run error: empty response
How to solve it?
I'll try reproduce it
When I only use one tool for calculation, I still get empty response
calculator := tools.Calculator{}
toolList := []tools.Tool{calculator}
a := agents.NewOpenAIFunctionsAgent(llm,
toolList,
agents.NewOpenAIOption().WithSystemMessage("you are a helpful assistant"),
agents.NewOpenAIOption().WithExtraMessages([]prompts.MessageFormatter{
prompts.NewHumanMessagePromptTemplate("please be strict", nil),
}),
)
e := agents.NewExecutor(a, toolList)
require.NoError(t, err)
result, err := chains.Run(context.Background(), e, "What is 3 plus 5 equal to?") //nolint:lll
require.NoError(t, err)
fmt.Println(result)
require.True(t, strings.Contains(result, "8"),
"correct answer 8 not in response")
run error: empty response