bstraehle commited on
Commit
fb08ce8
·
verified ·
1 Parent(s): 08d4fbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -11,10 +11,9 @@ import gradio as gr
11
  import os
12
 
13
  from assistants import (
14
- get_openai_client,
15
  set_openai_client,
16
- assistant,
17
- thread,
18
  create_assistant,
19
  load_assistant,
20
  create_thread,
@@ -32,23 +31,20 @@ def chat(message, history, openai_api_key):
32
  raise gr.Error("OpenAI API Key is required (see additional inputs below).")
33
  if not message:
34
  raise gr.Error("Message is required.")
35
-
36
- #raise gr.Error("Please clone and bring your own credentials.")
37
 
38
  global assistant, thread
39
-
40
- if get_openai_client() == None or len(history) == 0:
41
- set_openai_client(openai_api_key)
42
 
43
  # On first run, create assistant and update assistant_id,
44
  # see https://platform.openai.com/playground/assistants.
45
  # On subsequent runs, load assistant.
46
- if assistant == None:
47
  #assistant = create_assistant()
48
  assistant = load_assistant()
49
 
50
  # TODO: Use Gradio session to support multiple users
51
- if thread == None or len(history) == 0:
 
 
52
  thread = create_thread()
53
 
54
  create_message(thread, message)
 
11
  import os
12
 
13
  from assistants import (
 
14
  set_openai_client,
15
+ get_assistant,
16
+ get_thread,
17
  create_assistant,
18
  load_assistant,
19
  create_thread,
 
31
  raise gr.Error("OpenAI API Key is required (see additional inputs below).")
32
  if not message:
33
  raise gr.Error("Message is required.")
 
 
34
 
35
  global assistant, thread
 
 
 
36
 
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)