Spaces:
Sleeping
Sleeping
Pranjal Parashar commited on
rl training improved
Browse files- collect_traces.py +26 -1
- train.py +39 -4
- training_utils.py +31 -21
collect_traces.py
CHANGED
|
@@ -46,9 +46,32 @@ def parse_args() -> argparse.Namespace:
|
|
| 46 |
parser.add_argument("--max-turns", type=int, default=12, help="Max environment turns per episode")
|
| 47 |
parser.add_argument("--output-dir", default="outputs/sft_traces", help="Directory for JSONL traces")
|
| 48 |
parser.add_argument("--policy", default="fallback", choices=("fallback",), help="Teacher policy to use")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
return parser.parse_args()
|
| 50 |
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
def _quality_label(score: float) -> str:
|
| 53 |
if score >= 0.8:
|
| 54 |
return "high"
|
|
@@ -244,7 +267,9 @@ def main() -> None:
|
|
| 244 |
episodes_path = output_dir / "episodes.jsonl"
|
| 245 |
artifact_root = output_dir / "artifacts"
|
| 246 |
|
| 247 |
-
prompts = samples_to_dataset_prompts(
|
|
|
|
|
|
|
| 248 |
|
| 249 |
all_examples: list[dict[str, Any]] = []
|
| 250 |
all_episodes: list[dict[str, Any]] = []
|
|
|
|
| 46 |
parser.add_argument("--max-turns", type=int, default=12, help="Max environment turns per episode")
|
| 47 |
parser.add_argument("--output-dir", default="outputs/sft_traces", help="Directory for JSONL traces")
|
| 48 |
parser.add_argument("--policy", default="fallback", choices=("fallback",), help="Teacher policy to use")
|
| 49 |
+
parser.add_argument(
|
| 50 |
+
"--exclude-curriculum",
|
| 51 |
+
action="store_true",
|
| 52 |
+
help="Do not mix in the easy curriculum tasks when collecting traces for the main simulation workflow",
|
| 53 |
+
)
|
| 54 |
return parser.parse_args()
|
| 55 |
|
| 56 |
|
| 57 |
+
def _expanded_task_scope(task_scope: str, include_curriculum: bool) -> str:
|
| 58 |
+
if not include_curriculum:
|
| 59 |
+
return task_scope
|
| 60 |
+
requested = [task.strip() for task in task_scope.split(",") if task.strip()] if task_scope != "all" else ["all"]
|
| 61 |
+
if "all" in requested:
|
| 62 |
+
return task_scope
|
| 63 |
+
if "simulate_csv_report_workflow" not in requested:
|
| 64 |
+
return task_scope
|
| 65 |
+
expanded = list(requested)
|
| 66 |
+
for extra_task in (
|
| 67 |
+
"simulate_csv_report_curriculum_generate",
|
| 68 |
+
"simulate_csv_report_curriculum_repair",
|
| 69 |
+
):
|
| 70 |
+
if extra_task not in expanded:
|
| 71 |
+
expanded.append(extra_task)
|
| 72 |
+
return ",".join(expanded)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
def _quality_label(score: float) -> str:
|
| 76 |
if score >= 0.8:
|
| 77 |
return "high"
|
|
|
|
| 267 |
episodes_path = output_dir / "episodes.jsonl"
|
| 268 |
artifact_root = output_dir / "artifacts"
|
| 269 |
|
| 270 |
+
prompts = samples_to_dataset_prompts(
|
| 271 |
+
build_episode_samples(_expanded_task_scope(args.task_scope, not args.exclude_curriculum), args.dataset_size)
|
| 272 |
+
)
|
| 273 |
|
| 274 |
all_examples: list[dict[str, Any]] = []
|
| 275 |
all_episodes: list[dict[str, Any]] = []
|
train.py
CHANGED
|
@@ -68,7 +68,7 @@ def parse_args() -> argparse.Namespace:
|
|
| 68 |
parser.add_argument("--num-generations", type=int, default=4, help="GRPO generations per prompt")
|
| 69 |
parser.add_argument("--max-turns", type=int, default=DEFAULT_MAX_TURNS, help="Max environment turns per episode")
|
| 70 |
parser.add_argument("--max-new-tokens", type=int, default=DEFAULT_MAX_NEW_TOKENS, help="Max tokens per action generation")
|
| 71 |
-
parser.add_argument("--learning-rate", type=float, default=
|
| 72 |
parser.add_argument("--output-dir", default=None, help="Checkpoint output directory")
|
| 73 |
parser.add_argument("--task-scope", default="all", help="Task scope: all or comma-separated task ids")
|
| 74 |
parser.add_argument("--report-to", default="none", choices=("none", "tensorboard", "wandb"), help="Logging backend")
|
|
@@ -78,7 +78,7 @@ def parse_args() -> argparse.Namespace:
|
|
| 78 |
parser.add_argument("--per-device-train-batch-size", type=int, default=1, help="Per-device batch size")
|
| 79 |
parser.add_argument("--save-steps", type=int, default=10, help="Checkpoint save interval")
|
| 80 |
parser.add_argument("--logging-steps", type=int, default=1, help="Logging interval")
|
| 81 |
-
parser.add_argument("--temperature", type=float, default=0.
|
| 82 |
parser.add_argument(
|
| 83 |
"--log-step-rewards",
|
| 84 |
action="store_true",
|
|
@@ -203,6 +203,16 @@ def reward_total(completions: list[str], **kwargs: Any) -> list[float]:
|
|
| 203 |
return [float(value) for value in rewards] if rewards else [0.0] * len(completions)
|
| 204 |
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
def reward_score(completions: list[str], **kwargs: Any) -> list[float]:
|
| 207 |
rewards = kwargs.get("score_reward", [])
|
| 208 |
return [float(value) for value in rewards] if rewards else [0.0] * len(completions)
|
|
@@ -313,6 +323,8 @@ def main() -> None:
|
|
| 313 |
total_rewards: list[float] = []
|
| 314 |
score_rewards: list[float] = []
|
| 315 |
solved_rewards: list[float] = []
|
|
|
|
|
|
|
| 316 |
|
| 317 |
for prompt in prompts:
|
| 318 |
sample = parse_sample_prompt(prompt)
|
|
@@ -336,6 +348,7 @@ def main() -> None:
|
|
| 336 |
rollout_backend=args.rollout_backend,
|
| 337 |
)
|
| 338 |
parsed_action = parse_action_json(generation["text"])
|
|
|
|
| 339 |
valid_action = action_is_valid(parsed_action, observation)
|
| 340 |
if generation_debug_counter[0] < DEBUG_GENERATION_LOG_LIMIT:
|
| 341 |
logger.info(
|
|
@@ -359,6 +372,7 @@ def main() -> None:
|
|
| 359 |
fallback,
|
| 360 |
)
|
| 361 |
parsed_action = fallback
|
|
|
|
| 362 |
elif not valid_action:
|
| 363 |
logger.info(
|
| 364 |
"Invalid action penalized task=%s step=%s fallback_mode=%s",
|
|
@@ -366,9 +380,17 @@ def main() -> None:
|
|
| 366 |
observation.step_count + 1,
|
| 367 |
args.fallback_mode,
|
| 368 |
)
|
|
|
|
|
|
|
|
|
|
| 369 |
return {
|
| 370 |
"action": parsed_action,
|
| 371 |
-
"metadata":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
}
|
| 373 |
|
| 374 |
metrics = run_episode(
|
|
@@ -382,6 +404,14 @@ def main() -> None:
|
|
| 382 |
completion_batches.append(metrics.completion_ids or [])
|
| 383 |
logprob_batches.append(metrics.logprobs or [])
|
| 384 |
total_rewards.append(metrics.total_reward)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
score_rewards.append(metrics.score)
|
| 386 |
solved_rewards.append(1.0 if metrics.solved else 0.0)
|
| 387 |
log_episode(metrics)
|
|
@@ -391,6 +421,8 @@ def main() -> None:
|
|
| 391 |
"completion_ids": completion_batches,
|
| 392 |
"logprobs": logprob_batches,
|
| 393 |
"total_reward": total_rewards,
|
|
|
|
|
|
|
| 394 |
"score_reward": score_rewards,
|
| 395 |
"solved_reward": solved_rewards,
|
| 396 |
}
|
|
@@ -439,12 +471,15 @@ def main() -> None:
|
|
| 439 |
trainer = GRPOTrainer(
|
| 440 |
model=trainer_model,
|
| 441 |
processing_class=tokenizer,
|
| 442 |
-
reward_funcs=[reward_total, reward_score, reward_solved],
|
| 443 |
train_dataset=dataset,
|
| 444 |
args=grpo_config,
|
| 445 |
rollout_func=rollout_func,
|
| 446 |
peft_config=peft_config,
|
| 447 |
)
|
|
|
|
|
|
|
|
|
|
| 448 |
|
| 449 |
logger.info("Starting FlowOS GRPO training")
|
| 450 |
logger.info(
|
|
|
|
| 68 |
parser.add_argument("--num-generations", type=int, default=4, help="GRPO generations per prompt")
|
| 69 |
parser.add_argument("--max-turns", type=int, default=DEFAULT_MAX_TURNS, help="Max environment turns per episode")
|
| 70 |
parser.add_argument("--max-new-tokens", type=int, default=DEFAULT_MAX_NEW_TOKENS, help="Max tokens per action generation")
|
| 71 |
+
parser.add_argument("--learning-rate", type=float, default=5e-7, help="Trainer learning rate")
|
| 72 |
parser.add_argument("--output-dir", default=None, help="Checkpoint output directory")
|
| 73 |
parser.add_argument("--task-scope", default="all", help="Task scope: all or comma-separated task ids")
|
| 74 |
parser.add_argument("--report-to", default="none", choices=("none", "tensorboard", "wandb"), help="Logging backend")
|
|
|
|
| 78 |
parser.add_argument("--per-device-train-batch-size", type=int, default=1, help="Per-device batch size")
|
| 79 |
parser.add_argument("--save-steps", type=int, default=10, help="Checkpoint save interval")
|
| 80 |
parser.add_argument("--logging-steps", type=int, default=1, help="Logging interval")
|
| 81 |
+
parser.add_argument("--temperature", type=float, default=0.0, help="Sampling temperature")
|
| 82 |
parser.add_argument(
|
| 83 |
"--log-step-rewards",
|
| 84 |
action="store_true",
|
|
|
|
| 203 |
return [float(value) for value in rewards] if rewards else [0.0] * len(completions)
|
| 204 |
|
| 205 |
|
| 206 |
+
def reward_format(completions: list[str], **kwargs: Any) -> list[float]:
|
| 207 |
+
rewards = kwargs.get("format_reward", [])
|
| 208 |
+
return [float(value) for value in rewards] if rewards else [0.0] * len(completions)
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
def reward_valid_action(completions: list[str], **kwargs: Any) -> list[float]:
|
| 212 |
+
rewards = kwargs.get("valid_action_reward", [])
|
| 213 |
+
return [float(value) for value in rewards] if rewards else [0.0] * len(completions)
|
| 214 |
+
|
| 215 |
+
|
| 216 |
def reward_score(completions: list[str], **kwargs: Any) -> list[float]:
|
| 217 |
rewards = kwargs.get("score_reward", [])
|
| 218 |
return [float(value) for value in rewards] if rewards else [0.0] * len(completions)
|
|
|
|
| 323 |
total_rewards: list[float] = []
|
| 324 |
score_rewards: list[float] = []
|
| 325 |
solved_rewards: list[float] = []
|
| 326 |
+
format_rewards: list[float] = []
|
| 327 |
+
valid_action_rewards: list[float] = []
|
| 328 |
|
| 329 |
for prompt in prompts:
|
| 330 |
sample = parse_sample_prompt(prompt)
|
|
|
|
| 348 |
rollout_backend=args.rollout_backend,
|
| 349 |
)
|
| 350 |
parsed_action = parse_action_json(generation["text"])
|
| 351 |
+
json_format_valid = parsed_action is not None
|
| 352 |
valid_action = action_is_valid(parsed_action, observation)
|
| 353 |
if generation_debug_counter[0] < DEBUG_GENERATION_LOG_LIMIT:
|
| 354 |
logger.info(
|
|
|
|
| 372 |
fallback,
|
| 373 |
)
|
| 374 |
parsed_action = fallback
|
| 375 |
+
used_fallback = True
|
| 376 |
elif not valid_action:
|
| 377 |
logger.info(
|
| 378 |
"Invalid action penalized task=%s step=%s fallback_mode=%s",
|
|
|
|
| 380 |
observation.step_count + 1,
|
| 381 |
args.fallback_mode,
|
| 382 |
)
|
| 383 |
+
used_fallback = False
|
| 384 |
+
else:
|
| 385 |
+
used_fallback = False
|
| 386 |
return {
|
| 387 |
"action": parsed_action,
|
| 388 |
+
"metadata": {
|
| 389 |
+
**generation,
|
| 390 |
+
"used_fallback": used_fallback,
|
| 391 |
+
"model_action_valid": valid_action,
|
| 392 |
+
"json_format_valid": json_format_valid,
|
| 393 |
+
},
|
| 394 |
}
|
| 395 |
|
| 396 |
metrics = run_episode(
|
|
|
|
| 404 |
completion_batches.append(metrics.completion_ids or [])
|
| 405 |
logprob_batches.append(metrics.logprobs or [])
|
| 406 |
total_rewards.append(metrics.total_reward)
|
| 407 |
+
if metrics.steps > 0:
|
| 408 |
+
json_fraction = metrics.json_format_steps / metrics.steps
|
| 409 |
+
valid_fraction = metrics.valid_model_steps / metrics.steps
|
| 410 |
+
else:
|
| 411 |
+
json_fraction = 0.0
|
| 412 |
+
valid_fraction = 0.0
|
| 413 |
+
format_rewards.append(3.0 if json_fraction == 1.0 else -3.0 * (1.0 - json_fraction))
|
| 414 |
+
valid_action_rewards.append((2.0 * valid_fraction) - 1.0)
|
| 415 |
score_rewards.append(metrics.score)
|
| 416 |
solved_rewards.append(1.0 if metrics.solved else 0.0)
|
| 417 |
log_episode(metrics)
|
|
|
|
| 421 |
"completion_ids": completion_batches,
|
| 422 |
"logprobs": logprob_batches,
|
| 423 |
"total_reward": total_rewards,
|
| 424 |
+
"format_reward": format_rewards,
|
| 425 |
+
"valid_action_reward": valid_action_rewards,
|
| 426 |
"score_reward": score_rewards,
|
| 427 |
"solved_reward": solved_rewards,
|
| 428 |
}
|
|
|
|
| 471 |
trainer = GRPOTrainer(
|
| 472 |
model=trainer_model,
|
| 473 |
processing_class=tokenizer,
|
| 474 |
+
reward_funcs=[reward_format, reward_valid_action, reward_total, reward_score, reward_solved],
|
| 475 |
train_dataset=dataset,
|
| 476 |
args=grpo_config,
|
| 477 |
rollout_func=rollout_func,
|
| 478 |
peft_config=peft_config,
|
| 479 |
)
|
| 480 |
+
trainer_model_ref = getattr(trainer, "model", None)
|
| 481 |
+
if trainer_model_ref is not None and getattr(trainer_model_ref, "config", None) is not None:
|
| 482 |
+
trainer_model_ref.config.use_cache = False
|
| 483 |
|
| 484 |
logger.info("Starting FlowOS GRPO training")
|
| 485 |
logger.info(
|
training_utils.py
CHANGED
|
@@ -25,11 +25,21 @@ DEFAULT_TRAIN_MODEL = "Qwen/Qwen2.5-1.5B-Instruct"
|
|
| 25 |
DEFAULT_MAX_TURNS = 12
|
| 26 |
DEFAULT_MAX_NEW_TOKENS = 200
|
| 27 |
|
| 28 |
-
TRAIN_SYSTEM_PROMPT = """
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
{"action_type":"search_workspace","parameters":{"query":"..."}}
|
| 34 |
{"action_type":"read_file","parameters":{"path":"..."}}
|
| 35 |
{"action_type":"inspect_schema","parameters":{"asset":"..."}}
|
|
@@ -41,13 +51,9 @@ Allowed action shapes:
|
|
| 41 |
{"action_type":"submit_review","parameters":{"verdict":"approve|reject","issue_type":"...","summary":"..."}}
|
| 42 |
{"action_type":"submit_workspace","parameters":{"summary":"..."}}
|
| 43 |
|
| 44 |
-
|
| 45 |
-
Good examples:
|
| 46 |
{"action_type":"read_file","parameters":{"path":"docs/runtime_contract.md"}}
|
| 47 |
-
{"action_type":"inspect_schema","parameters":{"asset":"raw.sales_orders_csv"}}
|
| 48 |
-
{"action_type":"edit_file","parameters":{"path":"pipelines/report_job.yaml","content":"name: customer_daily_report_job\\nstorage_path: mock_s3/staged/sales_orders.csv\\nraw_table: raw_sales_orders\\nload_sql: sql/load_raw.sql\\nbuild_sql: sql/build_table.sql\\nreport_sql: sql/report_view.sql\\nfinal_view: customer_daily_report\\n"}}
|
| 49 |
-
For simulate_csv_report_workflow, prefer starting with read_file on docs/runtime_contract.md or templates/report_pipeline_template.yaml.
|
| 50 |
-
Return only one action per turn."""
|
| 51 |
|
| 52 |
|
| 53 |
@dataclass
|
|
@@ -73,6 +79,7 @@ class EpisodeMetrics:
|
|
| 73 |
report_preview: list[dict[str, Any]]
|
| 74 |
fallback_steps: int = 0
|
| 75 |
valid_model_steps: int = 0
|
|
|
|
| 76 |
prompt_ids: list[int] | None = None
|
| 77 |
completion_ids: list[int] | None = None
|
| 78 |
logprobs: list[float] | None = None
|
|
@@ -132,21 +139,20 @@ def parse_action_json(response_text: str) -> dict[str, Any] | None:
|
|
| 132 |
text = "\n".join(
|
| 133 |
line for line in text.splitlines() if not line.strip().startswith("```")
|
| 134 |
).strip()
|
|
|
|
|
|
|
| 135 |
try:
|
| 136 |
parsed = json.loads(text)
|
| 137 |
return parsed if isinstance(parsed, dict) else None
|
| 138 |
except json.JSONDecodeError:
|
| 139 |
decoder = json.JSONDecoder()
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
if isinstance(parsed, dict):
|
| 148 |
-
return parsed
|
| 149 |
-
return None
|
| 150 |
|
| 151 |
|
| 152 |
def coerce_action(action_dict: dict[str, Any] | None) -> DeveloperControlRoomAction:
|
|
@@ -273,6 +279,7 @@ async def run_episode_async(
|
|
| 273 |
rewards: list[float] = []
|
| 274 |
fallback_steps = 0
|
| 275 |
valid_model_steps = 0
|
|
|
|
| 276 |
prompt_ids: list[int] = []
|
| 277 |
completion_ids: list[int] = []
|
| 278 |
logprobs: list[float] = []
|
|
@@ -293,6 +300,8 @@ async def run_episode_async(
|
|
| 293 |
fallback_steps += 1
|
| 294 |
if metadata.get("model_action_valid", False):
|
| 295 |
valid_model_steps += 1
|
|
|
|
|
|
|
| 296 |
prompt_ids.extend(metadata.get("prompt_ids", []))
|
| 297 |
completion_ids.extend(metadata.get("completion_ids", []))
|
| 298 |
logprobs.extend(metadata.get("logprobs", []))
|
|
@@ -329,6 +338,7 @@ async def run_episode_async(
|
|
| 329 |
report_preview=list(getattr(observation, "report_preview", [])),
|
| 330 |
fallback_steps=fallback_steps,
|
| 331 |
valid_model_steps=valid_model_steps,
|
|
|
|
| 332 |
prompt_ids=prompt_ids,
|
| 333 |
completion_ids=completion_ids,
|
| 334 |
logprobs=logprobs,
|
|
|
|
| 25 |
DEFAULT_MAX_TURNS = 12
|
| 26 |
DEFAULT_MAX_NEW_TOKENS = 200
|
| 27 |
|
| 28 |
+
TRAIN_SYSTEM_PROMPT = """Return exactly one JSON object:
|
| 29 |
+
{"action_type":"...","parameters":{...}}
|
| 30 |
+
|
| 31 |
+
Rules:
|
| 32 |
+
- Output JSON only.
|
| 33 |
+
- No prose.
|
| 34 |
+
- No markdown.
|
| 35 |
+
- No code fences.
|
| 36 |
+
- No explanation.
|
| 37 |
+
- No extra keys.
|
| 38 |
+
- Use exact action names, file paths, asset names, and validator names from the observation.
|
| 39 |
+
- If unsure, return one best-effort JSON action anyway.
|
| 40 |
+
- Any non-JSON output is invalid and will be penalized.
|
| 41 |
+
|
| 42 |
+
Allowed actions:
|
| 43 |
{"action_type":"search_workspace","parameters":{"query":"..."}}
|
| 44 |
{"action_type":"read_file","parameters":{"path":"..."}}
|
| 45 |
{"action_type":"inspect_schema","parameters":{"asset":"..."}}
|
|
|
|
| 51 |
{"action_type":"submit_review","parameters":{"verdict":"approve|reject","issue_type":"...","summary":"..."}}
|
| 52 |
{"action_type":"submit_workspace","parameters":{"summary":"..."}}
|
| 53 |
|
| 54 |
+
Examples:
|
|
|
|
| 55 |
{"action_type":"read_file","parameters":{"path":"docs/runtime_contract.md"}}
|
| 56 |
+
{"action_type":"inspect_schema","parameters":{"asset":"raw.sales_orders_csv"}}"""
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
@dataclass
|
|
|
|
| 79 |
report_preview: list[dict[str, Any]]
|
| 80 |
fallback_steps: int = 0
|
| 81 |
valid_model_steps: int = 0
|
| 82 |
+
json_format_steps: int = 0
|
| 83 |
prompt_ids: list[int] | None = None
|
| 84 |
completion_ids: list[int] | None = None
|
| 85 |
logprobs: list[float] | None = None
|
|
|
|
| 139 |
text = "\n".join(
|
| 140 |
line for line in text.splitlines() if not line.strip().startswith("```")
|
| 141 |
).strip()
|
| 142 |
+
if not text.startswith("{"):
|
| 143 |
+
return None
|
| 144 |
try:
|
| 145 |
parsed = json.loads(text)
|
| 146 |
return parsed if isinstance(parsed, dict) else None
|
| 147 |
except json.JSONDecodeError:
|
| 148 |
decoder = json.JSONDecoder()
|
| 149 |
+
try:
|
| 150 |
+
parsed, end = decoder.raw_decode(text)
|
| 151 |
+
except json.JSONDecodeError:
|
| 152 |
+
return None
|
| 153 |
+
if isinstance(parsed, dict) and text[end:].strip() == "":
|
| 154 |
+
return parsed
|
| 155 |
+
return None
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
|
| 158 |
def coerce_action(action_dict: dict[str, Any] | None) -> DeveloperControlRoomAction:
|
|
|
|
| 279 |
rewards: list[float] = []
|
| 280 |
fallback_steps = 0
|
| 281 |
valid_model_steps = 0
|
| 282 |
+
json_format_steps = 0
|
| 283 |
prompt_ids: list[int] = []
|
| 284 |
completion_ids: list[int] = []
|
| 285 |
logprobs: list[float] = []
|
|
|
|
| 300 |
fallback_steps += 1
|
| 301 |
if metadata.get("model_action_valid", False):
|
| 302 |
valid_model_steps += 1
|
| 303 |
+
if metadata.get("json_format_valid", False):
|
| 304 |
+
json_format_steps += 1
|
| 305 |
prompt_ids.extend(metadata.get("prompt_ids", []))
|
| 306 |
completion_ids.extend(metadata.get("completion_ids", []))
|
| 307 |
logprobs.extend(metadata.get("logprobs", []))
|
|
|
|
| 338 |
report_preview=list(getattr(observation, "report_preview", [])),
|
| 339 |
fallback_steps=fallback_steps,
|
| 340 |
valid_model_steps=valid_model_steps,
|
| 341 |
+
json_format_steps=json_format_steps,
|
| 342 |
prompt_ids=prompt_ids,
|
| 343 |
completion_ids=completion_ids,
|
| 344 |
logprobs=logprobs,
|