Bläddra i källkod

feat: optimize output parse (#906)

tags/0.3.15
takatost 2 år sedan
förälder
incheckning
d9afebe216
Inget konto är kopplat till bidragsgivarens mejladress
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. 2
    2
      api/core/agent/agent/output_parser/structured_chat.py

+ 2
- 2
api/core/agent/agent/output_parser/structured_chat.py Visa fil

@@ -10,7 +10,7 @@ from langchain.schema import AgentAction, AgentFinish, OutputParserException
class StructuredChatOutputParser(LCStructuredChatOutputParser):
def parse(self, text: str) -> Union[AgentAction, AgentFinish]:
try:
action_match = re.search(r"```(.*?)\n?(.*?)```", text, re.DOTALL)
action_match = re.search(r"```(\w*)\n?({.*?)```", text, re.DOTALL)
if action_match is not None:
response = json.loads(action_match.group(2).strip(), strict=False)
if isinstance(response, list):
@@ -26,4 +26,4 @@ class StructuredChatOutputParser(LCStructuredChatOutputParser):
else:
return AgentFinish({"output": text}, text)
except Exception as e:
raise OutputParserException(f"Could not parse LLM output: {text}") from e
raise OutputParserException(f"Could not parse LLM output: {text}")

Laddar…
Avbryt
Spara