langchaingo icon indicating copy to clipboard operation
langchaingo copied to clipboard

When I want to define two tools, I will get an error empty response

Open txfsxq opened this issue 2 years ago • 2 comments

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?

txfsxq avatar Apr 10 '24 06:04 txfsxq

I'll try reproduce it

devalexandre avatar Apr 10 '24 12:04 devalexandre

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

txfsxq avatar Apr 11 '24 10:04 txfsxq