Spanicin commited on
Commit
842cb96
·
verified ·
1 Parent(s): 8a2e4ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
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=[{"role": "system", "content": "Ensure answers are concise, human-like, and clear while maintaining quality. Use the fewest possible words, avoiding unnecessary articles, prepositions, and adjectives. Responses should be short but still address the question thoroughly without being verbose.Keep them to one sentence only"},
168
- {"role": "user", "content": f"Hi! I need help with something. {text_prompt}"},
 
169
  ],
170
- max_tokens = len(text_prompt) + 300 # Use the length of the input text
171
- # temperature=0.3,
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')