Tonic commited on
Commit
75cae88
1 Parent(s): 03ff7a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -238,6 +238,32 @@ def convert_to_markdown(vectara_response_json):
238
  return "No data found in the response."
239
  # Main function to handle the Gradio interface logic
240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
 
242
  def process_and_query(text=None):
243
  try:
 
238
  return "No data found in the response."
239
  # Main function to handle the Gradio interface logic
240
 
241
+ def process_summary_with_openai(summary):
242
+ """
243
+ This function takes a summary text as input and processes it with OpenAI's GPT model.
244
+ """
245
+ try:
246
+ # Ensure that the OpenAI client is properly initialized
247
+ client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))
248
+
249
+ # Create the prompt for OpenAI's completion
250
+ prompt = "Please summarize the following text in two lines and make it more understandable:"
251
+
252
+ # Call the OpenAI API with the prompt and the summary
253
+ completion = client.chat.completions.create(
254
+ model="gpt-3.5-turbo", # Make sure to use the correct model name
255
+ messages=[
256
+ {"role": "system", "content": prompt},
257
+ {"role": "user", "content": summary}
258
+ ]
259
+ )
260
+
261
+ # Extract the content from the completion
262
+ final_summary = completion.choices[0].message.content
263
+ return final_summary
264
+ except Exception as e:
265
+ return str(e)
266
+
267
 
268
  def process_and_query(text=None):
269
  try: