feat(chat_manager.py): add file responses to ChatResponse

feat(schemas.py): add files field to ChatResponse schema
This commit is contained in:
Gabriel Almeida 2023-04-25 22:01:50 -03:00
commit 4dcfd9d1db
2 changed files with 11 additions and 0 deletions

View file

@ -120,10 +120,20 @@ class ChatManager:
raise e
# Send a response back to the frontend, if needed
intermediate_steps = intermediate_steps or ""
history = self.chat_history.get_history(client_id, filter=False)
file_responses = []
if history:
for msg in history:
if isinstance(msg, FileResponse):
file_responses.append(msg)
if msg.type == "start":
break
response = ChatResponse(
message=result or "",
intermediate_steps=intermediate_steps.strip(),
type="end",
files=file_responses,
)
self.chat_history.add_message(client_id, response)

View file

@ -16,6 +16,7 @@ class ChatResponse(ChatMessage):
intermediate_steps: str
type: str
is_bot: bool = True
files: list = []
@validator("type")
def validate_message_type(cls, v):