Update app.py
Browse files
app.py
CHANGED
@@ -164,19 +164,19 @@ client = OpenAI(api_key="sk-proj-04146TPzEmvdV6DzSxsvNM7jxOnzys5TnB7iZB0tp59B-jM
|
|
164 |
def openai_chat_avatar(text_prompt):
|
165 |
response = client.chat.completions.create(
|
166 |
model="gpt-4o-mini",
|
167 |
-
messages=[
|
168 |
-
{"role": "
|
|
|
169 |
],
|
170 |
-
max_tokens =
|
171 |
-
|
172 |
-
# stop=["Translate:", "Text:"]
|
173 |
)
|
174 |
return response
|
175 |
|
176 |
def ryzedb_chat_avatar(question, app_id):
|
177 |
url = "https://inference.dev.ryzeai.ai/chat/stream"
|
178 |
-
question = question + ". Summarize the answer in one line."
|
179 |
-
print("question",question)
|
180 |
payload = json.dumps({
|
181 |
"input": {
|
182 |
"chat_history": [],
|
@@ -344,6 +344,8 @@ def generate_video():
|
|
344 |
text_prompt = text_prompt.replace('\n', ' ').replace('\\n', ' ').strip()
|
345 |
if "No information available" in text_prompt:
|
346 |
text_prompt = re.sub(r'\\+', '', text_prompt)
|
|
|
|
|
347 |
app.config['text_prompt'] = text_prompt
|
348 |
print('Final output text prompt using ryzedb: ',text_prompt)
|
349 |
# events = response.split('\r\n\r\n')
|
|
|
164 |
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 text accurately and concisely. Avoid any hallucination and provide only the key points in a clear, concise manner."},
|
169 |
+
{"role": "user", "content": f"Please summarize the following paragraph: {text_prompt}"},
|
170 |
],
|
171 |
+
max_tokens = 500, # Limit the response to a reasonable length for a summary
|
172 |
+
temperature=0.3,
|
|
|
173 |
)
|
174 |
return response
|
175 |
|
176 |
def ryzedb_chat_avatar(question, app_id):
|
177 |
url = "https://inference.dev.ryzeai.ai/chat/stream"
|
178 |
+
# question = question + ". Summarize the answer in one line."
|
179 |
+
# print("question",question)
|
180 |
payload = json.dumps({
|
181 |
"input": {
|
182 |
"chat_history": [],
|
|
|
344 |
text_prompt = text_prompt.replace('\n', ' ').replace('\\n', ' ').strip()
|
345 |
if "No information available" in text_prompt:
|
346 |
text_prompt = re.sub(r'\\+', '', text_prompt)
|
347 |
+
|
348 |
+
text_prompt = openai_chat_avatar(text_prompt)
|
349 |
app.config['text_prompt'] = text_prompt
|
350 |
print('Final output text prompt using ryzedb: ',text_prompt)
|
351 |
# events = response.split('\r\n\r\n')
|