mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-20 03:21:33 +00:00
improve chat error (#1632)
This commit is contained in:
parent
cb646082ba
commit
72b461e257
@ -44,11 +44,14 @@ class ChatAgent(Agent):
|
|||||||
def _extract_tool_and_input(self, text: str) -> Optional[Tuple[str, str]]:
|
def _extract_tool_and_input(self, text: str) -> Optional[Tuple[str, str]]:
|
||||||
if FINAL_ANSWER_ACTION in text:
|
if FINAL_ANSWER_ACTION in text:
|
||||||
return "Final Answer", text.split(FINAL_ANSWER_ACTION)[-1].strip()
|
return "Final Answer", text.split(FINAL_ANSWER_ACTION)[-1].strip()
|
||||||
|
try:
|
||||||
_, action, _ = text.split("```")
|
_, action, _ = text.split("```")
|
||||||
|
|
||||||
response = json.loads(action.strip())
|
response = json.loads(action.strip())
|
||||||
return response["action"], response["action_input"]
|
return response["action"], response["action_input"]
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
raise ValueError(f"Could not parse LLM output: {text}")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _stop(self) -> List[str]:
|
def _stop(self) -> List[str]:
|
||||||
return ["Observation:"]
|
return ["Observation:"]
|
||||||
|
Loading…
Reference in New Issue
Block a user