Add validation to process_new_user_message to restrict multiple video uploads
Browse files
app.py
CHANGED
|
@@ -45,6 +45,9 @@ def process_new_user_message(message: dict) -> list[dict]:
|
|
| 45 |
if not message["files"]:
|
| 46 |
return [{"type": "text", "text": message["text"]}]
|
| 47 |
|
|
|
|
|
|
|
|
|
|
| 48 |
if "<image>" in message["text"]:
|
| 49 |
content = []
|
| 50 |
logger.debug(f"{message['files']=}")
|
|
|
|
| 45 |
if not message["files"]:
|
| 46 |
return [{"type": "text", "text": message["text"]}]
|
| 47 |
|
| 48 |
+
if len([path for path in message["files"] if path.endswith(".mp4")]) > 1:
|
| 49 |
+
raise gr.Error("Only one video is supported at a time.")
|
| 50 |
+
|
| 51 |
if "<image>" in message["text"]:
|
| 52 |
content = []
|
| 53 |
logger.debug(f"{message['files']=}")
|