bstraehle commited on
Commit
5d3a7fe
1 Parent(s): daf9947

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -32,10 +32,12 @@ def chat(message, history, openai_api_key):
32
  raise gr.Error("Message is required.")
33
 
34
  #raise gr.Error("Please clone and bring your own credentials.")
35
- os.environ["OPENAI_API_KEY"] = openai_api_key
36
 
37
- global assistant, thread
38
 
 
 
 
39
  # On first run, create assistant and update assistant_id,
40
  # see https://platform.openai.com/playground/assistants.
41
  # On subsequent runs, load assistant.
 
32
  raise gr.Error("Message is required.")
33
 
34
  #raise gr.Error("Please clone and bring your own credentials.")
 
35
 
36
+ global openai_client, assistant, thread
37
 
38
+ if openai_client == None:
39
+ openai_client = OpenAI(api_key=openai_api_key)
40
+
41
  # On first run, create assistant and update assistant_id,
42
  # see https://platform.openai.com/playground/assistants.
43
  # On subsequent runs, load assistant.