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) <the.xcdong@gmail.com>
This commit is contained in:
Xiaochao Dong 2023-06-26 17:30:17 +08:00 committed by GitHub
parent cc33bde74f
commit a15afc102c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,13 +17,15 @@ class ChatOutputParser(AgentOutputParser):
try:
action = text.split("```")[1]
response = json.loads(action.strip())
includes_action = "action" in response and "action_input" in response
includes_action = "action" in response
if includes_answer and includes_action:
raise OutputParserException(
"Parsing LLM output produced a final answer "
f"and a parse-able action: {text}"
)
return AgentAction(response["action"], response["action_input"], text)
return AgentAction(
response["action"], response.get("action_input", {}), text
)
except Exception:
if not includes_answer: