bstraehle commited on
Commit
df144ba
·
verified ·
1 Parent(s): adfc775

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -22,28 +22,30 @@ def init_assistant():
22
 
23
  _thread = _client.beta.threads.create()
24
 
25
- def wait_on_run(run, thread):
26
- global _client
 
27
  while run.status == "queued" or run.status == "in_progress":
28
  run = _client.beta.threads.runs.retrieve(
29
  run_id=run.id,
30
- thread_id=thread.id,
31
  )
32
  time.sleep(0.25)
 
33
  return run
34
 
35
  def extract_content_values(data):
36
  content_values = []
 
37
  for item in data.data:
38
  for content in item.content:
39
  if content.type == 'text':
40
  content_values.append(content.text.value)
 
41
  return content_values
42
 
43
  def chat(message, history):
44
- global _client
45
- global _assistant
46
- global _thread
47
 
48
  history_openai_format = []
49
 
@@ -76,7 +78,7 @@ def chat(message, history):
76
  thread_id=_thread.id,
77
  )
78
 
79
- run = wait_on_run(run, thread)
80
 
81
  #show_json("run", run)
82
 
 
22
 
23
  _thread = _client.beta.threads.create()
24
 
25
+ def wait_on_run(run):
26
+ global _client, _thread
27
+
28
  while run.status == "queued" or run.status == "in_progress":
29
  run = _client.beta.threads.runs.retrieve(
30
  run_id=run.id,
31
+ thread_id=_thread.id,
32
  )
33
  time.sleep(0.25)
34
+
35
  return run
36
 
37
  def extract_content_values(data):
38
  content_values = []
39
+
40
  for item in data.data:
41
  for content in item.content:
42
  if content.type == 'text':
43
  content_values.append(content.text.value)
44
+
45
  return content_values
46
 
47
  def chat(message, history):
48
+ global _client, _assistant, _thread
 
 
49
 
50
  history_openai_format = []
51
 
 
78
  thread_id=_thread.id,
79
  )
80
 
81
+ run = wait_on_run(run)
82
 
83
  #show_json("run", run)
84