Spaces:
Runtime error
Runtime error
Removed labels on the chatboxs
Browse files
app.py
CHANGED
@@ -3,12 +3,13 @@ import json
|
|
3 |
import gradio as gr
|
4 |
from glob import glob
|
5 |
|
6 |
-
from chatarena.arena import Arena
|
7 |
from chatarena.backends import BACKEND_REGISTRY
|
8 |
from chatarena.backends.human import HumanBackendError
|
9 |
from chatarena.config import ArenaConfig
|
10 |
-
from chatarena.environments import ENV_REGISTRY
|
11 |
from chatarena.database import log_arena, log_messages, SupabaseDB, supabase_available
|
|
|
12 |
|
13 |
css = """#col-container {max-width: 90%; margin-left: auto; margin-right: auto; display: flex; flex-direction: column;}
|
14 |
#header {text-align: center;}
|
@@ -110,14 +111,14 @@ Prompting multiple AI agents to play games in a language-driven environment.
|
|
110 |
with gr.Row():
|
111 |
with gr.Column(elem_id="col-chatbox"):
|
112 |
with gr.Tab("All"):
|
113 |
-
chatbot = gr.Chatbot(elem_id="chatbox", visible=True,
|
114 |
|
115 |
player_chatbots = []
|
116 |
for i in range(MAX_NUM_PLAYERS):
|
117 |
player_name = f"Player {i + 1}"
|
118 |
with gr.Tab(player_name, visible=(i < DEFAULT_NUM_PLAYERS)):
|
119 |
player_chatbot = gr.Chatbot(elem_id=f"chatbox-{i}", visible=i < DEFAULT_NUM_PLAYERS,
|
120 |
-
label=player_name)
|
121 |
player_chatbots.append(player_chatbot)
|
122 |
|
123 |
all_components += [chatbot, *player_chatbots]
|
@@ -200,7 +201,7 @@ Prompting multiple AI agents to play games in a language-driven environment.
|
|
200 |
player_config = {
|
201 |
"name": player_name,
|
202 |
"role_desc": role_desc,
|
203 |
-
"
|
204 |
"backend": {
|
205 |
"backend_type": backend_type,
|
206 |
"temperature": temperature,
|
@@ -216,7 +217,7 @@ Prompting multiple AI agents to play games in a language-driven environment.
|
|
216 |
all_comps[c] for c in moderator_components if not isinstance(c, (gr.Accordion, gr.Tab))]
|
217 |
moderator_config = {
|
218 |
"role_desc": mod_role_desc,
|
219 |
-
"
|
220 |
"terminal_condition": mod_terminal_condition,
|
221 |
"backend": {
|
222 |
"backend_type": moderator_backend_type,
|
@@ -226,7 +227,6 @@ Prompting multiple AI agents to play games in a language-driven environment.
|
|
226 |
}
|
227 |
env_config = {
|
228 |
"env_type": env_type,
|
229 |
-
"env_desc": env_desc,
|
230 |
"parallel": all_comps[parallel_checkbox],
|
231 |
"moderator": moderator_config,
|
232 |
"moderator_visibility": "all",
|
@@ -263,6 +263,11 @@ Prompting multiple AI agents to play games in a language-driven environment.
|
|
263 |
timestep = None # Failed to get human input
|
264 |
else:
|
265 |
timestep = arena.environment.step(e.agent_name, human_input)
|
|
|
|
|
|
|
|
|
|
|
266 |
|
267 |
if timestep is None:
|
268 |
yield {human_input_textbox: gr.update(value="", placeholder="Please enter a valid input"),
|
|
|
3 |
import gradio as gr
|
4 |
from glob import glob
|
5 |
|
6 |
+
from chatarena.arena import Arena, TooManyInvalidActions
|
7 |
from chatarena.backends import BACKEND_REGISTRY
|
8 |
from chatarena.backends.human import HumanBackendError
|
9 |
from chatarena.config import ArenaConfig
|
10 |
+
from chatarena.environments import ENV_REGISTRY, TimeStep
|
11 |
from chatarena.database import log_arena, log_messages, SupabaseDB, supabase_available
|
12 |
+
from chatarena.message import Message
|
13 |
|
14 |
css = """#col-container {max-width: 90%; margin-left: auto; margin-right: auto; display: flex; flex-direction: column;}
|
15 |
#header {text-align: center;}
|
|
|
111 |
with gr.Row():
|
112 |
with gr.Column(elem_id="col-chatbox"):
|
113 |
with gr.Tab("All"):
|
114 |
+
chatbot = gr.Chatbot(elem_id="chatbox", visible=True, show_label=False)
|
115 |
|
116 |
player_chatbots = []
|
117 |
for i in range(MAX_NUM_PLAYERS):
|
118 |
player_name = f"Player {i + 1}"
|
119 |
with gr.Tab(player_name, visible=(i < DEFAULT_NUM_PLAYERS)):
|
120 |
player_chatbot = gr.Chatbot(elem_id=f"chatbox-{i}", visible=i < DEFAULT_NUM_PLAYERS,
|
121 |
+
label=player_name, show_label=False)
|
122 |
player_chatbots.append(player_chatbot)
|
123 |
|
124 |
all_components += [chatbot, *player_chatbots]
|
|
|
201 |
player_config = {
|
202 |
"name": player_name,
|
203 |
"role_desc": role_desc,
|
204 |
+
"global_prompt": env_desc,
|
205 |
"backend": {
|
206 |
"backend_type": backend_type,
|
207 |
"temperature": temperature,
|
|
|
217 |
all_comps[c] for c in moderator_components if not isinstance(c, (gr.Accordion, gr.Tab))]
|
218 |
moderator_config = {
|
219 |
"role_desc": mod_role_desc,
|
220 |
+
"global_prompt": env_desc,
|
221 |
"terminal_condition": mod_terminal_condition,
|
222 |
"backend": {
|
223 |
"backend_type": moderator_backend_type,
|
|
|
227 |
}
|
228 |
env_config = {
|
229 |
"env_type": env_type,
|
|
|
230 |
"parallel": all_comps[parallel_checkbox],
|
231 |
"moderator": moderator_config,
|
232 |
"moderator_visibility": "all",
|
|
|
263 |
timestep = None # Failed to get human input
|
264 |
else:
|
265 |
timestep = arena.environment.step(e.agent_name, human_input)
|
266 |
+
except TooManyInvalidActions as e:
|
267 |
+
timestep = arena.current_timestep
|
268 |
+
timestep.observation.append(
|
269 |
+
Message("System", "Too many invalid actions. Game over.", turn=-1, visible_to="all"))
|
270 |
+
timestep.terminal = True
|
271 |
|
272 |
if timestep is None:
|
273 |
yield {human_input_textbox: gr.update(value="", placeholder="Please enter a valid input"),
|