feat(chat_manager.py): add base64 encoding for image data in FileResponse objects
This commit is contained in:
parent
d3b72f3958
commit
70bfc77a82
1 changed files with 4 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ class ChatHistory(Subject):
|
|||
"""Add a message to the chat history."""
|
||||
|
||||
self.history[client_id].append(message)
|
||||
|
||||
if not isinstance(message, FileResponse):
|
||||
self.notify()
|
||||
|
||||
|
|
@ -127,6 +128,9 @@ class ChatManager:
|
|||
# Iterate backwards through the history
|
||||
for msg in reversed(history):
|
||||
if isinstance(msg, FileResponse):
|
||||
if msg.data_type == "image":
|
||||
# Base64 encode the image
|
||||
msg.data = pil_to_base64(msg.data)
|
||||
file_responses.append(msg)
|
||||
if msg.type == "start":
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue