bstraehle commited on
Commit
2ff96fe
·
verified ·
1 Parent(s): b911d69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -1,8 +1,10 @@
1
  import gradio as gr
2
- import os
3
 
4
  from multi_agent import run_multi_agent
5
 
 
 
6
  LLM_WHITE = "gpt-4o"
7
  LLM_BLACK = "gpt-4o"
8
 
@@ -10,9 +12,11 @@ def invoke(openai_api_key, num_moves = 10):
10
  if (openai_api_key == ""):
11
  raise gr.Error("OpenAI API Key is required.")
12
 
13
- os.environ["OPENAI_API_KEY"] = openai_api_key
14
-
15
- return run_multi_agent(LLM_WHITE, LLM_BLACK, num_moves)
 
 
16
 
17
  gr.close_all()
18
 
 
1
  import gradio as gr
2
+ import os, threading
3
 
4
  from multi_agent import run_multi_agent
5
 
6
+ lock = threading.Lock()
7
+
8
  LLM_WHITE = "gpt-4o"
9
  LLM_BLACK = "gpt-4o"
10
 
 
12
  if (openai_api_key == ""):
13
  raise gr.Error("OpenAI API Key is required.")
14
 
15
+ with lock:
16
+ os.environ["OPENAI_API_KEY"] = openai_api_key
17
+ result = run_multi_agent(LLM_WHITE, LLM_BLACK, num_moves)
18
+ del os.environ["OPENAI_API_KEY"]
19
+ return result
20
 
21
  gr.close_all()
22