yuxwu commited on
Commit
e8c529b
·
1 Parent(s): 6c0d87a

Improved css

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -14,13 +14,19 @@ from chatarena.message import Message
14
 
15
  css = """#col-container {max-width: 90%; margin-left: auto; margin-right: auto; display: flex; flex-direction: column;}
16
  #header {text-align: center;}
17
- #col-chatbox {flex: 1; max-height: min(750px, 100%); display: flex;}
18
- #chatbox {height: min(750px, 100%); max-height: 750px; display:flex;}
19
  #label {font-size: 2em; padding: 0.5em; margin: 0;}
 
 
20
  .message {font-size: 1.2em;}
21
- .wrap {min-width: min(640px, 100vh)}
22
  .message-wrap {max-height: min(700px, 100vh);}
23
  """
 
 
 
 
 
 
24
 
25
  DEBUG = False
26
 
@@ -51,7 +57,7 @@ def get_moderator_components(visible=True):
51
  with gr.Row():
52
  with gr.Column():
53
  role_desc = gr.Textbox(label="Moderator role", lines=1, visible=visible, interactive=True,
54
- placeholder=f"Enter the role description for {name}")
55
  terminal_condition = gr.Textbox(show_label=False, lines=1, visible=visible, interactive=True,
56
  placeholder="Enter the end criteria for the conversation")
57
  with gr.Column():
@@ -94,12 +100,12 @@ with gr.Blocks(css=css) as demo:
94
  with gr.Column(elem_id="col-container"):
95
  gr.Markdown("""# 🏟 ChatArena️<br>
96
  Prompting multiple AI agents to play games in a language-driven environment.
97
- **[Project Homepage](https://github.com/chatarena/chatarena)**
98
- ### Due to the high volume of requests, our OpenAI API Token exceeded the billing limit. We are approaching OpenAI to get the research access at the moment. We encourage users to run the demo locally following [this instruction](https://github.com/chatarena/chatarena#launch-the-demo-locally).""", elem_id="header")
99
 
100
  with gr.Row():
101
  env_selector = gr.Dropdown(choices=list(ENV_REGISTRY.keys()), value=DEFAULT_ENV, interactive=True,
102
- label="Environment Type", show_label=True)
103
  example_selector = gr.Dropdown(choices=list(EXAMPLE_REGISTRY.keys()), interactive=True,
104
  label="Select Example", show_label=True)
105
 
@@ -111,13 +117,13 @@ Prompting multiple AI agents to play games in a language-driven environment.
111
 
112
  with gr.Row():
113
  with gr.Column(elem_id="col-chatbox"):
114
- with gr.Tab("All"):
115
  chatbot = gr.Chatbot(elem_id="chatbox", visible=True, show_label=False)
116
 
117
  player_chatbots = []
118
  for i in range(MAX_NUM_PLAYERS):
119
  player_name = f"Player {i + 1}"
120
- with gr.Tab(player_name, visible=(i < DEFAULT_NUM_PLAYERS)):
121
  player_chatbot = gr.Chatbot(elem_id=f"chatbox-{i}", visible=i < DEFAULT_NUM_PLAYERS,
122
  label=player_name, show_label=False)
123
  player_chatbots.append(player_chatbot)
@@ -244,7 +250,7 @@ Prompting multiple AI agents to play games in a language-driven environment.
244
  def step_game(all_comps: dict):
245
  yield {btn_step: gr.update(value="Running...", interactive=False),
246
  btn_restart: gr.update(interactive=False)}
247
- sleep(2) # control the rate of requests
248
 
249
  cur_state = all_comps[state]
250
 
 
14
 
15
  css = """#col-container {max-width: 90%; margin-left: auto; margin-right: auto; display: flex; flex-direction: column;}
16
  #header {text-align: center;}
17
+ #col-chatbox {flex: 1; max-height: min(750px, 100%);}
 
18
  #label {font-size: 2em; padding: 0.5em; margin: 0;}
19
+ .scroll-hide {overflow-y: scroll; max-height: 100px;}
20
+ .wrap {max-height: 680px;}
21
  .message {font-size: 1.2em;}
 
22
  .message-wrap {max-height: min(700px, 100vh);}
23
  """
24
+ # .wrap {min-width: min(640px, 100vh)}
25
+ # #env-desc {max-height: 100px; overflow-y: auto;}
26
+ # .textarea {height: 100px; max-height: 100px;}
27
+ #chatbot-tab-all {height: 750px; max-height: min(750px, 100%);}
28
+ #chatbox {height: min(750px, 100%); max-height: min(750px, 100%);}
29
+ #chatbox.block {height: 730px}
30
 
31
  DEBUG = False
32
 
 
57
  with gr.Row():
58
  with gr.Column():
59
  role_desc = gr.Textbox(label="Moderator role", lines=1, visible=visible, interactive=True,
60
+ placeholder=f"Enter the role description for {name}").style(resize="both", max_height="85px")
61
  terminal_condition = gr.Textbox(show_label=False, lines=1, visible=visible, interactive=True,
62
  placeholder="Enter the end criteria for the conversation")
63
  with gr.Column():
 
100
  with gr.Column(elem_id="col-container"):
101
  gr.Markdown("""# 🏟 ChatArena️<br>
102
  Prompting multiple AI agents to play games in a language-driven environment.
103
+ **[Project Homepage](https://github.com/chatarena/chatarena)**""", elem_id="header")
104
+ # ## Due to the high volume of requests, our OpenAI API Token exceeded the billing limit. We are approaching OpenAI to get the research access at the moment. We encourage users to run the demo locally following [this instruction](https://github.com/chatarena/chatarena#launch-the-demo-locally).""", elem_id="header")
105
 
106
  with gr.Row():
107
  env_selector = gr.Dropdown(choices=list(ENV_REGISTRY.keys()), value=DEFAULT_ENV, interactive=True,
108
+ label="Environment Type", show_label=True, elem_id="env-desc")
109
  example_selector = gr.Dropdown(choices=list(EXAMPLE_REGISTRY.keys()), interactive=True,
110
  label="Select Example", show_label=True)
111
 
 
117
 
118
  with gr.Row():
119
  with gr.Column(elem_id="col-chatbox"):
120
+ with gr.Tab("All", elem_id='chatbot-tab-all', visible=True):
121
  chatbot = gr.Chatbot(elem_id="chatbox", visible=True, show_label=False)
122
 
123
  player_chatbots = []
124
  for i in range(MAX_NUM_PLAYERS):
125
  player_name = f"Player {i + 1}"
126
+ with gr.Tab(player_name, elem_id=f'chatbot-tab-{i}', visible=(i < DEFAULT_NUM_PLAYERS)):
127
  player_chatbot = gr.Chatbot(elem_id=f"chatbox-{i}", visible=i < DEFAULT_NUM_PLAYERS,
128
  label=player_name, show_label=False)
129
  player_chatbots.append(player_chatbot)
 
250
  def step_game(all_comps: dict):
251
  yield {btn_step: gr.update(value="Running...", interactive=False),
252
  btn_restart: gr.update(interactive=False)}
253
+ sleep(0.5) # control the rate of requests
254
 
255
  cur_state = all_comps[state]
256