Mapping vs AgentAction #8466
Replies: 1 comment
-
Answer generated by a 🤖 AnswerHello, The error you're encountering is due to the fact that the The However, the To resolve this issue, you should modify your Here's an example of how you might modify your def parse(self, text: str) -> dict:
action_prefix = "Action: "
if not text.strip().split("
")[-1].startswith(action_prefix):
raise OutputParserException(f"Could not parse LLM Output: {text}")
action_block = text.strip().split("
")[-1]
action_str = action_block[len(action_prefix) :]
# Parse out the action and the directive.
re_matches = re.search(r"(.*?)\[(.*?)\]", action_str)
if re_matches is None:
raise OutputParserException(
f"Could not parse action directive: {action_str}"
)
action, action_input = re_matches.group(1), re_matches.group(2)
if action == "Finish":
return {"output": action_input}
else:
return {"action": action, "action_input": action_input} This version of the I hope this helps! Let me know if you have any other questions. SourcesThis response is meant to be useful, save you time, and share context. 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. |
Beta Was this translation helpful? Give feedback.
-
I was trying to implement parse function for the handle_parsing_errors parameter in initialize_agent, which is Conversational React, where I would eliminate the json markdown and backticks, and just return the action output key value pair. My return statement for the parse function is {return AgentAction(response["action"], response["action_input"], text)}, and the error that Im receiving is TypeError: langchain.agents.agent.ExceptionTool._run() argument after ** must be a mapping, not AgentAction. Can someone explain what needs to be done? Would be much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions