Tonic commited on
Commit
406e43d
Β·
1 Parent(s): a3ce232

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -30,9 +30,12 @@ def ask_openai(question):
30
  messages = client.beta.threads.messages.list(
31
  thread_id=thread.id,
32
  )
33
- response = next((msg for msg in messages['data'] if msg['role'] == 'assistant'), None)
34
- return response['content'][0]['text']['value'] if response else "No response."
 
35
 
 
 
36
  examples = [
37
  ["My Eucalyptus tree is struggling outside in the cold weather in europe"],
38
  ["My callatea house plant is yellowing."],
 
30
  messages = client.beta.threads.messages.list(
31
  thread_id=thread.id,
32
  )
33
+ for msg in messages:
34
+ if msg.role == 'assistant':
35
+ return msg.content[0]['text']['value']
36
 
37
+ return "No response."
38
+
39
  examples = [
40
  ["My Eucalyptus tree is struggling outside in the cold weather in europe"],
41
  ["My callatea house plant is yellowing."],