Update app.py
Browse files
app.py
CHANGED
@@ -18,13 +18,37 @@ def invoke(openai_api_key, num_moves = 10):
|
|
18 |
del os.environ["OPENAI_API_KEY"]
|
19 |
return result
|
20 |
|
21 |
-
|
|
|
22 |
|
23 |
-
|
24 |
-
inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
|
25 |
-
gr.Number(label = "Number of Moves", value = 10, minimum = 1, maximum = 50)],
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
del os.environ["OPENAI_API_KEY"]
|
19 |
return result
|
20 |
|
21 |
+
def clear():
|
22 |
+
return ""
|
23 |
|
24 |
+
gr.close_all()
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
with gr.Blocks() as assistant:
|
27 |
+
gr.Markdown("## Multi-Agent AI: Chess")
|
28 |
+
gr.Markdown(os.environ.get("DESCRIPTION"))
|
29 |
+
|
30 |
+
with gr.Row():
|
31 |
+
with gr.Column(scale=1):
|
32 |
+
with gr.Row():
|
33 |
+
openai_api_key = gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1)
|
34 |
+
num_moves = gr.Number(label = "Number of Moves", value = 10, minimum = 1, maximum = 50)
|
35 |
+
with gr.Row():
|
36 |
+
clear_btn = gr.ClearButton(
|
37 |
+
components=[openai_api_key, num_moves]
|
38 |
+
)
|
39 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
40 |
+
with gr.Column(scale=3):
|
41 |
+
game = gr.Markdown(label = "Game", value=os.environ["OUTPUT"], line_breaks=True, sanitize_html=False)
|
42 |
+
|
43 |
+
clear_btn.click(
|
44 |
+
fn=clear,
|
45 |
+
outputs=game
|
46 |
+
)
|
47 |
+
|
48 |
+
submit_btn.click(
|
49 |
+
fn=invoke,
|
50 |
+
inputs=[openai_api_key, num_moves],
|
51 |
+
outputs=game
|
52 |
+
)
|
53 |
+
|
54 |
+
assistant.launch()
|