Skip to content

Commit a15afc1

Browse files
authored
Relax the action input check for actions that require no input (#6357)
When the tool requires no input, the LLM often gives something like this: ```json { "action": "just_do_it" } ``` I have attempted to enhance the prompt, but it doesn't appear to be functioning effectively. Therefore, I believe we should consider easing the check a little bit. Signed-off-by: Xiaochao Dong (@damnever) <[email protected]>
1 parent cc33bde commit a15afc1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

langchain/agents/chat/output_parser.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ def parse(self, text: str) -> Union[AgentAction, AgentFinish]:
1717
try:
1818
action = text.split("```")[1]
1919
response = json.loads(action.strip())
20-
includes_action = "action" in response and "action_input" in response
20+
includes_action = "action" in response
2121
if includes_answer and includes_action:
2222
raise OutputParserException(
2323
"Parsing LLM output produced a final answer "
2424
f"and a parse-able action: {text}"
2525
)
26-
return AgentAction(response["action"], response["action_input"], text)
26+
return AgentAction(
27+
response["action"], response.get("action_input", {}), text
28+
)
2729

2830
except Exception:
2931
if not includes_answer:

0 commit comments

Comments
 (0)