diff --git a/app.py b/app.py
index d70ead4..2c83c1c 100644
--- a/app.py
+++ b/app.py
@@ -438,6 +438,13 @@ def handle_message(data):
# Cancel the most recent generation request
eventlet.spawn(cancel_generation, room_name, data["username"])
+ if "dall-e-3" in data["message"]:
+ # Use the entire message as the prompt for DALL-E 3
+ # Generate the image and emit its URL
+ eventlet.spawn(
+ generate_dalle_image, data["room_name"], data["message"], data["username"]
+ )
+
if (
"claude-v1" in data["message"]
or "claude-v2" in data["message"]
@@ -496,7 +503,12 @@ def chat_claude(username, room_name, message, model_name="anthropic.claude-v1"):
chat_history = ""
+ def is_base64_image(content):
+ return "
{revised_prompt}
' + + except Exception as e: + # Set the content to an error message + content = f"Error generating image: {e}" + + # Store the content in the database and emit to the frontend + with app.app_context(): + room = get_room(room_name) + new_message = Message( + username=username, + content=content, # Store the img tag or error message as the content + room_id=room.id, # Make sure you have the room ID available + ) + db.session.add(new_message) + db.session.commit() + + # Emit the message with the content to the frontend + socketio.emit( + "message", + {"id": new_message.id, "username": username, "content": content}, + room=room_name, + ) + + if __name__ == "__main__": import argparse