The LangChain AgentExecutor call() function raises an error stating that it expects one input key, but receives two inputs when a value is passed. It also raises an error indicating that input is missing

My current project involves using LangChain Typescript (version 0.0.96) to develop a basic chatbot capable of answering questions. In this setup, I am utilizing an AgentExecutor that leverages tools to retrieve information from a database and EntityMemory as the memory component. Below is a snippet of the code:

// Create memory input
const input = {"input": question};
// Load the relevant history using the entities used in the question and the conversation
relevantEntityHistory = await this.memory.loadMemoryVariables(input);

console.log('Relevant Entity History', relevantEntityHistory);
/**
* Relevant Entity History {
*  history: '',
*  entities: {
*    HTML: 'No current information known.',
*    AI: 'No current information known.',
*    JavaScript: 'No current information known.'
*  }
*}
*/

// Create the agent executor
if (!this.executor) {
   // Build the agent executor with options
   this.executor = await initializeAgentExecutorWithOptions(this.tools, this.model, {
       agentType: "chat-conversational-react-description",
       verbose: true,
       memory: this.memory,
    });
}

console.log("Executing with input: ", question);
// Executing with input:  Please create an HTML page with three columns. The left column will have a list of conversations the customer had with our AI chatbot. The middle column will contain all messages for a selected conversation and a text area for customers to send new messages. The right column will have a list of knowledge base sources that the chatbot can use to answer customer questions.

const result = await this.executor.call({ 
    input: question,
    chat_history: relevantEntityHistory.history,
});

The issue appears to be related to the input: question property passed to the executor call method. This portion of the code triggers the following error message:

Error: One input key expected, but got 2

An attempt to remove the input led to another error mentioning "Missing value for input variable input"

[chain/start] [1:chain:AgentExecutor] Entering Chain run with input: {
  "chat_history": [],
  "history": "",
  "entities": {
    "Human: \n\nOutput: NONE": "No current information known."
  }
}

[chain/start] [1:chain:AgentExecutor > 2:chain:LLMChain] Entering Chain run with input: {
  "chat_history": [],
  "history": "",
  "entities": {
     "Human: \n\nOutput: NONE": "No current information known."
  },
  "agent_scratchpad":[],
  "stop": [
     "Observation:"
  ]
}

[chain/error] [1:chain:AgentExecutor > 2:chain:LLMChain] [3ms] Chain run errored with error: "Missing value for input variable `input`"

[chain/error] [1:chain:AgentExecutor] [8ms] Chain run errored with error: "Missing value for input variable `input`"

at C:\Users\Sheri\autodev\node_modules\langchain\dist\prompts\chat.cjs:224:27
(...)

If anyone has insights on how to correctly pass the 'input' or identify any missing elements in my implementation, I would greatly appreciate your input. Many thanks!


Swift Update

To address the errors encountered, I experimented by replacing the call() method with run(). Although the distinction between them remains somewhat unclear due to limited TypeScript documentation. Here's the adjusted segment of the code:

const result = await this.executor.run({
    input: question,
});

Despite this modification, a similar error persisted:

Error retrieving response from as knowledge base using OpenAI: Error: Chain agent_executor expects multiple inputs, cannot use 'run'
(...)

I also opted to comment out the loadMemoryVariables() line to rule out potential duplicate input issues, yet yielded no improvement.

Answer №1

I encountered a similar issue but solved it by using the AbortSignal object in combination with the openai-functions agent.

You'll want to make the following adjustment:

const outcome = await this.executor.call({ 
    input: query,
    chat_history: relevantEntityHistory.history,
});

Change it to:

const history = relevantEntityHistory.history
const outcome = await this.executor.call({ 
    input: query,
    chat_history: history,
});

Hopefully, this solution works for you!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a split hero section view using a combination of absolute/relative CSS techniques, Tailwind, and React

I'm in the process of creating a website using Nextjs, React, and TailwindCSS, and I aim to design a Hero section that resembles the one on the following website. https://i.sstatic.net/tq3zW.png My goal is to: Have a text title and buttons on the l ...

Error with the `this` keyword in TypeScript - value is undefined

I'm encountering an issue with my AWS Lambda function written in TypeScript that calls functions from different classes. The problem is that I am receiving 'undefined' for the existingProducts variable, even though it functions correctly whe ...

Unable to update markers on agm-map for dynamic display

In my Angular 5 application, I am utilizing Angular Google Maps (https://angular-maps.com/) along with socket.io for real-time data updates of latitude and longitude from the server. Although I am successfully pushing the updated data to an array in the co ...

Can the typography style of a material-ui TextField component be modified to incorporate a caption variant?

Currently diving into the world of material-ui for implementation in a Typescript React setup. Utilizing the code snippet below in a Dialog: ... <React.Fragment> <Typography variant="body1"> <Box mt={1}>Heading</Box> & ...

Seeking a quick conversion method for transforming x or x[] into x[] in a single line of code

Is there a concise TypeScript one-liner that can replace the arrayOrMemberToArray function below? function arrayOrMemberToArray<T>(input: T | T[]): T[] { if(Arrary.isArray(input)) return input return [input] } Trying to cram this logic into a te ...

When I apply filtering and grouping to the table, the rows in the mat table disappear

When using mat-table, grouping works fine without filtering. However, once the table is filtered or if the search bar is focused, ungrouping causes the rows in the table to disappear. I am looking for a solution that allows me to group and ungroup the tabl ...

What is the best way to define a type for a variable within a function, depending on the type of an argument passed to that function in Typescript?

As I delve into developing a custom useFetch composable for a Vue application, the focus seems to shift towards TypeScript. Essentially, my query revolves around conditionally asserting a type to a variable within a function, contingent on the type of an a ...

The unsightly square surrounding my sprite in Three.js

I am attempting to create a beautiful "starry sky" effect using Three.js. However, I am encountering an issue where my transparent .png star sprites have a colored outline around them. Here is the sprite I am using: https://i.sstatic.net/2uylp.png This ...

What is the best way to create an instance method in a subclass that can also call a different instance method?

In our programming project, we have a hierarchy of classes where some classes inherit from a base class. Our goal is to create an instance method that is strongly-typed in such a way that it only accepts the name of another instance method as input. We d ...

Ways to maintain data returned by forkJoin

I encountered a situation where I needed to retrieve results from 2 HTTP calls and combine them into an array that would be passed to a class instantiation. Below is the code snippet: export class VideoListComponent implements OnInit { @ViewChild(MatPag ...

What is the best way to implement asynchronous guarding for users?

Seeking assistance with implementing async route guard. I have a service that handles user authentication: @Injectable() export class GlobalVarsService { private isAgreeOk = new BehaviorSubject(false); constructor() { }; getAgreeState(): Obser ...

The issue arises when the desired image size is not reflected correctly on the background after changing

I've been working on a basic image slideshow where the background image changes based on user selection. However, I've noticed that when I change the image for the first time, the backgroundSize: cover property seems to disappear. Even if I try c ...

Potential null object in React/TypeScript

Encountering a persistent error here - while the code functions smoothly in plain react, it consistently throws an error in typescript stating "Object is possibly null". Attempts to resolve with "!" have proved futile. Another error logged reads as follow ...

How should a React component's contextTypes be correctly defined using TypeScript?

What is the proper way to define the contextTypes in TypeScript? I have a component (note: I'm unsure of the necessary type of router as detailed in this question but that should be irrelevant here) export class Repos extends React.Component<Repo ...

The attempt to upload a file in Angular was unsuccessful

Below is the backend code snippet used to upload a file: $app->post('/upload/{studentid}', function(Request $request, Response $response, $args) { $uploadedFiles = $request->getUploadedFiles(); $uploadedFile = $uploadedFiles[&apo ...

Creating a fresh JSON structure by utilizing an established one

I have a JSON data that contains sections and rubrics, but I only need the items for a new listing. The new object named 'items' should consist of an array of all the items. The final JSON output should be sorted by the attribute 'name&apos ...

The error message "The file 'environment.ts' is not located within the specified 'rootDir' directory" was encountered during the Angular Library build process

When attempting to access the environment variable in an Angular 9 library, I encountered an error during the library build process. Here is how it was implemented: import { EnvironmentViewModel } from 'projects/falcon-core/src/lib/view-models/envir ...

Dealing with numerous errors from various asynchronous pipes in angular - a comprehensive guide

I am facing an issue with 2 mat-select elements in my component, both of which utilize the async pipe: <div class="flex-col"> <mat-label>Issue Desc </mat-label> <mat-form-field> < ...

What is GraphQl indicating when it informs me that I neglected to send arguments for the mutation

My GraphQL schema consists of various mutations and queries. I believe that validation of mutations should only occur when I send mutation { ... } to the graphql server. However, currently, the server is informing me that I have not sent arguments for all ...

Navigating through a complex array structure and having the capability to both search and filter its elements

hi there! I'm reaching out for some assistance with a challenge that I've encountered. Currently, I am working on developing a dashboard that iterates through criminal charges. I have structured the database table as follows: category charges ...