Update app.py
Browse files
app.py
CHANGED
@@ -166,14 +166,14 @@ def openai_chat_avatar(text_prompt):
|
|
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: {text_prompt}"},
|
170 |
],
|
171 |
max_tokens = len(text_prompt), # Limit the response to a reasonable length for a summary
|
172 |
)
|
173 |
return response
|
174 |
|
175 |
def ryzedb_chat_avatar(question, app_id):
|
176 |
-
url = "https://inference.dev.ryzeai.ai/chat/stream"
|
177 |
# question = question + ". Summarize the answer in one line."
|
178 |
# print("question",question)
|
179 |
payload = json.dumps({
|
@@ -182,7 +182,8 @@ def ryzedb_chat_avatar(question, app_id):
|
|
182 |
"app_id": app_id,
|
183 |
"question": question
|
184 |
},
|
185 |
-
"config": {
|
|
|
186 |
})
|
187 |
headers = {
|
188 |
'Content-Type': 'application/json'
|
@@ -289,13 +290,18 @@ def run_preprocessing(args):
|
|
289 |
# cleaned_text = re.sub(r'\s*\[.*?\]\s*$', '', text)
|
290 |
# return cleaned_text.strip()
|
291 |
|
292 |
-
def extract_content(
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
299 |
|
300 |
@app.route("/run", methods=['POST'])
|
301 |
def generate_video():
|
|
|
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
|
172 |
)
|
173 |
return response
|
174 |
|
175 |
def ryzedb_chat_avatar(question, app_id):
|
176 |
+
url = "https://inference.dev.ryzeai.ai/v2/chat/stream"
|
177 |
# question = question + ". Summarize the answer in one line."
|
178 |
# print("question",question)
|
179 |
payload = json.dumps({
|
|
|
182 |
"app_id": app_id,
|
183 |
"question": question
|
184 |
},
|
185 |
+
"config": {
|
186 |
+
"thread_id": "123456"
|
187 |
})
|
188 |
headers = {
|
189 |
'Content-Type': 'application/json'
|
|
|
290 |
# cleaned_text = re.sub(r'\s*\[.*?\]\s*$', '', text)
|
291 |
# return cleaned_text.strip()
|
292 |
|
293 |
+
def extract_content(line):
|
294 |
+
print("line :", line)
|
295 |
+
if line.startswith("data:"):
|
296 |
+
print("Entering extract content")
|
297 |
+
json_part = line[len("data:"):].strip()
|
298 |
+
if json_part:
|
299 |
+
try:
|
300 |
+
parsed = json.loads(json_part)
|
301 |
+
return parsed.get("content")
|
302 |
+
except json.JSONDecodeError:
|
303 |
+
pass
|
304 |
+
return None
|
305 |
|
306 |
@app.route("/run", methods=['POST'])
|
307 |
def generate_video():
|