Tonic commited on
Commit
5279d37
·
1 Parent(s): 979fe41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -4,6 +4,12 @@ from dotenv import load_dotenv
4
  import os
5
  import time
6
 
 
 
 
 
 
 
7
  load_dotenv()
8
  openai.api_key = os.getenv('OPENAI_API_KEY')
9
  assistant_id=os.getenv('ASSISTANT_ID')
@@ -55,14 +61,11 @@ def ask_openai(question):
55
  message_id=message_id
56
  )
57
  if message.content and message.content[0].type == 'text':
58
- return message.content[0].text.value # Accessing the 'value' field correctly
59
  return "No response."
60
-
61
- examples = [
62
- ["My Eucalyptus tree is struggling outside in the cold weather in europe"],
63
- ["My callatea house plant is yellowing."],
64
- ["We have a catcus as work that suddently started yellowing and wilting."]
65
- ]
66
 
67
  iface = gr.Interface(
68
  fn=ask_openai,
 
4
  import os
5
  import time
6
 
7
+ examples = [
8
+ ["My Eucalyptus tree is struggling outside in the cold weather in europe"],
9
+ ["My callatea house plant is yellowing."],
10
+ ["We have a catcus as work that suddently started yellowing and wilting."]
11
+ ]
12
+
13
  load_dotenv()
14
  openai.api_key = os.getenv('OPENAI_API_KEY')
15
  assistant_id=os.getenv('ASSISTANT_ID')
 
61
  message_id=message_id
62
  )
63
  if message.content and message.content[0].type == 'text':
64
+ return message.content[0].text.value
65
  return "No response."
66
+
67
+ except Exception as e:
68
+ return f"An error occurred: {str(e)}"
 
 
 
69
 
70
  iface = gr.Interface(
71
  fn=ask_openai,