bstraehle commited on
Commit
24755bb
1 Parent(s): 8fae4d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -18,6 +18,14 @@ def wait_on_run(run, thread):
18
  time.sleep(0.5)
19
  return run
20
 
 
 
 
 
 
 
 
 
21
  def chat(message, history):
22
  assistant = client.beta.assistants.create(
23
  name="Math Tutor",
@@ -53,12 +61,8 @@ def chat(message, history):
53
  messages = client.beta.threads.messages.list(thread_id=thread.id)
54
 
55
  show_json(messages)
56
- ###
57
-
58
- #for i in range(len(message)):
59
- # time.sleep(0.5)
60
- # yield "You typed: " + message[: i+1]
61
- return "Done"
62
 
63
  gr.ChatInterface(
64
  chat,
 
18
  time.sleep(0.5)
19
  return run
20
 
21
+ def extract_content_value(data):
22
+ content_values = []
23
+ for item in data['data']:
24
+ for content in item['content']:
25
+ if content['type'] == 'text':
26
+ content_values.append(content['text']['value'])
27
+ return content_values
28
+
29
  def chat(message, history):
30
  assistant = client.beta.assistants.create(
31
  name="Math Tutor",
 
61
  messages = client.beta.threads.messages.list(thread_id=thread.id)
62
 
63
  show_json(messages)
64
+
65
+ return extract_content_value(messages)[0]
 
 
 
 
66
 
67
  gr.ChatInterface(
68
  chat,