pull/22809/head
crazywoola 8 months ago
parent 6d3e198c3c
commit bcce68cead

@ -10,10 +10,12 @@ class SuggestedQuestionsAfterAnswerOutputParser:
return SUGGESTED_QUESTIONS_AFTER_ANSWER_INSTRUCTION_PROMPT
def parse(self, text: str) -> Any:
if not isinstance(text, str):
# Optionally log a warning here
return []
action_match = re.search(r"\[.*?\]", text.strip(), re.DOTALL)
if action_match is not None:
json_obj = json.loads(action_match.group(0).strip())
else:
json_obj = []
return json_obj

@ -317,7 +317,13 @@ class ToolNode(BaseNode):
elif message.type == ToolInvokeMessage.MessageType.FILE:
assert message.meta is not None
assert isinstance(message.meta, dict)
assert "file" in message.meta and isinstance(message.meta["file"], File)
# Validate that meta contains a 'file' key
if "file" not in message.meta:
raise ToolNodeError("File message is missing 'file' key in meta")
# Validate that the file is an instance of File
if not isinstance(message.meta["file"], File):
raise ToolNodeError(f"Expected File object but got {type(message.meta['file']).__name__}")
files.append(message.meta["file"])
elif message.type == ToolInvokeMessage.MessageType.LOG:
assert isinstance(message.message, ToolInvokeMessage.LogMessage)

Loading…
Cancel
Save