synth-ai 0.2.4.dev5__py3-none-any.whl → 0.2.4.dev7__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.
- synth_ai/__init__.py +18 -9
- synth_ai/cli/__init__.py +10 -5
- synth_ai/cli/balance.py +22 -17
- synth_ai/cli/calc.py +2 -3
- synth_ai/cli/demo.py +3 -5
- synth_ai/cli/legacy_root_backup.py +58 -32
- synth_ai/cli/man.py +22 -19
- synth_ai/cli/recent.py +9 -8
- synth_ai/cli/root.py +58 -13
- synth_ai/cli/status.py +13 -6
- synth_ai/cli/traces.py +45 -21
- synth_ai/cli/watch.py +40 -37
- synth_ai/config/base_url.py +1 -3
- synth_ai/core/experiment.py +1 -2
- synth_ai/environments/__init__.py +2 -6
- synth_ai/environments/environment/artifacts/base.py +3 -1
- synth_ai/environments/environment/db/sqlite.py +1 -1
- synth_ai/environments/environment/registry.py +19 -20
- synth_ai/environments/environment/resources/sqlite.py +2 -3
- synth_ai/environments/environment/rewards/core.py +3 -2
- synth_ai/environments/environment/tools/__init__.py +6 -4
- synth_ai/environments/examples/crafter_classic/__init__.py +1 -1
- synth_ai/environments/examples/crafter_classic/engine.py +21 -17
- synth_ai/environments/examples/crafter_classic/engine_deterministic_patch.py +1 -0
- synth_ai/environments/examples/crafter_classic/engine_helpers/action_map.py +2 -1
- synth_ai/environments/examples/crafter_classic/engine_helpers/serialization.py +2 -1
- synth_ai/environments/examples/crafter_classic/engine_serialization_patch_v3.py +3 -2
- synth_ai/environments/examples/crafter_classic/environment.py +16 -15
- synth_ai/environments/examples/crafter_classic/taskset.py +2 -2
- synth_ai/environments/examples/crafter_classic/trace_hooks_v3.py +2 -3
- synth_ai/environments/examples/crafter_classic/world_config_patch_simple.py +2 -1
- synth_ai/environments/examples/crafter_custom/crafter/__init__.py +2 -2
- synth_ai/environments/examples/crafter_custom/crafter/config.py +2 -2
- synth_ai/environments/examples/crafter_custom/crafter/env.py +1 -5
- synth_ai/environments/examples/crafter_custom/crafter/objects.py +1 -2
- synth_ai/environments/examples/crafter_custom/crafter/worldgen.py +1 -2
- synth_ai/environments/examples/crafter_custom/dataset_builder.py +5 -5
- synth_ai/environments/examples/crafter_custom/environment.py +13 -13
- synth_ai/environments/examples/crafter_custom/run_dataset.py +5 -5
- synth_ai/environments/examples/enron/art_helpers/email_search_tools.py +2 -2
- synth_ai/environments/examples/enron/art_helpers/local_email_db.py +5 -4
- synth_ai/environments/examples/enron/art_helpers/types_enron.py +2 -1
- synth_ai/environments/examples/enron/engine.py +18 -14
- synth_ai/environments/examples/enron/environment.py +12 -11
- synth_ai/environments/examples/enron/taskset.py +7 -7
- synth_ai/environments/examples/minigrid/__init__.py +6 -6
- synth_ai/environments/examples/minigrid/engine.py +6 -6
- synth_ai/environments/examples/minigrid/environment.py +6 -6
- synth_ai/environments/examples/minigrid/puzzle_loader.py +3 -2
- synth_ai/environments/examples/minigrid/taskset.py +13 -13
- synth_ai/environments/examples/nethack/achievements.py +1 -1
- synth_ai/environments/examples/nethack/engine.py +8 -7
- synth_ai/environments/examples/nethack/environment.py +10 -9
- synth_ai/environments/examples/nethack/helpers/__init__.py +8 -9
- synth_ai/environments/examples/nethack/helpers/action_mapping.py +1 -1
- synth_ai/environments/examples/nethack/helpers/nle_wrapper.py +2 -1
- synth_ai/environments/examples/nethack/helpers/observation_utils.py +1 -1
- synth_ai/environments/examples/nethack/helpers/recording_wrapper.py +3 -4
- synth_ai/environments/examples/nethack/helpers/trajectory_recorder.py +6 -5
- synth_ai/environments/examples/nethack/helpers/visualization/replay_viewer.py +5 -5
- synth_ai/environments/examples/nethack/helpers/visualization/visualizer.py +7 -6
- synth_ai/environments/examples/nethack/taskset.py +5 -5
- synth_ai/environments/examples/red/engine.py +9 -8
- synth_ai/environments/examples/red/engine_helpers/reward_components.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/__init__.py +7 -7
- synth_ai/environments/examples/red/engine_helpers/reward_library/adaptive_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/battle_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/composite_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/economy_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/efficiency_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/exploration_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/novelty_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/pallet_town_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/pokemon_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/social_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/reward_library/story_rewards.py +2 -1
- synth_ai/environments/examples/red/engine_helpers/screen_analysis.py +3 -2
- synth_ai/environments/examples/red/engine_helpers/state_extraction.py +2 -1
- synth_ai/environments/examples/red/environment.py +18 -15
- synth_ai/environments/examples/red/taskset.py +5 -3
- synth_ai/environments/examples/sokoban/engine.py +16 -13
- synth_ai/environments/examples/sokoban/engine_helpers/room_utils.py +3 -2
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/__init__.py +2 -1
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/__init__.py +1 -1
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/boxoban_env.py +7 -5
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/render_utils.py +1 -1
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/room_utils.py +2 -1
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env.py +5 -4
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_fixed_targets.py +3 -2
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_pull.py +2 -1
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_two_player.py +5 -4
- synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_variations.py +1 -1
- synth_ai/environments/examples/sokoban/environment.py +15 -14
- synth_ai/environments/examples/sokoban/generate_verified_puzzles.py +5 -3
- synth_ai/environments/examples/sokoban/puzzle_loader.py +3 -2
- synth_ai/environments/examples/sokoban/taskset.py +13 -10
- synth_ai/environments/examples/tictactoe/engine.py +6 -6
- synth_ai/environments/examples/tictactoe/environment.py +8 -7
- synth_ai/environments/examples/tictactoe/taskset.py +6 -5
- synth_ai/environments/examples/verilog/engine.py +4 -3
- synth_ai/environments/examples/verilog/environment.py +11 -10
- synth_ai/environments/examples/verilog/taskset.py +14 -12
- synth_ai/environments/examples/wordle/__init__.py +29 -0
- synth_ai/environments/examples/wordle/engine.py +398 -0
- synth_ai/environments/examples/wordle/environment.py +159 -0
- synth_ai/environments/examples/wordle/helpers/generate_instances_wordfreq.py +75 -0
- synth_ai/environments/examples/wordle/taskset.py +230 -0
- synth_ai/environments/reproducibility/core.py +1 -1
- synth_ai/environments/reproducibility/tree.py +21 -21
- synth_ai/environments/service/app.py +11 -2
- synth_ai/environments/service/core_routes.py +137 -105
- synth_ai/environments/service/external_registry.py +1 -2
- synth_ai/environments/service/registry.py +1 -1
- synth_ai/environments/stateful/core.py +1 -2
- synth_ai/environments/stateful/engine.py +1 -1
- synth_ai/environments/tasks/api.py +4 -4
- synth_ai/environments/tasks/core.py +14 -12
- synth_ai/environments/tasks/filters.py +6 -4
- synth_ai/environments/tasks/utils.py +13 -11
- synth_ai/evals/base.py +2 -3
- synth_ai/experimental/synth_oss.py +4 -4
- synth_ai/learning/gateway.py +1 -3
- synth_ai/learning/prompts/banking77_injection_eval.py +168 -0
- synth_ai/learning/prompts/hello_world_in_context_injection_ex.py +213 -0
- synth_ai/learning/prompts/mipro.py +282 -1
- synth_ai/learning/prompts/random_search.py +246 -0
- synth_ai/learning/prompts/run_mipro_banking77.py +172 -0
- synth_ai/learning/prompts/run_random_search_banking77.py +324 -0
- synth_ai/lm/__init__.py +5 -5
- synth_ai/lm/caching/ephemeral.py +9 -9
- synth_ai/lm/caching/handler.py +20 -20
- synth_ai/lm/caching/persistent.py +10 -10
- synth_ai/lm/config.py +3 -3
- synth_ai/lm/constants.py +7 -7
- synth_ai/lm/core/all.py +17 -3
- synth_ai/lm/core/exceptions.py +0 -2
- synth_ai/lm/core/main.py +26 -41
- synth_ai/lm/core/main_v3.py +20 -10
- synth_ai/lm/core/vendor_clients.py +18 -17
- synth_ai/lm/injection.py +80 -0
- synth_ai/lm/overrides.py +206 -0
- synth_ai/lm/provider_support/__init__.py +1 -1
- synth_ai/lm/provider_support/anthropic.py +51 -24
- synth_ai/lm/provider_support/openai.py +51 -22
- synth_ai/lm/structured_outputs/handler.py +34 -32
- synth_ai/lm/structured_outputs/inject.py +24 -27
- synth_ai/lm/structured_outputs/rehabilitate.py +19 -15
- synth_ai/lm/tools/base.py +17 -16
- synth_ai/lm/unified_interface.py +17 -18
- synth_ai/lm/vendors/base.py +20 -18
- synth_ai/lm/vendors/core/anthropic_api.py +50 -25
- synth_ai/lm/vendors/core/gemini_api.py +31 -36
- synth_ai/lm/vendors/core/mistral_api.py +19 -19
- synth_ai/lm/vendors/core/openai_api.py +11 -10
- synth_ai/lm/vendors/openai_standard.py +144 -88
- synth_ai/lm/vendors/openai_standard_responses.py +74 -61
- synth_ai/lm/vendors/retries.py +9 -1
- synth_ai/lm/vendors/supported/custom_endpoint.py +26 -26
- synth_ai/lm/vendors/supported/deepseek.py +10 -10
- synth_ai/lm/vendors/supported/grok.py +8 -8
- synth_ai/lm/vendors/supported/ollama.py +2 -1
- synth_ai/lm/vendors/supported/openrouter.py +11 -9
- synth_ai/lm/vendors/synth_client.py +69 -63
- synth_ai/lm/warmup.py +8 -7
- synth_ai/tracing/__init__.py +22 -10
- synth_ai/tracing_v1/__init__.py +22 -20
- synth_ai/tracing_v3/__init__.py +7 -7
- synth_ai/tracing_v3/abstractions.py +56 -52
- synth_ai/tracing_v3/config.py +4 -2
- synth_ai/tracing_v3/db_config.py +6 -8
- synth_ai/tracing_v3/decorators.py +29 -30
- synth_ai/tracing_v3/examples/basic_usage.py +12 -12
- synth_ai/tracing_v3/hooks.py +21 -21
- synth_ai/tracing_v3/llm_call_record_helpers.py +85 -98
- synth_ai/tracing_v3/lm_call_record_abstractions.py +2 -4
- synth_ai/tracing_v3/migration_helper.py +3 -5
- synth_ai/tracing_v3/replica_sync.py +30 -32
- synth_ai/tracing_v3/session_tracer.py +35 -29
- synth_ai/tracing_v3/storage/__init__.py +1 -1
- synth_ai/tracing_v3/storage/base.py +8 -7
- synth_ai/tracing_v3/storage/config.py +4 -4
- synth_ai/tracing_v3/storage/factory.py +4 -4
- synth_ai/tracing_v3/storage/utils.py +9 -9
- synth_ai/tracing_v3/turso/__init__.py +3 -3
- synth_ai/tracing_v3/turso/daemon.py +9 -9
- synth_ai/tracing_v3/turso/manager.py +60 -48
- synth_ai/tracing_v3/turso/models.py +24 -19
- synth_ai/tracing_v3/utils.py +5 -5
- synth_ai/tui/__main__.py +1 -1
- synth_ai/tui/cli/query_experiments.py +2 -3
- synth_ai/tui/cli/query_experiments_v3.py +2 -3
- synth_ai/tui/dashboard.py +97 -86
- synth_ai/v0/tracing/abstractions.py +28 -28
- synth_ai/v0/tracing/base_client.py +9 -9
- synth_ai/v0/tracing/client_manager.py +7 -7
- synth_ai/v0/tracing/config.py +7 -7
- synth_ai/v0/tracing/context.py +6 -6
- synth_ai/v0/tracing/decorators.py +6 -5
- synth_ai/v0/tracing/events/manage.py +1 -1
- synth_ai/v0/tracing/events/store.py +5 -4
- synth_ai/v0/tracing/immediate_client.py +4 -5
- synth_ai/v0/tracing/local.py +3 -3
- synth_ai/v0/tracing/log_client_base.py +4 -5
- synth_ai/v0/tracing/retry_queue.py +5 -6
- synth_ai/v0/tracing/trackers.py +25 -25
- synth_ai/v0/tracing/upload.py +6 -0
- synth_ai/v0/tracing_v1/__init__.py +1 -1
- synth_ai/v0/tracing_v1/abstractions.py +28 -28
- synth_ai/v0/tracing_v1/base_client.py +9 -9
- synth_ai/v0/tracing_v1/client_manager.py +7 -7
- synth_ai/v0/tracing_v1/config.py +7 -7
- synth_ai/v0/tracing_v1/context.py +6 -6
- synth_ai/v0/tracing_v1/decorators.py +7 -6
- synth_ai/v0/tracing_v1/events/manage.py +1 -1
- synth_ai/v0/tracing_v1/events/store.py +5 -4
- synth_ai/v0/tracing_v1/immediate_client.py +4 -5
- synth_ai/v0/tracing_v1/local.py +3 -3
- synth_ai/v0/tracing_v1/log_client_base.py +4 -5
- synth_ai/v0/tracing_v1/retry_queue.py +5 -6
- synth_ai/v0/tracing_v1/trackers.py +25 -25
- synth_ai/v0/tracing_v1/upload.py +25 -24
- synth_ai/zyk/__init__.py +1 -0
- {synth_ai-0.2.4.dev5.dist-info → synth_ai-0.2.4.dev7.dist-info}/METADATA +2 -11
- synth_ai-0.2.4.dev7.dist-info/RECORD +299 -0
- synth_ai-0.2.4.dev5.dist-info/RECORD +0 -287
- {synth_ai-0.2.4.dev5.dist-info → synth_ai-0.2.4.dev7.dist-info}/WHEEL +0 -0
- {synth_ai-0.2.4.dev5.dist-info → synth_ai-0.2.4.dev7.dist-info}/entry_points.txt +0 -0
- {synth_ai-0.2.4.dev5.dist-info → synth_ai-0.2.4.dev7.dist-info}/licenses/LICENSE +0 -0
- {synth_ai-0.2.4.dev5.dist-info → synth_ai-0.2.4.dev7.dist-info}/top_level.txt +0 -0
@@ -1,26 +1,27 @@
|
|
1
1
|
# environment.py
|
2
2
|
from __future__ import annotations
|
3
|
-
from typing import List, Optional, Dict, Any, Union
|
4
|
-
from pydantic import BaseModel, Field
|
5
3
|
|
4
|
+
from typing import Any, Dict, List, Optional, Union
|
5
|
+
|
6
|
+
from pydantic import BaseModel, Field
|
7
|
+
from synth_ai.environments.environment.shared_engine import (
|
8
|
+
GetObservationCallable,
|
9
|
+
InternalObservation,
|
10
|
+
)
|
6
11
|
from synth_ai.environments.environment.tools import (
|
12
|
+
TOOL_REGISTRY,
|
7
13
|
EnvToolCall,
|
8
14
|
ToolResult,
|
9
|
-
TOOL_REGISTRY,
|
10
15
|
register_tool,
|
11
16
|
)
|
12
|
-
from synth_ai.environments.environment.shared_engine import (
|
13
|
-
GetObservationCallable,
|
14
|
-
InternalObservation,
|
15
|
-
)
|
16
|
-
from synth_ai.environments.stateful.core import StatefulEnvironment
|
17
17
|
from synth_ai.environments.examples.enron.engine import (
|
18
|
-
EnronEngine,
|
19
|
-
ACTION_SEARCH,
|
20
|
-
ACTION_READ,
|
21
18
|
ACTION_ANSWER,
|
19
|
+
ACTION_READ,
|
20
|
+
ACTION_SEARCH,
|
21
|
+
EnronEngine,
|
22
22
|
)
|
23
23
|
from synth_ai.environments.examples.enron.taskset import EnronTaskInstance
|
24
|
+
from synth_ai.environments.stateful.core import StatefulEnvironment
|
24
25
|
|
25
26
|
|
26
27
|
# -------- pydantic schemas (used by agent / LLM function calls)
|
@@ -1,20 +1,20 @@
|
|
1
1
|
# taskset.py
|
2
2
|
from __future__ import annotations
|
3
|
+
|
3
4
|
import asyncio
|
4
|
-
from uuid import uuid4
|
5
5
|
import os
|
6
|
+
from dataclasses import asdict, dataclass
|
7
|
+
from uuid import uuid4
|
6
8
|
|
7
9
|
from datasets import load_dataset
|
8
|
-
from dataclasses import dataclass, asdict
|
9
|
-
|
10
10
|
from synth_ai.environments.tasks.core import (
|
11
|
+
Impetus,
|
12
|
+
Intent,
|
13
|
+
SplitInfo,
|
11
14
|
Task,
|
12
15
|
TaskInstance,
|
13
|
-
TaskInstanceSet,
|
14
16
|
TaskInstanceMetadata,
|
15
|
-
|
16
|
-
Impetus,
|
17
|
-
Intent,
|
17
|
+
TaskInstanceSet,
|
18
18
|
)
|
19
19
|
|
20
20
|
enron_task = Task(
|
@@ -5,23 +5,23 @@ with full state management, tool-based interaction, and task generation.
|
|
5
5
|
"""
|
6
6
|
|
7
7
|
from synth_ai.environments.examples.minigrid.engine import (
|
8
|
+
MiniGridCheckpointObservationCallable,
|
8
9
|
MiniGridEngine,
|
9
|
-
MiniGridPublicState,
|
10
|
-
MiniGridPrivateState,
|
11
10
|
MiniGridGoalReachedComponent,
|
12
|
-
MiniGridStepPenaltyComponent,
|
13
11
|
MiniGridObservationCallable,
|
14
|
-
|
12
|
+
MiniGridPrivateState,
|
13
|
+
MiniGridPublicState,
|
14
|
+
MiniGridStepPenaltyComponent,
|
15
15
|
)
|
16
16
|
from synth_ai.environments.examples.minigrid.environment import (
|
17
|
+
MiniGridActionInput,
|
17
18
|
MiniGridEnvironment,
|
18
19
|
MiniGridInteractTool,
|
19
|
-
MiniGridActionInput,
|
20
20
|
)
|
21
21
|
from synth_ai.environments.examples.minigrid.taskset import (
|
22
|
+
DEFAULT_MINIGRID_TASK,
|
22
23
|
MiniGridTaskInstance,
|
23
24
|
MiniGridTaskInstanceMetadata,
|
24
|
-
DEFAULT_MINIGRID_TASK,
|
25
25
|
create_minigrid_taskset,
|
26
26
|
taskset,
|
27
27
|
)
|
@@ -8,25 +8,25 @@ from __future__ import annotations
|
|
8
8
|
|
9
9
|
import json
|
10
10
|
from dataclasses import dataclass, field
|
11
|
-
from typing import Any, Dict, Optional, Tuple, Union
|
11
|
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
12
12
|
|
13
13
|
import gymnasium as gym
|
14
14
|
import numpy as np
|
15
|
-
from minigrid.core.constants import
|
15
|
+
from minigrid.core.constants import COLOR_TO_IDX, OBJECT_TO_IDX, STATE_TO_IDX
|
16
16
|
|
17
|
-
from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
|
18
|
-
from synth_ai.environments.reproducibility.core import IReproducibleEngine
|
19
17
|
from synth_ai.environments.environment.rewards.core import RewardComponent, RewardStack
|
20
18
|
from synth_ai.environments.environment.shared_engine import (
|
21
19
|
GetObservationCallable,
|
22
20
|
InternalObservation,
|
23
21
|
)
|
24
|
-
from synth_ai.environments.tasks.core import TaskInstance
|
25
22
|
from synth_ai.environments.examples.minigrid.environment_mapping import (
|
26
|
-
get_environment_from_seed,
|
27
23
|
get_difficulty_from_seed,
|
24
|
+
get_environment_from_seed,
|
28
25
|
validate_environment_name,
|
29
26
|
)
|
27
|
+
from synth_ai.environments.reproducibility.core import IReproducibleEngine
|
28
|
+
from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
|
29
|
+
from synth_ai.environments.tasks.core import TaskInstance
|
30
30
|
|
31
31
|
|
32
32
|
@dataclass
|
@@ -12,20 +12,20 @@ from typing import Any, Callable, Dict, List, Optional, Union
|
|
12
12
|
import numpy as np
|
13
13
|
from pydantic import BaseModel, Field
|
14
14
|
|
15
|
-
from synth_ai.environments.environment.tools import AbstractTool, EnvToolCall, ToolResult
|
16
|
-
from synth_ai.environments.stateful.core import StatefulEnvironment
|
17
|
-
from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
|
18
15
|
from synth_ai.environments.environment.shared_engine import (
|
19
16
|
GetObservationCallable,
|
20
17
|
InternalObservation,
|
21
18
|
)
|
19
|
+
from synth_ai.environments.environment.tools import AbstractTool, EnvToolCall, ToolResult
|
22
20
|
from synth_ai.environments.examples.minigrid.engine import (
|
21
|
+
MiniGridCheckpointObservationCallable,
|
23
22
|
MiniGridEngine,
|
24
|
-
MiniGridPublicState,
|
25
|
-
MiniGridPrivateState,
|
26
23
|
MiniGridObservationCallable,
|
27
|
-
|
24
|
+
MiniGridPrivateState,
|
25
|
+
MiniGridPublicState,
|
28
26
|
)
|
27
|
+
from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
|
28
|
+
from synth_ai.environments.stateful.core import StatefulEnvironment
|
29
29
|
from synth_ai.environments.tasks.core import TaskInstance
|
30
30
|
|
31
31
|
|
@@ -6,8 +6,9 @@ with deterministic seed-based selection and difficulty filtering.
|
|
6
6
|
"""
|
7
7
|
|
8
8
|
import logging
|
9
|
-
from dataclasses import
|
10
|
-
from typing import Dict, List, Optional, Tuple
|
9
|
+
from dataclasses import asdict, dataclass
|
10
|
+
from typing import Any, Dict, List, Optional, Tuple
|
11
|
+
|
11
12
|
from synth_ai.environments.examples.minigrid.environment_mapping import ENVIRONMENT_MAPPING
|
12
13
|
|
13
14
|
logger = logging.getLogger(__name__)
|
@@ -12,24 +12,24 @@ from dataclasses import dataclass, field
|
|
12
12
|
from typing import Any, Dict, List, Optional, Set, Tuple
|
13
13
|
from uuid import uuid4
|
14
14
|
|
15
|
-
from synth_ai.environments.tasks.api import (
|
16
|
-
Task,
|
17
|
-
TaskInstance,
|
18
|
-
TaskInstanceMetadata,
|
19
|
-
TaskInstanceSet,
|
20
|
-
SplitInfo,
|
21
|
-
Impetus,
|
22
|
-
Intent,
|
23
|
-
)
|
24
15
|
from synth_ai.environments.examples.minigrid.environment_mapping import (
|
25
|
-
get_environment_from_seed,
|
26
|
-
get_difficulty_from_seed,
|
27
16
|
get_all_environments,
|
17
|
+
get_difficulty_from_seed,
|
18
|
+
get_environment_from_seed,
|
28
19
|
)
|
29
20
|
from synth_ai.environments.examples.minigrid.puzzle_loader import (
|
30
|
-
get_puzzle_loader,
|
31
|
-
get_puzzle_by_seed,
|
32
21
|
MiniGridPuzzle,
|
22
|
+
get_puzzle_by_seed,
|
23
|
+
get_puzzle_loader,
|
24
|
+
)
|
25
|
+
from synth_ai.environments.tasks.api import (
|
26
|
+
Impetus,
|
27
|
+
Intent,
|
28
|
+
SplitInfo,
|
29
|
+
Task,
|
30
|
+
TaskInstance,
|
31
|
+
TaskInstanceMetadata,
|
32
|
+
TaskInstanceSet,
|
33
33
|
)
|
34
34
|
|
35
35
|
|
@@ -4,27 +4,28 @@ from __future__ import annotations
|
|
4
4
|
|
5
5
|
import asyncio
|
6
6
|
import base64
|
7
|
+
import logging
|
7
8
|
from dataclasses import dataclass, field
|
8
|
-
from typing import
|
9
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, cast
|
10
|
+
|
9
11
|
import numpy as np
|
10
|
-
import logging
|
11
12
|
|
12
|
-
from synth_ai.environments.
|
13
|
-
from synth_ai.environments.reproducibility.core import IReproducibleEngine
|
14
|
-
from synth_ai.environments.environment.rewards.core import RewardStack, RewardComponent
|
13
|
+
from synth_ai.environments.environment.rewards.core import RewardComponent, RewardStack
|
15
14
|
from synth_ai.environments.environment.shared_engine import (
|
16
15
|
GetObservationCallable,
|
17
16
|
InternalObservation,
|
18
17
|
)
|
18
|
+
from synth_ai.environments.reproducibility.core import IReproducibleEngine
|
19
|
+
from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
|
19
20
|
from synth_ai.environments.tasks.core import TaskInstance
|
20
21
|
|
21
22
|
logger = logging.getLogger(__name__)
|
22
23
|
|
23
24
|
# NLE imports are required
|
24
25
|
try:
|
25
|
-
from .helpers.nle_wrapper import NLEWrapper
|
26
|
-
from .helpers.action_mapping import convert_action_to_nle
|
27
26
|
from .achievements import NetHackAchievements, calculate_balrog_reward
|
27
|
+
from .helpers.action_mapping import convert_action_to_nle
|
28
|
+
from .helpers.nle_wrapper import NLEWrapper
|
28
29
|
except ImportError as e:
|
29
30
|
raise ImportError(
|
30
31
|
"NLE (NetHack Learning Environment) is required but not installed. "
|
@@ -3,30 +3,31 @@
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
5
|
import json
|
6
|
-
from typing import Dict,
|
6
|
+
from typing import Any, Dict, List, Optional, Union
|
7
|
+
|
7
8
|
from pydantic import BaseModel
|
8
9
|
|
9
|
-
from synth_ai.environments.stateful.core import StatefulEnvironment
|
10
|
-
from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
|
11
|
-
from synth_ai.environments.environment.tools import AbstractTool, EnvToolCall, ToolResult
|
12
10
|
from synth_ai.environments.environment.shared_engine import (
|
13
11
|
GetObservationCallable,
|
14
12
|
InternalObservation,
|
15
13
|
)
|
14
|
+
from synth_ai.environments.environment.tools import AbstractTool, EnvToolCall, ToolResult
|
15
|
+
from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
|
16
|
+
from synth_ai.environments.stateful.core import StatefulEnvironment
|
16
17
|
from synth_ai.environments.tasks.core import TaskInstance
|
17
18
|
|
18
19
|
from .engine import (
|
20
|
+
NetHackCheckpointObservationCallable,
|
19
21
|
NetHackEngine,
|
20
22
|
NetHackObservationCallable,
|
21
|
-
NetHackCheckpointObservationCallable,
|
22
|
-
NetHackPublicState,
|
23
23
|
NetHackPrivateState,
|
24
|
+
NetHackPublicState,
|
24
25
|
)
|
25
26
|
from .helpers import (
|
26
|
-
validate_action,
|
27
|
-
get_action_description,
|
28
|
-
NETHACK_ACTIONS,
|
29
27
|
MENU_ACTIONS,
|
28
|
+
NETHACK_ACTIONS,
|
29
|
+
get_action_description,
|
30
|
+
validate_action,
|
30
31
|
)
|
31
32
|
|
32
33
|
|
@@ -1,24 +1,23 @@
|
|
1
1
|
"""Helper utilities for NetHack environment."""
|
2
2
|
|
3
3
|
from .action_mapping import (
|
4
|
-
NETHACK_ACTIONS,
|
5
|
-
MENU_ACTIONS,
|
6
|
-
ALL_ACTIONS,
|
7
4
|
ACTION_CATEGORIES,
|
8
|
-
|
5
|
+
ALL_ACTIONS,
|
6
|
+
MENU_ACTIONS,
|
7
|
+
NETHACK_ACTIONS,
|
8
|
+
convert_action_to_nle,
|
9
9
|
get_action_description,
|
10
10
|
get_actions_for_context,
|
11
|
-
convert_action_to_nle,
|
12
11
|
parse_compound_action,
|
12
|
+
validate_action,
|
13
13
|
)
|
14
|
-
|
15
14
|
from .observation_utils import (
|
16
|
-
format_observation_for_llm,
|
17
|
-
parse_ascii_map,
|
18
15
|
extract_game_context,
|
19
|
-
simplify_observation,
|
20
16
|
extract_inventory_from_message,
|
17
|
+
format_observation_for_llm,
|
21
18
|
identify_item_type,
|
19
|
+
parse_ascii_map,
|
20
|
+
simplify_observation,
|
22
21
|
)
|
23
22
|
|
24
23
|
__all__ = [
|
@@ -1,15 +1,14 @@
|
|
1
1
|
"""Environment wrapper that adds trajectory recording capabilities."""
|
2
2
|
|
3
|
-
from typing import Dict, Any, Optional, Tuple
|
4
|
-
from pathlib import Path
|
5
3
|
import logging
|
4
|
+
from pathlib import Path
|
5
|
+
from typing import Any, Dict, Optional, Tuple
|
6
6
|
|
7
|
+
from src.synth_env.environment.tools import EnvToolCall
|
7
8
|
from src.synth_env.examples.nethack.environment import NetHackEnvironment
|
8
9
|
from src.synth_env.examples.nethack.helpers.trajectory_recorder import (
|
9
10
|
TrajectoryRecorder,
|
10
11
|
)
|
11
|
-
from src.synth_env.environment.tools import EnvToolCall
|
12
|
-
|
13
12
|
|
14
13
|
logger = logging.getLogger(__name__)
|
15
14
|
|
@@ -1,14 +1,15 @@
|
|
1
1
|
"""Trajectory recording and replay functionality for NetHack."""
|
2
2
|
|
3
|
+
import base64
|
4
|
+
import gzip
|
3
5
|
import json
|
4
6
|
import pickle
|
5
|
-
import
|
6
|
-
from pathlib import Path
|
7
|
-
from typing import Dict, Any, List, Optional, Tuple
|
7
|
+
from dataclasses import asdict, dataclass
|
8
8
|
from datetime import datetime
|
9
|
+
from pathlib import Path
|
10
|
+
from typing import Any, Dict, List, Optional, Tuple
|
11
|
+
|
9
12
|
import numpy as np
|
10
|
-
from dataclasses import dataclass, asdict
|
11
|
-
import base64
|
12
13
|
|
13
14
|
|
14
15
|
@dataclass
|
@@ -1,19 +1,19 @@
|
|
1
1
|
"""Interactive replay viewer for NetHack trajectories."""
|
2
2
|
|
3
|
+
import gzip
|
4
|
+
import json
|
3
5
|
import os
|
4
6
|
import sys
|
5
|
-
from pathlib import Path
|
6
|
-
from typing import List, Dict, Any, Optional, Tuple
|
7
|
-
import json
|
8
|
-
import gzip
|
9
7
|
from datetime import datetime
|
8
|
+
from pathlib import Path
|
9
|
+
from typing import Any, Dict, List, Optional, Tuple
|
10
10
|
|
11
11
|
# Add parent directory to path for imports
|
12
12
|
sys.path.append(str(Path(__file__).parent.parent.parent.parent.parent.parent))
|
13
13
|
|
14
14
|
from src.synth_env.examples.nethack.helpers.trajectory_recorder import (
|
15
|
-
TrajectoryRecorder,
|
16
15
|
TrajectoryFrame,
|
16
|
+
TrajectoryRecorder,
|
17
17
|
)
|
18
18
|
from src.synth_env.examples.nethack.helpers.visualization.visualizer import (
|
19
19
|
NetHackVisualizer,
|
@@ -1,14 +1,15 @@
|
|
1
1
|
"""Visualization tools for NetHack trajectories."""
|
2
2
|
|
3
|
-
import
|
4
|
-
from
|
3
|
+
import json
|
4
|
+
from datetime import datetime
|
5
5
|
from pathlib import Path
|
6
|
-
import
|
6
|
+
from typing import Any, Dict, List, Optional, Tuple
|
7
|
+
|
7
8
|
import matplotlib.animation as animation
|
8
|
-
|
9
|
+
import matplotlib.pyplot as plt
|
10
|
+
import numpy as np
|
9
11
|
import seaborn as sns
|
10
|
-
from
|
11
|
-
import json
|
12
|
+
from matplotlib.patches import Rectangle
|
12
13
|
|
13
14
|
try:
|
14
15
|
from PIL import Image, ImageDraw, ImageFont
|
@@ -3,17 +3,17 @@
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
5
|
import random
|
6
|
-
from uuid import uuid4
|
7
6
|
from dataclasses import dataclass
|
8
|
-
from typing import
|
7
|
+
from typing import Any, Dict, List, Optional, Set
|
8
|
+
from uuid import uuid4
|
9
9
|
|
10
10
|
from synth_ai.environments.tasks.core import (
|
11
|
-
TaskInstance,
|
12
|
-
TaskInstanceMetadata,
|
13
|
-
TaskInstanceSet,
|
14
11
|
Impetus,
|
15
12
|
Intent,
|
16
13
|
SplitInfo,
|
14
|
+
TaskInstance,
|
15
|
+
TaskInstanceMetadata,
|
16
|
+
TaskInstanceSet,
|
17
17
|
)
|
18
18
|
|
19
19
|
|
@@ -1,25 +1,26 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
+
|
2
3
|
import logging
|
3
|
-
from pathlib import Path
|
4
|
-
from typing import Dict, Any, Optional, List
|
5
4
|
from dataclasses import dataclass
|
5
|
+
from pathlib import Path
|
6
|
+
from typing import Any, Dict, List, Optional
|
6
7
|
|
7
|
-
|
8
|
+
from synth_ai.environments.environment.rewards.core import RewardStack
|
9
|
+
from synth_ai.environments.reproducibility.core import IReproducibleEngine
|
8
10
|
|
11
|
+
# Import logging configuration first to suppress JAX debug messages
|
9
12
|
from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
|
10
|
-
from synth_ai.environments.reproducibility.core import IReproducibleEngine
|
11
|
-
from synth_ai.environments.environment.rewards.core import RewardStack
|
12
13
|
from synth_ai.environments.tasks.core import TaskInstance
|
13
14
|
|
14
|
-
from .engine_helpers.state_extraction import extract_game_state
|
15
15
|
from .engine_helpers.reward_components import (
|
16
16
|
BadgeRewardComponent,
|
17
|
-
MapTransitionComponent,
|
18
17
|
BattleVictoryComponent,
|
19
18
|
LevelUpComponent,
|
20
|
-
|
19
|
+
MapTransitionComponent,
|
21
20
|
StepPenaltyComponent,
|
21
|
+
XPGainComponent,
|
22
22
|
)
|
23
|
+
from .engine_helpers.state_extraction import extract_game_state
|
23
24
|
|
24
25
|
try:
|
25
26
|
from pyboy import PyBoy
|
@@ -4,17 +4,17 @@ Pokemon Red Reward Library
|
|
4
4
|
Comprehensive collection of reward components organized by category.
|
5
5
|
"""
|
6
6
|
|
7
|
-
from .
|
8
|
-
from .exploration_rewards import *
|
9
|
-
from .social_rewards import *
|
10
|
-
from .pokemon_rewards import *
|
7
|
+
from .adaptive_rewards import *
|
11
8
|
from .battle_rewards import *
|
12
|
-
from .
|
9
|
+
from .composite_rewards import *
|
13
10
|
from .economy_rewards import *
|
14
11
|
from .efficiency_rewards import *
|
12
|
+
from .exploration_rewards import *
|
15
13
|
from .novelty_rewards import *
|
16
|
-
from .
|
17
|
-
from .
|
14
|
+
from .pallet_town_rewards import *
|
15
|
+
from .pokemon_rewards import *
|
16
|
+
from .social_rewards import *
|
17
|
+
from .story_rewards import *
|
18
18
|
|
19
19
|
__all__ = [
|
20
20
|
# Pallet Town Early Game
|
@@ -4,8 +4,9 @@ Adaptive & Learning Reward Components
|
|
4
4
|
Rewards for improvement over time and meta-learning.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from typing import Any, Dict
|
8
|
+
|
7
9
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
8
|
-
from typing import Dict, Any
|
9
10
|
|
10
11
|
|
11
12
|
class MistakeRecoveryReward(RewardComponent):
|
@@ -4,8 +4,9 @@ Battle & Combat Reward Components
|
|
4
4
|
Rewards for battle victories, combat strategy, and battle efficiency.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from typing import Any, Dict, Set
|
8
|
+
|
7
9
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
8
|
-
from typing import Dict, Any, Set
|
9
10
|
|
10
11
|
|
11
12
|
class WildPokemonDefeatedReward(RewardComponent):
|
@@ -4,8 +4,9 @@ Composite & Milestone Reward Components
|
|
4
4
|
Rewards for achievement combinations and progression streaks.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from typing import Any, Dict, Set
|
8
|
+
|
7
9
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
8
|
-
from typing import Dict, Any, Set
|
9
10
|
|
10
11
|
|
11
12
|
class PerfectGymRunReward(RewardComponent):
|
@@ -4,8 +4,9 @@ Economy & Resource Management Reward Components
|
|
4
4
|
Rewards for money management and inventory optimization.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from typing import Any, Dict, Set
|
8
|
+
|
7
9
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
8
|
-
from typing import Dict, Any, Set
|
9
10
|
|
10
11
|
|
11
12
|
class FirstEarningsReward(RewardComponent):
|
@@ -4,8 +4,9 @@ Efficiency & Optimization Reward Components
|
|
4
4
|
Rewards for optimal play, routing, and game knowledge.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from typing import Any, Dict
|
8
|
+
|
7
9
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
8
|
-
from typing import Dict, Any
|
9
10
|
|
10
11
|
|
11
12
|
class FastTravelUsageReward(RewardComponent):
|
@@ -4,8 +4,9 @@ Exploration & Discovery Reward Components
|
|
4
4
|
Rewards for map exploration, item discovery, and world interaction.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from typing import Any, Dict, Set
|
8
|
+
|
7
9
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
8
|
-
from typing import Dict, Any, Set
|
9
10
|
|
10
11
|
|
11
12
|
class NewAreaDiscoveryReward(RewardComponent):
|
@@ -4,8 +4,9 @@ Novelty & Exploration Bonus Reward Components
|
|
4
4
|
Rewards for first-time experiences and curiosity.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from typing import Any, Dict, Set
|
8
|
+
|
7
9
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
8
|
-
from typing import Dict, Any, Set
|
9
10
|
|
10
11
|
|
11
12
|
class FirstBattleReward(RewardComponent):
|
@@ -5,8 +5,9 @@ Rewards specifically designed for the first 50 steps of Pokemon Red,
|
|
5
5
|
focusing on house exploration, town discovery, and story triggers.
|
6
6
|
"""
|
7
7
|
|
8
|
+
from typing import Any, Dict, Set
|
9
|
+
|
8
10
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
9
|
-
from typing import Dict, Any, Set
|
10
11
|
|
11
12
|
|
12
13
|
class LeaveStartingRoomReward(RewardComponent):
|
@@ -4,8 +4,9 @@ Pokemon Collection & Management Reward Components
|
|
4
4
|
Rewards for catching Pokemon, Pokedex progress, and Pokemon development.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from typing import Any, Dict, Set
|
8
|
+
|
7
9
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
8
|
-
from typing import Dict, Any, Set
|
9
10
|
|
10
11
|
|
11
12
|
class FirstPokemonCaughtReward(RewardComponent):
|
@@ -4,8 +4,9 @@ Social & NPC Interaction Reward Components
|
|
4
4
|
Rewards for dialogue, information gathering, and NPC interactions.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from typing import Any, Dict, Set
|
8
|
+
|
7
9
|
from synth_ai.environments.environment.rewards.core import RewardComponent
|
8
|
-
from typing import Dict, Any, Set
|
9
10
|
|
10
11
|
|
11
12
|
class NewNPCConversationReward(RewardComponent):
|