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

how to call another tool from within a tool? #2990

Closed
stewones opened this issue Oct 20, 2023 · 1 comment
Closed

how to call another tool from within a tool? #2990

stewones opened this issue Oct 20, 2023 · 1 comment
Labels
auto:question A specific question about the codebase, product, project, or how to use a feature

Comments

@stewones
Copy link

So I have a use case where a tool must find information somewhere, and if the information is not found, it must call another tool to escalate support to a human. is there a way to do this?

I'm using initializeAgentExecutorWithOptions with agentType openai-functions

@dosubot dosubot bot added the auto:question A specific question about the codebase, product, project, or how to use a feature label Oct 20, 2023
@dosubot
Copy link

dosubot bot commented Oct 20, 2023

🤖

Hello,

Based on the current implementation of initializeAgentExecutorWithOptions in the LangChainJS framework, there isn't a built-in method to call another tool from within a tool in the event that the initial tool fails to find the required information. The initializeAgentExecutorWithOptions function is used to initialize an agent executor with a specific agent type and set of tools, but it does not provide functionality for switching to a different tool if the initial tool fails.

However, you can handle this in your application logic. For instance, you could catch any errors thrown by the initial tool, and in the catch block, re-initialize the agent executor with a different tool. Here's a rough example of how you might implement this:

try {
  // Initialize your agent executor with the initial tool
  const executor = initializeAgentExecutorWithOptions({ agentType: 'openai-functions', tool: 'initialTool' });
  // Use the executor to find the required information
  const info = executor.findInformation();
} catch (error) {
  // If the initial tool fails, re-initialize the executor with a different tool
  const executor = initializeAgentExecutorWithOptions({ agentType: 'openai-functions', tool: 'fallbackTool' });
  // Use the fallback tool to escalate support to a human
  executor.escalateSupport();
}

Please note that this would require modifications to your application code and is not a feature provided by the initializeAgentExecutorWithOptions function itself.

I hope this helps! If you have any other questions or need further clarification, feel free to ask.

Best regards.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:question A specific question about the codebase, product, project, or how to use a feature
Projects
None yet
Development

No branches or pull requests

1 participant