improve chat error (#1632)

This commit is contained in:
Harrison Chase 2023-03-13 07:43:44 -07:00 committed by GitHub
parent cb646082ba
commit 72b461e257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,10 +44,13 @@ class ChatAgent(Agent):
def _extract_tool_and_input(self, text: str) -> Optional[Tuple[str, str]]:
if FINAL_ANSWER_ACTION in text:
return "Final Answer", text.split(FINAL_ANSWER_ACTION)[-1].strip()
_, action, _ = text.split("```")
try:
_, action, _ = text.split("```")
response = json.loads(action.strip())
return response["action"], response["action_input"]
response = json.loads(action.strip())
return response["action"], response["action_input"]
except Exception:
raise ValueError(f"Could not parse LLM output: {text}")
@property
def _stop(self) -> List[str]: