burtenshaw HF Staff commited on
Commit
d7d36c6
·
verified ·
1 Parent(s): ef97fda

Upload folder using huggingface_hub

Browse files
Dockerfile CHANGED
@@ -89,3 +89,4 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
89
  # Run the FastAPI server
90
  # The module path is constructed to work with the /app/env structure
91
  CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
 
 
89
  # Run the FastAPI server
90
  # The module path is constructed to work with the /app/env structure
91
  CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
92
+ ENV TEXTARENA_ENV_ID=Wordle-v0
envs/textarena_env/openenv_textarena.egg-info/PKG-INFO CHANGED
@@ -3,7 +3,7 @@ Name: openenv-textarena
3
  Version: 0.1.0
4
  Summary: TextArena environment for OpenEnv
5
  Requires-Python: >=3.10
6
- Requires-Dist: openenv-core[core]>=0.2.1
7
  Requires-Dist: fastapi>=0.115.0
8
  Requires-Dist: pydantic>=2.0.0
9
  Requires-Dist: uvicorn>=0.24.0
 
3
  Version: 0.1.0
4
  Summary: TextArena environment for OpenEnv
5
  Requires-Python: >=3.10
6
+ Requires-Dist: openenv-core[core]>=0.2.2
7
  Requires-Dist: fastapi>=0.115.0
8
  Requires-Dist: pydantic>=2.0.0
9
  Requires-Dist: uvicorn>=0.24.0
envs/textarena_env/openenv_textarena.egg-info/requires.txt CHANGED
@@ -1,4 +1,4 @@
1
- openenv-core[core]>=0.2.1
2
  fastapi>=0.115.0
3
  pydantic>=2.0.0
4
  uvicorn>=0.24.0
 
1
+ openenv-core[core]>=0.2.2
2
  fastapi>=0.115.0
3
  pydantic>=2.0.0
4
  uvicorn>=0.24.0
envs/textarena_env/server/gradio_ui.py CHANGED
@@ -4,12 +4,7 @@
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
- """
8
- Custom Gradio tab for TextArena (e.g. Wordle) – renders a Wordle-style grid in an HTML block.
9
-
10
- This module is used as gradio_builder when creating the app; the returned Blocks
11
- appear in the "Custom" tab next to the default "Playground" tab.
12
- """
13
 
14
  from __future__ import annotations
15
 
@@ -57,6 +52,99 @@ def _wordle_demo_html() -> str:
57
  """
58
 
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  def build_textarena_gradio_app(
61
  web_manager: Any,
62
  action_fields: List[Dict[str, Any]],
@@ -65,18 +153,11 @@ def build_textarena_gradio_app(
65
  title: str,
66
  quick_start_md: str,
67
  ) -> gr.Blocks:
68
- """
69
- Build the Custom tab Blocks for TextArena: Wordle-style HTML block.
70
-
71
- Signature matches the gradio_builder contract (see docs/customizing-web-ui.md).
72
- In Gradio 6, gr.HTML(value=...) renders HTML; default html_template is "${value}".
73
- """
74
  with gr.Blocks(title=f"{title} — Custom") as blocks:
75
- gr.Markdown(value=f"# Wordle Visualization")
76
- gr.Markdown(
77
- value="This tab shows a **Wordle-style** view. Use the **Playground** tab to "
78
- "Reset and Step with guesses (e.g. `[crane]`, `[stone]`)."
79
- )
80
- # Gradio 6: gr.HTML(value=...) renders the string as HTML (html_template default "${value}")
81
- gr.HTML(value=_wordle_demo_html(), show_label=False)
82
  return blocks
 
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
+ """Custom Gradio tab for TextArena aliases."""
 
 
 
 
 
8
 
9
  from __future__ import annotations
10
 
 
52
  """
53
 
54
 
55
+ def _sudoku_demo_html() -> str:
56
+ """Static Sudoku-style grid HTML for the Custom tab (demo only)."""
57
+ cells = []
58
+ givens = {
59
+ (0, 0): "5",
60
+ (0, 1): "3",
61
+ (0, 4): "7",
62
+ (1, 0): "6",
63
+ (1, 3): "1",
64
+ (1, 4): "9",
65
+ (1, 5): "5",
66
+ (2, 1): "9",
67
+ (2, 2): "8",
68
+ (2, 7): "6",
69
+ }
70
+ for row in range(9):
71
+ for col in range(9):
72
+ value = givens.get((row, col), "")
73
+ border_right = "3px solid #0f172a" if col in {2, 5} else "1px solid #94a3b8"
74
+ border_bottom = "3px solid #0f172a" if row in {2, 5} else "1px solid #94a3b8"
75
+ background = "#e2e8f0" if value else "#ffffff"
76
+ cells.append(
77
+ f"""
78
+ <div style="
79
+ width: 100%;
80
+ aspect-ratio: 1;
81
+ display: flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ font-size: 1.1rem;
85
+ font-weight: {'700' if value else '400'};
86
+ color: #0f172a;
87
+ background: {background};
88
+ border-right: {border_right};
89
+ border-bottom: {border_bottom};
90
+ ">
91
+ {value}
92
+ </div>
93
+ """
94
+ )
95
+ return f"""
96
+ <div style="
97
+ font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
98
+ max-width: 420px;
99
+ margin: 0 auto;
100
+ padding: 16px;
101
+ ">
102
+ <div style="
103
+ display: grid;
104
+ grid-template-columns: repeat(9, 1fr);
105
+ border: 3px solid #0f172a;
106
+ background: #ffffff;
107
+ ">
108
+ {''.join(cells)}
109
+ </div>
110
+ <p style="margin-top: 16px; color: #475569; font-size: 0.95rem; line-height: 1.45;">
111
+ Use the <strong>Playground</strong> tab to reset the game and submit moves in the
112
+ environment's expected text format.
113
+ </p>
114
+ </div>
115
+ """
116
+
117
+
118
+ def _resolve_textarena_ui(web_manager: Any) -> tuple[str, str, Optional[str]]:
119
+ """Choose environment-specific copy and optional demo HTML."""
120
+ env_id = getattr(getattr(web_manager, "env", None), "env_id", "") or ""
121
+ normalized = env_id.lower()
122
+
123
+ if normalized.startswith("wordle"):
124
+ return (
125
+ "Wordle Visualization",
126
+ "This tab shows a **Wordle-style** view. Use the **Playground** tab to "
127
+ "Reset and Step with guesses such as `[crane]` and `[stone]`.",
128
+ _wordle_demo_html(),
129
+ )
130
+ if normalized.startswith("sudoku"):
131
+ return (
132
+ "Sudoku Overview",
133
+ "This tab shows a static **Sudoku-style** board preview. Use the "
134
+ "**Playground** tab to Reset and Step with the game's text actions.",
135
+ _sudoku_demo_html(),
136
+ )
137
+
138
+ label = env_id or "TextArena"
139
+ return (
140
+ f"{label} Overview",
141
+ "Use the **Playground** tab to Reset and Step through this TextArena game. "
142
+ "The custom tab is environment-aware but only includes a static preview for "
143
+ "selected aliases.",
144
+ None,
145
+ )
146
+
147
+
148
  def build_textarena_gradio_app(
149
  web_manager: Any,
150
  action_fields: List[Dict[str, Any]],
 
153
  title: str,
154
  quick_start_md: str,
155
  ) -> gr.Blocks:
156
+ """Build the Custom tab Blocks for TextArena aliases."""
157
+ heading, description, demo_html = _resolve_textarena_ui(web_manager)
 
 
 
 
158
  with gr.Blocks(title=f"{title} — Custom") as blocks:
159
+ gr.Markdown(value=f"# {heading}")
160
+ gr.Markdown(value=description)
161
+ if demo_html is not None:
162
+ gr.HTML(value=demo_html, show_label=False)
 
 
 
163
  return blocks
openenv_textarena.egg-info/PKG-INFO CHANGED
@@ -3,7 +3,7 @@ Name: openenv-textarena
3
  Version: 0.1.0
4
  Summary: TextArena environment for OpenEnv
5
  Requires-Python: >=3.10
6
- Requires-Dist: openenv-core[core]>=0.2.1
7
  Requires-Dist: fastapi>=0.115.0
8
  Requires-Dist: pydantic>=2.0.0
9
  Requires-Dist: uvicorn>=0.24.0
 
3
  Version: 0.1.0
4
  Summary: TextArena environment for OpenEnv
5
  Requires-Python: >=3.10
6
+ Requires-Dist: openenv-core[core]>=0.2.2
7
  Requires-Dist: fastapi>=0.115.0
8
  Requires-Dist: pydantic>=2.0.0
9
  Requires-Dist: uvicorn>=0.24.0
openenv_textarena.egg-info/requires.txt CHANGED
@@ -1,4 +1,4 @@
1
- openenv-core[core]>=0.2.1
2
  fastapi>=0.115.0
3
  pydantic>=2.0.0
4
  uvicorn>=0.24.0
 
1
+ openenv-core[core]>=0.2.2
2
  fastapi>=0.115.0
3
  pydantic>=2.0.0
4
  uvicorn>=0.24.0
server/gradio_ui.py CHANGED
@@ -4,12 +4,7 @@
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
- """
8
- Custom Gradio tab for TextArena (e.g. Wordle) – renders a Wordle-style grid in an HTML block.
9
-
10
- This module is used as gradio_builder when creating the app; the returned Blocks
11
- appear in the "Custom" tab next to the default "Playground" tab.
12
- """
13
 
14
  from __future__ import annotations
15
 
@@ -57,6 +52,99 @@ def _wordle_demo_html() -> str:
57
  """
58
 
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  def build_textarena_gradio_app(
61
  web_manager: Any,
62
  action_fields: List[Dict[str, Any]],
@@ -65,18 +153,11 @@ def build_textarena_gradio_app(
65
  title: str,
66
  quick_start_md: str,
67
  ) -> gr.Blocks:
68
- """
69
- Build the Custom tab Blocks for TextArena: Wordle-style HTML block.
70
-
71
- Signature matches the gradio_builder contract (see docs/customizing-web-ui.md).
72
- In Gradio 6, gr.HTML(value=...) renders HTML; default html_template is "${value}".
73
- """
74
  with gr.Blocks(title=f"{title} — Custom") as blocks:
75
- gr.Markdown(value=f"# Wordle Visualization")
76
- gr.Markdown(
77
- value="This tab shows a **Wordle-style** view. Use the **Playground** tab to "
78
- "Reset and Step with guesses (e.g. `[crane]`, `[stone]`)."
79
- )
80
- # Gradio 6: gr.HTML(value=...) renders the string as HTML (html_template default "${value}")
81
- gr.HTML(value=_wordle_demo_html(), show_label=False)
82
  return blocks
 
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
+ """Custom Gradio tab for TextArena aliases."""
 
 
 
 
 
8
 
9
  from __future__ import annotations
10
 
 
52
  """
53
 
54
 
55
+ def _sudoku_demo_html() -> str:
56
+ """Static Sudoku-style grid HTML for the Custom tab (demo only)."""
57
+ cells = []
58
+ givens = {
59
+ (0, 0): "5",
60
+ (0, 1): "3",
61
+ (0, 4): "7",
62
+ (1, 0): "6",
63
+ (1, 3): "1",
64
+ (1, 4): "9",
65
+ (1, 5): "5",
66
+ (2, 1): "9",
67
+ (2, 2): "8",
68
+ (2, 7): "6",
69
+ }
70
+ for row in range(9):
71
+ for col in range(9):
72
+ value = givens.get((row, col), "")
73
+ border_right = "3px solid #0f172a" if col in {2, 5} else "1px solid #94a3b8"
74
+ border_bottom = "3px solid #0f172a" if row in {2, 5} else "1px solid #94a3b8"
75
+ background = "#e2e8f0" if value else "#ffffff"
76
+ cells.append(
77
+ f"""
78
+ <div style="
79
+ width: 100%;
80
+ aspect-ratio: 1;
81
+ display: flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ font-size: 1.1rem;
85
+ font-weight: {'700' if value else '400'};
86
+ color: #0f172a;
87
+ background: {background};
88
+ border-right: {border_right};
89
+ border-bottom: {border_bottom};
90
+ ">
91
+ {value}
92
+ </div>
93
+ """
94
+ )
95
+ return f"""
96
+ <div style="
97
+ font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
98
+ max-width: 420px;
99
+ margin: 0 auto;
100
+ padding: 16px;
101
+ ">
102
+ <div style="
103
+ display: grid;
104
+ grid-template-columns: repeat(9, 1fr);
105
+ border: 3px solid #0f172a;
106
+ background: #ffffff;
107
+ ">
108
+ {''.join(cells)}
109
+ </div>
110
+ <p style="margin-top: 16px; color: #475569; font-size: 0.95rem; line-height: 1.45;">
111
+ Use the <strong>Playground</strong> tab to reset the game and submit moves in the
112
+ environment's expected text format.
113
+ </p>
114
+ </div>
115
+ """
116
+
117
+
118
+ def _resolve_textarena_ui(web_manager: Any) -> tuple[str, str, Optional[str]]:
119
+ """Choose environment-specific copy and optional demo HTML."""
120
+ env_id = getattr(getattr(web_manager, "env", None), "env_id", "") or ""
121
+ normalized = env_id.lower()
122
+
123
+ if normalized.startswith("wordle"):
124
+ return (
125
+ "Wordle Visualization",
126
+ "This tab shows a **Wordle-style** view. Use the **Playground** tab to "
127
+ "Reset and Step with guesses such as `[crane]` and `[stone]`.",
128
+ _wordle_demo_html(),
129
+ )
130
+ if normalized.startswith("sudoku"):
131
+ return (
132
+ "Sudoku Overview",
133
+ "This tab shows a static **Sudoku-style** board preview. Use the "
134
+ "**Playground** tab to Reset and Step with the game's text actions.",
135
+ _sudoku_demo_html(),
136
+ )
137
+
138
+ label = env_id or "TextArena"
139
+ return (
140
+ f"{label} Overview",
141
+ "Use the **Playground** tab to Reset and Step through this TextArena game. "
142
+ "The custom tab is environment-aware but only includes a static preview for "
143
+ "selected aliases.",
144
+ None,
145
+ )
146
+
147
+
148
  def build_textarena_gradio_app(
149
  web_manager: Any,
150
  action_fields: List[Dict[str, Any]],
 
153
  title: str,
154
  quick_start_md: str,
155
  ) -> gr.Blocks:
156
+ """Build the Custom tab Blocks for TextArena aliases."""
157
+ heading, description, demo_html = _resolve_textarena_ui(web_manager)
 
 
 
 
158
  with gr.Blocks(title=f"{title} — Custom") as blocks:
159
+ gr.Markdown(value=f"# {heading}")
160
+ gr.Markdown(value=description)
161
+ if demo_html is not None:
162
+ gr.HTML(value=demo_html, show_label=False)
 
 
 
163
  return blocks