Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -362,18 +362,18 @@ def generate_video():
|
|
362 |
content = None
|
363 |
for event in events:
|
364 |
# Split each event block by "\r\n" to get the lines
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
|
378 |
else:
|
379 |
response = openai_chat_avatar(text_prompt)
|
|
|
362 |
content = None
|
363 |
for event in events:
|
364 |
# Split each event block by "\r\n" to get the lines
|
365 |
+
lines = event.split('\r\n')
|
366 |
+
if len(lines) > 1 and lines[0] == 'event: data':
|
367 |
+
# Extract the JSON part from the second line and parse it
|
368 |
+
json_data = lines[1].replace('data: ', '')
|
369 |
+
try:
|
370 |
+
data = json.loads(json_data)
|
371 |
+
text_prompt = data.get('content')
|
372 |
+
app.config['text_prompt'] = text_prompt
|
373 |
+
print('Final output text prompt using ryzedb: ',text_prompt)
|
374 |
+
break # Exit the loop once content is found
|
375 |
+
except json.JSONDecodeError:
|
376 |
+
continue
|
377 |
|
378 |
else:
|
379 |
response = openai_chat_avatar(text_prompt)
|