langchainjs icon indicating copy to clipboard operation
langchainjs copied to clipboard

Agent outputParser mangles toolInput - removes final quote

Open kumavis opened this issue 2 years ago • 1 comments

current code https://github.com/hwchase17/langchainjs/blame/f78f2e90e95878da7c6067fd52e6a75eb0efb5fd/langchain/src/agents/mrkl/outputParser.ts#L17-L26

mangles tool input for this case:

const text = `
 I need to look for commits with a specific date
Action: git
Action Input: git log --pretty=format:"%h %an %ad" --since="date"
`
 
const match = /Action: (.*)\nAction Input: (.*)/s.exec(text);

console.log({
  action: match[1],
  actionInput: match[2],
  fixed: match[2].trim().replace(/^"+|"+$/g, "") ?? "",
})

// {
//   action: 'git',
//   actionInput: 'git log --pretty=format:"%h %an %ad" --since="date"\n',
//   fixed: 'git log --pretty=format:"%h %an %ad" --since="date'
// }

note missing double quote on end of "fixed" action input

kumavis avatar Apr 21 '23 07:04 kumavis

I'm not sure what the original intention was but this version worked for me:

    return {
      tool: match[1].trim(),
      toolInput: match[2].trim().replace(/\n/g, ""),
      log: text,
    };

kumavis avatar Apr 21 '23 07:04 kumavis

Hi, @kumavis. I'm helping the LangChain team manage their backlog and I wanted to let you know that we are marking this issue as stale. From what I understand, the outputParser.ts file in the LangChain repository is causing the final quote to be removed from the tool input. The suggested fix is to modify the code in the outputParser.ts file. We wanted to check if this issue is still relevant to the latest version of the LangChain repo. If you could let us know, the LangChain team will take a look. Otherwise, if we don't hear back from you, the issue will be automatically closed in 7 days.

dosubot[bot] avatar Aug 16 '23 16:08 dosubot[bot]