bstraehle commited on
Commit
89fe551
1 Parent(s): 5de99f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -13,7 +13,9 @@ import os
13
  from assistants import (
14
  set_openai_client,
15
  get_assistant,
 
16
  get_thread,
 
17
  create_assistant,
18
  load_assistant,
19
  create_thread,
@@ -37,22 +39,21 @@ def chat(message, history, openai_api_key):
37
  # On first run, create assistant and update assistant_id,
38
  # see https://platform.openai.com/playground/assistants.
39
  # On subsequent runs, load assistant.
40
- if get_assistant == None:
41
- #assistant = create_assistant()
42
- assistant = load_assistant()
43
 
44
  # TODO: Use Gradio session to support multiple users
45
  if get_thread == None or len(history) == 0:
46
  set_openai_client(openai_api_key)
47
-
48
- thread = create_thread()
49
 
50
- create_message(thread, message)
51
- run = create_run(assistant, thread)
52
- run = wait_on_run(thread, run)
53
- run_steps = get_run_steps(thread, run)
54
- recurse_execute_tool_calls(thread, run, run_steps, 0)
55
- messages = get_messages(thread)
56
  text_values, image_values = extract_content_values(messages)
57
 
58
  download_link = ""
 
13
  from assistants import (
14
  set_openai_client,
15
  get_assistant,
16
+ set_assistant,
17
  get_thread,
18
+ set_thread,
19
  create_assistant,
20
  load_assistant,
21
  create_thread,
 
39
  # On first run, create assistant and update assistant_id,
40
  # see https://platform.openai.com/playground/assistants.
41
  # On subsequent runs, load assistant.
42
+ if get_assistant() == None:
43
+ #set_assistant(create_assistant())
44
+ set_assistant(load_assistant())
45
 
46
  # TODO: Use Gradio session to support multiple users
47
  if get_thread == None or len(history) == 0:
48
  set_openai_client(openai_api_key)
49
+ set_thread(create_thread())
 
50
 
51
+ create_message(get_thread(), message)
52
+ run = create_run(get_assistant(), get_thread())
53
+ run = wait_on_run(get_thread(), run)
54
+ run_steps = get_run_steps(get_thread(), run)
55
+ recurse_execute_tool_calls(get_thread(), run, run_steps, 0)
56
+ messages = get_messages(get_thread())
57
  text_values, image_values = extract_content_values(messages)
58
 
59
  download_link = ""