synth-ai 0.2.10__py3-none-any.whl → 0.2.13.dev1__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.

Files changed (73) hide show
  1. examples/agora_ex/README_MoE.md +224 -0
  2. examples/agora_ex/__init__.py +7 -0
  3. examples/agora_ex/agora_ex.py +65 -0
  4. examples/agora_ex/agora_ex_task_app.py +590 -0
  5. examples/agora_ex/configs/rl_lora_qwen3_moe_2xh200.toml +121 -0
  6. examples/agora_ex/reward_fn_grpo-human.py +129 -0
  7. examples/agora_ex/system_prompt_CURRENT.md +63 -0
  8. examples/agora_ex/task_app/agora_ex_task_app.py +590 -0
  9. examples/agora_ex/task_app/reward_fn_grpo-human.py +129 -0
  10. examples/agora_ex/task_app/system_prompt_CURRENT.md +63 -0
  11. examples/multi_step/configs/crafter_rl_outcome.toml +74 -0
  12. examples/multi_step/configs/crafter_rl_stepwise_hosted_judge.toml +175 -0
  13. examples/multi_step/configs/crafter_rl_stepwise_shaped.toml +83 -0
  14. examples/multi_step/configs/crafter_rl_stepwise_simple.toml +78 -0
  15. examples/multi_step/crafter_rl_lora.md +51 -10
  16. examples/multi_step/sse_metrics_streaming_notes.md +357 -0
  17. examples/multi_step/task_app_config_notes.md +494 -0
  18. examples/warming_up_to_rl/configs/eval_stepwise_complex.toml +35 -0
  19. examples/warming_up_to_rl/configs/eval_stepwise_consistent.toml +26 -0
  20. examples/warming_up_to_rl/configs/eval_stepwise_per_achievement.toml +36 -0
  21. examples/warming_up_to_rl/configs/eval_stepwise_simple.toml +32 -0
  22. examples/warming_up_to_rl/run_eval.py +267 -41
  23. examples/warming_up_to_rl/task_app/grpo_crafter.py +3 -33
  24. examples/warming_up_to_rl/task_app/synth_envs_hosted/inference/openai_client.py +109 -45
  25. examples/warming_up_to_rl/task_app/synth_envs_hosted/policy_routes.py +42 -46
  26. examples/warming_up_to_rl/task_app/synth_envs_hosted/rollout.py +376 -193
  27. synth_ai/__init__.py +41 -1
  28. synth_ai/api/train/builders.py +74 -33
  29. synth_ai/api/train/cli.py +29 -6
  30. synth_ai/api/train/configs/__init__.py +44 -0
  31. synth_ai/api/train/configs/rl.py +133 -0
  32. synth_ai/api/train/configs/sft.py +94 -0
  33. synth_ai/api/train/configs/shared.py +24 -0
  34. synth_ai/api/train/env_resolver.py +18 -19
  35. synth_ai/api/train/supported_algos.py +8 -5
  36. synth_ai/api/train/utils.py +6 -1
  37. synth_ai/cli/__init__.py +4 -2
  38. synth_ai/cli/_storage.py +19 -0
  39. synth_ai/cli/balance.py +14 -2
  40. synth_ai/cli/calc.py +37 -22
  41. synth_ai/cli/demo.py +38 -39
  42. synth_ai/cli/legacy_root_backup.py +12 -14
  43. synth_ai/cli/recent.py +12 -7
  44. synth_ai/cli/rl_demo.py +81 -102
  45. synth_ai/cli/status.py +4 -3
  46. synth_ai/cli/task_apps.py +146 -137
  47. synth_ai/cli/traces.py +4 -3
  48. synth_ai/cli/watch.py +3 -2
  49. synth_ai/demos/core/cli.py +121 -159
  50. synth_ai/environments/examples/crafter_classic/environment.py +16 -0
  51. synth_ai/evals/__init__.py +15 -0
  52. synth_ai/evals/client.py +85 -0
  53. synth_ai/evals/types.py +42 -0
  54. synth_ai/jobs/client.py +15 -3
  55. synth_ai/judge_schemas.py +127 -0
  56. synth_ai/rubrics/__init__.py +22 -0
  57. synth_ai/rubrics/validators.py +126 -0
  58. synth_ai/task/server.py +14 -7
  59. synth_ai/tracing_v3/decorators.py +51 -26
  60. synth_ai/tracing_v3/examples/basic_usage.py +12 -7
  61. synth_ai/tracing_v3/llm_call_record_helpers.py +107 -53
  62. synth_ai/tracing_v3/replica_sync.py +8 -4
  63. synth_ai/tracing_v3/serialization.py +130 -0
  64. synth_ai/tracing_v3/storage/utils.py +11 -9
  65. synth_ai/tracing_v3/turso/__init__.py +12 -0
  66. synth_ai/tracing_v3/turso/daemon.py +2 -1
  67. synth_ai/tracing_v3/turso/native_manager.py +28 -15
  68. {synth_ai-0.2.10.dist-info → synth_ai-0.2.13.dev1.dist-info}/METADATA +4 -2
  69. {synth_ai-0.2.10.dist-info → synth_ai-0.2.13.dev1.dist-info}/RECORD +73 -40
  70. {synth_ai-0.2.10.dist-info → synth_ai-0.2.13.dev1.dist-info}/entry_points.txt +0 -1
  71. {synth_ai-0.2.10.dist-info → synth_ai-0.2.13.dev1.dist-info}/WHEEL +0 -0
  72. {synth_ai-0.2.10.dist-info → synth_ai-0.2.13.dev1.dist-info}/licenses/LICENSE +0 -0
  73. {synth_ai-0.2.10.dist-info → synth_ai-0.2.13.dev1.dist-info}/top_level.txt +0 -0
synth_ai/cli/rl_demo.py CHANGED
@@ -17,18 +17,25 @@ from __future__ import annotations
17
17
 
18
18
  import click
19
19
 
20
+ from synth_ai.demos.core import cli as demo_commands
20
21
 
21
- def _forward(args: list[str]) -> None:
22
- import sys
23
22
 
23
+ def _run_demo_command(func, *args, **kwargs) -> None:
24
+ """Invoke a demo command and exit via Click on non-zero status codes."""
25
+
26
+ try:
27
+ result = func(*args, **kwargs)
28
+ except SystemExit as exc: # pragma: no cover - defensive
29
+ raise click.exceptions.Exit(exc.code or 1) from exc
30
+
31
+ if result is None:
32
+ return
24
33
  try:
25
- from synth_ai.demos.core import cli as demo_cli # type: ignore
26
- except Exception as e: # pragma: no cover
27
- click.echo(f"Failed to import RL demo CLI: {e}")
28
- sys.exit(1)
29
- rc = int(demo_cli.main(args) or 0)
30
- if rc != 0:
31
- sys.exit(rc)
34
+ code = int(result)
35
+ except (TypeError, ValueError):
36
+ return
37
+ if code != 0:
38
+ raise click.exceptions.Exit(code)
32
39
 
33
40
 
34
41
  def register(cli):
@@ -44,7 +51,7 @@ def register(cli):
44
51
 
45
52
  @_rlg.command("setup")
46
53
  def rl_setup():
47
- _forward(["rl_demo.setup"]) # primary setup command
54
+ _run_demo_command(demo_commands.setup)
48
55
 
49
56
  # (prepare command removed; consolidated into configure)
50
57
 
@@ -64,34 +71,29 @@ def register(cli):
64
71
  help="Path to deploy_task_app.sh (optional legacy)",
65
72
  )
66
73
  def rl_deploy(local: bool, app: str | None, name: str, script: str | None):
67
- args: list[str] = ["rl_demo.deploy"]
68
- if local:
69
- args.append("--local")
70
- if app:
71
- args.extend(["--app", app])
72
- if name:
73
- args.extend(["--name", name])
74
- if script:
75
- args.extend(["--script", script])
76
- _forward(args)
74
+ _run_demo_command(
75
+ demo_commands.deploy,
76
+ local=local,
77
+ app=app,
78
+ name=name,
79
+ script=script,
80
+ )
77
81
 
78
82
  @_rlg.command("configure")
79
83
  def rl_configure():
80
- _forward(["rl_demo.configure"])
84
+ _run_demo_command(demo_commands.run)
81
85
 
82
86
  @_rlg.command("init")
83
87
  @click.option("--template", type=str, default=None, help="Template id to instantiate")
84
88
  @click.option("--dest", type=click.Path(), default=None, help="Destination directory for files")
85
89
  @click.option("--force", is_flag=True, help="Overwrite existing files in destination")
86
90
  def rl_init(template: str | None, dest: str | None, force: bool):
87
- args = ["rl_demo.init"]
88
- if template:
89
- args.extend(["--template", template])
90
- if dest:
91
- args.extend(["--dest", dest])
92
- if force:
93
- args.append("--force")
94
- _forward(args)
91
+ _run_demo_command(
92
+ demo_commands.init,
93
+ template=template,
94
+ dest=dest,
95
+ force=force,
96
+ )
95
97
 
96
98
  @_rlg.command("run")
97
99
  @click.option(
@@ -110,29 +112,24 @@ def register(cli):
110
112
  timeout: int,
111
113
  dry_run: bool,
112
114
  ):
113
- args = ["rl_demo.run"]
114
- if config:
115
- args.extend(["--config", config])
116
- if batch_size is not None:
117
- args.extend(["--batch-size", str(batch_size)])
118
- if group_size is not None:
119
- args.extend(["--group-size", str(group_size)])
120
- if model:
121
- args.extend(["--model", model])
122
- if timeout is not None:
123
- args.extend(["--timeout", str(timeout)])
124
- if dry_run:
125
- args.append("--dry-run")
126
- _forward(args)
115
+ _run_demo_command(
116
+ demo_commands.run,
117
+ config=config,
118
+ batch_size=batch_size,
119
+ group_size=group_size,
120
+ model=model,
121
+ timeout=timeout,
122
+ dry_run=dry_run,
123
+ )
127
124
 
128
125
  # Dotted aliases (top-level): legacy check → setup
129
126
  @cli.command("rl_demo.check")
130
127
  def rl_check_alias():
131
- _forward(["rl_demo.setup"])
128
+ _run_demo_command(demo_commands.setup)
132
129
 
133
130
  @cli.command("rl_demo.setup")
134
131
  def rl_setup_alias():
135
- _forward(["rl_demo.setup"])
132
+ _run_demo_command(demo_commands.setup)
136
133
 
137
134
  # (prepare alias removed)
138
135
 
@@ -152,34 +149,29 @@ def register(cli):
152
149
  help="Path to deploy_task_app.sh (optional legacy)",
153
150
  )
154
151
  def rl_deploy_alias(local: bool, app: str | None, name: str, script: str | None):
155
- args: list[str] = ["rl_demo.deploy"]
156
- if local:
157
- args.append("--local")
158
- if app:
159
- args.extend(["--app", app])
160
- if name:
161
- args.extend(["--name", name])
162
- if script:
163
- args.extend(["--script", script])
164
- _forward(args)
152
+ _run_demo_command(
153
+ demo_commands.deploy,
154
+ local=local,
155
+ app=app,
156
+ name=name,
157
+ script=script,
158
+ )
165
159
 
166
160
  @cli.command("rl_demo.configure")
167
161
  def rl_configure_alias():
168
- _forward(["rl_demo.configure"])
162
+ _run_demo_command(demo_commands.run)
169
163
 
170
164
  @cli.command("rl_demo.init")
171
165
  @click.option("--template", type=str, default=None, help="Template id to instantiate")
172
166
  @click.option("--dest", type=click.Path(), default=None, help="Destination directory for files")
173
167
  @click.option("--force", is_flag=True, help="Overwrite existing files in destination")
174
168
  def rl_init_alias(template: str | None, dest: str | None, force: bool):
175
- args = ["rl_demo.init"]
176
- if template:
177
- args.extend(["--template", template])
178
- if dest:
179
- args.extend(["--dest", dest])
180
- if force:
181
- args.append("--force")
182
- _forward(args)
169
+ _run_demo_command(
170
+ demo_commands.init,
171
+ template=template,
172
+ dest=dest,
173
+ force=force,
174
+ )
183
175
 
184
176
  @cli.command("rl_demo.run")
185
177
  @click.option(
@@ -198,20 +190,15 @@ def register(cli):
198
190
  timeout: int,
199
191
  dry_run: bool,
200
192
  ):
201
- args = ["rl_demo.run"]
202
- if config:
203
- args.extend(["--config", config])
204
- if batch_size is not None:
205
- args.extend(["--batch-size", str(batch_size)])
206
- if group_size is not None:
207
- args.extend(["--group-size", str(group_size)])
208
- if model:
209
- args.extend(["--model", model])
210
- if timeout is not None:
211
- args.extend(["--timeout", str(timeout)])
212
- if dry_run:
213
- args.append("--dry-run")
214
- _forward(args)
193
+ _run_demo_command(
194
+ demo_commands.run,
195
+ config=config,
196
+ batch_size=batch_size,
197
+ group_size=group_size,
198
+ model=model,
199
+ timeout=timeout,
200
+ dry_run=dry_run,
201
+ )
215
202
 
216
203
  # Top-level convenience alias: `synth-ai deploy`
217
204
  @cli.command("demo-deploy")
@@ -230,16 +217,13 @@ def register(cli):
230
217
  help="Path to deploy_task_app.sh (optional legacy)",
231
218
  )
232
219
  def deploy_demo(local: bool, app: str | None, name: str, script: str | None):
233
- args: list[str] = ["rl_demo.deploy"]
234
- if local:
235
- args.append("--local")
236
- if app:
237
- args.extend(["--app", app])
238
- if name:
239
- args.extend(["--name", name])
240
- if script:
241
- args.extend(["--script", script])
242
- _forward(args)
220
+ _run_demo_command(
221
+ demo_commands.deploy,
222
+ local=local,
223
+ app=app,
224
+ name=name,
225
+ script=script,
226
+ )
243
227
 
244
228
  @cli.command("run")
245
229
  @click.option(
@@ -258,17 +242,12 @@ def register(cli):
258
242
  timeout: int,
259
243
  dry_run: bool,
260
244
  ):
261
- args = ["run"]
262
- if config:
263
- args.extend(["--config", config])
264
- if batch_size is not None:
265
- args.extend(["--batch-size", str(batch_size)])
266
- if group_size is not None:
267
- args.extend(["--group-size", str(group_size)])
268
- if model:
269
- args.extend(["--model", model])
270
- if timeout is not None:
271
- args.extend(["--timeout", str(timeout)])
272
- if dry_run:
273
- args.append("--dry-run")
274
- _forward(args)
245
+ _run_demo_command(
246
+ demo_commands.run,
247
+ config=config,
248
+ batch_size=batch_size,
249
+ group_size=group_size,
250
+ model=model,
251
+ timeout=timeout,
252
+ dry_run=dry_run,
253
+ )
synth_ai/cli/status.py CHANGED
@@ -12,11 +12,12 @@ from rich.console import Console
12
12
  from rich.panel import Panel
13
13
  from rich.table import Table
14
14
 
15
+ from ._storage import load_storage
15
16
 
16
- async def _db_stats(db_url: str) -> dict:
17
- from synth_ai.tracing_v3.storage.factory import StorageConfig, create_storage
18
17
 
19
- db = create_storage(StorageConfig(connection_string=db_url))
18
+ async def _db_stats(db_url: str) -> dict:
19
+ create_storage, storage_config = load_storage()
20
+ db = create_storage(storage_config(connection_string=db_url))
20
21
  await db.initialize()
21
22
  try:
22
23
  out: dict = {}