Adding gpt feature

#3
by Roo-Kh - opened
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -233,7 +233,19 @@ def process_and_query(text=None, image=None, audio=None):
233
  # Now, use the text (either provided by the user or obtained from OpenAI) to query Vectara
234
  vectara_response_json = query_vectara(text)
235
  markdown_output = convert_to_markdown(vectara_response_json)
236
- return markdown_output + text
 
 
 
 
 
 
 
 
 
 
 
 
237
  except Exception as e:
238
  return str(e)
239
 
 
233
  # Now, use the text (either provided by the user or obtained from OpenAI) to query Vectara
234
  vectara_response_json = query_vectara(text)
235
  markdown_output = convert_to_markdown(vectara_response_json)
236
+ client = OpenAI()
237
+ prompt ="Answer in the same language, write it better, more understandable and shorter:"
238
+ markdown_output_final = markdown_output
239
+
240
+ completion = client.chat.completions.create(
241
+ model="gpt-3.5-turbo",
242
+ messages=[
243
+ {"role": "system", "content": prompt},
244
+ {"role": "user", "content": markdown_output_final}
245
+ ]
246
+ )
247
+ final_response= completion.choices[0].message.content
248
+ return final_response
249
  except Exception as e:
250
  return str(e)
251