synth-ai 0.2.6.dev1__py3-none-any.whl → 0.4.3__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.
Files changed (738) hide show
  1. synth_ai/__init__.py +44 -24
  2. synth_ai/__main__.py +30 -3
  3. synth_ai/cli/__init__.py +103 -48
  4. synth_ai/cli/__main__.py +42 -0
  5. synth_ai/cli/_internal/__init__.py +5 -0
  6. synth_ai/cli/_internal/modal_wrapper.py +31 -0
  7. synth_ai/cli/_internal/storage.py +20 -0
  8. synth_ai/cli/_internal/typer_patch.py +47 -0
  9. synth_ai/cli/_internal/validate_task_app.py +29 -0
  10. synth_ai/cli/agents/__init__.py +17 -0
  11. synth_ai/cli/agents/claude.py +77 -0
  12. synth_ai/cli/agents/codex.py +265 -0
  13. synth_ai/cli/agents/opencode.py +253 -0
  14. synth_ai/cli/commands/__init__.py +18 -0
  15. synth_ai/cli/commands/artifacts/__init__.py +13 -0
  16. synth_ai/cli/commands/artifacts/client.py +119 -0
  17. synth_ai/cli/commands/artifacts/config.py +57 -0
  18. synth_ai/cli/commands/artifacts/core.py +24 -0
  19. synth_ai/cli/commands/artifacts/download.py +188 -0
  20. synth_ai/cli/commands/artifacts/export.py +186 -0
  21. synth_ai/cli/commands/artifacts/list.py +156 -0
  22. synth_ai/cli/commands/artifacts/parsing.py +250 -0
  23. synth_ai/cli/commands/artifacts/show.py +336 -0
  24. synth_ai/cli/commands/demo/__init__.py +3 -0
  25. synth_ai/cli/commands/demo/core.py +153 -0
  26. synth_ai/cli/commands/eval/__init__.py +10 -0
  27. synth_ai/cli/commands/eval/config.py +338 -0
  28. synth_ai/cli/commands/eval/core.py +256 -0
  29. synth_ai/cli/commands/eval/runner.py +704 -0
  30. synth_ai/cli/commands/eval/validation.py +60 -0
  31. synth_ai/cli/commands/filter/__init__.py +12 -0
  32. synth_ai/cli/commands/filter/core.py +424 -0
  33. synth_ai/cli/commands/filter/errors.py +55 -0
  34. synth_ai/cli/commands/filter/validation.py +77 -0
  35. synth_ai/cli/commands/help/__init__.py +185 -0
  36. synth_ai/cli/commands/help/core.py +72 -0
  37. synth_ai/cli/commands/scan/__init__.py +19 -0
  38. synth_ai/cli/commands/scan/cloudflare_scanner.py +403 -0
  39. synth_ai/cli/commands/scan/core.py +344 -0
  40. synth_ai/cli/commands/scan/health_checker.py +242 -0
  41. synth_ai/cli/commands/scan/local_scanner.py +278 -0
  42. synth_ai/cli/commands/scan/models.py +83 -0
  43. synth_ai/cli/commands/smoke/__init__.py +7 -0
  44. synth_ai/cli/commands/smoke/core.py +1428 -0
  45. synth_ai/cli/commands/status/__init__.py +3 -0
  46. synth_ai/cli/commands/status/client.py +91 -0
  47. synth_ai/cli/commands/status/config.py +12 -0
  48. synth_ai/cli/commands/status/errors.py +11 -0
  49. synth_ai/cli/commands/status/subcommands/__init__.py +3 -0
  50. synth_ai/cli/commands/status/subcommands/config.py +13 -0
  51. synth_ai/cli/commands/status/subcommands/files.py +34 -0
  52. synth_ai/cli/commands/status/subcommands/jobs.py +51 -0
  53. synth_ai/cli/commands/status/subcommands/models.py +35 -0
  54. synth_ai/cli/commands/status/subcommands/runs.py +34 -0
  55. synth_ai/cli/commands/status/subcommands/session.py +77 -0
  56. synth_ai/cli/commands/status/subcommands/summary.py +39 -0
  57. synth_ai/cli/commands/status/subcommands/utils.py +41 -0
  58. synth_ai/cli/commands/status/utils.py +23 -0
  59. synth_ai/cli/commands/train/__init__.py +53 -0
  60. synth_ai/cli/commands/train/core.py +22 -0
  61. synth_ai/cli/commands/train/errors.py +117 -0
  62. synth_ai/cli/commands/train/judge_schemas.py +201 -0
  63. synth_ai/cli/commands/train/judge_validation.py +305 -0
  64. synth_ai/cli/commands/train/prompt_learning_validation.py +633 -0
  65. synth_ai/cli/commands/train/validation.py +392 -0
  66. synth_ai/cli/demo_apps/__init__.py +10 -0
  67. synth_ai/cli/demo_apps/core/__init__.py +28 -0
  68. synth_ai/cli/demo_apps/core/cli.py +1735 -0
  69. synth_ai/cli/demo_apps/crafter/__init__.py +1 -0
  70. synth_ai/cli/demo_apps/crafter/crafter_fft_4b.toml +55 -0
  71. synth_ai/cli/demo_apps/crafter/grpo_crafter_task_app.py +186 -0
  72. synth_ai/cli/demo_apps/crafter/rl_from_base_qwen4b.toml +74 -0
  73. synth_ai/cli/demo_apps/demo_registry.py +176 -0
  74. synth_ai/cli/demo_apps/demo_task_apps/__init__.py +7 -0
  75. synth_ai/{demos → cli/demo_apps}/demo_task_apps/core.py +117 -51
  76. synth_ai/cli/demo_apps/demo_task_apps/crafter/__init__.py +1 -0
  77. synth_ai/cli/demo_apps/demo_task_apps/crafter/configs/crafter_fft_4b.toml +53 -0
  78. synth_ai/cli/demo_apps/demo_task_apps/crafter/configs/rl_from_base_qwen4b.toml +73 -0
  79. synth_ai/cli/demo_apps/demo_task_apps/crafter/grpo_crafter_task_app.py +185 -0
  80. synth_ai/cli/demo_apps/demo_task_apps/math/_common.py +16 -0
  81. synth_ai/{demos → cli/demo_apps}/demo_task_apps/math/app.py +2 -1
  82. synth_ai/cli/demo_apps/demo_task_apps/math/config.toml +73 -0
  83. synth_ai/{demos → cli/demo_apps}/demo_task_apps/math/deploy_modal.py +3 -6
  84. synth_ai/cli/demo_apps/demo_task_apps/math/modal_task_app.py +738 -0
  85. synth_ai/cli/demo_apps/demo_task_apps/math/task_app_entry.py +39 -0
  86. synth_ai/cli/demo_apps/math/__init__.py +1 -0
  87. synth_ai/cli/demo_apps/math/_common.py +16 -0
  88. synth_ai/cli/demo_apps/math/app.py +38 -0
  89. synth_ai/cli/demo_apps/math/config.toml +75 -0
  90. synth_ai/cli/demo_apps/math/deploy_modal.py +54 -0
  91. synth_ai/cli/demo_apps/math/modal_task_app.py +698 -0
  92. synth_ai/cli/demo_apps/math/task_app_entry.py +53 -0
  93. synth_ai/cli/demo_apps/mipro/main.py +271 -0
  94. synth_ai/cli/demo_apps/mipro/task_app.py +922 -0
  95. synth_ai/cli/demo_apps/mipro/train_cfg.toml +92 -0
  96. synth_ai/cli/demos/__init__.py +12 -0
  97. synth_ai/cli/demos/demo.py +32 -0
  98. synth_ai/cli/demos/rl_demo.py +254 -0
  99. synth_ai/cli/deploy.py +216 -0
  100. synth_ai/cli/infra/__init__.py +14 -0
  101. synth_ai/cli/{balance.py → infra/balance.py} +21 -3
  102. synth_ai/cli/infra/mcp.py +35 -0
  103. synth_ai/cli/infra/modal_app.py +36 -0
  104. synth_ai/cli/infra/setup.py +69 -0
  105. synth_ai/cli/infra/status.py +16 -0
  106. synth_ai/cli/infra/turso.py +77 -0
  107. synth_ai/cli/lib/__init__.py +10 -0
  108. synth_ai/cli/lib/agents.py +76 -0
  109. synth_ai/cli/lib/apps/modal_app.py +101 -0
  110. synth_ai/cli/lib/apps/task_app.py +642 -0
  111. synth_ai/cli/lib/bin.py +39 -0
  112. synth_ai/cli/lib/env.py +375 -0
  113. synth_ai/cli/lib/errors.py +85 -0
  114. synth_ai/cli/lib/modal.py +315 -0
  115. synth_ai/cli/lib/plotting.py +126 -0
  116. synth_ai/cli/lib/prompt_args.py +39 -0
  117. synth_ai/cli/lib/prompts.py +284 -0
  118. synth_ai/cli/lib/sqld.py +122 -0
  119. synth_ai/cli/lib/task_app_discovery.py +884 -0
  120. synth_ai/cli/lib/task_app_env.py +295 -0
  121. synth_ai/cli/lib/train_cfgs.py +300 -0
  122. synth_ai/cli/lib/tunnel_records.py +207 -0
  123. synth_ai/cli/local/__init__.py +14 -0
  124. synth_ai/cli/local/experiment_queue/__init__.py +72 -0
  125. synth_ai/cli/local/experiment_queue/api_schemas.py +221 -0
  126. synth_ai/cli/local/experiment_queue/celery_app.py +208 -0
  127. synth_ai/cli/local/experiment_queue/config.py +128 -0
  128. synth_ai/cli/local/experiment_queue/config_utils.py +272 -0
  129. synth_ai/cli/local/experiment_queue/database.py +175 -0
  130. synth_ai/cli/local/experiment_queue/dispatcher.py +119 -0
  131. synth_ai/cli/local/experiment_queue/models.py +231 -0
  132. synth_ai/cli/local/experiment_queue/progress_info.py +160 -0
  133. synth_ai/cli/local/experiment_queue/results.py +373 -0
  134. synth_ai/cli/local/experiment_queue/schemas.py +131 -0
  135. synth_ai/cli/local/experiment_queue/service.py +344 -0
  136. synth_ai/cli/local/experiment_queue/status.py +372 -0
  137. synth_ai/cli/local/experiment_queue/status_tracker.py +360 -0
  138. synth_ai/cli/local/experiment_queue/tasks.py +1984 -0
  139. synth_ai/cli/local/experiment_queue/trace_storage.py +65 -0
  140. synth_ai/cli/local/experiment_queue/validation.py +157 -0
  141. synth_ai/cli/local/session/__init__.py +92 -0
  142. synth_ai/cli/local/session/client.py +383 -0
  143. synth_ai/cli/local/session/constants.py +63 -0
  144. synth_ai/cli/local/session/exceptions.py +105 -0
  145. synth_ai/cli/local/session/manager.py +139 -0
  146. synth_ai/cli/local/session/models.py +89 -0
  147. synth_ai/cli/local/session/query.py +110 -0
  148. synth_ai/cli/root.py +150 -102
  149. synth_ai/cli/task_apps/__init__.py +37 -0
  150. synth_ai/cli/task_apps/commands.py +3145 -0
  151. synth_ai/cli/task_apps/deploy.py +7 -0
  152. synth_ai/cli/task_apps/list.py +26 -0
  153. synth_ai/cli/task_apps/main.py +36 -0
  154. synth_ai/cli/task_apps/modal_serve.py +11 -0
  155. synth_ai/cli/task_apps/serve.py +11 -0
  156. synth_ai/cli/training/__init__.py +8 -0
  157. synth_ai/cli/training/train.py +5 -0
  158. synth_ai/cli/training/train_cfg.py +34 -0
  159. synth_ai/cli/{watch.py → training/watch.py} +13 -18
  160. synth_ai/cli/turso.py +52 -0
  161. synth_ai/cli/utils/__init__.py +8 -0
  162. synth_ai/cli/utils/experiments.py +235 -0
  163. synth_ai/cli/utils/queue.py +504 -0
  164. synth_ai/cli/{recent.py → utils/recent.py} +13 -7
  165. synth_ai/cli/{traces.py → utils/traces.py} +9 -5
  166. synth_ai/contracts/__init__.py +67 -0
  167. synth_ai/core/__init__.py +100 -0
  168. synth_ai/core/_utils/__init__.py +54 -0
  169. synth_ai/core/_utils/base_url.py +10 -0
  170. synth_ai/core/_utils/http.py +10 -0
  171. synth_ai/core/_utils/prompts.py +14 -0
  172. synth_ai/core/_utils/task_app_state.py +12 -0
  173. synth_ai/core/_utils/user_config.py +10 -0
  174. synth_ai/core/apps/common.py +116 -0
  175. synth_ai/core/auth.py +95 -0
  176. synth_ai/core/cfgs.py +240 -0
  177. synth_ai/core/config/__init__.py +16 -0
  178. synth_ai/core/config/base.py +168 -0
  179. synth_ai/core/config/resolver.py +89 -0
  180. synth_ai/core/env.py +231 -0
  181. synth_ai/core/errors.py +126 -0
  182. synth_ai/core/http.py +230 -0
  183. synth_ai/core/integrations/__init__.py +11 -0
  184. synth_ai/core/integrations/cloudflare.py +1710 -0
  185. synth_ai/core/integrations/mcp/__init__.py +6 -0
  186. synth_ai/core/integrations/mcp/__main__.py +8 -0
  187. synth_ai/core/integrations/mcp/claude.py +36 -0
  188. synth_ai/core/integrations/mcp/main.py +254 -0
  189. synth_ai/core/integrations/mcp/setup.py +100 -0
  190. synth_ai/core/integrations/modal.py +277 -0
  191. synth_ai/core/json.py +72 -0
  192. synth_ai/core/log_filter.py +99 -0
  193. synth_ai/core/logging.py +82 -0
  194. synth_ai/core/paths.py +107 -0
  195. synth_ai/core/pricing.py +109 -0
  196. synth_ai/core/process.py +233 -0
  197. synth_ai/core/ssl.py +25 -0
  198. synth_ai/core/storage/__init__.py +71 -0
  199. synth_ai/core/task_app_state.py +318 -0
  200. synth_ai/core/telemetry.py +282 -0
  201. synth_ai/{tracing_v3 → core/tracing_v3}/__init__.py +5 -1
  202. synth_ai/{tracing_v3 → core/tracing_v3}/abstractions.py +21 -4
  203. synth_ai/core/tracing_v3/config.py +229 -0
  204. synth_ai/core/tracing_v3/constants.py +21 -0
  205. synth_ai/{tracing_v3 → core/tracing_v3}/db_config.py +42 -29
  206. synth_ai/{tracing_v3 → core/tracing_v3}/decorators.py +80 -45
  207. synth_ai/{tracing_v3 → core/tracing_v3}/examples/basic_usage.py +15 -9
  208. synth_ai/{tracing_v3 → core/tracing_v3}/hooks.py +6 -4
  209. synth_ai/{tracing_v3 → core/tracing_v3}/llm_call_record_helpers.py +161 -61
  210. synth_ai/{tracing_v3 → core/tracing_v3}/migration_helper.py +1 -2
  211. synth_ai/{tracing_v3 → core/tracing_v3}/replica_sync.py +12 -7
  212. synth_ai/core/tracing_v3/serialization.py +130 -0
  213. synth_ai/{tracing_v3 → core/tracing_v3}/session_tracer.py +88 -21
  214. synth_ai/{tracing_v3 → core/tracing_v3}/storage/base.py +99 -12
  215. synth_ai/core/tracing_v3/storage/config.py +109 -0
  216. synth_ai/{tracing_v3 → core/tracing_v3}/storage/factory.py +11 -9
  217. synth_ai/{tracing_v3 → core/tracing_v3}/storage/utils.py +15 -11
  218. synth_ai/core/tracing_v3/trace_utils.py +326 -0
  219. synth_ai/core/tracing_v3/turso/__init__.py +12 -0
  220. synth_ai/core/tracing_v3/turso/daemon.py +278 -0
  221. synth_ai/{tracing_v3 → core/tracing_v3}/turso/models.py +7 -3
  222. synth_ai/core/tracing_v3/turso/native_manager.py +1385 -0
  223. synth_ai/{tracing_v3 → core/tracing_v3}/utils.py +5 -4
  224. synth_ai/core/urls.py +18 -0
  225. synth_ai/core/user_config.py +137 -0
  226. synth_ai/core/uvicorn.py +222 -0
  227. synth_ai/data/__init__.py +83 -0
  228. synth_ai/data/enums.py +123 -0
  229. synth_ai/data/rewards.py +152 -0
  230. synth_ai/data/traces.py +35 -0
  231. synth_ai/products/__init__.py +6 -0
  232. synth_ai/products/graph_evolve/__init__.py +46 -0
  233. synth_ai/products/graph_evolve/client.py +226 -0
  234. synth_ai/products/graph_evolve/config.py +591 -0
  235. synth_ai/products/graph_evolve/converters/__init__.py +42 -0
  236. synth_ai/products/graph_evolve/converters/openai_sft.py +484 -0
  237. synth_ai/products/graph_evolve/examples/hotpotqa/config.toml +109 -0
  238. synth_ai/products/graph_evolve/run.py +222 -0
  239. synth_ai/products/graph_gepa/__init__.py +23 -0
  240. synth_ai/products/graph_gepa/converters/__init__.py +19 -0
  241. synth_ai/products/graph_gepa/converters/openai_sft.py +29 -0
  242. synth_ai/sdk/__init__.py +123 -0
  243. synth_ai/sdk/api/__init__.py +1 -0
  244. synth_ai/sdk/api/models/supported.py +514 -0
  245. synth_ai/sdk/api/research_agent/__init__.py +296 -0
  246. synth_ai/sdk/api/train/__init__.py +85 -0
  247. synth_ai/sdk/api/train/builders.py +895 -0
  248. synth_ai/sdk/api/train/cli.py +2199 -0
  249. synth_ai/sdk/api/train/config_finder.py +267 -0
  250. synth_ai/sdk/api/train/configs/__init__.py +65 -0
  251. synth_ai/sdk/api/train/configs/prompt_learning.py +1706 -0
  252. synth_ai/sdk/api/train/configs/rl.py +187 -0
  253. synth_ai/sdk/api/train/configs/sft.py +99 -0
  254. synth_ai/sdk/api/train/configs/shared.py +81 -0
  255. synth_ai/sdk/api/train/context_learning.py +312 -0
  256. synth_ai/sdk/api/train/env_resolver.py +418 -0
  257. synth_ai/sdk/api/train/graph_validators.py +216 -0
  258. synth_ai/sdk/api/train/graphgen.py +984 -0
  259. synth_ai/sdk/api/train/graphgen_models.py +823 -0
  260. synth_ai/sdk/api/train/graphgen_validators.py +109 -0
  261. synth_ai/sdk/api/train/local_api.py +10 -0
  262. synth_ai/sdk/api/train/pollers.py +124 -0
  263. synth_ai/sdk/api/train/progress/__init__.py +97 -0
  264. synth_ai/sdk/api/train/progress/dataclasses.py +569 -0
  265. synth_ai/sdk/api/train/progress/events.py +326 -0
  266. synth_ai/sdk/api/train/progress/results.py +428 -0
  267. synth_ai/sdk/api/train/progress/tracker.py +641 -0
  268. synth_ai/sdk/api/train/prompt_learning.py +469 -0
  269. synth_ai/sdk/api/train/rl.py +441 -0
  270. synth_ai/sdk/api/train/sft.py +396 -0
  271. synth_ai/sdk/api/train/summary.py +522 -0
  272. synth_ai/sdk/api/train/supported_algos.py +147 -0
  273. synth_ai/sdk/api/train/task_app.py +351 -0
  274. synth_ai/sdk/api/train/utils.py +279 -0
  275. synth_ai/sdk/api/train/validators.py +2424 -0
  276. synth_ai/sdk/graphs/__init__.py +15 -0
  277. synth_ai/sdk/graphs/completions.py +570 -0
  278. synth_ai/{inference → sdk/inference}/__init__.py +0 -1
  279. synth_ai/sdk/inference/client.py +128 -0
  280. synth_ai/sdk/jobs/__init__.py +16 -0
  281. synth_ai/sdk/jobs/client.py +371 -0
  282. synth_ai/sdk/judging/__init__.py +14 -0
  283. synth_ai/sdk/judging/base.py +24 -0
  284. synth_ai/sdk/judging/client.py +40 -0
  285. synth_ai/sdk/judging/schemas.py +222 -0
  286. synth_ai/sdk/judging/types.py +42 -0
  287. synth_ai/sdk/learning/__init__.py +99 -0
  288. synth_ai/sdk/learning/algorithms.py +14 -0
  289. synth_ai/{learning → sdk/learning}/client.py +121 -30
  290. synth_ai/sdk/learning/config.py +5 -0
  291. synth_ai/{learning → sdk/learning}/constants.py +0 -2
  292. synth_ai/sdk/learning/context_learning_client.py +531 -0
  293. synth_ai/sdk/learning/context_learning_types.py +292 -0
  294. synth_ai/sdk/learning/ft_client.py +7 -0
  295. synth_ai/{learning → sdk/learning}/health.py +15 -9
  296. synth_ai/{learning → sdk/learning}/jobs.py +44 -47
  297. synth_ai/sdk/learning/prompt_extraction.py +334 -0
  298. synth_ai/sdk/learning/prompt_learning_client.py +455 -0
  299. synth_ai/sdk/learning/prompt_learning_types.py +186 -0
  300. synth_ai/{rl → sdk/learning/rl}/__init__.py +13 -8
  301. synth_ai/{learning/rl_client.py → sdk/learning/rl/client.py} +89 -77
  302. synth_ai/sdk/learning/rl/config.py +31 -0
  303. synth_ai/{rl → sdk/learning/rl}/contracts.py +5 -14
  304. synth_ai/{rl → sdk/learning/rl}/env_keys.py +45 -16
  305. synth_ai/sdk/learning/rl/secrets.py +13 -0
  306. synth_ai/sdk/learning/rl_client.py +5 -0
  307. synth_ai/sdk/learning/sft/__init__.py +29 -0
  308. synth_ai/sdk/learning/sft/client.py +95 -0
  309. synth_ai/sdk/learning/sft/config.py +270 -0
  310. synth_ai/sdk/learning/sft/data.py +698 -0
  311. synth_ai/sdk/learning/sse.py +57 -0
  312. synth_ai/sdk/learning/validators.py +52 -0
  313. synth_ai/sdk/localapi/__init__.py +40 -0
  314. synth_ai/sdk/localapi/apps/__init__.py +28 -0
  315. synth_ai/sdk/localapi/client.py +10 -0
  316. synth_ai/sdk/localapi/contracts.py +10 -0
  317. synth_ai/sdk/localapi/helpers.py +519 -0
  318. synth_ai/sdk/localapi/rollouts.py +87 -0
  319. synth_ai/sdk/localapi/server.py +29 -0
  320. synth_ai/sdk/localapi/template.py +70 -0
  321. synth_ai/sdk/streaming/__init__.py +35 -0
  322. synth_ai/sdk/streaming/config.py +94 -0
  323. synth_ai/sdk/streaming/handlers.py +1997 -0
  324. synth_ai/sdk/streaming/streamer.py +713 -0
  325. synth_ai/sdk/streaming/types.py +112 -0
  326. synth_ai/sdk/task/__init__.py +164 -0
  327. synth_ai/sdk/task/apps/__init__.py +169 -0
  328. synth_ai/sdk/task/auth.py +165 -0
  329. synth_ai/sdk/task/client.py +175 -0
  330. synth_ai/sdk/task/config.py +257 -0
  331. synth_ai/sdk/task/contracts.py +219 -0
  332. synth_ai/sdk/task/datasets.py +108 -0
  333. synth_ai/sdk/task/errors.py +50 -0
  334. synth_ai/sdk/task/health.py +34 -0
  335. synth_ai/sdk/task/in_process.py +1190 -0
  336. synth_ai/sdk/task/in_process_runner.py +314 -0
  337. synth_ai/sdk/task/inference_api.py +299 -0
  338. synth_ai/sdk/task/json.py +111 -0
  339. synth_ai/sdk/task/proxy.py +287 -0
  340. synth_ai/sdk/task/rubrics/__init__.py +55 -0
  341. synth_ai/sdk/task/rubrics/loaders.py +156 -0
  342. synth_ai/sdk/task/rubrics/models.py +57 -0
  343. synth_ai/sdk/task/rubrics/scoring.py +116 -0
  344. synth_ai/sdk/task/rubrics/strict.py +149 -0
  345. synth_ai/sdk/task/rubrics.py +219 -0
  346. synth_ai/sdk/task/server.py +631 -0
  347. synth_ai/sdk/task/trace_correlation_helpers.py +539 -0
  348. synth_ai/sdk/task/tracing_utils.py +95 -0
  349. synth_ai/sdk/task/validators.py +441 -0
  350. synth_ai/sdk/task/vendors.py +59 -0
  351. synth_ai/sdk/training/__init__.py +102 -0
  352. synth_ai/sdk/tunnels/__init__.py +83 -0
  353. synth_ai/sdk/tunnels/cleanup.py +83 -0
  354. synth_ai/sdk/tunnels/ports.py +120 -0
  355. synth_ai/utils/__init__.py +213 -0
  356. synth_ai-0.4.3.dist-info/METADATA +262 -0
  357. synth_ai-0.4.3.dist-info/RECORD +370 -0
  358. {synth_ai-0.2.6.dev1.dist-info → synth_ai-0.4.3.dist-info}/entry_points.txt +0 -1
  359. synth_ai/cli/calc.py +0 -69
  360. synth_ai/cli/demo.py +0 -131
  361. synth_ai/cli/legacy_root_backup.py +0 -470
  362. synth_ai/cli/man.py +0 -106
  363. synth_ai/cli/rl_demo.py +0 -137
  364. synth_ai/cli/status.py +0 -133
  365. synth_ai/config/base_url.py +0 -98
  366. synth_ai/core/experiment.py +0 -15
  367. synth_ai/core/system.py +0 -15
  368. synth_ai/demos/core/__init__.py +0 -1
  369. synth_ai/demos/core/cli.py +0 -685
  370. synth_ai/demos/demo_task_apps/__init__.py +0 -1
  371. synth_ai/demos/demo_task_apps/math/config.toml +0 -44
  372. synth_ai/demos/demo_task_apps/math/deploy_task_app.sh +0 -22
  373. synth_ai/environments/__init__.py +0 -31
  374. synth_ai/environments/environment/__init__.py +0 -1
  375. synth_ai/environments/environment/artifacts/__init__.py +0 -1
  376. synth_ai/environments/environment/artifacts/base.py +0 -52
  377. synth_ai/environments/environment/core.py +0 -67
  378. synth_ai/environments/environment/db/__init__.py +0 -1
  379. synth_ai/environments/environment/db/sqlite.py +0 -45
  380. synth_ai/environments/environment/registry.py +0 -233
  381. synth_ai/environments/environment/resources/sqlite.py +0 -45
  382. synth_ai/environments/environment/results.py +0 -1
  383. synth_ai/environments/environment/rewards/__init__.py +0 -1
  384. synth_ai/environments/environment/rewards/core.py +0 -29
  385. synth_ai/environments/environment/shared_engine.py +0 -26
  386. synth_ai/environments/environment/tools/__init__.py +0 -200
  387. synth_ai/environments/examples/__init__.py +0 -1
  388. synth_ai/environments/examples/bandit/__init__.py +0 -33
  389. synth_ai/environments/examples/bandit/engine.py +0 -294
  390. synth_ai/environments/examples/bandit/environment.py +0 -194
  391. synth_ai/environments/examples/bandit/taskset.py +0 -200
  392. synth_ai/environments/examples/crafter_classic/__init__.py +0 -8
  393. synth_ai/environments/examples/crafter_classic/agent_demos/analyze_semantic_words_markdown.py +0 -250
  394. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_comprehensive_evaluation.py +0 -59
  395. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_evaluation_browser.py +0 -152
  396. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_evaluation_config.toml +0 -24
  397. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_evaluation_framework.py +0 -1194
  398. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/crafter_synth_config.toml +0 -56
  399. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/filter_config_modal.toml +0 -32
  400. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/filter_traces_sft_turso.py +0 -724
  401. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/kick_off_ft_modal.py +0 -384
  402. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/analyze_action_results.py +0 -53
  403. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/analyze_agent_actions.py +0 -178
  404. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/analyze_latest_run.py +0 -222
  405. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/analyze_lm_traces.py +0 -183
  406. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/analyze_no_rewards.py +0 -210
  407. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/analyze_trace_issue.py +0 -206
  408. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/check_db_schema.py +0 -49
  409. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/check_latest_results.py +0 -64
  410. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/debug_agent_responses.py +0 -88
  411. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_modal_ft/old/quick_trace_check.py +0 -77
  412. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/compare_experiments.py +0 -324
  413. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/filter_traces_sft_turso.py +0 -580
  414. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/kick_off_ft_oai.py +0 -362
  415. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/multi_model_config.toml +0 -49
  416. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/old/analyze_enhanced_hooks.py +0 -332
  417. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/old/analyze_hook_events.py +0 -97
  418. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/old/analyze_hook_results.py +0 -217
  419. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/old/check_hook_storage.py +0 -87
  420. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/old/check_seeds.py +0 -88
  421. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/old/compare_seed_performance.py +0 -195
  422. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/old/custom_eval_pipelines.py +0 -400
  423. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/old/plot_hook_frequency.py +0 -195
  424. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/old/seed_analysis_summary.py +0 -56
  425. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_openai_ft/run_rollouts_for_models_and_compare_v3.py +0 -858
  426. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_quick_evaluation.py +0 -52
  427. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_react_agent.py +0 -874
  428. synth_ai/environments/examples/crafter_classic/agent_demos/crafter_trace_evaluation.py +0 -1412
  429. synth_ai/environments/examples/crafter_classic/agent_demos/example_v3_usage.py +0 -216
  430. synth_ai/environments/examples/crafter_classic/agent_demos/old/compare_traces.py +0 -296
  431. synth_ai/environments/examples/crafter_classic/agent_demos/old/crafter_comprehensive_evaluation.py +0 -58
  432. synth_ai/environments/examples/crafter_classic/agent_demos/old/crafter_env_serialization.py +0 -464
  433. synth_ai/environments/examples/crafter_classic/agent_demos/old/crafter_evaluation_browser.py +0 -152
  434. synth_ai/environments/examples/crafter_classic/agent_demos/old/crafter_quick_evaluation.py +0 -51
  435. synth_ai/environments/examples/crafter_classic/agent_demos/old/crafter_trace_evaluation.py +0 -1412
  436. synth_ai/environments/examples/crafter_classic/agent_demos/old/debug_player_loss.py +0 -112
  437. synth_ai/environments/examples/crafter_classic/agent_demos/old/diagnose_service.py +0 -203
  438. synth_ai/environments/examples/crafter_classic/agent_demos/old/diagnose_slowness.py +0 -305
  439. synth_ai/environments/examples/crafter_classic/agent_demos/old/eval_by_difficulty.py +0 -126
  440. synth_ai/environments/examples/crafter_classic/agent_demos/old/eval_example.py +0 -94
  441. synth_ai/environments/examples/crafter_classic/agent_demos/old/explore_saved_states.py +0 -142
  442. synth_ai/environments/examples/crafter_classic/agent_demos/old/filter_traces_sft.py +0 -26
  443. synth_ai/environments/examples/crafter_classic/agent_demos/old/filter_traces_sft_OLD.py +0 -984
  444. synth_ai/environments/examples/crafter_classic/agent_demos/old/generate_ft_data_gemini.py +0 -724
  445. synth_ai/environments/examples/crafter_classic/agent_demos/old/generate_ft_data_modal.py +0 -386
  446. synth_ai/environments/examples/crafter_classic/agent_demos/old/generate_ft_metadata.py +0 -205
  447. synth_ai/environments/examples/crafter_classic/agent_demos/old/kick_off_ft_gemini.py +0 -150
  448. synth_ai/environments/examples/crafter_classic/agent_demos/old/kick_off_ft_modal.py +0 -283
  449. synth_ai/environments/examples/crafter_classic/agent_demos/old/prepare_vertex_ft.py +0 -280
  450. synth_ai/environments/examples/crafter_classic/agent_demos/old/profile_env_slowness.py +0 -456
  451. synth_ai/environments/examples/crafter_classic/agent_demos/old/replicate_issue.py +0 -166
  452. synth_ai/environments/examples/crafter_classic/agent_demos/old/run_and_eval.py +0 -102
  453. synth_ai/environments/examples/crafter_classic/agent_demos/old/run_comparison.py +0 -128
  454. synth_ai/environments/examples/crafter_classic/agent_demos/old/run_qwen_rollouts.py +0 -655
  455. synth_ai/environments/examples/crafter_classic/agent_demos/old/trace_eval_OLD.py +0 -202
  456. synth_ai/environments/examples/crafter_classic/agent_demos/old/validate_openai_format.py +0 -166
  457. synth_ai/environments/examples/crafter_classic/config_logging.py +0 -111
  458. synth_ai/environments/examples/crafter_classic/debug_translation.py +0 -0
  459. synth_ai/environments/examples/crafter_classic/engine.py +0 -579
  460. synth_ai/environments/examples/crafter_classic/engine_deterministic_patch.py +0 -64
  461. synth_ai/environments/examples/crafter_classic/engine_helpers/action_map.py +0 -6
  462. synth_ai/environments/examples/crafter_classic/engine_helpers/serialization.py +0 -75
  463. synth_ai/environments/examples/crafter_classic/engine_serialization_patch_v3.py +0 -267
  464. synth_ai/environments/examples/crafter_classic/environment.py +0 -404
  465. synth_ai/environments/examples/crafter_classic/taskset.py +0 -233
  466. synth_ai/environments/examples/crafter_classic/trace_hooks_v3.py +0 -228
  467. synth_ai/environments/examples/crafter_classic/world_config_patch_simple.py +0 -299
  468. synth_ai/environments/examples/crafter_custom/__init__.py +0 -4
  469. synth_ai/environments/examples/crafter_custom/agent_demos/__init__.py +0 -1
  470. synth_ai/environments/examples/crafter_custom/agent_demos/trace_eval.py +0 -202
  471. synth_ai/environments/examples/crafter_custom/crafter/__init__.py +0 -7
  472. synth_ai/environments/examples/crafter_custom/crafter/config.py +0 -182
  473. synth_ai/environments/examples/crafter_custom/crafter/constants.py +0 -8
  474. synth_ai/environments/examples/crafter_custom/crafter/engine.py +0 -269
  475. synth_ai/environments/examples/crafter_custom/crafter/env.py +0 -262
  476. synth_ai/environments/examples/crafter_custom/crafter/objects.py +0 -417
  477. synth_ai/environments/examples/crafter_custom/crafter/recorder.py +0 -187
  478. synth_ai/environments/examples/crafter_custom/crafter/worldgen.py +0 -118
  479. synth_ai/environments/examples/crafter_custom/dataset_builder.py +0 -373
  480. synth_ai/environments/examples/crafter_custom/environment.py +0 -312
  481. synth_ai/environments/examples/crafter_custom/old/analyze_diamond_issue.py +0 -159
  482. synth_ai/environments/examples/crafter_custom/old/analyze_diamond_spawning.py +0 -158
  483. synth_ai/environments/examples/crafter_custom/old/compare_worlds.py +0 -71
  484. synth_ai/environments/examples/crafter_custom/old/dataset_stats.py +0 -105
  485. synth_ai/environments/examples/crafter_custom/old/diamond_spawning_summary.py +0 -119
  486. synth_ai/environments/examples/crafter_custom/old/example_dataset_usage.py +0 -52
  487. synth_ai/environments/examples/crafter_custom/run_dataset.py +0 -305
  488. synth_ai/environments/examples/enron/art_helpers/email_search_tools.py +0 -156
  489. synth_ai/environments/examples/enron/art_helpers/local_email_db.py +0 -281
  490. synth_ai/environments/examples/enron/art_helpers/types_enron.py +0 -25
  491. synth_ai/environments/examples/enron/engine.py +0 -295
  492. synth_ai/environments/examples/enron/environment.py +0 -166
  493. synth_ai/environments/examples/enron/taskset.py +0 -112
  494. synth_ai/environments/examples/enron/units/keyword_stats.py +0 -112
  495. synth_ai/environments/examples/minigrid/__init__.py +0 -48
  496. synth_ai/environments/examples/minigrid/agent_demos/minigrid_evaluation_framework.py +0 -1188
  497. synth_ai/environments/examples/minigrid/agent_demos/minigrid_quick_evaluation.py +0 -48
  498. synth_ai/environments/examples/minigrid/agent_demos/minigrid_react_agent.py +0 -562
  499. synth_ai/environments/examples/minigrid/agent_demos/minigrid_trace_evaluation.py +0 -221
  500. synth_ai/environments/examples/minigrid/engine.py +0 -589
  501. synth_ai/environments/examples/minigrid/environment.py +0 -274
  502. synth_ai/environments/examples/minigrid/environment_mapping.py +0 -242
  503. synth_ai/environments/examples/minigrid/puzzle_loader.py +0 -417
  504. synth_ai/environments/examples/minigrid/taskset.py +0 -583
  505. synth_ai/environments/examples/nethack/__init__.py +0 -7
  506. synth_ai/environments/examples/nethack/achievements.py +0 -337
  507. synth_ai/environments/examples/nethack/agent_demos/nethack_evaluation_framework.py +0 -981
  508. synth_ai/environments/examples/nethack/agent_demos/nethack_quick_evaluation.py +0 -74
  509. synth_ai/environments/examples/nethack/agent_demos/nethack_react_agent.py +0 -831
  510. synth_ai/environments/examples/nethack/engine.py +0 -739
  511. synth_ai/environments/examples/nethack/environment.py +0 -256
  512. synth_ai/environments/examples/nethack/helpers/__init__.py +0 -41
  513. synth_ai/environments/examples/nethack/helpers/action_mapping.py +0 -301
  514. synth_ai/environments/examples/nethack/helpers/nle_wrapper.py +0 -402
  515. synth_ai/environments/examples/nethack/helpers/observation_utils.py +0 -433
  516. synth_ai/environments/examples/nethack/helpers/recording_wrapper.py +0 -200
  517. synth_ai/environments/examples/nethack/helpers/trajectory_recorder.py +0 -269
  518. synth_ai/environments/examples/nethack/helpers/visualization/replay_viewer.py +0 -308
  519. synth_ai/environments/examples/nethack/helpers/visualization/visualizer.py +0 -431
  520. synth_ai/environments/examples/nethack/taskset.py +0 -323
  521. synth_ai/environments/examples/red/__init__.py +0 -7
  522. synth_ai/environments/examples/red/agent_demos/__init__.py +0 -1
  523. synth_ai/environments/examples/red/config_logging.py +0 -110
  524. synth_ai/environments/examples/red/engine.py +0 -694
  525. synth_ai/environments/examples/red/engine_helpers/__init__.py +0 -1
  526. synth_ai/environments/examples/red/engine_helpers/memory_map.py +0 -28
  527. synth_ai/environments/examples/red/engine_helpers/reward_components.py +0 -276
  528. synth_ai/environments/examples/red/engine_helpers/reward_library/__init__.py +0 -142
  529. synth_ai/environments/examples/red/engine_helpers/reward_library/adaptive_rewards.py +0 -57
  530. synth_ai/environments/examples/red/engine_helpers/reward_library/battle_rewards.py +0 -284
  531. synth_ai/environments/examples/red/engine_helpers/reward_library/composite_rewards.py +0 -150
  532. synth_ai/environments/examples/red/engine_helpers/reward_library/economy_rewards.py +0 -138
  533. synth_ai/environments/examples/red/engine_helpers/reward_library/efficiency_rewards.py +0 -57
  534. synth_ai/environments/examples/red/engine_helpers/reward_library/exploration_rewards.py +0 -331
  535. synth_ai/environments/examples/red/engine_helpers/reward_library/novelty_rewards.py +0 -121
  536. synth_ai/environments/examples/red/engine_helpers/reward_library/pallet_town_rewards.py +0 -559
  537. synth_ai/environments/examples/red/engine_helpers/reward_library/pokemon_rewards.py +0 -313
  538. synth_ai/environments/examples/red/engine_helpers/reward_library/social_rewards.py +0 -148
  539. synth_ai/environments/examples/red/engine_helpers/reward_library/story_rewards.py +0 -247
  540. synth_ai/environments/examples/red/engine_helpers/screen_analysis.py +0 -368
  541. synth_ai/environments/examples/red/engine_helpers/state_extraction.py +0 -140
  542. synth_ai/environments/examples/red/environment.py +0 -238
  543. synth_ai/environments/examples/red/taskset.py +0 -79
  544. synth_ai/environments/examples/red/units/__init__.py +0 -1
  545. synth_ai/environments/examples/sokoban/__init__.py +0 -1
  546. synth_ai/environments/examples/sokoban/agent_demos/sokoban_full_eval.py +0 -899
  547. synth_ai/environments/examples/sokoban/engine.py +0 -678
  548. synth_ai/environments/examples/sokoban/engine_helpers/__init__.py +0 -1
  549. synth_ai/environments/examples/sokoban/engine_helpers/room_utils.py +0 -657
  550. synth_ai/environments/examples/sokoban/engine_helpers/vendored/__init__.py +0 -18
  551. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/__init__.py +0 -3
  552. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/boxoban_env.py +0 -131
  553. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/render_utils.py +0 -370
  554. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/room_utils.py +0 -332
  555. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env.py +0 -306
  556. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_fixed_targets.py +0 -67
  557. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_pull.py +0 -115
  558. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_two_player.py +0 -123
  559. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_variations.py +0 -394
  560. synth_ai/environments/examples/sokoban/environment.py +0 -229
  561. synth_ai/environments/examples/sokoban/generate_verified_puzzles.py +0 -440
  562. synth_ai/environments/examples/sokoban/puzzle_loader.py +0 -312
  563. synth_ai/environments/examples/sokoban/taskset.py +0 -428
  564. synth_ai/environments/examples/sokoban/units/astar_common.py +0 -95
  565. synth_ai/environments/examples/tictactoe/__init__.py +0 -1
  566. synth_ai/environments/examples/tictactoe/engine.py +0 -368
  567. synth_ai/environments/examples/tictactoe/environment.py +0 -240
  568. synth_ai/environments/examples/tictactoe/taskset.py +0 -215
  569. synth_ai/environments/examples/verilog/__init__.py +0 -10
  570. synth_ai/environments/examples/verilog/engine.py +0 -329
  571. synth_ai/environments/examples/verilog/environment.py +0 -350
  572. synth_ai/environments/examples/verilog/taskset.py +0 -420
  573. synth_ai/environments/examples/wordle/__init__.py +0 -29
  574. synth_ai/environments/examples/wordle/engine.py +0 -398
  575. synth_ai/environments/examples/wordle/environment.py +0 -159
  576. synth_ai/environments/examples/wordle/helpers/generate_instances_wordfreq.py +0 -75
  577. synth_ai/environments/examples/wordle/taskset.py +0 -230
  578. synth_ai/environments/reproducibility/core.py +0 -42
  579. synth_ai/environments/reproducibility/helpers.py +0 -0
  580. synth_ai/environments/reproducibility/tree.py +0 -364
  581. synth_ai/environments/service/app.py +0 -91
  582. synth_ai/environments/service/core_routes.py +0 -1020
  583. synth_ai/environments/service/external_registry.py +0 -56
  584. synth_ai/environments/service/registry.py +0 -9
  585. synth_ai/environments/stateful/__init__.py +0 -1
  586. synth_ai/environments/stateful/core.py +0 -163
  587. synth_ai/environments/stateful/engine.py +0 -21
  588. synth_ai/environments/stateful/state.py +0 -7
  589. synth_ai/environments/tasks/api.py +0 -19
  590. synth_ai/environments/tasks/core.py +0 -80
  591. synth_ai/environments/tasks/filters.py +0 -41
  592. synth_ai/environments/tasks/utils.py +0 -91
  593. synth_ai/environments/v0_observability/history.py +0 -3
  594. synth_ai/environments/v0_observability/log.py +0 -2
  595. synth_ai/evals/base.py +0 -15
  596. synth_ai/experimental/synth_oss.py +0 -446
  597. synth_ai/http.py +0 -102
  598. synth_ai/inference/client.py +0 -20
  599. synth_ai/install_sqld.sh +0 -40
  600. synth_ai/jobs/client.py +0 -246
  601. synth_ai/learning/__init__.py +0 -24
  602. synth_ai/learning/config.py +0 -43
  603. synth_ai/learning/filtering.py +0 -0
  604. synth_ai/learning/ft_client.py +0 -59
  605. synth_ai/learning/offline/dpo.py +0 -0
  606. synth_ai/learning/offline/providers.py +0 -7
  607. synth_ai/learning/offline/sft.py +0 -0
  608. synth_ai/learning/offline/shared.py +0 -0
  609. synth_ai/learning/online/grpo.py +0 -0
  610. synth_ai/learning/online/irft.py +0 -0
  611. synth_ai/learning/prompts/banking77_injection_eval.py +0 -168
  612. synth_ai/learning/prompts/gepa.py +0 -0
  613. synth_ai/learning/prompts/hello_world_in_context_injection_ex.py +0 -213
  614. synth_ai/learning/prompts/mipro.py +0 -289
  615. synth_ai/learning/prompts/random_search.py +0 -246
  616. synth_ai/learning/prompts/run_mipro_banking77.py +0 -172
  617. synth_ai/learning/prompts/run_random_search_banking77.py +0 -324
  618. synth_ai/learning/sse.py +0 -58
  619. synth_ai/learning/validators.py +0 -48
  620. synth_ai/lm/__init__.py +0 -51
  621. synth_ai/lm/caching/constants.py +0 -6
  622. synth_ai/lm/caching/dbs.py +0 -0
  623. synth_ai/lm/caching/ephemeral.py +0 -102
  624. synth_ai/lm/caching/handler.py +0 -137
  625. synth_ai/lm/caching/initialize.py +0 -11
  626. synth_ai/lm/caching/persistent.py +0 -114
  627. synth_ai/lm/config.py +0 -110
  628. synth_ai/lm/constants.py +0 -32
  629. synth_ai/lm/core/__init__.py +0 -8
  630. synth_ai/lm/core/all.py +0 -73
  631. synth_ai/lm/core/exceptions.py +0 -7
  632. synth_ai/lm/core/main.py +0 -319
  633. synth_ai/lm/core/main_v3.py +0 -594
  634. synth_ai/lm/core/synth_models.py +0 -48
  635. synth_ai/lm/core/vendor_clients.py +0 -188
  636. synth_ai/lm/cost/__init__.py +0 -0
  637. synth_ai/lm/cost/monitor.py +0 -1
  638. synth_ai/lm/cost/statefulness.py +0 -1
  639. synth_ai/lm/injection.py +0 -80
  640. synth_ai/lm/overrides.py +0 -206
  641. synth_ai/lm/provider_support/__init__.py +0 -8
  642. synth_ai/lm/provider_support/anthropic.py +0 -972
  643. synth_ai/lm/provider_support/openai.py +0 -1139
  644. synth_ai/lm/provider_support/suppress_logging.py +0 -31
  645. synth_ai/lm/structured_outputs/__init__.py +0 -0
  646. synth_ai/lm/structured_outputs/handler.py +0 -440
  647. synth_ai/lm/structured_outputs/inject.py +0 -297
  648. synth_ai/lm/structured_outputs/rehabilitate.py +0 -185
  649. synth_ai/lm/tools/__init__.py +0 -3
  650. synth_ai/lm/tools/base.py +0 -172
  651. synth_ai/lm/unified_interface.py +0 -202
  652. synth_ai/lm/vendors/__init__.py +0 -0
  653. synth_ai/lm/vendors/base.py +0 -81
  654. synth_ai/lm/vendors/core/__init__.py +0 -0
  655. synth_ai/lm/vendors/core/anthropic_api.py +0 -387
  656. synth_ai/lm/vendors/core/gemini_api.py +0 -292
  657. synth_ai/lm/vendors/core/mistral_api.py +0 -322
  658. synth_ai/lm/vendors/core/openai_api.py +0 -220
  659. synth_ai/lm/vendors/core/synth_dev_api.py +0 -0
  660. synth_ai/lm/vendors/local/__init__.py +0 -0
  661. synth_ai/lm/vendors/local/ollama.py +0 -0
  662. synth_ai/lm/vendors/openai_standard.py +0 -780
  663. synth_ai/lm/vendors/openai_standard_responses.py +0 -256
  664. synth_ai/lm/vendors/retries.py +0 -22
  665. synth_ai/lm/vendors/supported/__init__.py +0 -0
  666. synth_ai/lm/vendors/supported/custom_endpoint.py +0 -417
  667. synth_ai/lm/vendors/supported/deepseek.py +0 -69
  668. synth_ai/lm/vendors/supported/grok.py +0 -75
  669. synth_ai/lm/vendors/supported/groq.py +0 -16
  670. synth_ai/lm/vendors/supported/ollama.py +0 -15
  671. synth_ai/lm/vendors/supported/openrouter.py +0 -74
  672. synth_ai/lm/vendors/supported/together.py +0 -11
  673. synth_ai/lm/vendors/synth_client.py +0 -808
  674. synth_ai/lm/warmup.py +0 -186
  675. synth_ai/rl/secrets.py +0 -19
  676. synth_ai/scripts/verify_rewards.py +0 -100
  677. synth_ai/task/__init__.py +0 -10
  678. synth_ai/task/contracts.py +0 -120
  679. synth_ai/task/health.py +0 -28
  680. synth_ai/task/validators.py +0 -12
  681. synth_ai/tracing/__init__.py +0 -30
  682. synth_ai/tracing_v1/__init__.py +0 -33
  683. synth_ai/tracing_v3/config.py +0 -84
  684. synth_ai/tracing_v3/storage/config.py +0 -62
  685. synth_ai/tracing_v3/turso/__init__.py +0 -25
  686. synth_ai/tracing_v3/turso/daemon.py +0 -144
  687. synth_ai/tracing_v3/turso/manager.py +0 -760
  688. synth_ai/v0/tracing/__init__.py +0 -0
  689. synth_ai/v0/tracing/abstractions.py +0 -224
  690. synth_ai/v0/tracing/base_client.py +0 -91
  691. synth_ai/v0/tracing/client_manager.py +0 -131
  692. synth_ai/v0/tracing/config.py +0 -140
  693. synth_ai/v0/tracing/context.py +0 -146
  694. synth_ai/v0/tracing/decorators.py +0 -680
  695. synth_ai/v0/tracing/events/__init__.py +0 -0
  696. synth_ai/v0/tracing/events/manage.py +0 -147
  697. synth_ai/v0/tracing/events/scope.py +0 -86
  698. synth_ai/v0/tracing/events/store.py +0 -228
  699. synth_ai/v0/tracing/immediate_client.py +0 -151
  700. synth_ai/v0/tracing/local.py +0 -18
  701. synth_ai/v0/tracing/log_client_base.py +0 -73
  702. synth_ai/v0/tracing/retry_queue.py +0 -186
  703. synth_ai/v0/tracing/trackers.py +0 -515
  704. synth_ai/v0/tracing/upload.py +0 -510
  705. synth_ai/v0/tracing/utils.py +0 -9
  706. synth_ai/v0/tracing_v1/__init__.py +0 -16
  707. synth_ai/v0/tracing_v1/abstractions.py +0 -224
  708. synth_ai/v0/tracing_v1/base_client.py +0 -91
  709. synth_ai/v0/tracing_v1/client_manager.py +0 -131
  710. synth_ai/v0/tracing_v1/config.py +0 -140
  711. synth_ai/v0/tracing_v1/context.py +0 -146
  712. synth_ai/v0/tracing_v1/decorators.py +0 -701
  713. synth_ai/v0/tracing_v1/events/__init__.py +0 -0
  714. synth_ai/v0/tracing_v1/events/manage.py +0 -147
  715. synth_ai/v0/tracing_v1/events/scope.py +0 -86
  716. synth_ai/v0/tracing_v1/events/store.py +0 -228
  717. synth_ai/v0/tracing_v1/immediate_client.py +0 -151
  718. synth_ai/v0/tracing_v1/local.py +0 -18
  719. synth_ai/v0/tracing_v1/log_client_base.py +0 -73
  720. synth_ai/v0/tracing_v1/retry_queue.py +0 -186
  721. synth_ai/v0/tracing_v1/trackers.py +0 -515
  722. synth_ai/v0/tracing_v1/upload.py +0 -525
  723. synth_ai/v0/tracing_v1/utils.py +0 -9
  724. synth_ai/zyk/__init__.py +0 -30
  725. synth_ai-0.2.6.dev1.dist-info/METADATA +0 -106
  726. synth_ai-0.2.6.dev1.dist-info/RECORD +0 -416
  727. /synth_ai/{demos → cli/demo_apps}/demo_task_apps/math/__init__.py +0 -0
  728. /synth_ai/{lm/caching → core/apps}/__init__.py +0 -0
  729. /synth_ai/{tracing_v3 → core/tracing_v3}/lm_call_record_abstractions.py +0 -0
  730. /synth_ai/{tracing_v3 → core/tracing_v3}/storage/__init__.py +0 -0
  731. /synth_ai/{tracing_v3 → core/tracing_v3}/storage/exceptions.py +0 -0
  732. /synth_ai/{tracing_v3 → core/tracing_v3}/storage/types.py +0 -0
  733. /synth_ai/{compound/cais.py → py.typed} +0 -0
  734. /synth_ai/{learning → sdk/learning}/core.py +0 -0
  735. /synth_ai/{learning → sdk/learning}/gateway.py +0 -0
  736. {synth_ai-0.2.6.dev1.dist-info → synth_ai-0.4.3.dist-info}/WHEEL +0 -0
  737. {synth_ai-0.2.6.dev1.dist-info → synth_ai-0.4.3.dist-info}/licenses/LICENSE +0 -0
  738. {synth_ai-0.2.6.dev1.dist-info → synth_ai-0.4.3.dist-info}/top_level.txt +0 -0
@@ -1,981 +0,0 @@
1
- """
2
- NetHack Evaluation Framework
3
- ============================
4
- Provides detailed metrics, trajectory analysis, and achievement statistics for NetHack.
5
- Mirrors the Crafter evaluation structure but adapted for NetHack specifics.
6
- """
7
-
8
- import asyncio
9
- import json
10
- import math
11
- import os
12
- import time
13
- import uuid
14
- from collections import defaultdict
15
- from dataclasses import asdict, dataclass
16
- from typing import Any, Dict, List, Optional, Set, Tuple
17
-
18
- import pandas as pd
19
- from src.synth_env.examples.nethack.achievements import NetHackAchievements
20
- from src.synth_env.examples.nethack.agent_demos.test_synth_react import (
21
- NetHackReActAgent,
22
- )
23
- from src.synth_env.examples.nethack.engine import NetHackObservationCallable
24
-
25
- # NetHack specific imports
26
- from src.synth_env.examples.nethack.environment import NetHackEnvironment
27
- from src.synth_env.examples.nethack.taskset import (
28
- NetHackTaskInstance,
29
- NetHackTaskInstanceMetadata,
30
- )
31
- from src.synth_env.tasks.core import Impetus, Intent
32
- from synth_ai.zyk import LM
33
- from tqdm import tqdm
34
-
35
- # Load achievements mapping for BALROG scoring
36
- _achievements_path = os.path.join(os.path.dirname(__file__), "..", "helpers", "achievements.json")
37
- with open(_achievements_path, "r") as f:
38
- BALROG_ACHIEVEMENTS = json.load(f)["3.4.3"]
39
-
40
- # Achievement categories based on difficulty/complexity
41
- ACHIEVEMENT_CATEGORIES = {
42
- "basic": [
43
- "first_kill",
44
- "first_spell_cast",
45
- "first_prayer",
46
- "survived_100_turns",
47
- "reached_dlvl_2",
48
- "reached_dlvl_5",
49
- "killed_10_monsters",
50
- ],
51
- "intermediate": [
52
- "reached_dlvl_10",
53
- "reached_dlvl_20",
54
- "killed_50_monsters",
55
- "killed_100_monsters",
56
- "collected_1000_gold",
57
- "reached_level_5",
58
- "reached_level_10",
59
- "reached_minetown",
60
- ],
61
- "advanced": [
62
- "reached_dlvl_30",
63
- "reached_castle",
64
- "got_quest",
65
- "completed_quest",
66
- "reached_level_20",
67
- "collected_10000_gold",
68
- "found_artifact",
69
- "reached_mines_end",
70
- ],
71
- }
72
-
73
- # Get all achievements from NetHackAchievements
74
- _sample_achievements = NetHackAchievements()
75
- ALL_ACHIEVEMENTS = list(_sample_achievements.get_unlocked_achievements().keys())
76
-
77
- TERMINATION_REASONS = ["timeout", "death", "agent_quit", "environment_error"]
78
-
79
- # SOTA scores (NetHack doesn't have published Hafner scores, only BALROG)
80
- BALROG_SOTA_SCORES = {
81
- "balrog_leaderboard": {
82
- # TODO: Add real BALROG leaderboard scores when available
83
- "Claude 3.5 Sonnet": 25.0, # Placeholder
84
- "GPT-4o": 20.0, # Placeholder
85
- "GPT-4o-mini": 15.0, # Placeholder
86
- "Gemini 1.5 Flash": 12.0, # Placeholder
87
- }
88
- }
89
-
90
- # Model name mapping for SOTA percentage calculations
91
- MODEL_NAME_TO_SOTA = {
92
- "claude-3-5-sonnet-latest": "Claude 3.5 Sonnet",
93
- "gpt-4o": "GPT-4o",
94
- "gpt-4o-mini": "GPT-4o-mini",
95
- "gemini-1.5-flash": "Gemini 1.5 Flash",
96
- "gemini-1.5-flash-latest": "Gemini 1.5 Flash",
97
- }
98
-
99
-
100
- def hafner_score(success_rates_percent: List[float]) -> float:
101
- """Compute the Hafner adjusted score (log-mean) for NetHack."""
102
- if not success_rates_percent:
103
- return 0.0
104
- N = len(success_rates_percent)
105
- g = sum(math.log(1 + s) for s in success_rates_percent) / N
106
- return math.exp(g) - 1
107
-
108
-
109
- def balrog_score_simple(percent: float) -> float:
110
- """BALROG score is already a percentage (0-100)."""
111
- return percent
112
-
113
-
114
- @dataclass
115
- class TrajectoryResult:
116
- """Results from a single NetHack trajectory/episode."""
117
-
118
- trajectory_id: str
119
- model_name: str
120
- difficulty: str
121
- seed: int
122
-
123
- # Core metrics
124
- success: bool
125
- total_steps: int
126
- total_turns: int
127
- total_reward: float
128
-
129
- # Achievement tracking
130
- achievements_unlocked: Set[str]
131
- achievement_turn_unlocked: Dict[str, int]
132
-
133
- # Multi-action metrics (if applicable)
134
- actions_per_turn: List[int]
135
- avg_actions_per_turn: float
136
-
137
- # Termination analysis
138
- termination_reason: str
139
- final_depth: Optional[int]
140
- final_level: Optional[int]
141
- final_gold: Optional[int]
142
-
143
- # BALROG scoring
144
- balrog_percent: float
145
-
146
- # Trajectory data for detailed analysis
147
- turn_by_turn_data: Optional[List[Dict[str, Any]]] = None
148
-
149
-
150
- @dataclass
151
- class AggregateResults:
152
- """Aggregate results across multiple NetHack trajectories."""
153
-
154
- model_name: str
155
- difficulty: str
156
- num_trajectories: int
157
-
158
- # Success metrics
159
- success_rate: float
160
- avg_total_steps: float
161
- avg_total_turns: float
162
- avg_total_reward: float
163
-
164
- # Achievement metrics
165
- unique_achievements_unlocked: Set[str]
166
- total_achievement_count: int
167
- avg_achievements_per_trajectory: float
168
- achievement_unlock_rates: Dict[str, float]
169
- hafner_score: float
170
- balrog_score_avg: float
171
- balrog_score_best: float
172
-
173
- # Multi-action metrics
174
- avg_actions_per_turn_overall: float
175
- actions_per_turn_distribution: Dict[int, int]
176
-
177
- # Termination analysis
178
- termination_breakdown: Dict[str, float]
179
- avg_final_depth: Optional[float]
180
- avg_final_level: Optional[float]
181
- avg_final_gold: Optional[float]
182
-
183
-
184
- class NetHackEvalFramework:
185
- """Standardized evaluation framework for NetHack environments."""
186
-
187
- def __init__(self):
188
- self.trajectory_results: List[TrajectoryResult] = []
189
-
190
- async def run_single_trajectory(
191
- self,
192
- model_name: str,
193
- difficulty: str,
194
- seed: int,
195
- max_turns: int = 200,
196
- collect_detailed_data: bool = True,
197
- ) -> TrajectoryResult:
198
- """Run a single NetHack trajectory and collect detailed metrics."""
199
-
200
- # Create task instance
201
- metadata = NetHackTaskInstanceMetadata(
202
- character_role="knight", # Default role
203
- starting_level=1,
204
- target_depth=5 if difficulty == "easy" else 10,
205
- time_limit=max_turns * 10, # Generous time limit
206
- difficulty=difficulty,
207
- special_objectives=[
208
- "Survive for as long as possible",
209
- "Collect gold",
210
- "Kill monsters",
211
- ],
212
- seed=seed,
213
- )
214
- instance = NetHackTaskInstance(
215
- id=uuid.uuid4(),
216
- impetus=Impetus(
217
- instructions=f"Explore the NetHack dungeon on {difficulty} difficulty. Survive as long as possible, kill monsters, collect items, and descend to deeper levels."
218
- ),
219
- intent=Intent(rubric={}, gold_trajectories=None, gold_state_diff={}),
220
- metadata=metadata,
221
- is_reproducible=True,
222
- initial_engine_snapshot=None,
223
- )
224
-
225
- # Setup environment and agent
226
- obs_callback = NetHackObservationCallable()
227
- env = NetHackEnvironment(instance, custom_step_obs=obs_callback)
228
-
229
- llm = LM(model_name=model_name, formatting_model_name=model_name, temperature=0.0)
230
- agent = NetHackReActAgent(llm, max_turns=max_turns)
231
-
232
- # Set system prompt for agent
233
- task_instructions = instance.impetus.instructions
234
- agent.system_prompt = agent._create_system_prompt(task_instructions)
235
-
236
- # Initialize tracking
237
- trajectory_id = str(uuid.uuid4())
238
- achievements = NetHackAchievements()
239
- achievements_unlocked = set()
240
- achievement_turn_unlocked = {}
241
- actions_per_turn = []
242
- turn_by_turn_data = [] if collect_detailed_data else None
243
-
244
- # Progress tracking for BALROG score
245
- class BalrogProgress:
246
- def __init__(self):
247
- self.percent = 0.0
248
- self.end_reason = None
249
-
250
- def update(self, depth: int, level: int, done: bool = False, end_reason: str = ""):
251
- # Simple progress based on depth and level
252
- depth_score = min(depth * 2, 50) # Max 50 from depth
253
- level_score = min(level * 3, 50) # Max 50 from level
254
- self.percent = max(depth_score, level_score)
255
- if done:
256
- self.end_reason = end_reason
257
-
258
- balrog_progress = BalrogProgress()
259
-
260
- # Run episode
261
- obs_payload = await env.initialize()
262
- turn_count = 0
263
- termination_reason = "unknown"
264
-
265
- # Create progress bar
266
- pbar = tqdm(
267
- total=max_turns,
268
- desc=f"{model_name} ({difficulty}) Seed {seed}",
269
- unit="turn",
270
- leave=False,
271
- ncols=100,
272
- )
273
-
274
- try:
275
- while turn_count < max_turns:
276
- turn_count += 1
277
- pbar.update(1)
278
-
279
- # Extract stats from observation for progress tracking
280
- if "formatted_obs" in obs_payload:
281
- current_formatted_obs = obs_payload["formatted_obs"]
282
- elif "message" in obs_payload:
283
- # Format the observation for the agent
284
- current_formatted_obs = f"""
285
- === NetHack Observation ===
286
- Message: {obs_payload.get("message", "")}
287
- Map:
288
- {obs_payload.get("ascii_map", "")}
289
-
290
- Stats: {obs_payload.get("player_stats", {})}
291
- Inventory: {obs_payload.get("inventory", [])}
292
- In Menu: {obs_payload.get("in_menu", False)}
293
- """
294
- else:
295
- # Fallback to string representation
296
- current_formatted_obs = str(obs_payload)
297
-
298
- # Update achievements (simplified - would need real obs parsing)
299
- prev_achievements = achievements_unlocked.copy()
300
-
301
- # Extract game state for BALROG scoring
302
- try:
303
- # Parse the actual game state from obs
304
- player_stats = obs_payload.get("player_stats", {})
305
- current_depth = player_stats.get("depth", 1)
306
- current_level = player_stats.get("experience_level", 1)
307
- balrog_progress.update(current_depth, current_level)
308
- except:
309
- current_depth = 1
310
- current_level = 1
311
- balrog_progress.update(current_depth, current_level)
312
-
313
- # Update progress bar
314
- easy_count = len(
315
- [a for a in achievements_unlocked if a in ACHIEVEMENT_CATEGORIES["basic"]]
316
- )
317
- inter_count = len(
318
- [
319
- a
320
- for a in achievements_unlocked
321
- if a in ACHIEVEMENT_CATEGORIES["intermediate"]
322
- ]
323
- )
324
- adv_count = len(
325
- [a for a in achievements_unlocked if a in ACHIEVEMENT_CATEGORIES["advanced"]]
326
- )
327
- total_count = len(achievements_unlocked)
328
- achievement_display = f"{total_count}({easy_count}/{inter_count}/{adv_count})"
329
-
330
- pbar.set_postfix(
331
- {
332
- "achievements": achievement_display,
333
- "balrog": f"{balrog_progress.percent:.1f}%",
334
- }
335
- )
336
-
337
- # Agent decision
338
- decision = await agent.decide(current_formatted_obs)
339
-
340
- # Check for termination - NetHack agent uses different format
341
- if isinstance(decision, dict):
342
- # Handle tool call format: {'name': 'tool_name', 'parameters': {...}}
343
- if decision.get("name") == "terminate":
344
- termination_reason = "agent_quit"
345
- break
346
-
347
- # Extract actions from NetHack agent response
348
- if "parameters" in decision and isinstance(decision["parameters"], dict):
349
- params = decision["parameters"]
350
- if "actions" in params:
351
- actions = params["actions"]
352
- elif "action" in params:
353
- actions = [params["action"]]
354
- else:
355
- actions = ["wait"] # Default action
356
- elif "actions" in decision:
357
- actions = decision["actions"]
358
- elif "action" in decision:
359
- actions = [decision["action"]]
360
- else:
361
- actions = ["wait"] # Default action
362
- else:
363
- # If decision is not a dict, assume it's a single action or termination
364
- if decision == -1 or decision == [-1]:
365
- termination_reason = "agent_quit"
366
- break
367
- elif isinstance(decision, list):
368
- actions = decision
369
- else:
370
- actions = [str(decision)]
371
-
372
- if not isinstance(actions, list):
373
- actions = [str(actions)]
374
-
375
- actions_per_turn.append(len(actions))
376
-
377
- # Collect turn data
378
- if collect_detailed_data:
379
- turn_data = {
380
- "turn": turn_count,
381
- "actions_planned": len(actions),
382
- "achievements_at_start": list(achievements_unlocked),
383
- "balrog_percent": balrog_progress.percent,
384
- }
385
- turn_by_turn_data.append(turn_data)
386
-
387
- # Execute actions
388
- for action in actions:
389
- obs_payload = await env.step(action)
390
-
391
- # Check for REAL environment errors (not NetHack game messages)
392
- if "error" in obs_payload:
393
- error_msg = obs_payload["error"]
394
- # NetHack game messages like "No stairs here" are normal, not environment errors
395
- if error_msg and not any(
396
- phrase in error_msg.lower()
397
- for phrase in [
398
- "no stairs",
399
- "can't go",
400
- "there is nothing",
401
- "you can't",
402
- "you don't",
403
- "you aren't",
404
- "you have no",
405
- "invalid action",
406
- "stairs here to",
407
- "can't",
408
- "there's nothing",
409
- "no door",
410
- ]
411
- ):
412
- print(f" ⚠️ Real environment error: {error_msg}")
413
- termination_reason = "environment_error"
414
- break
415
- # This is just a NetHack game message, continue playing
416
-
417
- # Check termination status
418
- private_state = obs_payload.get("private")
419
- if private_state:
420
- if getattr(private_state, "terminated", False) or getattr(
421
- private_state, "truncated", False
422
- ):
423
- termination_reason = (
424
- "timeout" if getattr(private_state, "truncated", False) else "death"
425
- )
426
- balrog_progress.update(
427
- current_depth,
428
- current_level,
429
- done=True,
430
- end_reason=termination_reason,
431
- )
432
- break
433
-
434
- if termination_reason in ["environment_error", "timeout", "death"]:
435
- break
436
-
437
- # Final metrics
438
- if termination_reason == "unknown":
439
- termination_reason = "timeout"
440
-
441
- final_private = obs_payload.get("private")
442
- final_public = obs_payload.get("public")
443
-
444
- total_steps = getattr(final_public, "step_count", turn_count)
445
- total_reward = getattr(final_private, "total_reward", 0.0)
446
-
447
- # Final stats from player_stats
448
- player_stats = obs_payload.get("player_stats", {})
449
- final_depth = player_stats.get("depth", current_depth)
450
- final_level = player_stats.get("experience_level", current_level)
451
- final_gold = player_stats.get("gold", 0)
452
-
453
- # Success determination
454
- success = len(achievements_unlocked) > 0 or balrog_progress.percent > 5.0
455
-
456
- avg_actions_per_turn = (
457
- sum(actions_per_turn) / len(actions_per_turn) if actions_per_turn else 0.0
458
- )
459
-
460
- return TrajectoryResult(
461
- trajectory_id=trajectory_id,
462
- model_name=model_name,
463
- difficulty=difficulty,
464
- seed=seed,
465
- success=success,
466
- total_steps=total_steps,
467
- total_turns=turn_count,
468
- total_reward=total_reward,
469
- achievements_unlocked=achievements_unlocked,
470
- achievement_turn_unlocked=achievement_turn_unlocked,
471
- actions_per_turn=actions_per_turn,
472
- avg_actions_per_turn=avg_actions_per_turn,
473
- termination_reason=termination_reason,
474
- final_depth=final_depth,
475
- final_level=final_level,
476
- final_gold=final_gold,
477
- balrog_percent=balrog_progress.percent,
478
- turn_by_turn_data=turn_by_turn_data,
479
- )
480
- finally:
481
- pbar.close()
482
-
483
- async def run_evaluation(
484
- self,
485
- model_names: List[str],
486
- difficulties: List[str] = ["easy", "hard"],
487
- num_trajectories_per_condition: int = 3,
488
- max_turns: int = 200,
489
- collect_detailed_data: bool = True,
490
- ) -> Dict[str, Any]:
491
- """Run comprehensive evaluation across models and difficulties."""
492
-
493
- print(f"🎯 Starting NetHack Evaluation")
494
- print(f" Models: {model_names}")
495
- print(f" Difficulties: {difficulties}")
496
- print(f" Trajectories per condition: {num_trajectories_per_condition}")
497
- print(f" Max turns per trajectory: {max_turns}")
498
-
499
- all_results = []
500
-
501
- for model_name in model_names:
502
- for difficulty in difficulties:
503
- print(f"\n🔄 Running {model_name} on {difficulty} difficulty...")
504
-
505
- # Run trajectories for this condition
506
- trajectory_tasks = []
507
- for i in range(num_trajectories_per_condition):
508
- seed = 1000 + i if difficulty == "easy" else 2000 + i
509
- trajectory_tasks.append(
510
- self.run_single_trajectory(
511
- model_name=model_name,
512
- difficulty=difficulty,
513
- seed=seed,
514
- max_turns=max_turns,
515
- collect_detailed_data=collect_detailed_data,
516
- )
517
- )
518
-
519
- condition_results = await asyncio.gather(*trajectory_tasks)
520
- all_results.extend(condition_results)
521
-
522
- self.trajectory_results = all_results
523
- return self._generate_comprehensive_report()
524
-
525
- def _compute_aggregate_metrics(
526
- self, model_name: str, difficulty: str, trajectories: List[TrajectoryResult]
527
- ) -> AggregateResults:
528
- """Compute aggregate metrics for a model-difficulty condition."""
529
-
530
- num_trajectories = len(trajectories)
531
- if num_trajectories == 0:
532
- return AggregateResults(
533
- model_name=model_name,
534
- difficulty=difficulty,
535
- num_trajectories=0,
536
- success_rate=0.0,
537
- avg_total_steps=0.0,
538
- avg_total_turns=0.0,
539
- avg_total_reward=0.0,
540
- unique_achievements_unlocked=set(),
541
- total_achievement_count=0,
542
- avg_achievements_per_trajectory=0.0,
543
- achievement_unlock_rates={},
544
- hafner_score=0.0,
545
- balrog_score_avg=0.0,
546
- balrog_score_best=0.0,
547
- avg_actions_per_turn_overall=0.0,
548
- actions_per_turn_distribution={},
549
- termination_breakdown={},
550
- avg_final_depth=None,
551
- avg_final_level=None,
552
- avg_final_gold=None,
553
- )
554
-
555
- # Success metrics
556
- success_rate = sum(1 for t in trajectories if t.success) / num_trajectories
557
- avg_total_steps = sum(t.total_steps for t in trajectories) / num_trajectories
558
- avg_total_turns = sum(t.total_turns for t in trajectories) / num_trajectories
559
- avg_total_reward = sum(t.total_reward for t in trajectories) / num_trajectories
560
-
561
- # Achievement analysis
562
- all_achievements = set()
563
- total_achievement_count = 0
564
- achievement_counts = defaultdict(int)
565
-
566
- for traj in trajectories:
567
- all_achievements.update(traj.achievements_unlocked)
568
- total_achievement_count += len(traj.achievements_unlocked)
569
- for ach in traj.achievements_unlocked:
570
- achievement_counts[ach] += 1
571
-
572
- achievement_unlock_rates = {
573
- ach: count / num_trajectories for ach, count in achievement_counts.items()
574
- }
575
- avg_achievements_per_trajectory = total_achievement_count / num_trajectories
576
-
577
- # Compute Hafner score
578
- all_achievement_rates = []
579
- for achievement in ALL_ACHIEVEMENTS:
580
- unlock_rate = achievement_counts.get(achievement, 0) / num_trajectories
581
- all_achievement_rates.append(unlock_rate * 100.0)
582
-
583
- hafner_adjusted_score = hafner_score(all_achievement_rates)
584
-
585
- # Compute BALROG scores
586
- balrog_scores = [t.balrog_percent for t in trajectories]
587
- balrog_score_avg = sum(balrog_scores) / len(balrog_scores) if balrog_scores else 0.0
588
- balrog_score_best = max(balrog_scores) if balrog_scores else 0.0
589
-
590
- # Multi-action analysis
591
- all_actions_per_turn = []
592
- actions_per_turn_dist = defaultdict(int)
593
- for traj in trajectories:
594
- all_actions_per_turn.extend(traj.actions_per_turn)
595
- for count in traj.actions_per_turn:
596
- actions_per_turn_dist[count] += 1
597
-
598
- avg_actions_per_turn_overall = (
599
- sum(all_actions_per_turn) / len(all_actions_per_turn) if all_actions_per_turn else 0.0
600
- )
601
-
602
- # Termination analysis
603
- termination_counts = defaultdict(int)
604
- for traj in trajectories:
605
- termination_counts[traj.termination_reason] += 1
606
- termination_breakdown = {
607
- reason: count / num_trajectories for reason, count in termination_counts.items()
608
- }
609
-
610
- # Final stats
611
- depth_values = [t.final_depth for t in trajectories if t.final_depth is not None]
612
- level_values = [t.final_level for t in trajectories if t.final_level is not None]
613
- gold_values = [t.final_gold for t in trajectories if t.final_gold is not None]
614
-
615
- avg_final_depth = sum(depth_values) / len(depth_values) if depth_values else None
616
- avg_final_level = sum(level_values) / len(level_values) if level_values else None
617
- avg_final_gold = sum(gold_values) / len(gold_values) if gold_values else None
618
-
619
- return AggregateResults(
620
- model_name=model_name,
621
- difficulty=difficulty,
622
- num_trajectories=num_trajectories,
623
- success_rate=success_rate,
624
- avg_total_steps=avg_total_steps,
625
- avg_total_turns=avg_total_turns,
626
- avg_total_reward=avg_total_reward,
627
- unique_achievements_unlocked=all_achievements,
628
- total_achievement_count=total_achievement_count,
629
- avg_achievements_per_trajectory=avg_achievements_per_trajectory,
630
- achievement_unlock_rates=achievement_unlock_rates,
631
- hafner_score=hafner_adjusted_score,
632
- balrog_score_avg=balrog_score_avg,
633
- balrog_score_best=balrog_score_best,
634
- avg_actions_per_turn_overall=avg_actions_per_turn_overall,
635
- actions_per_turn_distribution=dict(actions_per_turn_dist),
636
- termination_breakdown=termination_breakdown,
637
- avg_final_depth=avg_final_depth,
638
- avg_final_level=avg_final_level,
639
- avg_final_gold=avg_final_gold,
640
- )
641
-
642
- def _generate_comprehensive_report(self) -> Dict[str, Any]:
643
- """Generate comprehensive evaluation report with all metrics and tables."""
644
-
645
- # Group results by model and difficulty
646
- grouped_results = defaultdict(lambda: defaultdict(list))
647
- for result in self.trajectory_results:
648
- grouped_results[result.model_name][result.difficulty].append(result)
649
-
650
- # Generate aggregate results
651
- aggregate_results = []
652
- for model_name, difficulties in grouped_results.items():
653
- for difficulty, trajectories in difficulties.items():
654
- agg = self._compute_aggregate_metrics(model_name, difficulty, trajectories)
655
- aggregate_results.append(agg)
656
-
657
- # Generate all tables and analyses
658
- report = {
659
- "evaluation_summary": self._generate_summary_table(aggregate_results),
660
- "achievement_percentage_table": self._generate_achievement_percentage_table(
661
- grouped_results
662
- ),
663
- "termination_breakdown_table": self._generate_termination_breakdown_table(
664
- aggregate_results
665
- ),
666
- "trajectory_by_trajectory_breakdown": self._generate_trajectory_breakdown(),
667
- "sota_comparison": self._generate_sota_comparison(aggregate_results),
668
- "raw_aggregate_results": [asdict(agg) for agg in aggregate_results],
669
- "raw_trajectory_results": [asdict(traj) for traj in self.trajectory_results],
670
- }
671
-
672
- return report
673
-
674
- def _generate_summary_table(self, aggregate_results: List[AggregateResults]) -> pd.DataFrame:
675
- """Generate main summary table with key metrics."""
676
-
677
- data = []
678
- for agg in aggregate_results:
679
- data.append(
680
- {
681
- "Model": agg.model_name,
682
- "Difficulty": agg.difficulty,
683
- "Success Rate": f"{agg.success_rate:.1%}",
684
- "Hafner Score": f"{agg.hafner_score:.1f}%",
685
- "BALROG Avg": f"{agg.balrog_score_avg:.1f}%",
686
- "BALROG Best": f"{agg.balrog_score_best:.1f}%",
687
- "Avg Steps": f"{agg.avg_total_steps:.1f}",
688
- "Avg Turns": f"{agg.avg_total_turns:.1f}",
689
- "Avg Reward": f"{agg.avg_total_reward:.3f}",
690
- "Unique Achievements": len(agg.unique_achievements_unlocked),
691
- "Avg Achievements/Traj": f"{agg.avg_achievements_per_trajectory:.2f}",
692
- "Avg Actions/Turn": f"{agg.avg_actions_per_turn_overall:.1f}",
693
- }
694
- )
695
-
696
- return pd.DataFrame(data)
697
-
698
- def _generate_achievement_percentage_table(
699
- self, grouped_results: Dict[str, Dict[str, List[TrajectoryResult]]]
700
- ) -> pd.DataFrame:
701
- """Generate table showing percentage of trajectories achieving each achievement."""
702
-
703
- data = []
704
-
705
- for model_name, difficulties in grouped_results.items():
706
- for difficulty, trajectories in difficulties.items():
707
- if not trajectories:
708
- continue
709
-
710
- num_trajectories = len(trajectories)
711
- row = {"Model": model_name, "Difficulty": difficulty}
712
-
713
- # Count achievements
714
- achievement_counts = defaultdict(int)
715
- for traj in trajectories:
716
- for ach in traj.achievements_unlocked:
717
- achievement_counts[ach] += 1
718
-
719
- # Add percentage for each achievement
720
- for achievement in ALL_ACHIEVEMENTS:
721
- count = achievement_counts[achievement]
722
- percentage = count / num_trajectories if num_trajectories > 0 else 0.0
723
- row[achievement] = f"{percentage:.1%}"
724
-
725
- data.append(row)
726
-
727
- df = pd.DataFrame(data)
728
-
729
- # Reorder columns: Model, Difficulty, then achievements by category
730
- base_cols = ["Model", "Difficulty"]
731
- achievement_cols = []
732
- for category in ["basic", "intermediate", "advanced"]:
733
- for ach in ACHIEVEMENT_CATEGORIES[category]:
734
- if ach in df.columns:
735
- achievement_cols.append(ach)
736
-
737
- return df[base_cols + achievement_cols]
738
-
739
- def _generate_termination_breakdown_table(
740
- self, aggregate_results: List[AggregateResults]
741
- ) -> pd.DataFrame:
742
- """Generate table showing termination reason percentages."""
743
-
744
- data = []
745
- for agg in aggregate_results:
746
- row = {
747
- "Model": agg.model_name,
748
- "Difficulty": agg.difficulty,
749
- }
750
-
751
- for reason in TERMINATION_REASONS:
752
- percentage = agg.termination_breakdown.get(reason, 0.0)
753
- row[f"{reason.title()} %"] = f"{percentage:.1%}"
754
-
755
- data.append(row)
756
-
757
- return pd.DataFrame(data)
758
-
759
- def _generate_trajectory_breakdown(self) -> pd.DataFrame:
760
- """Generate detailed trajectory-by-trajectory breakdown."""
761
-
762
- data = []
763
- for traj in self.trajectory_results:
764
- # Achievement category breakdown
765
- basic_achievements = len(
766
- [a for a in traj.achievements_unlocked if a in ACHIEVEMENT_CATEGORIES["basic"]]
767
- )
768
- inter_achievements = len(
769
- [
770
- a
771
- for a in traj.achievements_unlocked
772
- if a in ACHIEVEMENT_CATEGORIES["intermediate"]
773
- ]
774
- )
775
- adv_achievements = len(
776
- [a for a in traj.achievements_unlocked if a in ACHIEVEMENT_CATEGORIES["advanced"]]
777
- )
778
-
779
- data.append(
780
- {
781
- "Trajectory ID": traj.trajectory_id[:8],
782
- "Model": traj.model_name,
783
- "Difficulty": traj.difficulty,
784
- "Seed": traj.seed,
785
- "Success": "✓" if traj.success else "✗",
786
- "Steps": traj.total_steps,
787
- "Turns": traj.total_turns,
788
- "Reward": f"{traj.total_reward:.3f}",
789
- "Total Achievements": len(traj.achievements_unlocked),
790
- "Basic": basic_achievements,
791
- "Intermediate": inter_achievements,
792
- "Advanced": adv_achievements,
793
- "BALROG Score": f"{traj.balrog_percent:.1f}%",
794
- "Termination": traj.termination_reason,
795
- "Final Depth": traj.final_depth,
796
- "Achievements": ", ".join(sorted(traj.achievements_unlocked))
797
- if traj.achievements_unlocked
798
- else "None",
799
- }
800
- )
801
-
802
- return pd.DataFrame(data)
803
-
804
- def _generate_sota_comparison(
805
- self, aggregate_results: List[AggregateResults]
806
- ) -> Dict[str, pd.DataFrame]:
807
- """Generate comparison tables with SOTA benchmarks, separating Hafner and BALROG methodologies."""
808
-
809
- # Create our results table for both methodologies
810
- our_hafner_data = []
811
- our_balrog_data = []
812
-
813
- for agg in aggregate_results:
814
- # Hafner results
815
- hafner_row = {
816
- "System": f"{agg.model_name} (multi-action)",
817
- "Hafner Score": f"{agg.hafner_score:.1f}%",
818
- "Category": "Current Evaluation (Hafner)",
819
- }
820
- our_hafner_data.append(hafner_row)
821
-
822
- # BALROG results
823
- balrog_row = {
824
- "System": f"{agg.model_name} (multi-action)",
825
- "BALROG Score (Avg)": f"{agg.balrog_score_avg:.1f}%",
826
- "BALROG Score (Best)": f"{agg.balrog_score_best:.1f}%",
827
- "Category": "Current Evaluation (BALROG)",
828
- }
829
-
830
- # Add percentage comparison to BALROG SOTA if we can map the model name
831
- if agg.model_name in MODEL_NAME_TO_SOTA:
832
- sota_name = MODEL_NAME_TO_SOTA[agg.model_name]
833
- if sota_name in BALROG_SOTA_SCORES["balrog_leaderboard"]:
834
- balrog_sota_score = BALROG_SOTA_SCORES["balrog_leaderboard"][sota_name]
835
- percentage_of_balrog_sota_avg = (agg.balrog_score_avg / balrog_sota_score) * 100
836
- percentage_of_balrog_sota_best = (
837
- agg.balrog_score_best / balrog_sota_score
838
- ) * 100
839
- balrog_row["% of BALROG SOTA (Avg)"] = f"{percentage_of_balrog_sota_avg:.1f}%"
840
- balrog_row["% of BALROG SOTA (Best)"] = f"{percentage_of_balrog_sota_best:.1f}%"
841
- balrog_row["BALROG SOTA Reference"] = f"{sota_name} ({balrog_sota_score:.1f}%)"
842
-
843
- our_balrog_data.append(balrog_row)
844
-
845
- our_hafner_df = pd.DataFrame(our_hafner_data)
846
- our_balrog_df = pd.DataFrame(our_balrog_data)
847
-
848
- return {
849
- "our_hafner_results": our_hafner_df,
850
- "our_balrog_results": our_balrog_df,
851
- "methodology_note": "⚠️ CRITICAL: Hafner scores (log-adjusted multi-episode) and BALROG scores (simple single-episode percentage) use different methodologies and are NOT directly comparable!",
852
- }
853
-
854
- def print_report(self, report: Dict[str, Any]):
855
- """Print a formatted evaluation report."""
856
-
857
- print("\n" + "=" * 80)
858
- print("🎯 NETHACK EVALUATION REPORT")
859
- print("=" * 80)
860
-
861
- # Summary table
862
- print("\n📊 EVALUATION SUMMARY")
863
- summary_df = report["evaluation_summary"]
864
- # Clean formatting for summary table
865
- for col in summary_df.columns:
866
- if len(col) > 12: # Truncate long column names
867
- summary_df = summary_df.rename(columns={col: col[:12]})
868
- print(summary_df.to_string(index=False, max_colwidth=12))
869
-
870
- # Create and show vertical achievement table
871
- print("\n🏆 ACHIEVEMENT UNLOCK RATES")
872
- print("Format: unlocked/total (percentage)")
873
-
874
- # Group results for achievement summary
875
- grouped_results = defaultdict(lambda: defaultdict(list))
876
- for traj in self.trajectory_results:
877
- grouped_results[traj.model_name][traj.difficulty].append(traj)
878
-
879
- achievement_summary = self._generate_achievement_summary_table(grouped_results)
880
-
881
- # Print by category for better readability
882
- for category in ["Basic", "Intermediate", "Advanced"]:
883
- category_data = achievement_summary[achievement_summary["Category"] == category]
884
- if not category_data.empty:
885
- print(f"\n{category.upper()} ACHIEVEMENTS:")
886
- category_display = category_data.drop("Category", axis=1)
887
- print(category_display.to_string(index=False))
888
-
889
- # Trajectory breakdown (summary stats only for space)
890
- traj_df = report["trajectory_by_trajectory_breakdown"]
891
- print(f"\n📋 TRAJECTORY BREAKDOWN ({len(traj_df)} total trajectories)")
892
- print("Sample trajectories:")
893
- sample_cols = [
894
- "Model",
895
- "Difficulty",
896
- "Success",
897
- "Steps",
898
- "Total Achievements",
899
- "BALROG Score",
900
- "Termination",
901
- ]
902
- sample_df = traj_df[sample_cols].head(5)
903
- print(sample_df.to_string(index=False, max_colwidth=12))
904
- if len(traj_df) > 5:
905
- print(f"... and {len(traj_df) - 5} more trajectories")
906
-
907
- # SOTA comparison
908
- sota_comparison = report["sota_comparison"]
909
- print("\n🏆 SOTA COMPARISON")
910
- print(sota_comparison["methodology_note"])
911
-
912
- print("\n📊 HAFNER METHODOLOGY RESULTS (Multi-episode log-adjusted)")
913
- hafner_df = sota_comparison["our_hafner_results"]
914
- print(hafner_df.to_string(index=False, max_colwidth=20))
915
-
916
- print("\n📊 BALROG METHODOLOGY RESULTS (Single-episode percentage)")
917
- balrog_df = sota_comparison["our_balrog_results"]
918
- # Clean up column names for better display
919
- balrog_clean = balrog_df.copy()
920
- if "% of BALROG SOTA (Avg)" in balrog_clean.columns:
921
- balrog_clean = balrog_clean.rename(columns={"% of BALROG SOTA (Avg)": "% SOTA Avg"})
922
- if "% of BALROG SOTA (Best)" in balrog_clean.columns:
923
- balrog_clean = balrog_clean.rename(columns={"% of BALROG SOTA (Best)": "% SOTA Best"})
924
- print(balrog_clean.to_string(index=False, max_colwidth=20))
925
-
926
- print("\n" + "=" * 80)
927
-
928
- def _generate_achievement_summary_table(
929
- self, grouped_results: Dict[str, Dict[str, List[TrajectoryResult]]]
930
- ) -> pd.DataFrame:
931
- """Generate a vertical achievement summary table that's easier to read."""
932
-
933
- data = []
934
-
935
- # For each achievement, show rates across all model/difficulty combinations
936
- for category_name, achievements in ACHIEVEMENT_CATEGORIES.items():
937
- for achievement in achievements:
938
- row = {
939
- "Category": category_name.capitalize(),
940
- "Achievement": achievement.replace("_", " ").title(),
941
- }
942
-
943
- # Add columns for each model/difficulty combination
944
- for model_name, difficulties in grouped_results.items():
945
- for difficulty, trajectories in difficulties.items():
946
- if not trajectories:
947
- continue
948
-
949
- num_trajectories = len(trajectories)
950
- count = sum(
951
- 1 for traj in trajectories if achievement in traj.achievements_unlocked
952
- )
953
- percentage = count / num_trajectories if num_trajectories > 0 else 0.0
954
-
955
- col_name = f"{model_name} ({difficulty})"
956
- row[col_name] = f"{count}/{num_trajectories} ({percentage:.1%})"
957
-
958
- data.append(row)
959
-
960
- return pd.DataFrame(data)
961
-
962
-
963
- # Convenience function for quick evaluations
964
- async def run_nethack_eval(
965
- model_names: List[str],
966
- difficulties: List[str] = ["easy", "hard"],
967
- num_trajectories: int = 3,
968
- max_turns: int = 200,
969
- ) -> Dict[str, Any]:
970
- """Quick evaluation runner with automatic report generation."""
971
-
972
- framework = NetHackEvalFramework()
973
- report = await framework.run_evaluation(
974
- model_names=model_names,
975
- difficulties=difficulties,
976
- num_trajectories_per_condition=num_trajectories,
977
- max_turns=max_turns,
978
- )
979
-
980
- framework.print_report(report)
981
- return report