File size: 872 Bytes
4ad819c
 
 
3ec6c47
4ad819c
c8eee95
79c1102
4ad819c
35c981f
4ad819c
 
 
 
25af752
3ec6c47
4ad819c
 
 
 
10437cc
c8eee95
62ae1b3
df4714a
4ad819c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
import os

from multi_agent import run_multi_agent

LLM_WHITE = "gpt-4o"
LLM_BLACK = "gpt-4o"

def invoke(openai_api_key, num_moves = 10):
    if (openai_api_key == ""):
        raise gr.Error("OpenAI API Key is required.")
        
    os.environ["OPENAI_API_KEY"] = openai_api_key

    return run_multi_agent(LLM_WHITE, LLM_BLACK, num_moves)

gr.close_all()

demo = gr.Interface(fn = invoke, 
                    inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
                              gr.Number(label = "Number of Moves", value = 3, minimum = 1, maximum = 100)],
                    outputs = [gr.Markdown(label = "Game", value=os.environ["OUTPUT"], line_breaks=True, sanitize_html=False)],
                    title = "Chess: AI vs. AI",
                    description = os.environ["DESCRIPTION"])

demo.launch()