set output attachment

This commit is contained in:
Billy Bao 2025-11-13 17:11:50 +08:00
parent 944d88de47
commit db39358f88
2 changed files with 7 additions and 2 deletions

View file

@ -405,6 +405,8 @@ class Canvas(Graph):
_m += m
cpn_obj.set_output("content", _m)
cite = re.search(r"\[ID:[ 0-9]+\]", _m)
elif isinstance(cpn_obj.output("attachment"), tuple):
yield decorate("message", {"attachment": cpn_obj.output("attachment")})
else:
yield decorate("message", {"content": cpn_obj.output("content")})
cite = re.search(r"\[ID:[ 0-9]+\]", cpn_obj.output("content"))

View file

@ -168,7 +168,6 @@ class Message(ComponentBase):
for n, v in kwargs.items():
content = re.sub(n, v, content)
self.set_output("content", content)
self._convert_content(content)
def thoughts(self) -> str:
@ -222,7 +221,11 @@ class Message(ComponentBase):
os.remove(tmp_name)
settings.STORAGE_IMPL.put(self._canvas._tenant_id, doc_id, binary_content)
self.set_output("attachment", (doc_id, self._param.output_format, f"{doc_id[:8]}.{self._param.output_format}"))
logging.info(f"Converted content uploaded as {doc_id} (format={self._param.output_format})")
except Exception as e:
logging.error(f"Error converting content to {self._param.output_format}: {e}")
logging.error(f"Error converting content to {self._param.output_format}: {e}")
self.set_output("attachment", None)