Bugfix/undefined returned by agent for lowercase (#2885)
fix undefined returned by agent for lowercase
This commit is contained in:
parent
c6264a24cc
commit
2dadf2e42b
|
|
@ -339,7 +339,7 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _call(inputs: ChainValues, runManager?: CallbackManagerForChainRun): Promise<AgentExecutorOutput> {
|
async _call(inputs: ChainValues, runManager?: CallbackManagerForChainRun): Promise<AgentExecutorOutput> {
|
||||||
const toolsByName = Object.fromEntries(this.tools.map((t) => [t.name.toLowerCase(), t]))
|
const toolsByName = Object.fromEntries(this.tools.map((t) => [t.name?.toLowerCase(), t]))
|
||||||
|
|
||||||
const steps: AgentStep[] = []
|
const steps: AgentStep[] = []
|
||||||
let iterations = 0
|
let iterations = 0
|
||||||
|
|
@ -608,7 +608,7 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
|
||||||
|
|
||||||
async _getToolReturn(nextStepOutput: AgentStep): Promise<AgentFinish | null> {
|
async _getToolReturn(nextStepOutput: AgentStep): Promise<AgentFinish | null> {
|
||||||
const { action, observation } = nextStepOutput
|
const { action, observation } = nextStepOutput
|
||||||
const nameToolMap = Object.fromEntries(this.tools.map((t) => [t.name.toLowerCase(), t]))
|
const nameToolMap = Object.fromEntries(this.tools.map((t) => [t.name?.toLowerCase(), t]))
|
||||||
const [returnValueKey = 'output'] = this.agent.returnValues
|
const [returnValueKey = 'output'] = this.agent.returnValues
|
||||||
// Invalid tools won't be in the map, so we return False.
|
// Invalid tools won't be in the map, so we return False.
|
||||||
if (action.tool in nameToolMap) {
|
if (action.tool in nameToolMap) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue