Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,8 @@ import requests
|
|
21 |
import json
|
22 |
import pickle
|
23 |
import re
|
|
|
|
|
24 |
# from videoretalking import inference_function
|
25 |
# import base64
|
26 |
# import gfpgan_enhancer
|
@@ -165,7 +167,7 @@ def openai_chat_avatar(text_prompt):
|
|
165 |
response = client.chat.completions.create(
|
166 |
model="gpt-4o-mini",
|
167 |
messages=[
|
168 |
-
{"role": "system", "content": "Summarize the following paragraph into a complete and accurate single sentence with no more than 15 words. The summary should capture the gist of the paragraph and make sense."},
|
169 |
{"role": "user", "content": f"Please summarize the following paragraph into one sentence with 15 words or fewer, ensuring it makes sense and captures the gist and remove the citation from the end: {text_prompt}"},
|
170 |
],
|
171 |
max_tokens = len(text_prompt), # Limit the response to a reasonable length for a summary
|
@@ -347,17 +349,20 @@ def generate_video():
|
|
347 |
|
348 |
|
349 |
if chat_model_used == 'ryzedb':
|
|
|
350 |
start_time_ryze = time.time()
|
351 |
response = ryzedb_chat_avatar(text_prompt, app_id)
|
|
|
|
|
352 |
text_prompt = extract_content(response)
|
|
|
353 |
text_prompt = text_prompt.replace('\n', ' ').replace('\\n', ' ').strip()
|
|
|
|
|
354 |
if "No information available" in text_prompt:
|
355 |
text_prompt = re.sub(r'\\+', '', text_prompt)
|
|
|
356 |
|
357 |
-
response = openai_chat_avatar(text_prompt)
|
358 |
-
text_prompt = response.choices[0].message.content.strip()
|
359 |
-
app.config['text_prompt'] = text_prompt
|
360 |
-
print('Final output text prompt using ryzedb: ',text_prompt)
|
361 |
# events = response.split('\r\n\r\n')
|
362 |
# content = None
|
363 |
# for event in events:
|
|
|
21 |
import json
|
22 |
import pickle
|
23 |
import re
|
24 |
+
import aiohttp
|
25 |
+
import random
|
26 |
# from videoretalking import inference_function
|
27 |
# import base64
|
28 |
# import gfpgan_enhancer
|
|
|
167 |
response = client.chat.completions.create(
|
168 |
model="gpt-4o-mini",
|
169 |
messages=[
|
170 |
+
{"role": "system", "content": "Summarize the following paragraph into a complete and accurate single sentence with no more than 15 words. The summary should capture the gist of the paragraph and make sense and remove the citation and document name from the end."},
|
171 |
{"role": "user", "content": f"Please summarize the following paragraph into one sentence with 15 words or fewer, ensuring it makes sense and captures the gist and remove the citation from the end: {text_prompt}"},
|
172 |
],
|
173 |
max_tokens = len(text_prompt), # Limit the response to a reasonable length for a summary
|
|
|
349 |
|
350 |
|
351 |
if chat_model_used == 'ryzedb':
|
352 |
+
start_time_ryze = time.time()
|
353 |
start_time_ryze = time.time()
|
354 |
response = ryzedb_chat_avatar(text_prompt, app_id)
|
355 |
+
text_prompt = ryzedb_chat_avatar(text_prompt, app_id)
|
356 |
+
print("Response from inference",text_prompt)
|
357 |
text_prompt = extract_content(response)
|
358 |
+
# text_prompt = extract_content(response)
|
359 |
text_prompt = text_prompt.replace('\n', ' ').replace('\\n', ' ').strip()
|
360 |
+
# text_prompt = text_prompt.replace('\n', ' ').replace('\\n', ' ').strip()
|
361 |
+
if "No information available" in text_prompt:
|
362 |
if "No information available" in text_prompt:
|
363 |
text_prompt = re.sub(r'\\+', '', text_prompt)
|
364 |
+
text_prompt = re.sub(r'\\+', '', text_prompt)
|
365 |
|
|
|
|
|
|
|
|
|
366 |
# events = response.split('\r\n\r\n')
|
367 |
# content = None
|
368 |
# for event in events:
|