mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-03 21:54:04 +00:00
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:
parent
cc33bde74f
commit
a15afc102c
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user