synth-ai 0.2.12__py3-none-any.whl → 0.2.13.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of synth-ai might be problematic. Click here for more details.
- examples/multi_step/configs/crafter_rl_outcome.toml +74 -0
- examples/multi_step/configs/crafter_rl_stepwise_hosted_judge.toml +186 -0
- examples/multi_step/configs/crafter_rl_stepwise_shaped.toml +83 -0
- examples/multi_step/configs/crafter_rl_stepwise_simple.toml +78 -0
- examples/multi_step/crafter_rl_lora.md +51 -10
- examples/multi_step/sse_metrics_streaming_notes.md +357 -0
- examples/multi_step/task_app_config_notes.md +7 -1
- examples/swe/task_app/grpo_swe_mini.py +55 -26
- examples/swe/task_app/hosted/rollout.py +40 -0
- examples/swe/task_app/hosted/test_service.py +5 -6
- examples/task_apps/TESTING.md +275 -0
- examples/task_apps/__init__.py +0 -0
- examples/task_apps/crafter/__init__.py +0 -0
- examples/task_apps/crafter/task_app/__init__.py +2 -0
- examples/{warming_up_to_rl → task_apps/crafter}/task_app/grpo_crafter.py +21 -46
- examples/{warming_up_to_rl → task_apps/crafter}/task_app/grpo_crafter_task_app.py +1 -1
- examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/policy.py +60 -4
- examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/inference/openai_client.py +109 -45
- examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/policy_routes.py +67 -49
- examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/rollout.py +242 -193
- examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/test_service.py +5 -6
- examples/task_apps/dev/pokemon_emerald/__init__.py +2 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/README.md +811 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/__init__.py +120 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/action.py +160 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/memory.py +155 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/perception.py +69 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/planning.py +96 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/simple.py +1502 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/system_prompt.py +4 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/grab_map.py +68 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/manual.py +216 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/__init__.py +35 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/emerald_utils.py +631 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/emulator.py +1544 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/enums.py +1428 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/memory_reader.py +4848 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/types.py +41 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/utils.py +298 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pyproject.toml +95 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/run.py +204 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/server/__init__.py +0 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/server/app.py +2152 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/server/client.py +429 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/server/frame_server.py +155 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/README.md +78 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/__init__.py +0 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/run_tests.py +122 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_agent_direct.py +76 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_agent_prompts.py +413 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_battle_state_formatting.py +204 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_dialogue_detection.py +133 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_dialogue_detection_comprehensive.py +229 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_direct_agent_emulator.py +300 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_fps_adjustment_pytest.py +205 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_house_to_outside_direct.py +200 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_house_to_outside_transition.py +284 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_map_ground_truth_comparison.py +468 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_memory_map.py +575 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_server_map_validation.py +311 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_torchic_state.py +259 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/__init__.py +0 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/anticheat.py +372 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/checkpoint.py +296 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/error_handler.py +275 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/get_local_ip.py +22 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/helpers.py +44 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/llm_logger.py +514 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_formatter.py +415 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_stitcher.py +1763 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_stitcher_singleton.py +33 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_trimmer.py +106 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_visualizer.py +334 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/ocr_dialogue.py +1020 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/recording.py +188 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/state_formatter.py +1481 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/vlm.py +862 -0
- examples/task_apps/dev/pokemon_emerald/modal_app.py +114 -0
- examples/task_apps/dev/pokemon_emerald/task_app/README.md +81 -0
- examples/task_apps/dev/pokemon_emerald/task_app/__init__.py +6 -0
- examples/task_apps/dev/pokemon_emerald/task_app/pokemon_emerald.py +685 -0
- examples/task_apps/enron/__init__.py +1 -0
- examples/task_apps/enron/eval_groq_qwen32.toml +16 -0
- examples/task_apps/enron/task_app/README.md +14 -0
- examples/task_apps/enron/task_app/__init__.py +1 -0
- examples/task_apps/enron/task_app/grpo_enron.py +906 -0
- examples/task_apps/enron/task_app/grpo_enron_task_app.py +146 -0
- examples/task_apps/enron/tests/__init__.py +2 -0
- examples/task_apps/enron/tests/conftest.py +115 -0
- examples/task_apps/enron/tests/integration/__init__.py +2 -0
- examples/task_apps/enron/tests/integration/test_enron_eval.py +177 -0
- examples/task_apps/enron/tests/integration/test_enron_rollout.py +135 -0
- examples/task_apps/enron/tests/unit/__init__.py +2 -0
- examples/task_apps/enron/tests/unit/test_enron_environment.py +126 -0
- examples/task_apps/math/__init__.py +0 -0
- examples/{rl/task_app → task_apps/math}/math_single_step.py +19 -10
- examples/task_apps/pokemon_battle/__init__.py +2 -0
- examples/task_apps/pokemon_battle/modal_app.py +104 -0
- examples/task_apps/pokemon_battle/task_app/README.md +68 -0
- examples/task_apps/pokemon_battle/task_app/__init__.py +6 -0
- examples/task_apps/pokemon_battle/task_app/pokemon_showdown.py +932 -0
- examples/task_apps/pokemon_red/README.md +357 -0
- examples/task_apps/pokemon_red/__init__.py +3 -0
- examples/task_apps/pokemon_red/eval_pokemon_red_policy.py +225 -0
- examples/task_apps/pokemon_red/pallet_town_rl_config.toml +73 -0
- examples/task_apps/pokemon_red/task_app.py +606 -0
- examples/task_apps/pokemon_red/test_pallet_town_rewards.py +191 -0
- examples/task_apps/sokoban/README.md +307 -0
- examples/task_apps/sokoban/__init__.py +3 -0
- examples/task_apps/sokoban/eval_groq_qwen32.toml +16 -0
- examples/task_apps/sokoban/eval_openai_gpt5.toml +16 -0
- examples/task_apps/sokoban/task_app.py +1058 -0
- examples/task_apps/sokoban/tests/__init__.py +2 -0
- examples/task_apps/sokoban/tests/conftest.py +113 -0
- examples/task_apps/sokoban/tests/integration/__init__.py +2 -0
- examples/task_apps/sokoban/tests/integration/test_sokoban_eval.py +57 -0
- examples/task_apps/sokoban/tests/integration/test_sokoban_rollout.py +198 -0
- examples/task_apps/sokoban/tests/unit/__init__.py +2 -0
- examples/task_apps/sokoban/tests/unit/test_sokoban_environment.py +114 -0
- examples/task_apps/verilog/__init__.py +1 -0
- examples/task_apps/verilog/eval_groq_qwen32b.toml +20 -0
- examples/task_apps/verilog/task_app/README.md +12 -0
- examples/task_apps/verilog/task_app/__init__.py +1 -0
- examples/task_apps/verilog/task_app/grpo_verilog.py +931 -0
- examples/task_apps/verilog/task_app/grpo_verilog_task_app.py +145 -0
- examples/task_apps/verilog/tests/__init__.py +2 -0
- examples/task_apps/verilog/tests/conftest.py +115 -0
- examples/task_apps/verilog/tests/integration/__init__.py +2 -0
- examples/task_apps/verilog/tests/integration/test_verilog_eval.py +179 -0
- examples/task_apps/verilog/tests/integration/test_verilog_rollout.py +55 -0
- examples/task_apps/verilog/tests/unit/__init__.py +2 -0
- examples/task_apps/verilog/tests/unit/test_verilog_scoring.py +118 -0
- examples/vlm/crafter_openai_vlm_agent.py +4 -4
- examples/vlm/run_crafter_vlm_benchmark.py +4 -4
- examples/warming_up_to_rl/configs/eval_stepwise_complex.toml +4 -2
- examples/warming_up_to_rl/configs/eval_stepwise_simple.toml +4 -2
- examples/warming_up_to_rl/run_eval.py +127 -18
- examples/workflows/__init__.py +0 -0
- examples/workflows/math_rl/__init__.py +0 -0
- examples/workflows/math_rl/download_dataset.py +80 -0
- synth_ai/__init__.py +41 -1
- synth_ai/api/train/builders.py +73 -29
- synth_ai/api/train/cli.py +12 -6
- synth_ai/api/train/configs/__init__.py +44 -0
- synth_ai/api/train/configs/rl.py +134 -0
- synth_ai/api/train/configs/sft.py +95 -0
- synth_ai/api/train/configs/shared.py +24 -0
- synth_ai/api/train/env_resolver.py +5 -2
- synth_ai/api/train/supported_algos.py +10 -5
- synth_ai/api/train/utils.py +7 -4
- synth_ai/cli/__init__.py +7 -51
- synth_ai/cli/_storage.py +4 -3
- synth_ai/cli/_validate_task_app.py +11 -0
- synth_ai/cli/balance.py +4 -3
- synth_ai/cli/calc.py +2 -2
- synth_ai/cli/demo.py +49 -43
- synth_ai/cli/legacy_root_backup.py +1 -1
- synth_ai/cli/rl_demo.py +86 -106
- synth_ai/cli/root.py +0 -97
- synth_ai/cli/task_apps.py +1710 -186
- synth_ai/demos/core/cli.py +121 -159
- synth_ai/demos/demo_task_apps/crafter/grpo_crafter_task_app.py +28 -16
- synth_ai/environments/examples/crafter_classic/environment.py +16 -0
- synth_ai/environments/examples/enron/engine.py +7 -2
- synth_ai/environments/examples/enron/environment.py +68 -0
- synth_ai/environments/examples/red/engine.py +27 -0
- synth_ai/environments/examples/red/engine_helpers/memory_map.py +7 -0
- synth_ai/environments/examples/red/engine_helpers/reward_library/pallet_town_progression.py +477 -0
- synth_ai/environments/examples/red/engine_helpers/state_extraction.py +32 -0
- synth_ai/environments/examples/red/environment.py +60 -0
- synth_ai/environments/examples/sokoban/taskset.py +116 -0
- synth_ai/environments/examples/verilog/engine.py +30 -4
- synth_ai/evals/__init__.py +15 -0
- synth_ai/evals/client.py +82 -0
- synth_ai/evals/types.py +42 -0
- synth_ai/jobs/client.py +16 -4
- synth_ai/judge_schemas.py +127 -0
- synth_ai/py.typed +0 -0
- synth_ai/task/__init__.py +14 -5
- synth_ai/task/contracts.py +124 -38
- synth_ai/task/proxy.py +48 -56
- synth_ai/task/rubrics/__init__.py +53 -0
- synth_ai/task/rubrics/loaders.py +133 -0
- synth_ai/task/rubrics/models.py +57 -0
- synth_ai/task/rubrics/scoring.py +113 -0
- synth_ai/task/rubrics/strict.py +149 -0
- synth_ai/task/server.py +8 -7
- synth_ai/task/validators.py +269 -6
- synth_ai/tracing_v3/decorators.py +7 -3
- synth_ai/tracing_v3/replica_sync.py +4 -4
- synth_ai/tracing_v3/serialization.py +130 -0
- synth_ai/tracing_v3/trace_utils.py +317 -0
- synth_ai/tracing_v3/turso/native_manager.py +3 -3
- {synth_ai-0.2.12.dist-info → synth_ai-0.2.13.dev2.dist-info}/METADATA +4 -1
- {synth_ai-0.2.12.dist-info → synth_ai-0.2.13.dev2.dist-info}/RECORD +228 -89
- {synth_ai-0.2.12.dist-info → synth_ai-0.2.13.dev2.dist-info}/entry_points.txt +0 -1
- synth_ai/task/rubrics.py +0 -219
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/README.md +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/README.md +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/__init__.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/branching.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/environment_routes.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/__init__.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/__init__.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/app.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/environment.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/react_agent.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/shared.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/tools.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/hosted_app.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/inference/__init__.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/main.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/registry.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/storage/__init__.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/storage/volume.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/test_agents.py +0 -0
- /examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/utils.py +0 -0
- /examples/{rl/task_app → task_apps/math}/README.md +0 -0
- /examples/{rl/task_app → task_apps/math}/math_task_app.py +0 -0
- /examples/{rl → workflows/math_rl}/configs/eval_base_qwen.toml +0 -0
- /examples/{rl → workflows/math_rl}/configs/eval_rl_qwen.toml +0 -0
- /examples/{rl → workflows/math_rl}/configs/rl_from_base_qwen.toml +0 -0
- /examples/{rl → workflows/math_rl}/configs/rl_from_base_qwen17.toml +0 -0
- /examples/{rl → workflows/math_rl}/configs/rl_from_ft_qwen.toml +0 -0
- /examples/{rl → workflows/math_rl}/run_eval.py +0 -0
- /examples/{rl → workflows/math_rl}/run_rl_and_save.py +0 -0
- {synth_ai-0.2.12.dist-info → synth_ai-0.2.13.dev2.dist-info}/WHEEL +0 -0
- {synth_ai-0.2.12.dist-info → synth_ai-0.2.13.dev2.dist-info}/licenses/LICENSE +0 -0
- {synth_ai-0.2.12.dist-info → synth_ai-0.2.13.dev2.dist-info}/top_level.txt +0 -0
synth_ai/task/rubrics.py
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"""Rubric schema, loading, and scoring helpers for Task Apps."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import json
|
|
6
|
-
from collections.abc import Iterable
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
from typing import Any
|
|
9
|
-
|
|
10
|
-
from pydantic import BaseModel, Field, field_validator
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class Criterion(BaseModel):
|
|
14
|
-
id: str
|
|
15
|
-
description: str
|
|
16
|
-
weight: float = 1.0
|
|
17
|
-
required: bool = False
|
|
18
|
-
|
|
19
|
-
@field_validator("weight")
|
|
20
|
-
@classmethod
|
|
21
|
-
def _validate_weight(cls, value: float) -> float:
|
|
22
|
-
if value <= 0:
|
|
23
|
-
raise ValueError("criterion weight must be positive")
|
|
24
|
-
return value
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class Rubric(BaseModel):
|
|
28
|
-
version: str
|
|
29
|
-
goal_text: str | None = None
|
|
30
|
-
criteria: list[Criterion] = Field(default_factory=list)
|
|
31
|
-
aggregation: str = "weighted_sum"
|
|
32
|
-
|
|
33
|
-
@field_validator("aggregation")
|
|
34
|
-
@classmethod
|
|
35
|
-
def _validate_aggregation(cls, value: str) -> str:
|
|
36
|
-
allowed = {"sum", "weighted_sum", "custom", "inherit"}
|
|
37
|
-
if value not in allowed:
|
|
38
|
-
raise ValueError(f"aggregation must be one of {sorted(allowed)}")
|
|
39
|
-
return value
|
|
40
|
-
|
|
41
|
-
@field_validator("criteria")
|
|
42
|
-
@classmethod
|
|
43
|
-
def _validate_criteria(cls, criteria: list[Criterion]) -> list[Criterion]:
|
|
44
|
-
seen = set()
|
|
45
|
-
for criterion in criteria:
|
|
46
|
-
if criterion.id in seen:
|
|
47
|
-
raise ValueError(f"duplicate criterion id: {criterion.id}")
|
|
48
|
-
seen.add(criterion.id)
|
|
49
|
-
return criteria
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def _load_text(source: str) -> tuple[str, str | None]:
|
|
53
|
-
path = Path(source)
|
|
54
|
-
if path.exists():
|
|
55
|
-
return path.read_text(encoding="utf-8"), path.suffix.lower()
|
|
56
|
-
return source, None
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def _parse_structured(text: str, suffix: str | None) -> dict[str, Any]:
|
|
60
|
-
text = text.strip()
|
|
61
|
-
if not text:
|
|
62
|
-
raise ValueError("Rubric source is empty")
|
|
63
|
-
if suffix in (".yaml", ".yml"):
|
|
64
|
-
try:
|
|
65
|
-
import yaml # type: ignore
|
|
66
|
-
except Exception as exc: # pragma: no cover - optional dependency
|
|
67
|
-
raise RuntimeError("PyYAML is required to load YAML rubrics") from exc
|
|
68
|
-
data = yaml.safe_load(text)
|
|
69
|
-
if not isinstance(data, dict):
|
|
70
|
-
raise ValueError("Rubric YAML must produce a mapping") from None
|
|
71
|
-
return data
|
|
72
|
-
if text.startswith("{"):
|
|
73
|
-
return json.loads(text)
|
|
74
|
-
if text.startswith("http://") or text.startswith("https://"):
|
|
75
|
-
import requests # type: ignore
|
|
76
|
-
|
|
77
|
-
response = requests.get(text, timeout=15)
|
|
78
|
-
response.raise_for_status()
|
|
79
|
-
return _parse_structured(response.text, suffix)
|
|
80
|
-
try:
|
|
81
|
-
return json.loads(text)
|
|
82
|
-
except json.JSONDecodeError:
|
|
83
|
-
try:
|
|
84
|
-
import yaml # type: ignore
|
|
85
|
-
except Exception as exc: # pragma: no cover - optional dependency
|
|
86
|
-
raise RuntimeError("PyYAML is required to load rubric text") from exc
|
|
87
|
-
data = yaml.safe_load(text)
|
|
88
|
-
if not isinstance(data, dict):
|
|
89
|
-
raise ValueError("Rubric text must decode to a mapping") from None
|
|
90
|
-
return data
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def load_rubric(source: str | dict[str, Any] | Rubric | None) -> Rubric | None:
|
|
94
|
-
if source is None:
|
|
95
|
-
return None
|
|
96
|
-
if isinstance(source, Rubric):
|
|
97
|
-
return source
|
|
98
|
-
if isinstance(source, dict):
|
|
99
|
-
return Rubric.model_validate(source)
|
|
100
|
-
text, suffix = _load_text(str(source))
|
|
101
|
-
data = _parse_structured(text, suffix)
|
|
102
|
-
return Rubric.model_validate(data)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def _merge_weights(base: Criterion, override: Criterion) -> float:
|
|
106
|
-
if override.weight != 1.0 and base.weight != 1.0:
|
|
107
|
-
return base.weight * override.weight
|
|
108
|
-
if override.weight != 1.0:
|
|
109
|
-
return override.weight
|
|
110
|
-
return base.weight
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def blend_rubrics(base: Rubric | None, override: Rubric | None) -> Rubric | None:
|
|
114
|
-
if override is None and base is None:
|
|
115
|
-
return None
|
|
116
|
-
if base is None:
|
|
117
|
-
return override
|
|
118
|
-
if override is None:
|
|
119
|
-
return base
|
|
120
|
-
|
|
121
|
-
base_map = {criterion.id: criterion for criterion in base.criteria}
|
|
122
|
-
merged: list[Criterion] = []
|
|
123
|
-
|
|
124
|
-
for ov in override.criteria:
|
|
125
|
-
if ov.id in base_map:
|
|
126
|
-
existing = base_map.pop(ov.id)
|
|
127
|
-
merged.append(
|
|
128
|
-
Criterion(
|
|
129
|
-
id=ov.id,
|
|
130
|
-
description=ov.description or existing.description,
|
|
131
|
-
weight=_merge_weights(existing, ov),
|
|
132
|
-
required=ov.required if ov.required is not None else existing.required,
|
|
133
|
-
)
|
|
134
|
-
)
|
|
135
|
-
else:
|
|
136
|
-
merged.append(ov)
|
|
137
|
-
|
|
138
|
-
merged.extend(base_map.values())
|
|
139
|
-
|
|
140
|
-
aggregation = override.aggregation
|
|
141
|
-
if aggregation == "inherit":
|
|
142
|
-
aggregation = base.aggregation
|
|
143
|
-
|
|
144
|
-
return Rubric(
|
|
145
|
-
version=override.version or base.version,
|
|
146
|
-
goal_text=override.goal_text or base.goal_text,
|
|
147
|
-
criteria=merged,
|
|
148
|
-
aggregation=aggregation,
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
def _as_float(value: Any) -> float | None:
|
|
153
|
-
try:
|
|
154
|
-
return float(value)
|
|
155
|
-
except Exception:
|
|
156
|
-
return None
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def _score(
|
|
160
|
-
criteria: Iterable[Criterion], values: dict[str, float], aggregation: str
|
|
161
|
-
) -> dict[str, Any]:
|
|
162
|
-
if aggregation == "inherit":
|
|
163
|
-
aggregation = "weighted_sum"
|
|
164
|
-
per_criterion: dict[str, dict[str, Any]] = {}
|
|
165
|
-
total = 0.0
|
|
166
|
-
total_weight = 0.0
|
|
167
|
-
for criterion in criteria:
|
|
168
|
-
score = values.get(criterion.id, 0.0)
|
|
169
|
-
per_criterion[criterion.id] = {
|
|
170
|
-
"score": score,
|
|
171
|
-
"weight": criterion.weight,
|
|
172
|
-
"required": criterion.required,
|
|
173
|
-
}
|
|
174
|
-
if aggregation == "sum":
|
|
175
|
-
total += score
|
|
176
|
-
elif aggregation == "weighted_sum":
|
|
177
|
-
total += score * criterion.weight
|
|
178
|
-
total_weight += criterion.weight
|
|
179
|
-
if aggregation == "weighted_sum" and total_weight > 0:
|
|
180
|
-
total = total / total_weight
|
|
181
|
-
if aggregation == "custom":
|
|
182
|
-
total = None # type: ignore[assignment]
|
|
183
|
-
return {
|
|
184
|
-
"aggregation": aggregation,
|
|
185
|
-
"score": total,
|
|
186
|
-
"per_criterion": per_criterion,
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
def score_events_against_rubric(
|
|
191
|
-
events: list[dict[str, Any]], rubric: Rubric | None
|
|
192
|
-
) -> dict[str, Any]:
|
|
193
|
-
if rubric is None:
|
|
194
|
-
return {"aggregation": "none", "score": None, "per_criterion": {}}
|
|
195
|
-
values: dict[str, float] = {}
|
|
196
|
-
for event in events or []:
|
|
197
|
-
if not isinstance(event, dict):
|
|
198
|
-
continue
|
|
199
|
-
cid = event.get("criterion_id") or event.get("id") or event.get("criterion")
|
|
200
|
-
score = _as_float(event.get("score"))
|
|
201
|
-
if cid and score is not None:
|
|
202
|
-
values[str(cid)] = score
|
|
203
|
-
return _score(rubric.criteria, values, rubric.aggregation)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
def score_outcome_against_rubric(outcome: dict[str, Any], rubric: Rubric | None) -> dict[str, Any]:
|
|
207
|
-
if rubric is None:
|
|
208
|
-
return {"aggregation": "none", "score": None, "per_criterion": {}}
|
|
209
|
-
values: dict[str, float] = {}
|
|
210
|
-
if isinstance(outcome, dict):
|
|
211
|
-
candidates = (
|
|
212
|
-
outcome.get("criteria") if isinstance(outcome.get("criteria"), dict) else outcome
|
|
213
|
-
)
|
|
214
|
-
if isinstance(candidates, dict):
|
|
215
|
-
for key, value in candidates.items():
|
|
216
|
-
score = _as_float(value)
|
|
217
|
-
if score is not None:
|
|
218
|
-
values[str(key)] = score
|
|
219
|
-
return _score(rubric.criteria, values, rubric.aggregation)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/environment_routes.py
RENAMED
|
File without changes
|
/examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/__init__.py
RENAMED
|
File without changes
|
/examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/__init__.py
RENAMED
|
File without changes
|
/examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/app.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/shared.py
RENAMED
|
File without changes
|
/examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/envs/crafter/tools.py
RENAMED
|
File without changes
|
|
File without changes
|
/examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/inference/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/storage/__init__.py
RENAMED
|
File without changes
|
/examples/{warming_up_to_rl → task_apps/crafter}/task_app/synth_envs_hosted/storage/volume.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|