not-lain Roo-Kh commited on
Commit
9fadbfb
·
1 Parent(s): 4c789f9

Adding gpt feature (#3)

Browse files

- Adding gpt feature (522ab632278a0b6fda2806d6931aa59b06b41b86)


Co-authored-by: Rawan <Roo-Kh@users.noreply.huggingface.co>

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