tc043 Codex commited on
Commit
19a5a7c
·
1 Parent(s): e41aa9d

refactor: remove experimental test files and enable production mode in Dockerfile

Browse files
Dockerfile CHANGED
@@ -7,7 +7,7 @@ RUN pip install --no-cache-dir -r requirements.txt
7
 
8
  COPY . .
9
 
10
- ENV STEP_ZERO_MOCK=1
11
  EXPOSE 7860
12
 
13
  CMD ["python", "app.py"]
 
7
 
8
  COPY . .
9
 
10
+ ENV STEP_ZERO_MOCK=0
11
  EXPOSE 7860
12
 
13
  CMD ["python", "app.py"]
app.py CHANGED
@@ -25,9 +25,33 @@ NEMOTRON_MODEL_PATH = os.getenv("NEMOTRON_MODEL_PATH", "./models/step-zero-nemot
25
  MINICPM_MODEL_PATH = os.getenv("MINICPM_MODEL_PATH", "./models/minicpm-3-4b.gguf")
26
 
27
  if not MOCK_MODE:
 
 
28
  from llama_cpp import Llama
29
  from llama_cpp import LlamaGrammar
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  grammar = LlamaGrammar.from_file(str(GRAMMAR_PATH))
32
 
33
  # Use small context windows to save RAM.
@@ -77,6 +101,41 @@ def is_semantic_repeat(new_task: str, history: list) -> bool:
77
  return True
78
  return False
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  async def generate_atomic_task(goal: str, previous_failures: int, history: list = None, skipped_history: list = None, rejected_task: str = None) -> str:
81
  if history is None:
82
  history = []
@@ -116,9 +175,9 @@ async def generate_atomic_task(goal: str, previous_failures: int, history: list
116
  max_tokens=64,
117
  temperature=0.1
118
  )
119
- content = fallback_res['choices'][0]['message']['content'].strip()
120
- print(f"MINICPM BREAKDOWN OUT: {content}", flush=True)
121
- content = content.strip('"\' ,.-1234567890)')
122
  return content or "Focus on the screen."
123
 
124
  # REAL INFERENCE using the exact string template used during fine-tuning
@@ -136,13 +195,13 @@ async def generate_atomic_task(goal: str, previous_failures: int, history: list
136
  stop=["\n", "<extra_id_1>"],
137
  grammar=grammar # Enforcing grammar here!
138
  )
139
- content = response['choices'][0]['text'].strip()
 
140
 
141
- # Check if output is empty or a repetition
142
- is_invalid = not content or is_semantic_repeat(content, history + skipped_history)
143
 
144
- if is_invalid:
145
- print(f"NEMOTRON OUTPUT INVALID OR REPETITION ('{content}'). FALLING BACK TO MINICPM...", flush=True)
146
  last_task = history[-1] if history else ""
147
  last_skipped = skipped_history[-1] if skipped_history else ""
148
 
@@ -164,14 +223,15 @@ async def generate_atomic_task(goal: str, previous_failures: int, history: list
164
  max_tokens=64,
165
  temperature=0.1
166
  )
167
- content = fallback_res['choices'][0]['message']['content'].strip()
168
- print(f"MINICPM FALLBACK OUT: {content}", flush=True)
169
- else:
170
- print(f"NEMOTRON RAW OUT: {content}", flush=True)
171
-
172
- content = content.strip('"\' ,.-1234567890)')
173
  return content or "Focus on the screen."
174
 
 
175
  async def apply_activation_style(task: str, style="direct") -> str:
176
  if MOCK_MODE:
177
  await asyncio.sleep(0.5)
@@ -228,8 +288,30 @@ async def apply_activation_style(task: str, style="direct") -> str:
228
  # --- GRADIO UI ---
229
 
230
  custom_css = """
231
- body { background-color: #0a0a0a; color: #ffffff; font-family: 'Helvetica Neue', sans-serif; }
232
- .gradio-container { background-color: transparent !important; border: none !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  footer { display: none !important; }
234
  .fog { opacity: 0.3; filter: blur(2px); transition: all 0.5s ease; }
235
  .fade-in { animation: fadeIn 0.5s ease-in forwards; }
@@ -256,7 +338,7 @@ footer { display: none !important; }
256
  #btn-trace:hover { color: #d1d5db !important; }
257
 
258
  /* Big Task Text */
259
- #current-task { text-align: center; font-size: 3rem; font-weight: 800; min-height: 150px; display: flex; align-items: center; justify-content: center; }
260
  @media (min-width: 768px) { #current-task { font-size: 4.5rem; } }
261
  """
262
 
@@ -341,7 +423,7 @@ async def process_step(state, action: str, goal: str = None, style: str = None,
341
 
342
  return state, generate_task_html(styled_task), generate_breadcrumbs_html(state["history"][-3:]), gr.Row(visible=True)
343
 
344
- with gr.Blocks(css=custom_css, title="Step-Zero") as app:
345
  session_state = gr.State()
346
 
347
  with gr.Column(visible=True) as screen_start:
 
25
  MINICPM_MODEL_PATH = os.getenv("MINICPM_MODEL_PATH", "./models/minicpm-3-4b.gguf")
26
 
27
  if not MOCK_MODE:
28
+ import os
29
+ from huggingface_hub import hf_hub_download
30
  from llama_cpp import Llama
31
  from llama_cpp import LlamaGrammar
32
 
33
+ os.makedirs("./models", exist_ok=True)
34
+
35
+ if not os.path.exists(NEMOTRON_MODEL_PATH):
36
+ print(f"Downloading Nemotron model to {NEMOTRON_MODEL_PATH}...", flush=True)
37
+ hf_hub_download(
38
+ repo_id="tc043/step-zero-nemotron",
39
+ filename="step-zero-nemotron-finetuned.gguf",
40
+ local_dir="./models"
41
+ )
42
+
43
+ if not os.path.exists(MINICPM_MODEL_PATH):
44
+ print(f"Downloading MiniCPM model to {MINICPM_MODEL_PATH}...", flush=True)
45
+ downloaded = hf_hub_download(
46
+ repo_id="mradermacher/MiniCPM3-4B-GGUF",
47
+ filename="MiniCPM3-4B.Q4_K_M.gguf",
48
+ local_dir="./models"
49
+ )
50
+ expected_path = os.path.abspath(MINICPM_MODEL_PATH)
51
+ downloaded_path = os.path.abspath(downloaded)
52
+ if downloaded_path != expected_path and os.path.exists(downloaded_path):
53
+ os.rename(downloaded_path, expected_path)
54
+
55
  grammar = LlamaGrammar.from_file(str(GRAMMAR_PATH))
56
 
57
  # Use small context windows to save RAM.
 
101
  return True
102
  return False
103
 
104
+ def clean_and_validate_task(raw_output: str, history: list, skipped_history: list) -> tuple[str, bool]:
105
+ import re
106
+ if not raw_output:
107
+ return "", False
108
+
109
+ # Split by sentence boundaries and take the first sentence
110
+ sentences = re.split(r'(?<=[.!?])\s+', raw_output)
111
+ first_sentence = sentences[0].strip() if sentences else raw_output
112
+
113
+ # Strip quotes, punctuation, numbers, etc. at ends
114
+ cleaned = first_sentence.strip('"\' ,.-1234567890)')
115
+ if not cleaned:
116
+ return "", False
117
+
118
+ # Check for prompt leakage and scaffolding words
119
+ invalid_keywords = [
120
+ "completed tasks", "failures", "system", "user", "assistant",
121
+ "next step", "done", "fail", "gbnf", "pacemaker", "extra_id_",
122
+ "instruction", "output", "goal:", "failures:"
123
+ ]
124
+ contains_scaffold = any(k in cleaned.lower() for k in invalid_keywords)
125
+
126
+ # Check for reasonable length (under 12 words)
127
+ word_count = len(cleaned.split())
128
+ if word_count > 12:
129
+ return cleaned, False
130
+
131
+ if contains_scaffold:
132
+ return cleaned, False
133
+
134
+ if is_semantic_repeat(cleaned, history + skipped_history):
135
+ return cleaned, False
136
+
137
+ return cleaned, True
138
+
139
  async def generate_atomic_task(goal: str, previous_failures: int, history: list = None, skipped_history: list = None, rejected_task: str = None) -> str:
140
  if history is None:
141
  history = []
 
175
  max_tokens=64,
176
  temperature=0.1
177
  )
178
+ raw_fallback = fallback_res['choices'][0]['message']['content'].strip()
179
+ print(f"MINICPM BREAKDOWN OUT: {raw_fallback}", flush=True)
180
+ content, _ = clean_and_validate_task(raw_fallback, [], [])
181
  return content or "Focus on the screen."
182
 
183
  # REAL INFERENCE using the exact string template used during fine-tuning
 
195
  stop=["\n", "<extra_id_1>"],
196
  grammar=grammar # Enforcing grammar here!
197
  )
198
+ raw_content = response['choices'][0]['text'].strip()
199
+ print(f"NEMOTRON RAW OUT: {raw_content}", flush=True)
200
 
201
+ content, is_valid = clean_and_validate_task(raw_content, history, skipped_history)
 
202
 
203
+ if not is_valid:
204
+ print(f"NEMOTRON OUTPUT INVALID OR REPETITION ('{raw_content}'). FALLING BACK TO MINICPM...", flush=True)
205
  last_task = history[-1] if history else ""
206
  last_skipped = skipped_history[-1] if skipped_history else ""
207
 
 
223
  max_tokens=64,
224
  temperature=0.1
225
  )
226
+ raw_fallback = fallback_res['choices'][0]['message']['content'].strip()
227
+ print(f"MINICPM FALLBACK OUT: {raw_fallback}", flush=True)
228
+ content, _ = clean_and_validate_task(raw_fallback, [], [])
229
+ if not content:
230
+ content = raw_fallback.strip('"\' ,.-1234567890)')
231
+
232
  return content or "Focus on the screen."
233
 
234
+
235
  async def apply_activation_style(task: str, style="direct") -> str:
236
  if MOCK_MODE:
237
  await asyncio.sleep(0.5)
 
288
  # --- GRADIO UI ---
289
 
290
  custom_css = """
291
+ :root, .dark {
292
+ --body-background-fill: #0a0a0a !important;
293
+ --background-fill-primary: #0a0a0a !important;
294
+ --background-fill-secondary: #121212 !important;
295
+ --border-color-primary: #1f2937 !important;
296
+ --border-color-secondary: #374151 !important;
297
+ --text-color-primary: #ffffff !important;
298
+ --text-color-secondary: #d1d5db !important;
299
+ --input-background-fill: #121212 !important;
300
+ --input-border-width: 1px !important;
301
+ --input-border-color: #1f2937 !important;
302
+ }
303
+
304
+ body {
305
+ background-color: #0a0a0a !important;
306
+ color: #ffffff !important;
307
+ font-family: 'Helvetica Neue', sans-serif !important;
308
+ }
309
+
310
+ .gradio-container {
311
+ background-color: #0a0a0a !important;
312
+ border: none !important;
313
+ }
314
+
315
  footer { display: none !important; }
316
  .fog { opacity: 0.3; filter: blur(2px); transition: all 0.5s ease; }
317
  .fade-in { animation: fadeIn 0.5s ease-in forwards; }
 
338
  #btn-trace:hover { color: #d1d5db !important; }
339
 
340
  /* Big Task Text */
341
+ #current-task { text-align: center; font-size: 3rem; font-weight: 800; min-height: 150px; display: flex; align-items: center; justify-content: center; color: #ffffff !important; }
342
  @media (min-width: 768px) { #current-task { font-size: 4.5rem; } }
343
  """
344
 
 
423
 
424
  return state, generate_task_html(styled_task), generate_breadcrumbs_html(state["history"][-3:]), gr.Row(visible=True)
425
 
426
+ with gr.Blocks(css=custom_css, js="() => { document.documentElement.classList.add('dark'); }", title="Step-Zero") as app:
427
  session_state = gr.State()
428
 
429
  with gr.Column(visible=True) as screen_start:
app_test.py DELETED
@@ -1,379 +0,0 @@
1
- import asyncio
2
- import json
3
- import os
4
- from pathlib import Path
5
- from dotenv import load_dotenv
6
- load_dotenv()
7
-
8
- import gradio as gr
9
-
10
- ROOT = Path(__file__).parent
11
- GRAMMAR_PATH = ROOT / "grammar.gbnf"
12
-
13
- # Keep the demo runnable while the GGUF files are still being prepared.
14
- MOCK_MODE = os.getenv("STEP_ZERO_MOCK", "1") != "0"
15
- NEMOTRON_MODEL_PATH = os.getenv("NEMOTRON_MODEL_PATH", "./models/step-zero-nemotron-finetuned.gguf")
16
- MINICPM_MODEL_PATH = os.getenv("MINICPM_MODEL_PATH", "./models/minicpm-3-4b.gguf")
17
-
18
- if not MOCK_MODE:
19
- from llama_cpp import Llama
20
- from llama_cpp import LlamaGrammar
21
-
22
- grammar = LlamaGrammar.from_file(str(GRAMMAR_PATH))
23
-
24
- # Use small context windows to save RAM.
25
- nemotron = Llama(model_path=NEMOTRON_MODEL_PATH, n_ctx=1024)
26
- minicpm = Llama(model_path=MINICPM_MODEL_PATH, n_ctx=1024)
27
-
28
- # Per-model locks for concurrency
29
- nemotron_lock = asyncio.Lock()
30
- minicpm_lock = asyncio.Lock()
31
-
32
- async def run_nemotron(func, *args, **kwargs):
33
- async with nemotron_lock:
34
- return await asyncio.to_thread(func, *args, **kwargs)
35
-
36
- async def run_minicpm(func, *args, **kwargs):
37
- async with minicpm_lock:
38
- return await asyncio.to_thread(func, *args, **kwargs)
39
-
40
- MAX_TRACE_EVENTS = 50
41
- MAX_HISTORY_ITEMS = 20
42
-
43
- def append_trace(state, event: dict) -> None:
44
- state["trace"].append(event)
45
- if len(state["trace"]) > MAX_TRACE_EVENTS:
46
- state["trace"] = state["trace"][-MAX_TRACE_EVENTS:]
47
-
48
- def append_history(state, displayed_task: str, raw_task: str) -> None:
49
- state["history"].append(displayed_task)
50
- state["raw_history"].append(raw_task)
51
- if len(state["history"]) > MAX_HISTORY_ITEMS:
52
- state["history"] = state["history"][-MAX_HISTORY_ITEMS:]
53
- if len(state["raw_history"]) > MAX_HISTORY_ITEMS:
54
- state["raw_history"] = state["raw_history"][-MAX_HISTORY_ITEMS:]
55
-
56
- def is_semantic_repeat(new_task: str, history: list) -> bool:
57
- if not history:
58
- return False
59
- new_words = set(new_task.lower().split())
60
- if not new_words:
61
- return False
62
- for past in history[-3:]:
63
- past_words = set(past.lower().split())
64
- if not past_words:
65
- continue
66
- overlap = len(new_words & past_words) / max(len(new_words | past_words), 1)
67
- if overlap > 0.7: # 70% word overlap = semantic repeat
68
- return True
69
- return False
70
-
71
- async def generate_atomic_task(goal: str, previous_failures: int, history: list = None, rejected_task: str = None) -> str:
72
- if history is None:
73
- history = []
74
-
75
- recent_history = history[-3:] if history else []
76
- history_str = "\n".join([f"- {t}" for t in recent_history]) if recent_history else "None"
77
-
78
- if MOCK_MODE:
79
- await asyncio.sleep(1) # Simulate inference latency
80
- demo_steps = [
81
- "Open a new browser tab.",
82
- "Create a blank document.",
83
- "Write the first sentence.",
84
- "Save the file.",
85
- ]
86
- if previous_failures == 1:
87
- return "Move your mouse to the browser icon."
88
- return demo_steps[min(len(history), len(demo_steps) - 1)]
89
-
90
- else:
91
- # If a task was rejected as too hard, route to MiniCPM to break it down further
92
- if previous_failures > 0 and rejected_task:
93
- print(f"TASK WAS REJECTED ('{rejected_task}'). ROUTING TO MINICPM FOR SUB-STEP BREAKDOWN...", flush=True)
94
- messages = [
95
- {"role": "system", "content": "You are a cognitive pacemaker. When a task is too hard, break it down into a single, even simpler, tiny physical starting action under 8 words. Return ONLY the starting action. CRITICAL: Focus strictly on the physical movement. Do NOT suggest thinking, planning, or remembering."},
96
- {"role": "user", "content": f"The task '{rejected_task}' was too hard. Break it down into a single, even simpler physical starting action."}
97
- ]
98
- fallback_res = await run_minicpm(
99
- minicpm.create_chat_completion,
100
- messages=messages,
101
- max_tokens=20,
102
- temperature=0.1
103
- )
104
- content = fallback_res['choices'][0]['message']['content'].strip()
105
- print(f"MINICPM BREAKDOWN OUT: {content}", flush=True)
106
- content = content.strip('"\' ,.-1234567890)')
107
- return content or "Focus on the screen."
108
-
109
- # REAL INFERENCE using the exact string template used during fine-tuning
110
- system_msg = "You are a cognitive pacemaker. Break down goals into extremely tiny, atomic physical actions under 8 words."
111
-
112
- prompt = f"<extra_id_0>System\n{system_msg}\n\n"
113
- prompt += f"<extra_id_1>User\nGoal: {goal}\nCompleted Tasks: {history_str}\nFailures: {previous_failures}\nOutput the NEXT step.\n"
114
- prompt += f"<extra_id_1>Assistant\n"
115
-
116
- response = await run_nemotron(
117
- nemotron,
118
- prompt,
119
- max_tokens=20,
120
- temperature=0.3,
121
- stop=["\n", "<extra_id_1>"],
122
- grammar=grammar # Enforcing grammar here!
123
- )
124
- content = response['choices'][0]['text'].strip()
125
-
126
- # Check if output is empty or a repetition
127
- is_invalid = not content or is_semantic_repeat(content, history)
128
-
129
- if is_invalid:
130
- print(f"NEMOTRON OUTPUT INVALID OR REPETITION ('{content}'). FALLING BACK TO MINICPM...", flush=True)
131
- last_task = history[-1] if history else ""
132
- user_content = f"Goal: {goal}\nCompleted Tasks: {history_str}\nFailures: {previous_failures}\n"
133
- if last_task:
134
- user_content += f"CRITICAL: Do NOT output '{last_task}'. Output the strictly NEXT new physical step."
135
- else:
136
- user_content += "Output the NEXT step."
137
-
138
- messages = [
139
- {"role": "system", "content": "You are a cognitive pacemaker. Focus strictly on the physical goal and break it down into an extremely tiny, atomic physical action under 8 words. Ignore mental blocks or feelings of being stuck and output ONLY the single physical action step."},
140
- {"role": "user", "content": user_content}
141
- ]
142
- fallback_res = await run_minicpm(
143
- minicpm.create_chat_completion,
144
- messages=messages,
145
- max_tokens=20,
146
- temperature=0.1
147
- )
148
- content = fallback_res['choices'][0]['message']['content'].strip()
149
- print(f"MINICPM FALLBACK OUT: {content}", flush=True)
150
- else:
151
- print(f"NEMOTRON RAW OUT: {content}", flush=True)
152
-
153
- content = content.strip('"\' ,.-1234567890)')
154
- return content or "Focus on the screen."
155
-
156
- async def apply_activation_style(task: str, style="direct") -> str:
157
- if MOCK_MODE:
158
- await asyncio.sleep(0.5)
159
- if style == "calm":
160
- return f"When you are ready, {task[0].lower()}{task[1:]}"
161
- if style == "encouraging":
162
- return f"You can do this: {task}"
163
- return f"{task} Now."
164
-
165
- else:
166
- # REAL INFERENCE
167
- if style == "direct":
168
- return f"{task.capitalize()}."
169
-
170
- if style == "encouraging":
171
- system_prompt = (
172
- "You are a cognitive pacemaker. Rewrite the given task into an encouraging, supportive tone.\n"
173
- "RULES:\n"
174
- "1. Keep it as an action/command the user MUST do now. Start or end with an encouraging phrase like 'You got this!', 'Let's do it!', or 'Go ahead and...'.\n"
175
- "2. Do NOT write in the past tense, do NOT congratulate the user, and do NOT treat the task as already completed.\n"
176
- "3. Limit your response to EXACTLY ONE short sentence (under 12 words) and output ONLY the final rewritten task."
177
- )
178
- elif style == "calm":
179
- system_prompt = (
180
- "You are a cognitive pacemaker. Rewrite the given task into a calm, gentle tone.\n"
181
- "RULES:\n"
182
- "1. Keep it as an action/command. Use gentle prefixes like 'When you are ready, ...' or 'Take your time and ...'.\n"
183
- "2. Do NOT write in the past tense and do NOT congratulate the user.\n"
184
- "3. Limit your response to EXACTLY ONE short sentence (under 12 words) and output ONLY the final rewritten task."
185
- )
186
- else:
187
- system_prompt = (
188
- f"You are a cognitive pacemaker. Rewrite the given task into a {style} tone.\n"
189
- "RULES:\n"
190
- "1. Keep it as an action/command the user MUST do now.\n"
191
- "2. Do NOT write in the past tense, do NOT congratulate the user, and do NOT treat the task as already completed.\n"
192
- "3. Limit your response to EXACTLY ONE short sentence (under 12 words) and output ONLY the final rewritten task."
193
- )
194
-
195
- messages = [
196
- {"role": "system", "content": system_prompt},
197
- {"role": "user", "content": f"Task: {task}"}
198
- ]
199
- response = await run_minicpm(
200
- minicpm.create_chat_completion,
201
- messages=messages,
202
- max_tokens=40,
203
- temperature=0.2
204
- )
205
- content = response['choices'][0]['message']['content'].strip()
206
- print(f"MINICPM RAW OUT: {content}", flush=True)
207
- return content
208
-
209
- # --- GRADIO UI ---
210
-
211
- custom_css = """
212
- body { background-color: #0a0a0a; color: #ffffff; font-family: 'Helvetica Neue', sans-serif; }
213
- .gradio-container { background-color: transparent !important; border: none !important; }
214
- footer { display: none !important; }
215
- .fog { opacity: 0.3; filter: blur(2px); transition: all 0.5s ease; }
216
- .fade-in { animation: fadeIn 0.5s ease-in forwards; }
217
- @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
218
-
219
- /* Goal Input Styling */
220
- #goal-input textarea {
221
- background: transparent !important;
222
- border: none !important;
223
- border-bottom: 2px solid #4b5563 !important;
224
- color: white !important;
225
- font-size: 1.5rem !important;
226
- text-align: center !important;
227
- box-shadow: none !important;
228
- border-radius: 0 !important;
229
- }
230
- #goal-input textarea:focus { border-bottom: 2px solid white !important; }
231
-
232
- /* Buttons */
233
- #btn-done { background-color: #16a34a !important; color: white !important; font-weight: bold; font-size: 1.25rem !important; }
234
- #btn-skip { background-color: #4b5563 !important; color: white !important; font-weight: bold; font-size: 1.25rem !important; }
235
- #btn-hard { background-color: #1f2937 !important; color: #d1d5db !important; font-weight: bold; font-size: 1.25rem !important; }
236
- #btn-trace { background: transparent !important; border: none !important; color: #4b5563 !important; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.75rem !important; }
237
- #btn-trace:hover { color: #d1d5db !important; }
238
-
239
- /* Big Task Text */
240
- #current-task { text-align: center; font-size: 3rem; font-weight: 800; min-height: 150px; display: flex; align-items: center; justify-content: center; }
241
- @media (min-width: 768px) { #current-task { font-size: 4.5rem; } }
242
- """
243
-
244
- def generate_breadcrumbs_html(history: list) -> str:
245
- html = "<div class='fog text-sm space-y-2'>"
246
- for t in history:
247
- html += f"<div>✓ {t}</div>"
248
- html += "</div>"
249
- return html
250
-
251
- def generate_task_html(task: str, animate=True) -> str:
252
- class_str = "fade-in" if animate else ""
253
- return f"<div id='current-task' class='{class_str}'>{task}</div>"
254
-
255
- async def process_step(state, action: str, goal: str = None, style: str = None, last_task: str = None):
256
- if not state:
257
- state = {}
258
- # Initialization
259
- if action == "start":
260
- state["goal"] = goal
261
- state["style"] = style
262
- state["current_task"] = ""
263
- state["current_raw_task"] = ""
264
- state["too_hard_count"] = 0
265
- state["history"] = []
266
- state["raw_history"] = []
267
- state["trace"] = [{"event": "start", "goal": state["goal"], "style": state["style"]}]
268
-
269
- elif action == "too_hard":
270
- state["too_hard_count"] += 1
271
- append_trace(state, {
272
- "event": "too_hard",
273
- "task": state["current_task"],
274
- "too_hard_count": state["too_hard_count"],
275
- })
276
-
277
- elif action == "skip":
278
- append_trace(state, {"event": "skip", "task": state["current_task"]})
279
- # Note: Do not increment too_hard_count
280
-
281
- elif action == "done":
282
- state["too_hard_count"] = 0
283
- if last_task:
284
- raw_task_done = state.get("current_raw_task") or last_task
285
- append_history(state, last_task, raw_task_done)
286
- append_trace(state, {"event": "done", "task": last_task})
287
-
288
- # HARD CIRCUIT BREAKER
289
- if state["too_hard_count"] >= 3:
290
- breaker_task = "You are out of activation energy. Step away from the screen for 3 minutes. I will be here."
291
- state["current_task"] = breaker_task
292
- append_trace(state, {"event": "circuit_breaker", "task": breaker_task})
293
- state["too_hard_count"] = 0 # Reset after breaking
294
- return state, generate_task_html(breaker_task), generate_breadcrumbs_html(state["history"][-3:]), gr.update(visible=False)
295
-
296
- # Standard Loop
297
- rejected_task = state["current_task"] if state["too_hard_count"] > 0 else None
298
-
299
- raw_task = await generate_atomic_task(
300
- state["goal"],
301
- state["too_hard_count"],
302
- history=state["raw_history"],
303
- rejected_task=rejected_task,
304
- )
305
- styled_task = await apply_activation_style(raw_task, state["style"])
306
- state["current_task"] = styled_task
307
- state["current_raw_task"] = raw_task
308
-
309
- append_trace(state, {
310
- "event": "generated_step",
311
- "raw_task": raw_task,
312
- "styled_task": styled_task,
313
- "style": state["style"],
314
- "too_hard_count": state["too_hard_count"],
315
- })
316
-
317
- return state, generate_task_html(styled_task), generate_breadcrumbs_html(state["history"][-3:]), gr.update(visible=True)
318
-
319
- with gr.Blocks(css=custom_css, title="Step-Zero") as app:
320
- session_state = gr.State()
321
-
322
- with gr.Column(visible=True) as screen_start:
323
- gr.HTML("<h1 class='text-4xl font-bold mb-8 text-center mt-20'>What is paralyzing you?</h1>")
324
- goal_input = gr.Textbox(elem_id="goal-input", show_label=False, placeholder="e.g. Write my thesis...", lines=1)
325
-
326
- with gr.Row(elem_classes="justify-center mt-8"):
327
- style_radio = gr.Radio(
328
- choices=["direct", "calm", "encouraging"],
329
- value="direct",
330
- show_label=False,
331
- container=False
332
- )
333
-
334
- start_btn = gr.Button("Start", variant="primary", elem_classes="mt-8 mx-auto w-48")
335
-
336
- with gr.Column(visible=False) as screen_task:
337
- breadcrumbs_display = gr.HTML(elem_id="breadcrumbs-container")
338
- task_display = gr.HTML(elem_id="task-container")
339
-
340
- with gr.Row(elem_id="controls-container") as controls_row:
341
- btn_done = gr.Button("I DID THIS", elem_id="btn-done")
342
- btn_skip = gr.Button("SKIP", elem_id="btn-skip")
343
- btn_hard = gr.Button("TOO HARD", elem_id="btn-hard")
344
-
345
- with gr.Row(elem_classes="justify-center mt-4 gap-4"):
346
- btn_trace = gr.Button("Export Trace", elem_id="btn-trace")
347
- btn_push = gr.Button("Push to Hub", elem_id="btn-trace")
348
-
349
- trace_download = gr.File(visible=False)
350
- hub_status = gr.HTML(visible=False, elem_classes="text-center text-sm text-gray-400 mt-2")
351
-
352
- # Temporary Loading State Function
353
- def show_loading():
354
- return gr.update(visible=False), gr.update(visible=True), generate_task_html("<span class='text-gray-600 animate-pulse'>Calculating constraint...</span>", animate=False), gr.update(visible=False)
355
-
356
- def show_loading_step():
357
- return generate_task_html("<span class='text-gray-600 animate-pulse'>Loading next step...</span>", animate=False), gr.update(visible=False)
358
-
359
- # --- Event Handlers ---
360
-
361
- async def handle_start(state, goal, style):
362
- return await process_step(state, "start", goal=goal, style=style)
363
-
364
- async def handle_done(state):
365
- if not state: state = {}
366
- return await process_step(state, "done", last_task=state.get("current_task"))
367
-
368
- async def handle_skip(state):
369
- return await process_step(state, "skip")
370
-
371
- async def handle_too_hard(state):
372
- return await process_step(state, "too_hard")
373
-
374
- # Start Session
375
- start_btn.click(
376
- fn=show_loading,
377
- outputs=[screen_start, screen_task, task_display, controls_row]
378
- ).then(
379
- fn=handle_start,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
field_notes.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Field Notes: Building Step-Zero (Cognitive Pacemaker)
2
+
3
+ Step-Zero is a local-first "Cognitive Pacemaker" application designed to break down overwhelming goals into atomic physical actions to overcome executive dysfunction.
4
+
5
+ During development, we encountered several unique challenges in aligning very small language models (≤4B parameters) to produce strictly physical actions under strict grammar constraints. Here is the report of what we built, what we learned, and how we optimized the system.
6
+
7
+ ---
8
+
9
+ ## 1. System Architecture
10
+
11
+ The core of Step-Zero is a **dual-model orchestrator** that runs entirely locally on CPU/laptop hardware via `llama.cpp` runtimes.
12
+
13
+ ```
14
+ ┌──────────────────────┐
15
+ │ Goal & UI Input │
16
+ └──────────┬───────────┘
17
+
18
+
19
+ ┌───────────────────────────┐
20
+ │ Primary Model (Nemotron) │
21
+ └─────────────┬─────────────┘
22
+
23
+ [Output Valid?]
24
+ / \
25
+ Yes No (or "Too Hard")
26
+ / \
27
+ ▼ ▼
28
+ ┌──────────────────────┐ ┌───────────────────────┐
29
+ │ Render Action in UI │ │ Fallback (MiniCPM) │
30
+ └──────────────────────┘ └───────────────────────┘
31
+ ```
32
+
33
+ 1. **Primary Model (Nemotron-Mini-4B):** Fine-tuned specifically for step breakdown using a synthetic task-reduction dataset (`verbs.jsonl`).
34
+ 2. **Fallback Model (MiniCPM-3-4B):** An instruction-following model used for stylistic adjustment, semantic repetition recovery, and breaking down actions when the user signals "Too Hard".
35
+
36
+ ---
37
+
38
+ ## 2. Technical Alignments & Guardrails
39
+
40
+ Deploying small LLMs locally introduces high variability in output formatting. We implemented three layers of guardrails to enforce strict formatting:
41
+
42
+ ### A. GBNF Grammars
43
+ We defined a GBNF grammar (`[a-zA-Z0-9 ,.!?'-]+`) to force the models to generate raw plain text rather than markdown lists, JSON objects, or verbose chat commentary. This bypasses the need for complex output parser libraries.
44
+
45
+ ### B. Output Validation & First-Sentence Extraction
46
+ Small fine-tuned models can experience "prompt leakage" or echo prompt formatting when encountering out-of-distribution user inputs. To solve this, we implemented a custom post-processing pipeline that:
47
+ - Splits output at sentence boundaries to extract only the *first* sentence (guaranteeing one atomic starting action).
48
+ - Validates the output against a list of prompt scaffolding keywords (e.g. `Completed Tasks`, `User`, `Assistant`, `Failures`).
49
+ - Immediately routes any invalid or overly verbose output to the fallback MiniCPM model.
50
+
51
+ ### C. Semantic Repetition Guard
52
+ Instead of exact string matching, we implemented a sliding-window overlap check. If a newly generated action has >70% word overlap with the user's recent history or skipped tasks, the system intercepts it as a repetition loop and routes it to MiniCPM to generate a novel alternative.
53
+
54
+ ### D. Hard Circuit Breaker
55
+ If the user indicates a task is "Too Hard" three times consecutively, the app triggers a hard-coded cooldown screen: *"You are out of activation energy. Step away from the screen for 3 minutes. I will be here."* This prevents the AI from entering infinite breakdown loops that increase user frustration.
56
+
57
+ ---
58
+
59
+ ## 3. Custom UI/UX: The "Fog of War"
60
+
61
+ To support the cognitive design of the pacemaker (which aims to reduce cognitive load), the app features a minimal, custom dark theme. By leveraging Gradio's CSS custom properties on `:root` and `.dark`, we overrode Gradio's standard elements to deliver a clean, borderless dark UI styled like a game interface:
62
+ - **Fog of War:** Completed history is styled with low opacity (`opacity: 0.3`) and blurred (`filter: blur(2px)`) to keep the user's attention anchored on the single next step.
63
+ - **Minimalist Controls:** Big, clear action buttons ("I DID THIS", "SKIP", "TOO HARD") keep user interactions simple.
64
+
65
+ ---
66
+
67
+ ## 4. Key Takeaways & Small Model Constraints
68
+
69
+ 1. **Alignment Tax on Small Models:** Fine-tuning a 4B model changes its distribution significantly. Even mild discrepancies between fine-tuning format and inference prompts can lead to format breakdown. A strict post-validation filter is essential when building production applications around them.
70
+ 2. **Grammar Constraints are a Superpower:** Restricting token generation at the sampler level is far more efficient than prompt-engineering a small model to follow output rules.
71
+ 3. **Local-First is Ready:** With optimized GGUF quantizations, both Nemotron and MiniCPM run under 50ms per token on modern consumer laptops.
implemention_plan.md DELETED
@@ -1,72 +0,0 @@
1
- This is your **Final Execution Playbook**. All the VC fluff, fake science, and over-engineered bloat have been stripped out.
2
-
3
- What remains is a brutally effective, highly defensible 48-hour sprint to build **Step-Zero: The Cognitive Pacemaker**.
4
-
5
- The core thesis you are building (and pitching) is this: *“What if an AI refused to let you think about more than one thing at a time?”*
6
-
7
- Here is the step-by-step implementation plan to build the tech, hit the corporate bounties, and record the winning demo.
8
-
9
- ---
10
-
11
- ### The Bounty Matrix (Your Checklist)
12
-
13
- * **Track:** Backyard AI 🏡 (Target: Anyone paralyzed by task friction).
14
- * **NVIDIA ($10k) + Llama Champion:** `Nemotron-Mini-4B` running locally via `llama-cpp-python` to generate the strict logic steps.
15
- * **OpenBMB ($10k):** `MiniCPM-3-4B` running locally to translate the logic step into the user's chosen "Activation Style" (Calm, Structured, Direct).
16
- * **Modal ($20k) + Well-Tuned:** A fast LoRA fine-tune on Nemotron explicitly for *Syntactic Verb Enforcement* (forcing outputs under 8 words starting with an action verb).
17
- * **OpenAI ($10k) + Off-Brand:** Custom HTML/JS "Fog of War" frontend generated 100% by GitHub Copilot/Codex, served over Gradio `gr.Server`.
18
- * **Badges:** Tiny Titan (≤4B models), Off the Grid (100% offline inference), Sharing is Caring (Agent JSON trace export).
19
-
20
- ---
21
-
22
- ### Phase 1: The Modal Fine-Tuning Sprint (Friday Night)
23
-
24
- *You do this first so you can use the fine-tuned model all weekend.*
25
-
26
- 1. **The Dataset (`verbs.jsonl`):** Create 200 rows of training data.
27
- * *Input:* "I need to clean my room but I am paralyzed."
28
- * *Output:* "Pick up one sock." *(Notice: No conversational fluff. Starts with a verb. Under 8 words).*
29
-
30
-
31
- 2. **The Modal Script:** Use Modal's serverless GPU to run an Unsloth script. Fine-tune `Nemotron-Mini-4B` on this dataset to heavily bias it toward strict, atomic, imperative statements.
32
- 3. **The Export:** Download the adapter weights, convert to `.gguf`, and save it to your local machine as `nemotron_atomic_v1.gguf`.
33
-
34
- ### Phase 2: The Local Engine & Circuit Breaker (Saturday Morning)
35
-
36
- *You build the Python backend that hot-swaps the models to keep RAM under 6GB.*
37
-
38
- 1. **The GBNF Grammar:** Write a `Llama.cpp` grammar file that forces Nemotron to *only* output a single string, stripping its ability to hallucinate markdown or lists.
39
- 2. **The State Machine (`app.py`):** * Initialize a fastAPI/Gradio backend with a simple Python dictionary for state: `{"current_task": "", "too_hard_count": 0, "past_steps": []}`.
40
- 3. **The `[TOO HARD]` Fallback Loop:** * If the user hits `[TOO HARD]`, Python increments the counter.
41
- * It passes the current task back to Nemotron: *"The user failed to do: [Task]. Provide a physically smaller, easier pre-requisite action."*
42
-
43
-
44
- 4. **The Hard Circuit Breaker:** * If `too_hard_count == 2`, the backend bypasses the LLM entirely and hard-returns: *"You are out of activation energy. Step away from the screen for 3 minutes. Leave this window open."* (This proves to judges you care about UX, not just spamming AI outputs).
45
-
46
- ### Phase 3: The OpenBMB Stylizer (Saturday Afternoon)
47
-
48
- 1. **The Pipeline:** Once Nemotron outputs the raw atomic step (e.g., "Open the PDF"), Python pipes that string into OpenBMB.
49
- 2. **The Persona Prompt:** OpenBMB receives: *"Rewrite this task: 'Open the PDF' in a [Calm/Direct/Encouraging] tone. Keep it under 2 sentences."*
50
- 3. **WebSocket Broadcast:** The final stylized text is pushed to the frontend via Gradio's Async API or a raw WebSocket.
51
-
52
- ### Phase 4: The Codex "Fog of War" UI (Saturday Night)
53
-
54
- *Do not write this yourself. You must use Codex/Copilot to win the OpenAI track.*
55
-
56
- 1. Open VS Code and use the Copilot Chat panel.
57
- 2. **Your exact prompt to Copilot:** > *"Generate a single-page HTML/JS/Tailwind interface. It must have a pure black background. At the top, put a very faint, blurred text area called 'Breadcrumbs'. In the dead center, place a massive text block (72px font, white) for a single instruction. Below it, place two buttons: A green [I DID THIS] button, and a muted gray [THIS IS TOO HARD] button. Write the WebSocket JS to connect to a local backend at `ws://localhost:7860`. When the user clicks [I DID THIS], the center text fades out, moves to the blurred 'Breadcrumbs' section, and the new text fades in. Do not use standard chatbot layouts."*
58
- 3. **Commit the Code:** Make a git commit with the message: `feat: Generated proprietary Fog of War SPA interface using OpenAI Codex`.
59
- 4. Serve this `index.html` file using `gr.Server(serve_static=["index.html"])`.
60
-
61
- ### Phase 5: The Demo & The Pitch (Sunday)
62
-
63
- The demo video is where you separate yourselves from the "wrapper" projects.
64
-
65
- **The Video Script (Keep it tight and grounded):**
66
-
67
- 1. **The Hook (0:00-0:15):** *"Standard AI assistants are built for conversation and expansion. But when a user is experiencing executive dysfunction or task paralysis, a conversational list is overwhelming. We built Step-Zero: a local-only Cognitive Pacemaker that enforces strict attentional constraints. It refuses to let you see the future."*
68
- 2. **The Tech Flex (0:15-0:45):** *"Because this involves sensitive behavioral friction, it runs 100% off-the-grid. We used Modal to fine-tune Nemotron-4B to strictly output 8-word imperative verbs. Nemotron manages our hidden friction-state machine. Once a task is scaled to the user's capability, OpenBMB-4B dynamically translates the tone to match the user's required activation energy."*
69
- 3. **The UI Flex (0:45-1:15):** *"Gradio's default chat interface couldn't handle our 'Fog of War' design, so we used OpenAI Codex to generate a completely custom, headless DOM overlay hosted via `gr.Server`."*
70
- 4. **The Live Demo (1:15-2:00):** Show the app. Type *"I need to write my tax report."* Show the screen displaying only *"Open a new folder."* Hit `[TOO HARD]`. Show Nemotron dynamically downgrading the task to *"Click the finder icon."* Hit `[TOO HARD]` again. Show the Circuit Breaker activating: *"Walk away for 3 minutes."*
71
-
72
- **Final check:** Does this plan align with your team's capability to split the work? One person on the Llama.cpp backend (Python), one person wrangling the Copilot frontend (HTML/JS), and one person managing the Modal Fine-tune (Data/Unsloth)?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
output.txt DELETED
@@ -1,417 +0,0 @@
1
- ERROR: Exception in ASGI application
2
- Traceback (most recent call last):
3
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
4
- result = await app( # type: ignore[func-returns-value]
5
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
7
- return await self.app(scope, receive, send)
8
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9
- File "/usr/local/lib/python3.12/dist-packages/fastapi/applications.py", line 1054, in __call__
10
- await super().__call__(scope, receive, send)
11
- File "/usr/local/lib/python3.12/dist-packages/starlette/applications.py", line 113, in __call__
12
- await self.middleware_stack(scope, receive, send)
13
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 187, in __call__
14
- raise exc
15
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 165, in __call__
16
- await self.app(scope, receive, _send)
17
- File "/usr/local/lib/python3.12/dist-packages/gradio/route_utils.py", line 789, in __call__
18
- await self.app(scope, receive, send)
19
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__
20
- await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
21
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
22
- raise exc
23
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
24
- await app(scope, receive, sender)
25
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 715, in __call__
26
- await self.middleware_stack(scope, receive, send)
27
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 735, in app
28
- await route.handle(scope, receive, send)
29
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 288, in handle
30
- await self.app(scope, receive, send)
31
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 76, in app
32
- await wrap_app_handling_exceptions(app, request)(scope, receive, send)
33
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
34
- raise exc
35
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
36
- await app(scope, receive, sender)
37
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 73, in app
38
- response = await f(request)
39
- ^^^^^^^^^^^^^^^^
40
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 301, in app
41
- raw_response = await run_endpoint_function(
42
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 214, in run_endpoint_function
44
- return await run_in_threadpool(dependant.call, **values)
45
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46
- File "/usr/local/lib/python3.12/dist-packages/starlette/concurrency.py", line 39, in run_in_threadpool
47
- return await anyio.to_thread.run_sync(func, *args)
48
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
49
- File "/usr/local/lib/python3.12/dist-packages/anyio/to_thread.py", line 63, in run_sync
50
- return await get_async_backend().run_sync_in_worker_thread(
51
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 2502, in run_sync_in_worker_thread
53
- return await future
54
- ^^^^^^^^^^^^
55
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 986, in run
56
- result = context.run(func, *args)
57
- ^^^^^^^^^^^^^^^^^^^^^^^^
58
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 552, in main
59
- gradio_api_info = api_info(request)
60
- ^^^^^^^^^^^^^^^^^
61
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 582, in api_info
62
- api_info = utils.safe_deepcopy(app.get_blocks().get_api_info())
63
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64
- File "/usr/local/lib/python3.12/dist-packages/gradio/blocks.py", line 2992, in get_api_info
65
- python_type = client_utils.json_schema_to_python_type(info)
66
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 920, in json_schema_to_python_type
68
- type_ = _json_schema_to_python_type(schema, schema.get("$defs"))
69
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 975, in _json_schema_to_python_type
71
- f"{n}: {_json_schema_to_python_type(v, defs)}{get_desc(v)}"
72
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 982, in _json_schema_to_python_type
74
- f"str, {_json_schema_to_python_type(schema['additionalProperties'], defs)}"
75
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 928, in _json_schema_to_python_type
77
- type_ = get_type(schema)
78
- ^^^^^^^^^^^^^^^^
79
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 887, in get_type
80
- if "const" in schema:
81
- ^^^^^^^^^^^^^^^^^
82
- TypeError: argument of type 'bool' is not iterable
83
- ERROR: Exception in ASGI application
84
- Traceback (most recent call last):
85
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
86
- result = await app( # type: ignore[func-returns-value]
87
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
89
- return await self.app(scope, receive, send)
90
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91
- File "/usr/local/lib/python3.12/dist-packages/fastapi/applications.py", line 1054, in __call__
92
- await super().__call__(scope, receive, send)
93
- File "/usr/local/lib/python3.12/dist-packages/starlette/applications.py", line 113, in __call__
94
- await self.middleware_stack(scope, receive, send)
95
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 187, in __call__
96
- raise exc
97
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 165, in __call__
98
- await self.app(scope, receive, _send)
99
- File "/usr/local/lib/python3.12/dist-packages/gradio/route_utils.py", line 789, in __call__
100
- await self.app(scope, receive, send)
101
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__
102
- await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
103
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
104
- raise exc
105
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
106
- await app(scope, receive, sender)
107
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 715, in __call__
108
- await self.middleware_stack(scope, receive, send)
109
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 735, in app
110
- await route.handle(scope, receive, send)
111
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 288, in handle
112
- await self.app(scope, receive, send)
113
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 76, in app
114
- await wrap_app_handling_exceptions(app, request)(scope, receive, send)
115
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
116
- raise exc
117
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
118
- await app(scope, receive, sender)
119
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 73, in app
120
- response = await f(request)
121
- ^^^^^^^^^^^^^^^^
122
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 301, in app
123
- raw_response = await run_endpoint_function(
124
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 214, in run_endpoint_function
126
- return await run_in_threadpool(dependant.call, **values)
127
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
128
- File "/usr/local/lib/python3.12/dist-packages/starlette/concurrency.py", line 39, in run_in_threadpool
129
- return await anyio.to_thread.run_sync(func, *args)
130
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131
- File "/usr/local/lib/python3.12/dist-packages/anyio/to_thread.py", line 63, in run_sync
132
- return await get_async_backend().run_sync_in_worker_thread(
133
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
134
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 2502, in run_sync_in_worker_thread
135
- return await future
136
- ^^^^^^^^^^^^
137
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 986, in run
138
- result = context.run(func, *args)
139
- ^^^^^^^^^^^^^^^^^^^^^^^^
140
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 552, in main
141
- gradio_api_info = api_info(request)
142
- ^^^^^^^^^^^^^^^^^
143
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 582, in api_info
144
- api_info = utils.safe_deepcopy(app.get_blocks().get_api_info())
145
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146
- File "/usr/local/lib/python3.12/dist-packages/gradio/blocks.py", line 2992, in get_api_info
147
- python_type = client_utils.json_schema_to_python_type(info)
148
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
149
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 920, in json_schema_to_python_type
150
- type_ = _json_schema_to_python_type(schema, schema.get("$defs"))
151
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 975, in _json_schema_to_python_type
153
- f"{n}: {_json_schema_to_python_type(v, defs)}{get_desc(v)}"
154
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
155
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 982, in _json_schema_to_python_type
156
- f"str, {_json_schema_to_python_type(schema['additionalProperties'], defs)}"
157
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 928, in _json_schema_to_python_type
159
- type_ = get_type(schema)
160
- ^^^^^^^^^^^^^^^^
161
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 887, in get_type
162
- if "const" in schema:
163
- ^^^^^^^^^^^^^^^^^
164
- TypeError: argument of type 'bool' is not iterable
165
- ERROR: Exception in ASGI application
166
- Traceback (most recent call last):
167
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
168
- result = await app( # type: ignore[func-returns-value]
169
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
170
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
171
- return await self.app(scope, receive, send)
172
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
173
- File "/usr/local/lib/python3.12/dist-packages/fastapi/applications.py", line 1054, in __call__
174
- await super().__call__(scope, receive, send)
175
- File "/usr/local/lib/python3.12/dist-packages/starlette/applications.py", line 113, in __call__
176
- await self.middleware_stack(scope, receive, send)
177
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 187, in __call__
178
- raise exc
179
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 165, in __call__
180
- await self.app(scope, receive, _send)
181
- File "/usr/local/lib/python3.12/dist-packages/gradio/route_utils.py", line 789, in __call__
182
- await self.app(scope, receive, send)
183
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__
184
- await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
185
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
186
- raise exc
187
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
188
- await app(scope, receive, sender)
189
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 715, in __call__
190
- await self.middleware_stack(scope, receive, send)
191
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 735, in app
192
- await route.handle(scope, receive, send)
193
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 288, in handle
194
- await self.app(scope, receive, send)
195
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 76, in app
196
- await wrap_app_handling_exceptions(app, request)(scope, receive, send)
197
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
198
- raise exc
199
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
200
- await app(scope, receive, sender)
201
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 73, in app
202
- response = await f(request)
203
- ^^^^^^^^^^^^^^^^
204
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 301, in app
205
- raw_response = await run_endpoint_function(
206
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
207
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 214, in run_endpoint_function
208
- return await run_in_threadpool(dependant.call, **values)
209
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
210
- File "/usr/local/lib/python3.12/dist-packages/starlette/concurrency.py", line 39, in run_in_threadpool
211
- return await anyio.to_thread.run_sync(func, *args)
212
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
213
- File "/usr/local/lib/python3.12/dist-packages/anyio/to_thread.py", line 63, in run_sync
214
- return await get_async_backend().run_sync_in_worker_thread(
215
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
216
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 2502, in run_sync_in_worker_thread
217
- return await future
218
- ^^^^^^^^^^^^
219
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 986, in run
220
- result = context.run(func, *args)
221
- ^^^^^^^^^^^^^^^^^^^^^^^^
222
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 552, in main
223
- gradio_api_info = api_info(request)
224
- ^^^^^^^^^^^^^^^^^
225
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 582, in api_info
226
- api_info = utils.safe_deepcopy(app.get_blocks().get_api_info())
227
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
228
- File "/usr/local/lib/python3.12/dist-packages/gradio/blocks.py", line 2992, in get_api_info
229
- python_type = client_utils.json_schema_to_python_type(info)
230
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
231
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 920, in json_schema_to_python_type
232
- type_ = _json_schema_to_python_type(schema, schema.get("$defs"))
233
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
234
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 975, in _json_schema_to_python_type
235
- f"{n}: {_json_schema_to_python_type(v, defs)}{get_desc(v)}"
236
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
237
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 982, in _json_schema_to_python_type
238
- f"str, {_json_schema_to_python_type(schema['additionalProperties'], defs)}"
239
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
240
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 928, in _json_schema_to_python_type
241
- type_ = get_type(schema)
242
- ^^^^^^^^^^^^^^^^
243
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 887, in get_type
244
- if "const" in schema:
245
- ^^^^^^^^^^^^^^^^^
246
- TypeError: argument of type 'bool' is not iterable
247
- ERROR: Exception in ASGI application
248
- Traceback (most recent call last):
249
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
250
- result = await app( # type: ignore[func-returns-value]
251
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
252
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
253
- return await self.app(scope, receive, send)
254
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
255
- File "/usr/local/lib/python3.12/dist-packages/fastapi/applications.py", line 1054, in __call__
256
- await super().__call__(scope, receive, send)
257
- File "/usr/local/lib/python3.12/dist-packages/starlette/applications.py", line 113, in __call__
258
- await self.middleware_stack(scope, receive, send)
259
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 187, in __call__
260
- raise exc
261
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 165, in __call__
262
- await self.app(scope, receive, _send)
263
- File "/usr/local/lib/python3.12/dist-packages/gradio/route_utils.py", line 789, in __call__
264
- await self.app(scope, receive, send)
265
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__
266
- await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
267
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
268
- raise exc
269
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
270
- await app(scope, receive, sender)
271
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 715, in __call__
272
- await self.middleware_stack(scope, receive, send)
273
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 735, in app
274
- await route.handle(scope, receive, send)
275
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 288, in handle
276
- await self.app(scope, receive, send)
277
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 76, in app
278
- await wrap_app_handling_exceptions(app, request)(scope, receive, send)
279
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
280
- raise exc
281
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
282
- await app(scope, receive, sender)
283
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 73, in app
284
- response = await f(request)
285
- ^^^^^^^^^^^^^^^^
286
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 301, in app
287
- raw_response = await run_endpoint_function(
288
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
289
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 214, in run_endpoint_function
290
- return await run_in_threadpool(dependant.call, **values)
291
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
292
- File "/usr/local/lib/python3.12/dist-packages/starlette/concurrency.py", line 39, in run_in_threadpool
293
- return await anyio.to_thread.run_sync(func, *args)
294
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
295
- File "/usr/local/lib/python3.12/dist-packages/anyio/to_thread.py", line 63, in run_sync
296
- return await get_async_backend().run_sync_in_worker_thread(
297
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
298
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 2502, in run_sync_in_worker_thread
299
- return await future
300
- ^^^^^^^^^^^^
301
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 986, in run
302
- result = context.run(func, *args)
303
- ^^^^^^^^^^^^^^^^^^^^^^^^
304
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 552, in main
305
- gradio_api_info = api_info(request)
306
- ^^^^^^^^^^^^^^^^^
307
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 582, in api_info
308
- api_info = utils.safe_deepcopy(app.get_blocks().get_api_info())
309
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
310
- File "/usr/local/lib/python3.12/dist-packages/gradio/blocks.py", line 2992, in get_api_info
311
- python_type = client_utils.json_schema_to_python_type(info)
312
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
313
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 920, in json_schema_to_python_type
314
- type_ = _json_schema_to_python_type(schema, schema.get("$defs"))
315
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
316
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 975, in _json_schema_to_python_type
317
- f"{n}: {_json_schema_to_python_type(v, defs)}{get_desc(v)}"
318
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
319
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 982, in _json_schema_to_python_type
320
- f"str, {_json_schema_to_python_type(schema['additionalProperties'], defs)}"
321
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
322
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 928, in _json_schema_to_python_type
323
- type_ = get_type(schema)
324
- ^^^^^^^^^^^^^^^^
325
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 887, in get_type
326
- if "const" in schema:
327
- ^^^^^^^^^^^^^^^^^
328
- TypeError: argument of type 'bool' is not iterable
329
- ERROR: Exception in ASGI application
330
- Traceback (most recent call last):
331
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
332
- result = await app( # type: ignore[func-returns-value]
333
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
334
- File "/usr/local/lib/python3.12/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
335
- return await self.app(scope, receive, send)
336
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
337
- File "/usr/local/lib/python3.12/dist-packages/fastapi/applications.py", line 1054, in __call__
338
- await super().__call__(scope, receive, send)
339
- File "/usr/local/lib/python3.12/dist-packages/starlette/applications.py", line 113, in __call__
340
- await self.middleware_stack(scope, receive, send)
341
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 187, in __call__
342
- raise exc
343
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 165, in __call__
344
- await self.app(scope, receive, _send)
345
- File "/usr/local/lib/python3.12/dist-packages/gradio/route_utils.py", line 789, in __call__
346
- await self.app(scope, receive, send)
347
- File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__
348
- await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
349
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
350
- raise exc
351
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
352
- await app(scope, receive, sender)
353
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 715, in __call__
354
- await self.middleware_stack(scope, receive, send)
355
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 735, in app
356
- await route.handle(scope, receive, send)
357
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 288, in handle
358
- await self.app(scope, receive, send)
359
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 76, in app
360
- await wrap_app_handling_exceptions(app, request)(scope, receive, send)
361
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
362
- raise exc
363
- File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
364
- await app(scope, receive, sender)
365
- File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 73, in app
366
- response = await f(request)
367
- ^^^^^^^^^^^^^^^^
368
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 301, in app
369
- raw_response = await run_endpoint_function(
370
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
371
- File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 214, in run_endpoint_function
372
- return await run_in_threadpool(dependant.call, **values)
373
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
374
- File "/usr/local/lib/python3.12/dist-packages/starlette/concurrency.py", line 39, in run_in_threadpool
375
- return await anyio.to_thread.run_sync(func, *args)
376
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
377
- File "/usr/local/lib/python3.12/dist-packages/anyio/to_thread.py", line 63, in run_sync
378
- return await get_async_backend().run_sync_in_worker_thread(
379
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
380
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 2502, in run_sync_in_worker_thread
381
- return await future
382
- ^^^^^^^^^^^^
383
- File "/usr/local/lib/python3.12/dist-packages/anyio/_backends/_asyncio.py", line 986, in run
384
- result = context.run(func, *args)
385
- ^^^^^^^^^^^^^^^^^^^^^^^^
386
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 552, in main
387
- gradio_api_info = api_info(request)
388
- ^^^^^^^^^^^^^^^^^
389
- File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 582, in api_info
390
- api_info = utils.safe_deepcopy(app.get_blocks().get_api_info())
391
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
392
- File "/usr/local/lib/python3.12/dist-packages/gradio/blocks.py", line 2992, in get_api_info
393
- python_type = client_utils.json_schema_to_python_type(info)
394
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
395
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 920, in json_schema_to_python_type
396
- type_ = _json_schema_to_python_type(schema, schema.get("$defs"))
397
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
398
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 975, in _json_schema_to_python_type
399
- f"{n}: {_json_schema_to_python_type(v, defs)}{get_desc(v)}"
400
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
401
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 982, in _json_schema_to_python_type
402
- f"str, {_json_schema_to_python_type(schema['additionalProperties'], defs)}"
403
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
404
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 928, in _json_schema_to_python_type
405
- type_ = get_type(schema)
406
- ^^^^^^^^^^^^^^^^
407
- File "/usr/local/lib/python3.12/dist-packages/gradio_client/utils.py", line 887, in get_type
408
- if "const" in schema:
409
- ^^^^^^^^^^^^^^^^^
410
- TypeError: argument of type 'bool' is not iterable
411
- * Running on local URL: http://0.0.0.0:7860
412
- Traceback (most recent call last):
413
- File "/root/step-zero/app.py", line 470, in <module>
414
- app.launch(server_name="0.0.0.0", server_port=7860)
415
- File "/usr/local/lib/python3.12/dist-packages/gradio/blocks.py", line 2619, in launch
416
- raise ValueError(
417
- ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
print_template.py DELETED
@@ -1,4 +0,0 @@
1
- from llama_cpp import Llama
2
- import json
3
- nem = Llama(model_path="./models/nemotron-mini-4b.gguf", n_ctx=1024, verbose=False)
4
- print("TEMPLATE:", nem.metadata.get("tokenizer.chat_template"))
 
 
 
 
 
requirements.txt CHANGED
@@ -1,7 +1,4 @@
1
- fastapi==0.115.6
2
  gradio==5.9.1
3
- uvicorn[standard]==0.32.1
4
- websockets==14.1
5
  requests
6
  python-dotenv
7
  llama-cpp-python
 
 
1
  gradio==5.9.1
 
 
2
  requests
3
  python-dotenv
4
  llama-cpp-python
scratch/test_models.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llama_cpp import Llama, LlamaGrammar
2
+ import os
3
+
4
+ grammar = LlamaGrammar.from_file("grammar.gbnf")
5
+ nemotron = Llama(model_path="./models/step-zero-nemotron-finetuned.gguf", n_ctx=1024, verbose=False)
6
+
7
+ system_msg = "You are a cognitive pacemaker. Break down goals into extremely tiny, atomic physical actions under 8 words."
8
+
9
+ goals = [
10
+ "I want to study",
11
+ "I want to clean my room",
12
+ "I need to write a python script"
13
+ ]
14
+
15
+ for goal in goals:
16
+ prompt = f"<extra_id_0>System\n{system_msg}\n\n"
17
+ prompt += f"<extra_id_1>User\nGoal: {goal}\nCompleted Tasks: None\nFailures: 0\nOutput the NEXT step.\n"
18
+ prompt += f"<extra_id_1>Assistant\n"
19
+
20
+ response = nemotron(
21
+ prompt,
22
+ max_tokens=64,
23
+ temperature=0.3,
24
+ stop=["\n", "<extra_id_1>"],
25
+ grammar=grammar
26
+ )
27
+ print(f"Goal: {goal}")
28
+ print(f"Response: {response['choices'][0]['text']}")
29
+ print("-" * 40)
semantic_test.py DELETED
@@ -1,38 +0,0 @@
1
- import asyncio
2
- import websockets
3
- import json
4
-
5
- GOALS = [
6
- "clean my messy bedroom",
7
- "write a python script to parse a csv",
8
- "i feel overwhelmed by my taxes",
9
- "cook dinner for 4 people",
10
- "learn to play the guitar",
11
- "i don't know what to do",
12
- "read a 500 page book",
13
- "plan a vacation to japan"
14
- ]
15
-
16
- async def semantic_test():
17
- uri = "ws://127.0.0.1:7860/ws"
18
-
19
- print("Running Semantic Stress Test...\n")
20
-
21
- for goal in GOALS:
22
- async with websockets.connect(uri) as ws:
23
- # Action: Start
24
- await ws.send(json.dumps({"action": "start", "goal": goal, "style": "direct"}))
25
- resp1 = await ws.recv()
26
- task1 = json.loads(resp1)['task']
27
-
28
- # Action: Done (Get the NEXT logical step)
29
- await ws.send(json.dumps({"action": "done", "last_task": task1}))
30
- resp2 = await ws.recv()
31
- task2 = json.loads(resp2)['task']
32
-
33
- print(f"GOAL: '{goal}'")
34
- print(f" -> STEP 1: {task1}")
35
- print(f" -> STEP 2: {task2}\n")
36
-
37
- if __name__ == "__main__":
38
- asyncio.run(semantic_test())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stress_test.py DELETED
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Stress test for the fine-tuned Step-Zero model."""
3
-
4
- import asyncio
5
- import json
6
- import websockets
7
-
8
- TEST_PROMPTS = [
9
- "I want to clean my room",
10
- "I need to write a python script",
11
- "I should study for my exam",
12
- "I want to cook dinner",
13
- "I need to do laundry",
14
- "I want to start exercising",
15
- "I should organize my desk",
16
- "I want to learn guitar",
17
- "I need to fix my bike",
18
- "I want to read a book",
19
- "I should call my mom",
20
- "I want to meditate",
21
- "I need to pay my bills",
22
- "I want to go grocery shopping",
23
- "I should write in my journal",
24
- ]
25
-
26
- async def test_prompt(prompt: str) -> dict:
27
- uri = "ws://localhost:7860/ws"
28
- try:
29
- async with websockets.connect(uri, open_timeout=30) as ws:
30
- # Send the goal
31
- await ws.send(json.dumps({
32
- "action": "start",
33
- "goal": prompt
34
- }))
35
-
36
- # Wait for the task response
37
- response = await asyncio.wait_for(ws.recv(), timeout=120)
38
- data = json.loads(response)
39
- return {"prompt": prompt, "response": data, "status": "OK"}
40
- except Exception as e:
41
- return {"prompt": prompt, "error": str(e), "status": "ERROR"}
42
-
43
- async def main():
44
- print("=" * 70)
45
- print("STEP-ZERO FINE-TUNED MODEL STRESS TEST")
46
- print("=" * 70)
47
- print()
48
-
49
- results = []
50
- for i, prompt in enumerate(TEST_PROMPTS, 1):
51
- print(f"[{i}/{len(TEST_PROMPTS)}] Testing: \"{prompt}\"")
52
- result = await test_prompt(prompt)
53
- results.append(result)
54
-
55
- if result["status"] == "OK":
56
- task = result["response"].get("task", result["response"])
57
- print(f" → Task: {task}")
58
- word_count = len(str(task).split())
59
- if word_count > 8:
60
- print(f" ⚠️ OVER 8 WORDS ({word_count} words)")
61
- else:
62
- print(f" ✅ {word_count} words")
63
- else:
64
- print(f" ❌ ERROR: {result['error']}")
65
- print()
66
-
67
- # Summary
68
- print("=" * 70)
69
- print("SUMMARY")
70
- print("=" * 70)
71
- ok_count = sum(1 for r in results if r["status"] == "OK")
72
- err_count = sum(1 for r in results if r["status"] == "ERROR")
73
- over_8 = 0
74
- for r in results:
75
- if r["status"] == "OK":
76
- task = str(r["response"].get("task", r["response"]))
77
- if len(task.split()) > 8:
78
- over_8 += 1
79
-
80
- print(f" Total: {len(results)}")
81
- print(f" Success: {ok_count}")
82
- print(f" Errors: {err_count}")
83
- print(f" Over 8 words: {over_8}")
84
- print(f" Pass rate: {((ok_count - over_8) / len(results) * 100):.1f}%")
85
-
86
- if __name__ == "__main__":
87
- asyncio.run(main())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_app.py DELETED
@@ -1,6 +0,0 @@
1
- try:
2
- import app
3
- app.app.get_api_info()
4
- except Exception as e:
5
- import traceback
6
- traceback.print_exc()
 
 
 
 
 
 
 
test_async_dict.py DELETED
@@ -1,8 +0,0 @@
1
- import gradio as gr
2
- with gr.Blocks() as app:
3
- state = gr.State()
4
- b = gr.Button()
5
- async def fn(s):
6
- return {"a": 1}
7
- b.click(fn=fn, inputs=state, outputs=state)
8
- app.get_api_info()
 
 
 
 
 
 
 
 
 
test_bisect.py DELETED
@@ -1,27 +0,0 @@
1
- import gradio as gr
2
- from app import show_loading, handle_start, process_step
3
-
4
- with gr.Blocks() as app:
5
- session_state = gr.State()
6
- goal_input = gr.Textbox()
7
- style_radio = gr.Radio(["direct"])
8
- screen_start = gr.Column()
9
- screen_task = gr.Column()
10
- task_display = gr.HTML()
11
- controls_row = gr.Row()
12
- start_btn = gr.Button()
13
-
14
- start_btn.click(
15
- fn=show_loading,
16
- outputs=[screen_start, screen_task, task_display, controls_row]
17
- ).then(
18
- fn=handle_start,
19
- inputs=[session_state, goal_input, style_radio],
20
- outputs=[session_state, task_display, task_display, controls_row]
21
- )
22
-
23
- try:
24
- print(type(app.get_api_info()))
25
- except Exception as e:
26
- import traceback
27
- traceback.print_exc()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_bisect2.py DELETED
@@ -1,30 +0,0 @@
1
- import sys
2
-
3
- with open("app.py", "r") as f:
4
- lines = f.readlines()
5
-
6
- import tempfile
7
- import subprocess
8
-
9
- def test_lines(end_line):
10
- with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as f:
11
- f.writelines(lines[:end_line])
12
- if "app.launch" not in lines[end_line-1]:
13
- f.write("\napp.get_api_info()\n")
14
- name = f.name
15
-
16
- res = subprocess.run(["python3", name], capture_output=True, text=True)
17
- return "TypeError: argument of type 'bool' is not iterable" in res.stderr
18
-
19
- print("Testing...")
20
- # Binary search
21
- low = 315
22
- high = 450
23
- while low < high:
24
- mid = (low + high) // 2
25
- if test_lines(mid):
26
- high = mid
27
- else:
28
- low = mid + 1
29
-
30
- print(f"First failing line is {low}: {lines[low-1].strip()}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_breakdown.py DELETED
@@ -1,20 +0,0 @@
1
- from llama_cpp import Llama
2
-
3
- minicpm = Llama(model_path="./models/minicpm-3-4b.gguf", n_ctx=1024, verbose=False)
4
-
5
- system_msg = "You are a cognitive pacemaker. When a task is too hard, break it down into a single, even simpler, tiny physical starting action under 8 words. Return ONLY the starting action."
6
-
7
- rejected_tasks = [
8
- "Sweeping the kitchen floor.",
9
- "Organize the top left drawer.",
10
- "Open the textbook to chapter one.",
11
- "Pay the minimum payment on my credit card bill."
12
- ]
13
-
14
- for task in rejected_tasks:
15
- messages = [
16
- {"role": "system", "content": system_msg},
17
- {"role": "user", "content": f"The task '{task}' was too hard. Break it down into a single, even simpler physical starting action."}
18
- ]
19
- response = minicpm.create_chat_completion(messages=messages, max_tokens=20, temperature=0.1)
20
- print(f"Rejected: '{task}' -> Simpler: {repr(response['choices'][0]['message']['content'].strip())}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_comp.py DELETED
@@ -1,10 +0,0 @@
1
- import app
2
- from gradio_client import utils
3
-
4
- for block_id, comp in app.app.blocks.items():
5
- if hasattr(comp, "api_info"):
6
- try:
7
- info = comp.api_info()
8
- utils.json_schema_to_python_type(info)
9
- except Exception as e:
10
- print(f"FAILED ON COMPONENT: {comp.__class__.__name__}")
 
 
 
 
 
 
 
 
 
 
 
test_debug.py DELETED
@@ -1,6 +0,0 @@
1
- import app
2
- import traceback
3
- try:
4
- app.app.get_api_info()
5
- except Exception as e:
6
- traceback.print_exc()
 
 
 
 
 
 
 
test_dict.py DELETED
@@ -1,8 +0,0 @@
1
- import gradio as gr
2
- with gr.Blocks() as app:
3
- state = gr.State()
4
- b = gr.Button()
5
- def fn(s):
6
- return {"a": 1}
7
- b.click(fn=fn, inputs=state, outputs=state)
8
- app.get_api_info()
 
 
 
 
 
 
 
 
 
test_exact.py DELETED
@@ -1,7 +0,0 @@
1
- import app
2
- try:
3
- app.app.get_api_info()
4
- print("SUCCESS")
5
- except Exception as e:
6
- import traceback
7
- traceback.print_exc()
 
 
 
 
 
 
 
 
test_extract.py DELETED
@@ -1,16 +0,0 @@
1
- import asyncio
2
- from llama_cpp import Llama
3
-
4
- minicpm = Llama(model_path="./models/minicpm-3-4b.gguf", n_ctx=1024, verbose=False)
5
-
6
- def extract(text):
7
- messages = [
8
- {"role": "system", "content": "You extract the very first physical action from the user's text. Return ONLY a single physical action under 8 words. Do not include any other words."},
9
- {"role": "user", "content": f"Text: {text}"}
10
- ]
11
- response = minicpm.create_chat_completion(messages=messages, max_tokens=15, temperature=0.1)
12
- return response['choices'][0]['message']['content'].strip()
13
-
14
- print("1:", extract("Clean bedroom floor, tidy bed, organize drawers, dust surfaces, vacuum carpet."))
15
- print("2:", extract("Sure, here's a python script that uses the pandas library to parse a csv file:"))
16
- print("3:", extract("Fail to identify goal."))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_file_update.py DELETED
@@ -1,13 +0,0 @@
1
- import gradio as gr
2
- with gr.Blocks() as app:
3
- f = gr.File(visible=False)
4
- b = gr.Button("Test")
5
- def fn():
6
- return gr.File(value="test.txt", visible=True)
7
- b.click(fn=fn, outputs=[f])
8
- try:
9
- app.get_api_info()
10
- print("SUCCESS")
11
- except Exception as e:
12
- import traceback
13
- traceback.print_exc()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_find_fn.py DELETED
@@ -1,11 +0,0 @@
1
- import app
2
- import copy
3
- from gradio_client import utils
4
-
5
- for idx, fn in enumerate(app.app.fns.values()):
6
- try:
7
- info = fn.get_api_info(None)
8
- client_utils_info = utils.safe_deepcopy(info)
9
- client_utils.json_schema_to_python_type(client_utils_info)
10
- except Exception as e:
11
- print(f"FAILED ON FUNCTION: {fn.name or fn.__class__.__name__} (index {idx})")
 
 
 
 
 
 
 
 
 
 
 
 
test_find_fn2.py DELETED
@@ -1,10 +0,0 @@
1
- import app
2
- from gradio_client import utils
3
-
4
- for idx, fn in enumerate(app.app.fns.values()):
5
- try:
6
- info = fn.get_api_info(app.app.blocks)
7
- client_utils_info = utils.safe_deepcopy(info)
8
- utils.json_schema_to_python_type(client_utils_info)
9
- except Exception as e:
10
- print(f"FAILED ON FUNCTION: {fn.name or fn.__class__.__name__} (index {idx})")
 
 
 
 
 
 
 
 
 
 
 
test_gradio.py DELETED
@@ -1,4 +0,0 @@
1
- import gradio as gr
2
- with gr.Blocks() as app:
3
- session_state = gr.State({})
4
- app.launch(server_name="0.0.0.0", server_port=7860, share=False)
 
 
 
 
 
test_intercept.py DELETED
@@ -1,18 +0,0 @@
1
- import gradio as gr
2
- from gradio_client import utils as client_utils
3
-
4
- original = client_utils.json_schema_to_python_type
5
-
6
- def hook(schema):
7
- try:
8
- return original(schema)
9
- except Exception as e:
10
- print("CRASHING SCHEMA:")
11
- import pprint
12
- pprint.pprint(schema)
13
- raise e
14
-
15
- client_utils.json_schema_to_python_type = hook
16
-
17
- import app
18
- app.app.get_api_info()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_isolate.py DELETED
@@ -1,6 +0,0 @@
1
- import gradio as gr
2
- with gr.Blocks() as app:
3
- state = gr.State({})
4
- b = gr.Button("Test")
5
- # b.click(fn=lambda s: s, inputs=state, outputs=state)
6
- app.get_api_info()
 
 
 
 
 
 
 
test_isolate2.py DELETED
@@ -1,6 +0,0 @@
1
- import gradio as gr
2
- with gr.Blocks() as app:
3
- state = gr.State({})
4
- b = gr.Button("Test")
5
- b.click(fn=lambda s: s, inputs=state, outputs=state)
6
- app.get_api_info()
 
 
 
 
 
 
 
test_isolate3.py DELETED
@@ -1,9 +0,0 @@
1
- import gradio as gr
2
- from app import push_to_hub_fn, export_trace_fn, show_loading, show_loading_step, handle_start, handle_done, handle_skip, handle_too_hard
3
- with gr.Blocks() as app:
4
- session_state = gr.State({})
5
- b = gr.Button("Test")
6
- # Uncomment one by one
7
- # b.click(fn=export_trace_fn, inputs=[session_state], outputs=[session_state])
8
- # b.click(fn=push_to_hub_fn, inputs=[session_state], outputs=[session_state])
9
- app.get_api_info()
 
 
 
 
 
 
 
 
 
 
test_isolate4.py DELETED
@@ -1,14 +0,0 @@
1
- import gradio as gr
2
- from app import push_to_hub_fn, export_trace_fn, show_loading, show_loading_step, handle_start, handle_done, handle_skip, handle_too_hard
3
-
4
- funcs = [export_trace_fn, push_to_hub_fn, show_loading, show_loading_step, handle_start, handle_done, handle_skip, handle_too_hard]
5
-
6
- for f in funcs:
7
- with gr.Blocks() as app:
8
- state = gr.State({})
9
- b = gr.Button("Test")
10
- b.click(fn=f, inputs=[state], outputs=[state])
11
- try:
12
- app.get_api_info()
13
- except Exception as e:
14
- print(f"FAILED on {f.__name__}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_isolate5.py DELETED
@@ -1,11 +0,0 @@
1
- import gradio as gr
2
- with gr.Blocks() as app:
3
- col = gr.Column()
4
- b = gr.Button()
5
- def fn():
6
- return gr.update(visible=False)
7
- b.click(fn=fn, outputs=[col])
8
- try:
9
- app.get_api_info()
10
- except Exception as e:
11
- print("FAILED on col update")
 
 
 
 
 
 
 
 
 
 
 
 
test_isolate6.py DELETED
@@ -1,13 +0,0 @@
1
- import gradio as gr
2
- with gr.Blocks() as app:
3
- row = gr.Row()
4
- b = gr.Button()
5
- def fn():
6
- return gr.update(visible=False)
7
- b.click(fn=fn, outputs=[row])
8
- try:
9
- app.get_api_info()
10
- except Exception as e:
11
- import traceback
12
- traceback.print_exc()
13
- print("FAILED on row update")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_isolate7.py DELETED
@@ -1,11 +0,0 @@
1
- import gradio as gr
2
- with gr.Blocks() as app:
3
- f = gr.File(visible=False)
4
- b = gr.Button()
5
- def fn():
6
- return gr.update(visible=True)
7
- b.click(fn=fn, outputs=[f])
8
- try:
9
- app.get_api_info()
10
- except Exception as e:
11
- print("FAILED on file")
 
 
 
 
 
 
 
 
 
 
 
 
test_lambda.py DELETED
@@ -1,10 +0,0 @@
1
- import gradio as gr
2
-
3
- def test():
4
- pass
5
-
6
- with gr.Blocks() as app:
7
- b = gr.Button()
8
- b.click(fn=lambda x: x, inputs=[b], outputs=[b])
9
-
10
- app.get_api_info()
 
 
 
 
 
 
 
 
 
 
 
test_modal_ls.py DELETED
@@ -1,16 +0,0 @@
1
- import modal
2
-
3
- image = modal.Image.from_registry("ubuntu:22.04")
4
-
5
- app = modal.App("step-zero-test-ls")
6
- vol = modal.Volume.from_name("step-zero-volume")
7
-
8
- @app.function(image=image, volumes={"/vol": vol})
9
- def check_vol():
10
- import os
11
- print("Files in /vol:")
12
- os.system("ls -la /vol")
13
-
14
- @app.local_entrypoint()
15
- def main():
16
- check_vol.remote()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_modal_mount.py DELETED
@@ -1,2 +0,0 @@
1
- import modal
2
- print(hasattr(modal.Image, 'add_local_file'))
 
 
 
test_monkeypatch.py DELETED
@@ -1,15 +0,0 @@
1
- import gradio_client.utils as client_utils
2
- original_get_type = client_utils.get_type
3
- def safe_get_type(schema):
4
- if isinstance(schema, bool):
5
- return "Any"
6
- return original_get_type(schema)
7
- client_utils.get_type = safe_get_type
8
-
9
- import app
10
- try:
11
- app.app.get_api_info()
12
- print("SUCCESS")
13
- except Exception as e:
14
- import traceback
15
- traceback.print_exc()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_nem_out.txt DELETED
@@ -1,4 +0,0 @@
1
- Error in sitecustomize; set PYTHONVERBOSE for traceback:
2
- ModuleNotFoundError: No module named 'wrapt'
3
- llama_context: n_ctx_seq (1024) < n_ctx_train (4096) -- the full capacity of the model will not be utilized
4
- NEMOTRON: '{\n "task": "vacuum, dust, mop, clean bathroom, clean kitchen,'
 
 
 
 
 
test_nemotron.py DELETED
@@ -1,9 +0,0 @@
1
- import json
2
- from llama_cpp import Llama
3
- nemotron = Llama(model_path="./models/nemotron-mini-4b.gguf", n_ctx=1024, verbose=False)
4
- messages = [
5
- {"role": "system", "content": "You are a cognitive pacemaker. Break down goals into extremely tiny, atomic physical actions under 8 words. Return ONLY a JSON object with a 'task' key."},
6
- {"role": "user", "content": "Goal: clean the house. Failures: 0."}
7
- ]
8
- response = nemotron.create_chat_completion(messages=messages, max_tokens=20, temperature=0.1, response_format={"type": "json_object"})
9
- print("NEMOTRON:", repr(response['choices'][0]['message']['content']))
 
 
 
 
 
 
 
 
 
 
test_rut.py DELETED
@@ -1,31 +0,0 @@
1
- from llama_cpp import Llama
2
-
3
- minicpm = Llama(model_path="./models/minicpm-3-4b.gguf", n_ctx=1024, verbose=False)
4
-
5
- rut_history = [
6
- "Move towards the living room",
7
- "Move the laundry basket to the laundry room",
8
- "Move the dirty dishes to the sink",
9
- "Move the empty dishwasher to the kitchen counter",
10
- "Move the empty trash can to the curb",
11
- "Move the dirty laundry into the laundry basket",
12
- "Move the empty mop bucket to the bathroom",
13
- "Move the empty mop bucket to the laundry room"
14
- ]
15
-
16
- def test_minicpm(history_items, temperature):
17
- history_str = "\n".join([f"- {t}" for t in history_items]) if history_items else "None"
18
- goal = "i wanna do some chores but im mentally stuck"
19
-
20
- last_task = history_items[-1] if history_items else ""
21
- messages = [
22
- {"role": "system", "content": "You are a cognitive pacemaker. Focus strictly on the physical goal and break it down into an extremely tiny, atomic physical action under 8 words. Ignore mental blocks or feelings of being stuck and output ONLY the single physical action step."},
23
- {"role": "user", "content": f"Goal: {goal}\nCompleted Tasks:\n{history_str}\nFailures: 0\nCRITICAL: Do NOT output '{last_task}'. Output the strictly NEXT new physical step."}
24
- ]
25
-
26
- res = minicpm.create_chat_completion(messages=messages, max_tokens=20, temperature=temperature)
27
- return res['choices'][0]['message']['content'].strip()
28
-
29
- print("Full rut history (temp 0.1):", repr(test_minicpm(rut_history, 0.1)))
30
- print("Short history (last 2) (temp 0.1):", repr(test_minicpm(rut_history[-2:], 0.1)))
31
- print("Short history (last 2) (temp 0.4):", repr(test_minicpm(rut_history[-2:], 0.4)))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_schema.py DELETED
@@ -1,7 +0,0 @@
1
- import gradio as gr
2
- from gradio_client import utils
3
- schema = {"type": "object", "additionalProperties": False}
4
- try:
5
- print(utils.json_schema_to_python_type(schema))
6
- except Exception as e:
7
- print("ERROR:", type(e), str(e))
 
 
 
 
 
 
 
 
test_ws.py DELETED
@@ -1,11 +0,0 @@
1
- import asyncio
2
- import websockets
3
- import json
4
-
5
- async def test():
6
- async with websockets.connect("ws://127.0.0.1:7860/ws") as websocket:
7
- await websocket.send(json.dumps({"action": "start", "goal": "clean the house", "style": "direct"}))
8
- response = await websocket.recv()
9
- print(f"WS RESPONSE: {response}")
10
-
11
- asyncio.run(test())