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

fix(langchain): Prevent exception when using plan & execute agent with no tools #6744

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class PlanAndExecuteAgentExecutor extends BaseChain {
}) {
let agent;

if (isDynamicStructuredTool(tools[0])) {
if (tools.length > 0 && isDynamicStructuredTool(tools[0])) {
agent = StructuredChatAgent.fromLLMAndTools(llm, tools, {
humanMessageTemplate,
inputVariables: ["previous_steps", "current_step", "agent_scratchpad"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ test.skip("Run agent with a sequential math problem", async () => {

// console.log(result);
});

test.skip("Should run agent with no tools", async () => {
const model = new ChatOpenAI({
temperature: 0,
modelName: "gpt-3.5-turbo",
verbose: true,
});
const executor = await PlanAndExecuteAgentExecutor.fromLLMAndTools({
llm: model,
tools: [],
});

// @eslint-disable-next-line/@typescript-eslint/ban-ts-comment
// @ts-expect-error unused var
const result = await executor.call({
bracesproul marked this conversation as resolved.
Show resolved Hide resolved
input: `Who is the current president of the United States? What is their current age raised to the second power?`,
});
});
Loading