Refactor ChatVertex class to update artifacts and params

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-02-27 20:39:59 -03:00
commit 8b7ee72252

View file

@ -424,15 +424,16 @@ class ChatVertex(StatelessVertex):
message = message.text if hasattr(message, "text") else message
yield message
complete_message += message
self._built_object = Record(text=complete_message, data=self.artifacts)
self._built_result = complete_message
# Update artifacts with the message
# and remove the stream_url
self.artifacts = ChatOutputResponse(
message=complete_message,
sender=self.params.get("sender", ""),
sender_name=self.params.get("sender_name", ""),
).model_dump()
self.params[INPUT_FIELD_NAME] = complete_message
self._built_object = Record(text=complete_message, data=self.artifacts)
self._built_result = complete_message
# Update artifacts with the message
# and remove the stream_url
logger.debug(f"Streamed message: {complete_message}")
await log_message(
@ -443,6 +444,9 @@ class ChatVertex(StatelessVertex):
artifacts=self.artifacts,
)
self._validate_built_object()
self._built = True
class RoutingVertex(StatelessVertex):
def __init__(self, data: Dict, graph):