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.