bstraehle commited on
Commit
7aa6874
1 Parent(s): 515acfe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py CHANGED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
11
+ def invoke(openai_api_key, num_moves = 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
+
23
+ demo = gr.Interface(fn = invoke,
24
+ inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
25
+ gr.Number(label = "Number of Moves", value = 10, minimum = 1, maximum = 25)],
26
+ outputs = [gr.Markdown(label = "Game", value=os.environ["OUTPUT"], line_breaks=True, sanitize_html=False)],
27
+ title = "Multi-Agent AI: Chess",
28
+ description = os.environ["DESCRIPTION"])
29
+
30
+ demo.launch()