synth-ai 0.2.9.dev0__py3-none-any.whl → 0.2.23.dev3__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.
- examples/README.md +1 -0
- examples/__init__.py +16 -0
- examples/analyze_semantic_words.sh +17 -0
- examples/baseline/banking77_baseline.py +243 -0
- examples/baseline/banking77_pipeline_baseline.py +294 -0
- examples/baseline/crafter_baseline.py +407 -0
- examples/baseline/pokemon_red_baseline.py +326 -0
- examples/baseline/simple_baseline.py +56 -0
- examples/baseline/warming_up_to_rl_baseline.py +239 -0
- examples/blog_posts/gepa/README.md +355 -0
- examples/blog_posts/gepa/configs/banking77_gepa_local.toml +95 -0
- examples/blog_posts/gepa/configs/banking77_gepa_test.toml +80 -0
- examples/blog_posts/gepa/configs/banking77_mipro_local.toml +50 -0
- examples/blog_posts/gepa/configs/banking77_pipeline_gepa_local.toml +101 -0
- examples/blog_posts/gepa/configs/banking77_pipeline_gepa_test.toml +96 -0
- examples/blog_posts/gepa/configs/hotpotqa_gepa_local.toml +57 -0
- examples/blog_posts/gepa/configs/hotpotqa_gepa_qwen.toml +35 -0
- examples/blog_posts/gepa/configs/hotpotqa_mipro_local.toml +51 -0
- examples/blog_posts/gepa/configs/hover_gepa_local.toml +57 -0
- examples/blog_posts/gepa/configs/hover_gepa_qwen.toml +35 -0
- examples/blog_posts/gepa/configs/hover_mipro_local.toml +51 -0
- examples/blog_posts/gepa/configs/ifbench_gepa_local.toml +57 -0
- examples/blog_posts/gepa/configs/ifbench_gepa_qwen.toml +35 -0
- examples/blog_posts/gepa/configs/ifbench_mipro_local.toml +51 -0
- examples/blog_posts/gepa/configs/pupa_gepa_local.toml +58 -0
- examples/blog_posts/gepa/configs/pupa_mipro_local.toml +52 -0
- examples/blog_posts/gepa/deploy_banking77_task_app.sh +54 -0
- examples/blog_posts/gepa/gepa_baseline.py +204 -0
- examples/blog_posts/gepa/query_prompts_example.py +97 -0
- examples/blog_posts/gepa/run_gepa_banking77.sh +112 -0
- examples/blog_posts/gepa/run_gepa_banking77_pipeline.sh +163 -0
- examples/blog_posts/gepa/task_apps.py +105 -0
- examples/blog_posts/gepa/test_gepa_local.sh +67 -0
- examples/blog_posts/gepa/verify_banking77_setup.sh +123 -0
- examples/blog_posts/mipro/README.md +415 -0
- examples/blog_posts/mipro/configs/banking77_mipro_local.toml +91 -0
- examples/blog_posts/mipro/configs/banking77_mipro_test.toml +87 -0
- examples/blog_posts/mipro/configs/banking77_pipeline_mipro_gemini_flash_lite_local.toml +98 -0
- examples/blog_posts/mipro/configs/banking77_pipeline_mipro_gpt41mini_local.toml +96 -0
- examples/blog_posts/mipro/configs/banking77_pipeline_mipro_local.toml +94 -0
- examples/blog_posts/mipro/configs/banking77_pipeline_mipro_test.toml +170 -0
- examples/blog_posts/mipro/deploy_banking77_pipeline_task_app.sh +59 -0
- examples/blog_posts/mipro/deploy_banking77_task_app.sh +41 -0
- examples/blog_posts/mipro/multi_step.md +79 -0
- examples/blog_posts/mipro/run_mipro_banking77.sh +191 -0
- examples/blog_posts/mipro/run_mipro_banking77_pipeline.sh +171 -0
- examples/blog_posts/mipro/run_mipro_banking77_pipeline_gemini_flash_lite.sh +177 -0
- examples/blog_posts/mipro/run_mipro_banking77_pipeline_gpt41mini.sh +173 -0
- examples/blog_posts/mipro/verify_banking77_setup.sh +117 -0
- examples/blog_posts/pokemon_vl/README.md +98 -0
- examples/blog_posts/pokemon_vl/configs/eval_gpt5nano.toml +26 -0
- examples/blog_posts/pokemon_vl/configs/eval_qwen3_vl.toml +27 -0
- examples/blog_posts/pokemon_vl/configs/eval_rl_final.toml +24 -0
- examples/blog_posts/pokemon_vl/configs/filter_high_reward.toml +10 -0
- examples/blog_posts/pokemon_vl/configs/train_rl_from_sft.toml +43 -0
- examples/blog_posts/pokemon_vl/configs/train_sft_qwen4b_vl.toml +40 -0
- examples/blog_posts/pokemon_vl/extract_images.py +239 -0
- examples/blog_posts/pokemon_vl/pokemon_vl_baseline.py +326 -0
- examples/blog_posts/pokemon_vl/run_eval_extract_images.py +209 -0
- examples/blog_posts/pokemon_vl/run_qwen_eval_extract_images.py +212 -0
- examples/blog_posts/pokemon_vl/text_box_analysis.md +106 -0
- examples/blog_posts/warming_up_to_rl/ARCHITECTURE.md +195 -0
- examples/blog_posts/warming_up_to_rl/FINAL_TEST_RESULTS.md +127 -0
- examples/blog_posts/warming_up_to_rl/INFERENCE_SUCCESS.md +132 -0
- examples/blog_posts/warming_up_to_rl/README.md +158 -0
- examples/blog_posts/warming_up_to_rl/SMOKE_TESTING.md +164 -0
- examples/blog_posts/warming_up_to_rl/SMOKE_TEST_COMPLETE.md +253 -0
- examples/blog_posts/warming_up_to_rl/configs/eval_baseline_qwen32b_10x20.toml +25 -0
- examples/blog_posts/warming_up_to_rl/configs/eval_ft_qwen4b.toml +25 -0
- examples/blog_posts/warming_up_to_rl/configs/eval_ft_qwen4b_10x20.toml +26 -0
- examples/blog_posts/warming_up_to_rl/configs/eval_groq_qwen32b.toml +25 -0
- examples/blog_posts/warming_up_to_rl/configs/eval_openai_gpt_oss_120b.toml +29 -0
- examples/blog_posts/warming_up_to_rl/configs/filter_high_reward_dataset.toml +10 -0
- examples/blog_posts/warming_up_to_rl/configs/smoke_test.toml +75 -0
- examples/blog_posts/warming_up_to_rl/configs/train_rl_from_sft.toml +91 -0
- examples/blog_posts/warming_up_to_rl/configs/train_sft_qwen4b.toml +40 -0
- examples/blog_posts/warming_up_to_rl/warming_up_to_rl_baseline.py +187 -0
- examples/crafter_debug_render.py +186 -0
- examples/dev/qwen3_32b_qlora_4xh100.toml +45 -0
- examples/gepa/banking77_pipeline_gepa.toml +96 -0
- examples/gepa/multi_stage_gepa_example.toml +84 -0
- examples/gepa/run_gepa_banking77_pipeline.sh +157 -0
- examples/multi_step/SFT_README.md +147 -0
- examples/multi_step/configs/README_verilog_rl.md +77 -0
- examples/multi_step/configs/VERILOG_REWARDS.md +103 -0
- examples/multi_step/configs/VERILOG_RL_CHECKLIST.md +196 -0
- examples/multi_step/configs/crafter_eval_synth_qwen4b.toml +35 -0
- examples/multi_step/configs/crafter_eval_text_only_groq_qwen32b.toml +36 -0
- examples/multi_step/configs/crafter_rl_outcome.toml +75 -0
- examples/multi_step/configs/crafter_rl_stepwise_hosted_judge.toml +145 -0
- examples/multi_step/configs/crafter_rl_stepwise_shaped.toml +84 -0
- examples/multi_step/configs/crafter_rl_stepwise_simple.toml +79 -0
- examples/multi_step/configs/crafter_rl_stepwise_simple_NEW_FORMAT.toml +105 -0
- examples/multi_step/configs/crafter_sft_qwen30b_lora.toml +62 -0
- examples/multi_step/configs/crafter_synth_backend.md +40 -0
- examples/multi_step/configs/verilog_eval_groq_qwen32b.toml +31 -0
- examples/multi_step/configs/verilog_eval_synth_qwen8b.toml +33 -0
- examples/multi_step/configs/verilog_rl_lora.toml +147 -0
- examples/multi_step/convert_traces_to_sft.py +84 -0
- examples/multi_step/crafter_rl_lora.md +70 -0
- examples/multi_step/judges/crafter_backend_judge.py +220 -0
- examples/multi_step/judges/verilog_backend_judge.py +234 -0
- examples/multi_step/readme.md +48 -0
- examples/multi_step/run_sft_qwen30b.sh +45 -0
- examples/multi_step/sse_metrics_streaming_notes.md +357 -0
- examples/multi_step/task_app_config_notes.md +494 -0
- examples/multi_step/verilog_rl_lora.md +218 -0
- examples/qwen_coder/README.md +102 -0
- examples/qwen_coder/_shared.py +113 -0
- examples/qwen_coder/configs/coder_lora_30b.toml +60 -0
- examples/qwen_coder/configs/coder_lora_4b.toml +61 -0
- examples/qwen_coder/configs/coder_lora_small.toml +57 -0
- examples/qwen_coder/generate_dataset.py +98 -0
- examples/qwen_coder/infer_ft_smoke.py +65 -0
- examples/qwen_coder/infer_prod_proxy.py +73 -0
- examples/qwen_coder/infer_via_synth.py +87 -0
- examples/qwen_coder/scripts/infer_coder.sh +19 -0
- examples/qwen_coder/scripts/train_coder_30b.sh +22 -0
- examples/qwen_coder/sft_full_17b.py +103 -0
- examples/qwen_coder/sft_lora_30b.py +110 -0
- examples/qwen_coder/subset_jsonl.py +39 -0
- examples/qwen_coder/todos.md +38 -0
- examples/qwen_coder/validate_jsonl.py +60 -0
- examples/qwen_vl/BUGS_AND_FIXES.md +232 -0
- examples/qwen_vl/IMAGE_VALIDATION_COMPLETE.md +271 -0
- examples/qwen_vl/IMAGE_VALIDATION_SUMMARY.md +260 -0
- examples/qwen_vl/INFERENCE_SFT_TESTS.md +412 -0
- examples/qwen_vl/NEXT_STEPS_2B.md +325 -0
- examples/qwen_vl/QUICKSTART.md +327 -0
- examples/qwen_vl/QUICKSTART_RL_VISION.md +110 -0
- examples/qwen_vl/README.md +152 -0
- examples/qwen_vl/RL_VISION_COMPLETE.md +475 -0
- examples/qwen_vl/RL_VISION_TESTING.md +333 -0
- examples/qwen_vl/SDK_VISION_INTEGRATION.md +328 -0
- examples/qwen_vl/SETUP_COMPLETE.md +274 -0
- examples/qwen_vl/VISION_TESTS_COMPLETE.md +489 -0
- examples/qwen_vl/VLM_PIPELINE_COMPLETE.md +242 -0
- examples/qwen_vl/__init__.py +2 -0
- examples/qwen_vl/collect_data_via_cli.md +415 -0
- examples/qwen_vl/collect_vision_traces.py +368 -0
- examples/qwen_vl/configs/crafter_rl_vision_qwen3vl4b.toml +110 -0
- examples/qwen_vl/configs/crafter_vlm_sft_example.toml +59 -0
- examples/qwen_vl/configs/eval_gpt4o_mini_vision.toml +26 -0
- examples/qwen_vl/configs/eval_gpt4o_vision_proper.toml +29 -0
- examples/qwen_vl/configs/eval_gpt5nano_vision.toml +26 -0
- examples/qwen_vl/configs/eval_qwen3vl_vision.toml +26 -0
- examples/qwen_vl/configs/filter_qwen3vl_sft.toml +49 -0
- examples/qwen_vl/configs/filter_vision_sft.toml +52 -0
- examples/qwen_vl/configs/filter_vision_test.toml +8 -0
- examples/qwen_vl/configs/sft_qwen3_vl_2b_test.toml +54 -0
- examples/qwen_vl/crafter_gpt5nano_agent.py +308 -0
- examples/qwen_vl/crafter_qwen_vl_agent.py +300 -0
- examples/qwen_vl/run_vision_comparison.sh +61 -0
- examples/qwen_vl/run_vision_sft_pipeline.sh +175 -0
- examples/qwen_vl/test_image_validation.py +201 -0
- examples/qwen_vl/test_sft_vision_data.py +110 -0
- examples/rl/README.md +169 -0
- examples/rl/configs/eval_base_qwen.toml +17 -0
- examples/rl/configs/eval_rl_qwen.toml +13 -0
- examples/rl/configs/rl_from_base_qwen.toml +62 -0
- examples/rl/configs/rl_from_base_qwen17.toml +80 -0
- examples/rl/configs/rl_from_ft_qwen.toml +37 -0
- examples/rl/download_dataset.py +80 -0
- examples/rl/run_eval.py +436 -0
- examples/rl/run_rl_and_save.py +111 -0
- examples/rl/task_app/README.md +21 -0
- {synth_ai/task/apps → examples/rl/task_app}/math_single_step.py +188 -50
- examples/rl/task_app/math_task_app.py +111 -0
- examples/run_crafter_demo.sh +10 -0
- examples/sdk_prompt_learning_example.py +55 -0
- examples/sft/README.md +139 -0
- examples/sft/configs/crafter_fft_qwen0p6b.toml +49 -0
- examples/sft/configs/crafter_lora_qwen0p6b.toml +49 -0
- examples/sft/evaluate.py +117 -0
- examples/sft/export_dataset.py +120 -0
- examples/sft/generate_traces.py +164 -0
- examples/swe/__init__.py +12 -0
- examples/swe/task_app/README.md +135 -0
- examples/swe/task_app/__init__.py +2 -0
- examples/swe/task_app/grpo_swe_mini.py +604 -0
- examples/swe/task_app/grpo_swe_mini_task_app.py +124 -0
- examples/swe/task_app/hosted/README.md +173 -0
- examples/swe/task_app/hosted/__init__.py +5 -0
- examples/swe/task_app/hosted/branching.py +143 -0
- examples/swe/task_app/hosted/environment_routes.py +1289 -0
- examples/swe/task_app/hosted/envs/__init__.py +1 -0
- examples/swe/task_app/hosted/envs/crafter/__init__.py +6 -0
- examples/swe/task_app/hosted/envs/crafter/app.py +1 -0
- examples/swe/task_app/hosted/envs/crafter/environment.py +522 -0
- examples/swe/task_app/hosted/envs/crafter/policy.py +478 -0
- examples/swe/task_app/hosted/envs/crafter/react_agent.py +108 -0
- examples/swe/task_app/hosted/envs/crafter/shared.py +305 -0
- examples/swe/task_app/hosted/envs/crafter/tools.py +47 -0
- examples/swe/task_app/hosted/envs/mini_swe/__init__.py +8 -0
- examples/swe/task_app/hosted/envs/mini_swe/environment.py +1191 -0
- examples/swe/task_app/hosted/envs/mini_swe/policy.py +355 -0
- examples/swe/task_app/hosted/envs/mini_swe/shared.py +83 -0
- examples/swe/task_app/hosted/envs/mini_swe/tools.py +96 -0
- examples/swe/task_app/hosted/hosted_app.py +204 -0
- examples/swe/task_app/hosted/inference/__init__.py +5 -0
- examples/swe/task_app/hosted/inference/openai_client.py +584 -0
- examples/swe/task_app/hosted/main.py +100 -0
- examples/swe/task_app/hosted/policy_routes.py +1094 -0
- examples/swe/task_app/hosted/registry.py +195 -0
- examples/swe/task_app/hosted/rollout.py +1905 -0
- examples/swe/task_app/hosted/storage/__init__.py +5 -0
- examples/swe/task_app/hosted/storage/volume.py +211 -0
- examples/swe/task_app/hosted/test_agents.py +161 -0
- examples/swe/task_app/hosted/test_service.py +136 -0
- examples/swe/task_app/hosted/utils.py +62 -0
- examples/swe/task_app/morph_backend.py +178 -0
- examples/task_apps/IMAGE_ONLY_EVAL_QUICKSTART.md +258 -0
- examples/task_apps/TESTING.md +275 -0
- examples/task_apps/banking77/__init__.py +6 -0
- examples/task_apps/banking77/banking77_task_app.py +912 -0
- examples/task_apps/banking77/deploy_wrapper.py +46 -0
- examples/task_apps/banking77_pipeline/__init__.py +6 -0
- examples/task_apps/banking77_pipeline/banking77_pipeline_task_app.py +489 -0
- examples/task_apps/banking77_pipeline/deploy_wrapper.py +50 -0
- examples/task_apps/crafter/CREATE_SFT_DATASET.md +286 -0
- examples/task_apps/crafter/EVAL_IMAGE_ONLY_RESULTS.md +152 -0
- examples/task_apps/crafter/FILTER_COMMAND_STATUS.md +187 -0
- examples/task_apps/crafter/FILTER_COMMAND_SUCCESS.md +281 -0
- examples/task_apps/crafter/QUERY_EXAMPLES.md +203 -0
- examples/task_apps/crafter/README_IMAGE_ONLY_EVAL.md +316 -0
- examples/task_apps/crafter/eval_image_only_gpt4o.toml +28 -0
- examples/task_apps/crafter/eval_text_only_groq_llama.toml +36 -0
- examples/task_apps/crafter/filter_sft_dataset.toml +16 -0
- examples/task_apps/crafter/task_app/README.md +42 -0
- examples/task_apps/crafter/task_app/__init__.py +5 -0
- examples/task_apps/crafter/task_app/grpo_crafter.py +1055 -0
- examples/task_apps/crafter/task_app/grpo_crafter_task_app.py +146 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/README.md +173 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/__init__.py +5 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/branching.py +143 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/environment_routes.py +1226 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/envs/__init__.py +1 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/envs/crafter/__init__.py +6 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/envs/crafter/app.py +1 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/envs/crafter/environment.py +532 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/envs/crafter/policy.py +583 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/envs/crafter/react_agent.py +122 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/envs/crafter/shared.py +305 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/envs/crafter/tools.py +47 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/hosted_app.py +253 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/inference/__init__.py +5 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/inference/openai_client.py +999 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/main.py +100 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/policy_routes.py +1252 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/registry.py +195 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/rollout.py +2233 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/storage/__init__.py +5 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/storage/volume.py +211 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/test_agents.py +161 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/test_service.py +136 -0
- examples/task_apps/crafter/task_app/synth_envs_hosted/utils.py +411 -0
- examples/task_apps/dev/pokemon_emerald/__init__.py +2 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/README.md +811 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/__init__.py +120 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/action.py +160 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/memory.py +155 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/perception.py +69 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/planning.py +96 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/simple.py +1502 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/agent/system_prompt.py +4 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/grab_map.py +68 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/manual.py +216 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/__init__.py +35 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/emerald_utils.py +631 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/emulator.py +1544 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/enums.py +1428 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/memory_reader.py +4848 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/types.py +41 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pokemon_env/utils.py +298 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/pyproject.toml +95 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/run.py +204 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/server/app.py +2152 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/server/client.py +429 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/server/frame_server.py +155 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/README.md +78 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/run_tests.py +122 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_agent_direct.py +76 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_agent_prompts.py +413 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_battle_state_formatting.py +204 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_dialogue_detection.py +133 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_dialogue_detection_comprehensive.py +229 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_direct_agent_emulator.py +300 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_fps_adjustment_pytest.py +205 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_house_to_outside_direct.py +200 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_house_to_outside_transition.py +284 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_map_ground_truth_comparison.py +468 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_memory_map.py +575 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_server_map_validation.py +311 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests/test_torchic_state.py +259 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/anticheat.py +372 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/checkpoint.py +296 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/error_handler.py +275 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/get_local_ip.py +22 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/helpers.py +44 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/llm_logger.py +514 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_formatter.py +415 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_stitcher.py +1763 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_stitcher_singleton.py +33 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_trimmer.py +106 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/map_visualizer.py +334 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/ocr_dialogue.py +1020 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/recording.py +188 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/state_formatter.py +1481 -0
- examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils/vlm.py +862 -0
- examples/task_apps/dev/pokemon_emerald/modal_app.py +114 -0
- examples/task_apps/dev/pokemon_emerald/task_app/README.md +81 -0
- examples/task_apps/dev/pokemon_emerald/task_app/__init__.py +6 -0
- examples/task_apps/dev/pokemon_emerald/task_app/pokemon_emerald.py +685 -0
- examples/task_apps/enron/__init__.py +2 -0
- examples/task_apps/enron/eval_groq_qwen32.toml +16 -0
- examples/task_apps/enron/filter_sft.toml +5 -0
- examples/task_apps/enron/task_app/README.md +14 -0
- examples/task_apps/enron/task_app/__init__.py +1 -0
- examples/task_apps/enron/task_app/grpo_enron.py +906 -0
- examples/task_apps/enron/task_app/grpo_enron_task_app.py +146 -0
- examples/task_apps/enron/tests/__init__.py +4 -0
- examples/task_apps/enron/tests/conftest.py +115 -0
- examples/task_apps/enron/tests/integration/__init__.py +4 -0
- examples/task_apps/enron/tests/integration/test_enron_eval.py +179 -0
- examples/task_apps/enron/tests/integration/test_enron_rollout.py +135 -0
- examples/task_apps/enron/tests/unit/__init__.py +4 -0
- examples/task_apps/enron/tests/unit/test_enron_environment.py +126 -0
- examples/task_apps/gepa_benchmarks/__init__.py +7 -0
- examples/task_apps/gepa_benchmarks/common.py +260 -0
- examples/task_apps/gepa_benchmarks/hotpotqa_task_app.py +507 -0
- examples/task_apps/gepa_benchmarks/hover_task_app.py +436 -0
- examples/task_apps/gepa_benchmarks/ifbench_task_app.py +563 -0
- examples/task_apps/gepa_benchmarks/pupa_task_app.py +460 -0
- examples/task_apps/math/README.md +21 -0
- examples/task_apps/math/math_single_step.py +1000 -0
- examples/task_apps/math/math_task_app.py +115 -0
- examples/task_apps/pokemon_battle/__init__.py +2 -0
- examples/task_apps/pokemon_battle/modal_app.py +104 -0
- examples/task_apps/pokemon_battle/task_app/README.md +68 -0
- examples/task_apps/pokemon_battle/task_app/__init__.py +6 -0
- examples/task_apps/pokemon_battle/task_app/pokemon_showdown.py +932 -0
- examples/task_apps/pokemon_red/EVAL_IMAGE_ONLY_COMPLETE.md +283 -0
- examples/task_apps/pokemon_red/EVAL_IMAGE_ONLY_STATUS.md +155 -0
- examples/task_apps/pokemon_red/README.md +356 -0
- examples/task_apps/pokemon_red/README_IMAGE_ONLY_EVAL.md +428 -0
- examples/task_apps/pokemon_red/__init__.py +3 -0
- examples/task_apps/pokemon_red/eval_image_only_gpt4o.toml +30 -0
- examples/task_apps/pokemon_red/eval_pokemon_red_policy.py +224 -0
- examples/task_apps/pokemon_red/pallet_town_rl_config.toml +75 -0
- examples/task_apps/pokemon_red/task_app.py +1048 -0
- examples/task_apps/pokemon_red/test_pallet_town_rewards.py +193 -0
- examples/task_apps/sokoban/README.md +306 -0
- examples/task_apps/sokoban/__init__.py +3 -0
- examples/task_apps/sokoban/eval_groq_qwen32.toml +16 -0
- examples/task_apps/sokoban/eval_openai_gpt5.toml +16 -0
- examples/task_apps/sokoban/filter_sft.toml +5 -0
- examples/task_apps/sokoban/task_app.py +1058 -0
- examples/task_apps/sokoban/tests/__init__.py +4 -0
- examples/task_apps/sokoban/tests/conftest.py +113 -0
- examples/task_apps/sokoban/tests/integration/__init__.py +4 -0
- examples/task_apps/sokoban/tests/integration/test_sokoban_eval.py +57 -0
- examples/task_apps/sokoban/tests/integration/test_sokoban_rollout.py +198 -0
- examples/task_apps/sokoban/tests/unit/__init__.py +4 -0
- examples/task_apps/sokoban/tests/unit/test_sokoban_environment.py +114 -0
- examples/task_apps/verilog/__init__.py +1 -0
- examples/task_apps/verilog/eval_groq_qwen32b.toml +22 -0
- examples/task_apps/verilog/filter_sft.toml +5 -0
- examples/task_apps/verilog/task_app/README.md +12 -0
- examples/task_apps/verilog/task_app/__init__.py +1 -0
- examples/task_apps/verilog/task_app/grpo_verilog.py +1166 -0
- examples/task_apps/verilog/task_app/grpo_verilog_task_app.py +145 -0
- examples/task_apps/verilog/tests/__init__.py +4 -0
- examples/task_apps/verilog/tests/conftest.py +115 -0
- examples/task_apps/verilog/tests/integration/__init__.py +4 -0
- examples/task_apps/verilog/tests/integration/test_verilog_eval.py +181 -0
- examples/task_apps/verilog/tests/integration/test_verilog_rollout.py +55 -0
- examples/task_apps/verilog/tests/unit/__init__.py +4 -0
- examples/task_apps/verilog/tests/unit/test_verilog_scoring.py +118 -0
- examples/tunnel_gepa_banking77/README.md +106 -0
- examples/tunnel_gepa_banking77/banking77_gepa_tunnel.toml +95 -0
- examples/tunnel_gepa_banking77/keep_tunnel_running.py +60 -0
- examples/tunnel_gepa_banking77/run_gepa_with_tunnel.sh +226 -0
- examples/vlm/PROPOSAL.md +53 -0
- examples/vlm/README.md +68 -0
- examples/vlm/configs/crafter_vlm_gpt4o.toml +49 -0
- examples/vlm/crafter_image_only_agent.py +207 -0
- examples/vlm/crafter_openai_vlm_agent.py +275 -0
- examples/vlm/filter_image_rows.py +63 -0
- examples/vlm/run_crafter_vlm_benchmark.py +316 -0
- examples/warming_up_to_rl/_utils.py +92 -0
- examples/warming_up_to_rl/analyze_trace_db.py +422 -0
- examples/warming_up_to_rl/configs/crafter_fft.toml +53 -0
- examples/warming_up_to_rl/configs/crafter_fft_4b.toml +54 -0
- examples/warming_up_to_rl/configs/eval_fft_qwen4b.toml +22 -0
- examples/warming_up_to_rl/configs/eval_groq_qwen32b.toml +15 -0
- examples/warming_up_to_rl/configs/eval_modal_qwen4b.toml +24 -0
- examples/warming_up_to_rl/configs/eval_stepwise_complex.toml +35 -0
- examples/warming_up_to_rl/configs/eval_stepwise_consistent.toml +26 -0
- examples/warming_up_to_rl/configs/eval_stepwise_per_achievement.toml +36 -0
- examples/warming_up_to_rl/configs/eval_stepwise_simple.toml +32 -0
- examples/warming_up_to_rl/configs/rl_from_base_qwen4b.toml +85 -0
- examples/warming_up_to_rl/configs/rl_from_ft.toml +58 -0
- examples/warming_up_to_rl/export_trace_sft.py +837 -0
- examples/warming_up_to_rl/groq_test.py +97 -0
- examples/warming_up_to_rl/manage_secrets.py +131 -0
- examples/warming_up_to_rl/old/event_rewards.md +234 -0
- examples/warming_up_to_rl/old/notes.md +73 -0
- examples/warming_up_to_rl/readme.md +110 -0
- examples/warming_up_to_rl/run_eval.py +736 -0
- examples/warming_up_to_rl/run_fft_and_save.py +380 -0
- examples/warming_up_to_rl/run_local_rollout.py +239 -0
- examples/warming_up_to_rl/run_local_rollout_modal.py +248 -0
- examples/warming_up_to_rl/run_local_rollout_parallel.py +405 -0
- examples/warming_up_to_rl/run_local_rollout_traced.py +477 -0
- examples/warming_up_to_rl/run_rl_and_save.py +124 -0
- examples/warming_up_to_rl/run_rollout_remote.py +156 -0
- examples/warming_up_to_rl/task_app/README.md +42 -0
- examples/warming_up_to_rl/task_app/grpo_crafter.py +876 -0
- examples/warming_up_to_rl/task_app/grpo_crafter_task_app.py +135 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/README.md +173 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/__init__.py +5 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/branching.py +143 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/environment_routes.py +1226 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/__init__.py +1 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/__init__.py +6 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/app.py +1 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/environment.py +522 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/policy.py +454 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/react_agent.py +108 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/shared.py +305 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/envs/crafter/tools.py +47 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/hosted_app.py +253 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/inference/__init__.py +5 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/inference/openai_client.py +729 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/main.py +100 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/policy_routes.py +1114 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/registry.py +195 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/rollout.py +1891 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/storage/__init__.py +5 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/storage/volume.py +211 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/test_agents.py +161 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/test_service.py +137 -0
- examples/warming_up_to_rl/task_app/synth_envs_hosted/utils.py +129 -0
- examples/workflows/math_rl/configs/eval_base_qwen.toml +15 -0
- examples/workflows/math_rl/configs/eval_rl_qwen.toml +11 -0
- examples/workflows/math_rl/configs/rl_from_base_qwen.toml +62 -0
- examples/workflows/math_rl/configs/rl_from_base_qwen17.toml +80 -0
- examples/workflows/math_rl/configs/rl_from_ft_qwen.toml +35 -0
- examples/workflows/math_rl/download_dataset.py +80 -0
- examples/workflows/math_rl/run_eval.py +436 -0
- examples/workflows/math_rl/run_rl_and_save.py +111 -0
- synth_ai/__init__.py +47 -23
- synth_ai/_utils/__init__.py +47 -0
- synth_ai/_utils/base_url.py +10 -0
- synth_ai/_utils/http.py +10 -0
- synth_ai/_utils/prompts.py +10 -0
- synth_ai/_utils/task_app_state.py +12 -0
- synth_ai/_utils/user_config.py +10 -0
- synth_ai/api/models/supported.py +514 -0
- synth_ai/api/train/__init__.py +60 -2
- synth_ai/api/train/builders.py +347 -39
- synth_ai/api/train/cli.py +895 -160
- synth_ai/api/train/config_finder.py +103 -25
- synth_ai/api/train/configs/__init__.py +65 -0
- synth_ai/api/train/configs/prompt_learning.py +496 -0
- synth_ai/api/train/configs/rl.py +188 -0
- synth_ai/api/train/configs/sft.py +99 -0
- synth_ai/api/train/configs/shared.py +81 -0
- synth_ai/api/train/env_resolver.py +70 -20
- synth_ai/api/train/pollers.py +29 -4
- synth_ai/api/train/prompt_learning.py +425 -0
- synth_ai/api/train/sft.py +390 -0
- synth_ai/api/train/supported_algos.py +147 -0
- synth_ai/api/train/task_app.py +6 -4
- synth_ai/api/train/utils.py +64 -52
- synth_ai/api/train/validators.py +1117 -0
- synth_ai/api/tunnel.py +49 -0
- synth_ai/auth/credentials.py +94 -0
- synth_ai/baseline/__init__.py +25 -0
- synth_ai/baseline/config.py +209 -0
- synth_ai/baseline/discovery.py +214 -0
- synth_ai/baseline/execution.py +146 -0
- synth_ai/cfgs.py +227 -0
- synth_ai/cli/__init__.py +85 -63
- synth_ai/cli/_modal_wrapper.py +31 -0
- synth_ai/cli/_storage.py +20 -0
- synth_ai/cli/_typer_patch.py +47 -0
- synth_ai/cli/_validate_task_app.py +29 -0
- synth_ai/cli/balance.py +16 -4
- synth_ai/cli/calc.py +36 -21
- synth_ai/cli/claude.py +70 -0
- synth_ai/cli/codex.py +267 -0
- synth_ai/cli/commands/__init__.py +18 -0
- synth_ai/cli/commands/baseline/__init__.py +12 -0
- synth_ai/cli/commands/baseline/core.py +637 -0
- synth_ai/cli/commands/baseline/list.py +93 -0
- synth_ai/cli/commands/demo/__init__.py +6 -0
- synth_ai/cli/commands/demo/core.py +163 -0
- synth_ai/cli/commands/eval/__init__.py +19 -0
- synth_ai/cli/commands/eval/core.py +1112 -0
- synth_ai/cli/commands/eval/errors.py +81 -0
- synth_ai/cli/commands/eval/validation.py +133 -0
- synth_ai/cli/commands/filter/__init__.py +12 -0
- synth_ai/cli/commands/filter/core.py +424 -0
- synth_ai/cli/commands/filter/errors.py +55 -0
- synth_ai/cli/commands/filter/validation.py +77 -0
- synth_ai/cli/commands/help/__init__.py +185 -0
- synth_ai/cli/commands/help/core.py +72 -0
- synth_ai/cli/commands/smoke/__init__.py +7 -0
- synth_ai/cli/commands/smoke/core.py +1437 -0
- synth_ai/cli/commands/status/__init__.py +66 -0
- synth_ai/cli/commands/status/client.py +192 -0
- synth_ai/cli/commands/status/config.py +92 -0
- synth_ai/cli/commands/status/errors.py +20 -0
- synth_ai/cli/commands/status/formatters.py +164 -0
- synth_ai/cli/commands/status/subcommands/__init__.py +9 -0
- synth_ai/cli/commands/status/subcommands/files.py +79 -0
- synth_ai/cli/commands/status/subcommands/jobs.py +334 -0
- synth_ai/cli/commands/status/subcommands/models.py +79 -0
- synth_ai/cli/commands/status/subcommands/pricing.py +22 -0
- synth_ai/cli/commands/status/subcommands/runs.py +81 -0
- synth_ai/cli/commands/status/subcommands/session.py +183 -0
- synth_ai/cli/commands/status/subcommands/summary.py +47 -0
- synth_ai/cli/commands/status/subcommands/usage.py +203 -0
- synth_ai/cli/commands/status/utils.py +114 -0
- synth_ai/cli/commands/train/__init__.py +53 -0
- synth_ai/cli/commands/train/core.py +21 -0
- synth_ai/cli/commands/train/errors.py +117 -0
- synth_ai/cli/commands/train/judge_schemas.py +200 -0
- synth_ai/cli/commands/train/judge_validation.py +305 -0
- synth_ai/cli/commands/train/validation.py +386 -0
- synth_ai/cli/demo.py +32 -140
- synth_ai/cli/deploy.py +233 -0
- synth_ai/cli/eval/__init__.py +36 -0
- synth_ai/cli/eval/core.py +5 -0
- synth_ai/cli/eval/errors.py +31 -0
- synth_ai/cli/eval/validation.py +5 -0
- synth_ai/cli/filter/__init__.py +28 -0
- synth_ai/cli/filter/core.py +5 -0
- synth_ai/cli/filter/errors.py +23 -0
- synth_ai/cli/filter/validation.py +5 -0
- synth_ai/cli/legacy_root_backup.py +28 -22
- synth_ai/cli/lib/__init__.py +10 -0
- synth_ai/cli/lib/task_app_discovery.py +7 -0
- synth_ai/cli/lib/task_app_env.py +518 -0
- synth_ai/cli/mcp.py +34 -0
- synth_ai/cli/modal_serve/__init__.py +12 -0
- synth_ai/cli/modal_serve/core.py +14 -0
- synth_ai/cli/modal_serve/errors.py +8 -0
- synth_ai/cli/modal_serve/validation.py +11 -0
- synth_ai/cli/opencode.py +256 -0
- synth_ai/cli/recent.py +13 -7
- synth_ai/cli/rl_demo.py +156 -116
- synth_ai/cli/root.py +131 -132
- synth_ai/cli/serve/__init__.py +12 -0
- synth_ai/cli/serve/core.py +14 -0
- synth_ai/cli/serve/errors.py +8 -0
- synth_ai/cli/serve/validation.py +11 -0
- synth_ai/cli/setup.py +49 -0
- synth_ai/cli/status.py +7 -125
- synth_ai/cli/task_app_deploy.py +7 -0
- synth_ai/cli/task_app_list.py +25 -0
- synth_ai/cli/task_app_modal_serve.py +11 -0
- synth_ai/cli/task_app_serve.py +11 -0
- synth_ai/cli/task_apps.py +2284 -257
- synth_ai/cli/traces.py +9 -5
- synth_ai/cli/train/__init__.py +12 -0
- synth_ai/cli/train/core.py +21 -0
- synth_ai/cli/train/errors.py +8 -0
- synth_ai/cli/train/validation.py +24 -0
- synth_ai/cli/train.py +5 -0
- synth_ai/cli/turso.py +73 -0
- synth_ai/cli/watch.py +13 -18
- synth_ai/demos/__init__.py +10 -0
- synth_ai/demos/core/__init__.py +28 -1
- synth_ai/demos/core/cli.py +579 -291
- synth_ai/demos/crafter/__init__.py +1 -0
- synth_ai/demos/crafter/crafter_fft_4b.toml +55 -0
- synth_ai/demos/crafter/grpo_crafter_task_app.py +185 -0
- synth_ai/demos/crafter/rl_from_base_qwen4b.toml +74 -0
- synth_ai/demos/demo_registry.py +176 -0
- synth_ai/demos/demo_task_apps/__init__.py +3 -3
- synth_ai/demos/demo_task_apps/core.py +64 -28
- synth_ai/demos/demo_task_apps/crafter/__init__.py +1 -0
- synth_ai/demos/demo_task_apps/crafter/configs/crafter_fft_4b.toml +53 -0
- synth_ai/demos/demo_task_apps/crafter/configs/rl_from_base_qwen4b.toml +73 -0
- synth_ai/demos/demo_task_apps/crafter/grpo_crafter_task_app.py +184 -0
- synth_ai/demos/demo_task_apps/math/_common.py +1 -2
- synth_ai/demos/demo_task_apps/math/app.py +2 -1
- synth_ai/demos/demo_task_apps/math/deploy_modal.py +3 -6
- synth_ai/demos/demo_task_apps/math/modal_task_app.py +185 -83
- synth_ai/demos/demo_task_apps/math/task_app_entry.py +0 -2
- synth_ai/demos/math/__init__.py +1 -0
- synth_ai/demos/math/_common.py +16 -0
- synth_ai/demos/math/app.py +38 -0
- synth_ai/demos/math/config.toml +76 -0
- synth_ai/demos/math/deploy_modal.py +54 -0
- synth_ai/demos/math/modal_task_app.py +703 -0
- synth_ai/demos/math/task_app_entry.py +51 -0
- synth_ai/environments/environment/core.py +7 -1
- synth_ai/environments/examples/bandit/engine.py +12 -5
- synth_ai/environments/examples/bandit/environment.py +0 -1
- synth_ai/environments/examples/bandit/taskset.py +4 -4
- synth_ai/environments/examples/crafter_classic/engine_deterministic_patch.py +7 -4
- synth_ai/environments/examples/crafter_classic/engine_serialization_patch_v3.py +9 -5
- synth_ai/environments/examples/crafter_classic/environment.py +93 -2
- synth_ai/environments/examples/crafter_classic/world_config_patch_simple.py +4 -3
- synth_ai/environments/examples/enron/engine.py +7 -2
- synth_ai/environments/examples/enron/environment.py +68 -0
- synth_ai/environments/examples/red/engine.py +60 -12
- synth_ai/environments/examples/red/engine_helpers/memory_map.py +7 -0
- synth_ai/environments/examples/red/engine_helpers/reward_components.py +151 -179
- synth_ai/environments/examples/red/engine_helpers/reward_library/pallet_town_progression.py +477 -0
- synth_ai/environments/examples/red/engine_helpers/state_extraction.py +32 -0
- synth_ai/environments/examples/red/environment.py +86 -0
- synth_ai/environments/examples/red/trace_hooks_v3.py +168 -0
- synth_ai/environments/examples/sokoban/taskset.py +116 -0
- synth_ai/environments/examples/verilog/engine.py +104 -12
- synth_ai/environments/examples/wordle/environment.py +0 -1
- synth_ai/environments/reproducibility/tree.py +5 -6
- synth_ai/environments/service/app.py +11 -12
- synth_ai/environments/service/core_routes.py +10 -9
- synth_ai/environments/stateful/engine.py +1 -1
- synth_ai/environments/tasks/core.py +1 -0
- synth_ai/environments/tasks/filters.py +5 -6
- synth_ai/environments/tasks/utils.py +4 -5
- synth_ai/evals/__init__.py +15 -0
- synth_ai/evals/base.py +14 -5
- synth_ai/evals/client.py +82 -0
- synth_ai/evals/types.py +42 -0
- synth_ai/http.py +8 -22
- synth_ai/http_client.py +45 -12
- synth_ai/inference/__init__.py +0 -2
- synth_ai/inference/client.py +21 -7
- synth_ai/jobs/client.py +129 -80
- synth_ai/judge_schemas.py +127 -0
- synth_ai/learning/__init__.py +51 -6
- synth_ai/learning/algorithms.py +14 -0
- synth_ai/learning/client.py +122 -30
- synth_ai/learning/config.py +2 -40
- synth_ai/learning/constants.py +0 -2
- synth_ai/learning/ft_client.py +4 -56
- synth_ai/learning/health.py +14 -8
- synth_ai/learning/jobs.py +43 -47
- synth_ai/learning/prompt_learning_client.py +276 -0
- synth_ai/learning/prompt_learning_types.py +185 -0
- synth_ai/{rl → learning/rl}/__init__.py +14 -5
- synth_ai/learning/rl/client.py +269 -0
- synth_ai/learning/rl/config.py +31 -0
- synth_ai/{rl → learning/rl}/contracts.py +5 -10
- synth_ai/{rl → learning/rl}/env_keys.py +45 -16
- synth_ai/learning/rl/secrets.py +13 -0
- synth_ai/learning/rl_client.py +2 -253
- synth_ai/learning/sft/__init__.py +29 -0
- synth_ai/learning/sft/client.py +68 -0
- synth_ai/learning/sft/config.py +270 -0
- synth_ai/learning/sft/data.py +698 -0
- synth_ai/learning/sse.py +25 -26
- synth_ai/learning/validators.py +29 -25
- synth_ai/mcp/__init__.py +5 -0
- synth_ai/mcp/__main__.py +8 -0
- synth_ai/mcp/main.py +254 -0
- synth_ai/mcp/setup.py +100 -0
- synth_ai/modal.py +257 -0
- synth_ai/pricing/__init__.py +3 -0
- synth_ai/pricing/model_pricing.py +64 -0
- synth_ai/session/__init__.py +75 -0
- synth_ai/session/client.py +383 -0
- synth_ai/session/constants.py +63 -0
- synth_ai/session/exceptions.py +105 -0
- synth_ai/session/manager.py +139 -0
- synth_ai/session/models.py +89 -0
- synth_ai/session/query.py +110 -0
- synth_ai/spec/__init__.py +46 -0
- synth_ai/spec/dataclasses.py +149 -0
- synth_ai/spec/loader.py +144 -0
- synth_ai/spec/serializer.py +199 -0
- synth_ai/spec/validation.py +250 -0
- synth_ai/streaming/__init__.py +29 -0
- synth_ai/streaming/config.py +94 -0
- synth_ai/streaming/handlers.py +589 -0
- synth_ai/streaming/streamer.py +320 -0
- synth_ai/streaming/types.py +95 -0
- synth_ai/task/__init__.py +50 -30
- synth_ai/task/apps/__init__.py +63 -19
- synth_ai/task/auth.py +35 -23
- synth_ai/task/client.py +15 -13
- synth_ai/task/config.py +261 -0
- synth_ai/task/contracts.py +165 -64
- synth_ai/task/datasets.py +9 -6
- synth_ai/task/errors.py +11 -10
- synth_ai/task/health.py +17 -11
- synth_ai/task/inference_api.py +101 -0
- synth_ai/task/json.py +58 -24
- synth_ai/task/proxy.py +59 -66
- synth_ai/task/rubrics/__init__.py +55 -0
- synth_ai/task/rubrics/loaders.py +156 -0
- synth_ai/task/rubrics/models.py +57 -0
- synth_ai/task/rubrics/scoring.py +116 -0
- synth_ai/task/rubrics/strict.py +149 -0
- synth_ai/task/rubrics.py +22 -15
- synth_ai/task/server.py +65 -31
- synth_ai/task/trace_correlation_helpers.py +328 -0
- synth_ai/task/tracing_utils.py +44 -28
- synth_ai/task/validators.py +449 -6
- synth_ai/task/vendors.py +5 -7
- synth_ai/tracing_v3/__init__.py +4 -0
- synth_ai/tracing_v3/abstractions.py +21 -4
- synth_ai/tracing_v3/config.py +167 -22
- synth_ai/tracing_v3/constants.py +21 -0
- synth_ai/tracing_v3/db_config.py +42 -29
- synth_ai/tracing_v3/decorators.py +80 -45
- synth_ai/tracing_v3/examples/basic_usage.py +15 -9
- synth_ai/tracing_v3/hooks.py +6 -4
- synth_ai/tracing_v3/llm_call_record_helpers.py +161 -61
- synth_ai/tracing_v3/migration_helper.py +1 -2
- synth_ai/tracing_v3/replica_sync.py +12 -7
- synth_ai/tracing_v3/serialization.py +130 -0
- synth_ai/tracing_v3/session_tracer.py +73 -16
- synth_ai/tracing_v3/storage/base.py +89 -1
- synth_ai/tracing_v3/storage/config.py +63 -16
- synth_ai/tracing_v3/storage/factory.py +11 -9
- synth_ai/tracing_v3/storage/utils.py +15 -11
- synth_ai/tracing_v3/trace_utils.py +317 -0
- synth_ai/tracing_v3/turso/__init__.py +8 -21
- synth_ai/tracing_v3/turso/daemon.py +123 -15
- synth_ai/tracing_v3/turso/models.py +5 -2
- synth_ai/tracing_v3/turso/native_manager.py +1293 -0
- synth_ai/tracing_v3/utils.py +5 -4
- synth_ai/tunnel.py +143 -0
- synth_ai/tunnel_deploy.py +278 -0
- synth_ai/types.py +8 -0
- synth_ai/urls.py +11 -0
- synth_ai/utils/__init__.py +166 -0
- synth_ai/utils/agents.py +74 -0
- synth_ai/utils/apps.py +152 -0
- synth_ai/utils/base_url.py +94 -0
- synth_ai/utils/bin.py +39 -0
- synth_ai/utils/claude.py +36 -0
- synth_ai/utils/cli.py +284 -0
- synth_ai/utils/config.py +81 -0
- synth_ai/utils/env.py +346 -0
- synth_ai/utils/errors.py +85 -0
- synth_ai/utils/http.py +172 -0
- synth_ai/utils/json.py +72 -0
- synth_ai/utils/log_filter.py +99 -0
- synth_ai/utils/logging.py +198 -0
- synth_ai/utils/modal.py +299 -0
- synth_ai/utils/paths.py +95 -0
- synth_ai/utils/process.py +233 -0
- synth_ai/utils/prompts.py +39 -0
- synth_ai/utils/sqld.py +122 -0
- synth_ai/utils/ssl.py +25 -0
- synth_ai/utils/task_app_discovery.py +882 -0
- synth_ai/utils/task_app_env.py +186 -0
- synth_ai/utils/task_app_state.py +318 -0
- synth_ai/utils/tunnel/__init__.py +12 -0
- synth_ai/utils/tunnel/config.py +55 -0
- synth_ai/utils/user_config.py +137 -0
- synth_ai/uvicorn.py +77 -0
- synth_ai-0.2.23.dev3.dist-info/METADATA +357 -0
- synth_ai-0.2.23.dev3.dist-info/RECORD +983 -0
- {synth_ai-0.2.9.dev0.dist-info → synth_ai-0.2.23.dev3.dist-info}/entry_points.txt +0 -1
- {synth_ai-0.2.9.dev0.dist-info → synth_ai-0.2.23.dev3.dist-info}/top_level.txt +1 -0
- synth_ai/cli/man.py +0 -106
- synth_ai/core/experiment.py +0 -15
- synth_ai/core/system.py +0 -15
- synth_ai/demo_registry.py +0 -258
- synth_ai/environments/examples/sokoban/units/astar_common.py +0 -95
- synth_ai/experimental/synth_oss.py +0 -446
- synth_ai/handshake.py +0 -107
- synth_ai/install_sqld.sh +0 -40
- synth_ai/learning/offline/dpo.py +0 -0
- synth_ai/learning/offline/providers.py +0 -7
- synth_ai/learning/offline/sft.py +0 -0
- synth_ai/learning/offline/shared.py +0 -0
- synth_ai/learning/online/grpo.py +0 -0
- synth_ai/learning/online/irft.py +0 -0
- synth_ai/learning/prompts/banking77_injection_eval.py +0 -168
- synth_ai/learning/prompts/gepa.py +0 -0
- synth_ai/learning/prompts/hello_world_in_context_injection_ex.py +0 -213
- synth_ai/learning/prompts/mipro.py +0 -289
- synth_ai/learning/prompts/random_search.py +0 -246
- synth_ai/learning/prompts/run_mipro_banking77.py +0 -172
- synth_ai/learning/prompts/run_random_search_banking77.py +0 -324
- synth_ai/lm/__init__.py +0 -51
- synth_ai/lm/caching/constants.py +0 -6
- synth_ai/lm/caching/dbs.py +0 -0
- synth_ai/lm/caching/ephemeral.py +0 -102
- synth_ai/lm/caching/handler.py +0 -137
- synth_ai/lm/caching/initialize.py +0 -11
- synth_ai/lm/caching/persistent.py +0 -114
- synth_ai/lm/config.py +0 -110
- synth_ai/lm/constants.py +0 -32
- synth_ai/lm/core/__init__.py +0 -8
- synth_ai/lm/core/all.py +0 -73
- synth_ai/lm/core/exceptions.py +0 -7
- synth_ai/lm/core/main.py +0 -319
- synth_ai/lm/core/main_v3.py +0 -594
- synth_ai/lm/core/synth_models.py +0 -48
- synth_ai/lm/core/vendor_clients.py +0 -188
- synth_ai/lm/cost/monitor.py +0 -1
- synth_ai/lm/cost/statefulness.py +0 -1
- synth_ai/lm/injection.py +0 -80
- synth_ai/lm/overrides.py +0 -206
- synth_ai/lm/provider_support/__init__.py +0 -8
- synth_ai/lm/provider_support/anthropic.py +0 -972
- synth_ai/lm/provider_support/openai.py +0 -1139
- synth_ai/lm/provider_support/suppress_logging.py +0 -31
- synth_ai/lm/structured_outputs/handler.py +0 -440
- synth_ai/lm/structured_outputs/inject.py +0 -297
- synth_ai/lm/structured_outputs/rehabilitate.py +0 -185
- synth_ai/lm/tools/__init__.py +0 -3
- synth_ai/lm/tools/base.py +0 -172
- synth_ai/lm/unified_interface.py +0 -202
- synth_ai/lm/vendors/base.py +0 -81
- synth_ai/lm/vendors/core/anthropic_api.py +0 -387
- synth_ai/lm/vendors/core/gemini_api.py +0 -292
- synth_ai/lm/vendors/core/mistral_api.py +0 -322
- synth_ai/lm/vendors/core/openai_api.py +0 -225
- synth_ai/lm/vendors/core/synth_dev_api.py +0 -0
- synth_ai/lm/vendors/local/ollama.py +0 -0
- synth_ai/lm/vendors/openai_standard.py +0 -780
- synth_ai/lm/vendors/openai_standard_responses.py +0 -256
- synth_ai/lm/vendors/retries.py +0 -22
- synth_ai/lm/vendors/supported/custom_endpoint.py +0 -417
- synth_ai/lm/vendors/supported/deepseek.py +0 -69
- synth_ai/lm/vendors/supported/grok.py +0 -75
- synth_ai/lm/vendors/supported/groq.py +0 -16
- synth_ai/lm/vendors/supported/ollama.py +0 -15
- synth_ai/lm/vendors/supported/openrouter.py +0 -74
- synth_ai/lm/vendors/supported/together.py +0 -11
- synth_ai/lm/vendors/synth_client.py +0 -808
- synth_ai/lm/warmup.py +0 -186
- synth_ai/rl/secrets.py +0 -19
- synth_ai/scripts/verify_rewards.py +0 -100
- synth_ai/task/apps/grpo_crafter.py +0 -438
- synth_ai/tracing/__init__.py +0 -30
- synth_ai/tracing_v1/__init__.py +0 -33
- synth_ai/tracing_v3/turso/manager.py +0 -774
- synth_ai/v0/tracing/abstractions.py +0 -224
- synth_ai/v0/tracing/base_client.py +0 -91
- synth_ai/v0/tracing/client_manager.py +0 -131
- synth_ai/v0/tracing/config.py +0 -142
- synth_ai/v0/tracing/context.py +0 -146
- synth_ai/v0/tracing/decorators.py +0 -682
- synth_ai/v0/tracing/events/__init__.py +0 -0
- synth_ai/v0/tracing/events/manage.py +0 -147
- synth_ai/v0/tracing/events/scope.py +0 -86
- synth_ai/v0/tracing/events/store.py +0 -228
- synth_ai/v0/tracing/immediate_client.py +0 -151
- synth_ai/v0/tracing/local.py +0 -18
- synth_ai/v0/tracing/log_client_base.py +0 -73
- synth_ai/v0/tracing/retry_queue.py +0 -186
- synth_ai/v0/tracing/trackers.py +0 -515
- synth_ai/v0/tracing/upload.py +0 -512
- synth_ai/v0/tracing/utils.py +0 -9
- synth_ai/v0/tracing_v1/__init__.py +0 -16
- synth_ai/v0/tracing_v1/abstractions.py +0 -224
- synth_ai/v0/tracing_v1/base_client.py +0 -91
- synth_ai/v0/tracing_v1/client_manager.py +0 -131
- synth_ai/v0/tracing_v1/config.py +0 -142
- synth_ai/v0/tracing_v1/context.py +0 -146
- synth_ai/v0/tracing_v1/decorators.py +0 -703
- synth_ai/v0/tracing_v1/events/__init__.py +0 -0
- synth_ai/v0/tracing_v1/events/manage.py +0 -147
- synth_ai/v0/tracing_v1/events/scope.py +0 -86
- synth_ai/v0/tracing_v1/events/store.py +0 -228
- synth_ai/v0/tracing_v1/immediate_client.py +0 -151
- synth_ai/v0/tracing_v1/local.py +0 -18
- synth_ai/v0/tracing_v1/log_client_base.py +0 -73
- synth_ai/v0/tracing_v1/retry_queue.py +0 -186
- synth_ai/v0/tracing_v1/trackers.py +0 -515
- synth_ai/v0/tracing_v1/upload.py +0 -527
- synth_ai/v0/tracing_v1/utils.py +0 -9
- synth_ai/zyk/__init__.py +0 -30
- synth_ai-0.2.9.dev0.dist-info/METADATA +0 -131
- synth_ai-0.2.9.dev0.dist-info/RECORD +0 -444
- {synth_ai/lm/caching → examples/task_apps}/__init__.py +0 -0
- {synth_ai/lm/cost → examples/task_apps/crafter}/__init__.py +0 -0
- {synth_ai/lm/structured_outputs → examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/server}/__init__.py +0 -0
- {synth_ai/lm/vendors → examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/tests}/__init__.py +0 -0
- {synth_ai/lm/vendors/core → examples/task_apps/dev/pokemon_emerald/external/pokeagent-speedrun/utils}/__init__.py +0 -0
- {synth_ai/lm/vendors/local → examples/task_apps/math}/__init__.py +0 -0
- {synth_ai/lm/vendors/supported → examples/workflows}/__init__.py +0 -0
- {synth_ai/v0/tracing → examples/workflows/math_rl}/__init__.py +0 -0
- /synth_ai/{compound/cais.py → cli/__main__.py} +0 -0
- /synth_ai/{learning/filtering.py → py.typed} +0 -0
- {synth_ai-0.2.9.dev0.dist-info → synth_ai-0.2.23.dev3.dist-info}/WHEEL +0 -0
- {synth_ai-0.2.9.dev0.dist-info → synth_ai-0.2.23.dev3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,703 +0,0 @@
|
|
|
1
|
-
# synth_sdk/tracing/decorators.py
|
|
2
|
-
import inspect
|
|
3
|
-
import logging
|
|
4
|
-
import os
|
|
5
|
-
import time
|
|
6
|
-
import warnings
|
|
7
|
-
from collections.abc import Callable
|
|
8
|
-
from functools import wraps
|
|
9
|
-
from typing import TYPE_CHECKING, Any, Literal, ParamSpec, TypeVar, Union
|
|
10
|
-
|
|
11
|
-
if TYPE_CHECKING:
|
|
12
|
-
from .trackers import SynthTrackerAsync, SynthTrackerSync
|
|
13
|
-
|
|
14
|
-
from synth_ai.config.base_url import PROD_BASE_URL_DEFAULT
|
|
15
|
-
|
|
16
|
-
from .abstractions import (
|
|
17
|
-
AgentComputeStep,
|
|
18
|
-
ArbitraryInputs,
|
|
19
|
-
ArbitraryOutputs,
|
|
20
|
-
EnvironmentComputeStep,
|
|
21
|
-
Event,
|
|
22
|
-
MessageInputs,
|
|
23
|
-
MessageOutputs,
|
|
24
|
-
)
|
|
25
|
-
from .config import EventManagement, LoggingMode, Origin, TracingConfig
|
|
26
|
-
from .context import (
|
|
27
|
-
get_current_context,
|
|
28
|
-
trace_context,
|
|
29
|
-
)
|
|
30
|
-
from .events.manage import set_current_event
|
|
31
|
-
from .events.store import event_store
|
|
32
|
-
from .immediate_client import (
|
|
33
|
-
AsyncImmediateLogClient,
|
|
34
|
-
ImmediateLogClient,
|
|
35
|
-
)
|
|
36
|
-
from .local import (
|
|
37
|
-
_local,
|
|
38
|
-
active_events_var,
|
|
39
|
-
logger,
|
|
40
|
-
)
|
|
41
|
-
from .retry_queue import initialize_retry_queue, retry_queue
|
|
42
|
-
from .trackers import (
|
|
43
|
-
synth_tracker_async,
|
|
44
|
-
synth_tracker_sync,
|
|
45
|
-
)
|
|
46
|
-
from .utils import get_system_id
|
|
47
|
-
|
|
48
|
-
logger = logging.getLogger(__name__)
|
|
49
|
-
|
|
50
|
-
P = ParamSpec("P") # For capturing any parameters
|
|
51
|
-
R = TypeVar("R") # For capturing return type
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def clear_current_event(event_type: str) -> None:
|
|
55
|
-
"""Clear the current event from the appropriate storage based on context.
|
|
56
|
-
|
|
57
|
-
Args:
|
|
58
|
-
event_type: The type of event to clear
|
|
59
|
-
"""
|
|
60
|
-
try:
|
|
61
|
-
# Check if we're in an async context
|
|
62
|
-
import asyncio
|
|
63
|
-
|
|
64
|
-
asyncio.get_running_loop()
|
|
65
|
-
# We're in async context
|
|
66
|
-
active_events = active_events_var.get()
|
|
67
|
-
if event_type in active_events:
|
|
68
|
-
del active_events[event_type]
|
|
69
|
-
active_events_var.set(active_events)
|
|
70
|
-
except RuntimeError:
|
|
71
|
-
# We're in sync context
|
|
72
|
-
if hasattr(_local, "active_events") and event_type in _local.active_events:
|
|
73
|
-
del _local.active_events[event_type]
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
# Cache the config to avoid repeated env lookups
|
|
77
|
-
def get_tracing_config() -> TracingConfig:
|
|
78
|
-
config = TracingConfig(
|
|
79
|
-
mode=LoggingMode.INSTANT
|
|
80
|
-
if os.getenv("SYNTH_LOGGING_MODE") == "instant"
|
|
81
|
-
else LoggingMode.DEFERRED,
|
|
82
|
-
api_key=os.getenv("SYNTH_API_KEY", ""),
|
|
83
|
-
base_url=os.getenv("SYNTH_ENDPOINT_OVERRIDE", PROD_BASE_URL_DEFAULT),
|
|
84
|
-
)
|
|
85
|
-
# Initialize retry queue with config if needed
|
|
86
|
-
initialize_retry_queue(config)
|
|
87
|
-
return config
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def process_retry_queue_sync() -> None:
|
|
91
|
-
"""Process the retry queue synchronously."""
|
|
92
|
-
try:
|
|
93
|
-
success, failure = retry_queue.process_sync()
|
|
94
|
-
if success or failure:
|
|
95
|
-
logger.info(f"Processed retry queue: {success} succeeded, {failure} failed")
|
|
96
|
-
except Exception as e:
|
|
97
|
-
logger.error(f"Error processing retry queue: {e}")
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
async def process_retry_queue_async() -> None:
|
|
101
|
-
"""Process the retry queue asynchronously."""
|
|
102
|
-
try:
|
|
103
|
-
success, failure = await retry_queue.process_async()
|
|
104
|
-
if success or failure:
|
|
105
|
-
logger.info(f"Processed retry queue: {success} succeeded, {failure} failed")
|
|
106
|
-
except Exception as e:
|
|
107
|
-
logger.error(f"Error processing retry queue: {e}")
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def trace_event_sync(
|
|
111
|
-
event_type: str,
|
|
112
|
-
finetune_step: bool = True,
|
|
113
|
-
origin: Origin = Origin.AGENT,
|
|
114
|
-
log_result: bool = False,
|
|
115
|
-
manage_event: EventManagement = EventManagement.CREATE_AND_END,
|
|
116
|
-
increment_partition: bool = True,
|
|
117
|
-
verbose: bool = False,
|
|
118
|
-
) -> Callable[[Callable[P, R]], Callable[P, R]]:
|
|
119
|
-
"""Decorator for tracing synchronous function execution.
|
|
120
|
-
|
|
121
|
-
DEPRECATED: This tracing system (v1) is deprecated. Please use synth_ai.tracing_v2 instead.
|
|
122
|
-
Backend upload functionality is no longer supported.
|
|
123
|
-
|
|
124
|
-
Args:
|
|
125
|
-
event_type: Type of event being traced (e.g., "inference", "training")
|
|
126
|
-
finetune_step: Whether this step should be used for fine-tuning
|
|
127
|
-
origin: Source of computation (AI/model or external system)
|
|
128
|
-
log_result: Whether to log the function's return value
|
|
129
|
-
manage_event: Controls the lifecycle of the event
|
|
130
|
-
increment_partition: Whether to increment the partition index
|
|
131
|
-
verbose: Whether to print debug information
|
|
132
|
-
|
|
133
|
-
Example:
|
|
134
|
-
>>> @trace_event_sync("inference")
|
|
135
|
-
... def process_input(self, text: str) -> str:
|
|
136
|
-
... return f"Processed: {text}"
|
|
137
|
-
|
|
138
|
-
Returns:
|
|
139
|
-
A decorator that wraps the function and traces its execution
|
|
140
|
-
"""
|
|
141
|
-
warnings.warn(
|
|
142
|
-
"trace_event_sync from synth_ai.tracing_v1 is deprecated. "
|
|
143
|
-
"Please use synth_ai.tracing_v2 instead. "
|
|
144
|
-
"Backend upload functionality is no longer supported in v1.",
|
|
145
|
-
DeprecationWarning,
|
|
146
|
-
stacklevel=2,
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
def decorator(func: Callable[P, R]) -> Callable[P, R]:
|
|
150
|
-
@wraps(func)
|
|
151
|
-
def wrapper(*args, **kwargs):
|
|
152
|
-
# Determine the instance (self) if it's a method
|
|
153
|
-
if not hasattr(func, "__self__") or not func.__self__:
|
|
154
|
-
if not args:
|
|
155
|
-
raise ValueError("Instance method expected, but no arguments were passed.")
|
|
156
|
-
self_instance = args[0]
|
|
157
|
-
else:
|
|
158
|
-
self_instance = func.__self__
|
|
159
|
-
|
|
160
|
-
# Ensure required attributes are present
|
|
161
|
-
required_attrs = ["system_instance_id", "system_name"]
|
|
162
|
-
for attr in required_attrs:
|
|
163
|
-
if not hasattr(self_instance, attr):
|
|
164
|
-
raise ValueError(
|
|
165
|
-
f"Instance of class '{self_instance.__class__.__name__}' missing required attribute '{attr}'"
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
# Use context manager for setup/cleanup
|
|
169
|
-
with trace_context(
|
|
170
|
-
system_name=self_instance.system_name,
|
|
171
|
-
system_id=get_system_id(self_instance.system_name),
|
|
172
|
-
system_instance_id=self_instance.system_instance_id,
|
|
173
|
-
system_instance_metadata=getattr(self_instance, "system_instance_metadata", None),
|
|
174
|
-
):
|
|
175
|
-
# Initialize Trace
|
|
176
|
-
synth_tracker_sync.initialize()
|
|
177
|
-
|
|
178
|
-
event = None
|
|
179
|
-
compute_began = time.time()
|
|
180
|
-
try:
|
|
181
|
-
if manage_event in ["create", "create_and_end"]:
|
|
182
|
-
# Create new event
|
|
183
|
-
context = get_current_context()
|
|
184
|
-
event = Event(
|
|
185
|
-
system_instance_id=context["system_instance_id"],
|
|
186
|
-
event_type=event_type,
|
|
187
|
-
opened=compute_began,
|
|
188
|
-
closed=None,
|
|
189
|
-
partition_index=0,
|
|
190
|
-
agent_compute_step=None,
|
|
191
|
-
environment_compute_steps=[],
|
|
192
|
-
system_name=context["system_name"],
|
|
193
|
-
system_id=context["system_id"],
|
|
194
|
-
)
|
|
195
|
-
if increment_partition:
|
|
196
|
-
event.partition_index = event_store.increment_partition(
|
|
197
|
-
context["system_name"],
|
|
198
|
-
context["system_id"],
|
|
199
|
-
context["system_instance_id"],
|
|
200
|
-
)
|
|
201
|
-
logger.debug(f"Incremented partition to: {event.partition_index}")
|
|
202
|
-
set_current_event(event, decorator_type="sync")
|
|
203
|
-
|
|
204
|
-
# Automatically trace function inputs
|
|
205
|
-
bound_args = inspect.signature(func).bind(*args, **kwargs)
|
|
206
|
-
bound_args.apply_defaults()
|
|
207
|
-
for param, value in bound_args.arguments.items():
|
|
208
|
-
if param == "self":
|
|
209
|
-
continue
|
|
210
|
-
# print("Tracking state - 178")
|
|
211
|
-
# synth_tracker_sync.track_state(
|
|
212
|
-
# variable_name=param, variable_value=value, origin=origin
|
|
213
|
-
# )
|
|
214
|
-
|
|
215
|
-
# Execute the function
|
|
216
|
-
result = func(*args, **kwargs)
|
|
217
|
-
|
|
218
|
-
# Automatically trace function output
|
|
219
|
-
# track_result(result, synth_tracker_sync, origin)
|
|
220
|
-
|
|
221
|
-
# Collect traced inputs and outputs
|
|
222
|
-
traced_inputs, traced_outputs = synth_tracker_sync.get_traced_data()
|
|
223
|
-
|
|
224
|
-
compute_steps_by_origin: dict[
|
|
225
|
-
Literal["agent", "environment"], dict[str, list[Any]]
|
|
226
|
-
] = {
|
|
227
|
-
"agent": {"inputs": [], "outputs": []},
|
|
228
|
-
"environment": {"inputs": [], "outputs": []},
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
# Organize traced data by origin
|
|
232
|
-
# print("N items in traced inputs: ", len(traced_inputs), ["messages" in item for item in traced_inputs], [item.keys() for item in traced_inputs])
|
|
233
|
-
for item in traced_inputs:
|
|
234
|
-
# print("Item: ", item)
|
|
235
|
-
var_origin = item["origin"]
|
|
236
|
-
if "variable_value" in item and "variable_name" in item:
|
|
237
|
-
# Standard variable input
|
|
238
|
-
compute_steps_by_origin[var_origin]["inputs"].append(
|
|
239
|
-
ArbitraryInputs(
|
|
240
|
-
inputs={item["variable_name"]: item["variable_value"]}
|
|
241
|
-
)
|
|
242
|
-
)
|
|
243
|
-
compute_steps_by_origin[var_origin]["finetune"] = (
|
|
244
|
-
item["finetune"] if "finetune" in item else False
|
|
245
|
-
)
|
|
246
|
-
compute_steps_by_origin[var_origin]["model_name"] = (
|
|
247
|
-
item["model_name"] if "model_name" in item else None
|
|
248
|
-
)
|
|
249
|
-
compute_steps_by_origin[var_origin]["model_params"] = (
|
|
250
|
-
item["model_params"] if "model_params" in item else None
|
|
251
|
-
)
|
|
252
|
-
elif "messages" in item:
|
|
253
|
-
# Message input from track_lm
|
|
254
|
-
compute_steps_by_origin[var_origin]["inputs"].append(
|
|
255
|
-
MessageInputs(messages=item["messages"])
|
|
256
|
-
)
|
|
257
|
-
finetune = finetune_step or item["finetune"]
|
|
258
|
-
compute_steps_by_origin[var_origin]["finetune"] = finetune
|
|
259
|
-
|
|
260
|
-
model_name = item["model_name"]
|
|
261
|
-
model_params = item["model_params"]
|
|
262
|
-
compute_steps_by_origin[var_origin]["model_name"] = model_name
|
|
263
|
-
compute_steps_by_origin[var_origin]["model_params"] = model_params
|
|
264
|
-
else:
|
|
265
|
-
logger.warning(f"Unhandled traced input item: {item}")
|
|
266
|
-
|
|
267
|
-
# print("N items in traced outputs: ", len(traced_outputs), ["messages" in item for item in traced_outputs], [item.keys() for item in traced_outputs])
|
|
268
|
-
|
|
269
|
-
# Temporary Kludge
|
|
270
|
-
for item in [i for i in traced_outputs if "messages" in i]:
|
|
271
|
-
var_origin = item["origin"]
|
|
272
|
-
if "variable_value" in item and "variable_name" in item:
|
|
273
|
-
# Standard variable output
|
|
274
|
-
compute_steps_by_origin[var_origin]["outputs"].append(
|
|
275
|
-
ArbitraryOutputs(
|
|
276
|
-
outputs={item["variable_name"]: item["variable_value"]}
|
|
277
|
-
)
|
|
278
|
-
)
|
|
279
|
-
elif "messages" in item:
|
|
280
|
-
# Message output from track_lm
|
|
281
|
-
compute_steps_by_origin[var_origin]["outputs"].append(
|
|
282
|
-
MessageOutputs(messages=item["messages"])
|
|
283
|
-
)
|
|
284
|
-
else:
|
|
285
|
-
logger.warning(f"Unhandled traced output item: {item}")
|
|
286
|
-
|
|
287
|
-
# Capture compute end time
|
|
288
|
-
compute_ended = time.time()
|
|
289
|
-
|
|
290
|
-
# Create compute steps grouped by origin
|
|
291
|
-
for var_origin in ["agent", "environment"]:
|
|
292
|
-
inputs = compute_steps_by_origin[var_origin]["inputs"]
|
|
293
|
-
outputs = compute_steps_by_origin[var_origin]["outputs"]
|
|
294
|
-
should_learn = (
|
|
295
|
-
compute_steps_by_origin[var_origin]["finetune"]
|
|
296
|
-
if "finetune" in compute_steps_by_origin[var_origin]
|
|
297
|
-
else False
|
|
298
|
-
)
|
|
299
|
-
model_name = (
|
|
300
|
-
compute_steps_by_origin[var_origin]["model_name"]
|
|
301
|
-
if "model_name" in compute_steps_by_origin[var_origin]
|
|
302
|
-
else None
|
|
303
|
-
)
|
|
304
|
-
model_params = (
|
|
305
|
-
compute_steps_by_origin[var_origin]["model_params"]
|
|
306
|
-
if "model_params" in compute_steps_by_origin[var_origin]
|
|
307
|
-
else None
|
|
308
|
-
)
|
|
309
|
-
if inputs or outputs:
|
|
310
|
-
event_order = (
|
|
311
|
-
1 + len(event.environment_compute_steps) + 1 if event else 1
|
|
312
|
-
)
|
|
313
|
-
compute_step = (
|
|
314
|
-
AgentComputeStep(
|
|
315
|
-
model_name=model_name,
|
|
316
|
-
model_params=model_params,
|
|
317
|
-
should_learn=should_learn,
|
|
318
|
-
event_order=event_order,
|
|
319
|
-
compute_began=compute_began,
|
|
320
|
-
compute_ended=compute_ended,
|
|
321
|
-
compute_input=inputs,
|
|
322
|
-
compute_output=outputs,
|
|
323
|
-
)
|
|
324
|
-
if var_origin == "agent"
|
|
325
|
-
else EnvironmentComputeStep(
|
|
326
|
-
event_order=event_order,
|
|
327
|
-
compute_began=compute_began,
|
|
328
|
-
compute_ended=compute_ended,
|
|
329
|
-
compute_input=inputs,
|
|
330
|
-
compute_output=outputs,
|
|
331
|
-
)
|
|
332
|
-
)
|
|
333
|
-
if event:
|
|
334
|
-
if var_origin == "agent":
|
|
335
|
-
event.agent_compute_step = compute_step
|
|
336
|
-
else:
|
|
337
|
-
event.environment_compute_steps.append(compute_step)
|
|
338
|
-
|
|
339
|
-
# Optionally log the function result
|
|
340
|
-
if log_result:
|
|
341
|
-
logger.info(f"Function result: {result}")
|
|
342
|
-
|
|
343
|
-
# Handle event management after function execution
|
|
344
|
-
if manage_event in ("end", "create_and_end"):
|
|
345
|
-
context = get_current_context()
|
|
346
|
-
current_event = _local.active_events.get(event_type)
|
|
347
|
-
if current_event:
|
|
348
|
-
current_event.closed = compute_ended
|
|
349
|
-
config = get_tracing_config()
|
|
350
|
-
if config.mode == LoggingMode.INSTANT:
|
|
351
|
-
client = ImmediateLogClient(config)
|
|
352
|
-
client.send_event(current_event, context)
|
|
353
|
-
# print("Adding this event: ", current_event)
|
|
354
|
-
event_store.add_event(
|
|
355
|
-
context["system_name"],
|
|
356
|
-
context["system_id"],
|
|
357
|
-
context["system_instance_id"],
|
|
358
|
-
current_event,
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
# Process retry queue after successful execution
|
|
362
|
-
process_retry_queue_sync()
|
|
363
|
-
|
|
364
|
-
return result
|
|
365
|
-
except Exception as e:
|
|
366
|
-
logger.error(f"Exception in traced function '{func.__name__}': {e}")
|
|
367
|
-
raise
|
|
368
|
-
|
|
369
|
-
return wrapper
|
|
370
|
-
|
|
371
|
-
return decorator
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
def trace_event_async(
|
|
375
|
-
event_type: str,
|
|
376
|
-
finetune_step: bool = True,
|
|
377
|
-
origin: Origin = Origin.AGENT,
|
|
378
|
-
log_result: bool = False,
|
|
379
|
-
manage_event: EventManagement = EventManagement.CREATE_AND_END,
|
|
380
|
-
increment_partition: bool = True,
|
|
381
|
-
verbose: bool = False,
|
|
382
|
-
) -> Callable[[Callable[P, R]], Callable[P, R]]:
|
|
383
|
-
"""Decorator for tracing asynchronous function execution.
|
|
384
|
-
|
|
385
|
-
DEPRECATED: This tracing system (v1) is deprecated. Please use synth_ai.tracing_v2 instead.
|
|
386
|
-
Backend upload functionality is no longer supported.
|
|
387
|
-
|
|
388
|
-
Args:
|
|
389
|
-
event_type: Type of event being traced (e.g., "inference", "training")
|
|
390
|
-
finetune_step: Whether this step should be used for fine-tuning
|
|
391
|
-
origin: Source of computation (AI/model or external system)
|
|
392
|
-
log_result: Whether to log the function's return value
|
|
393
|
-
manage_event: Controls the lifecycle of the event
|
|
394
|
-
increment_partition: Whether to increment the partition index
|
|
395
|
-
verbose: Whether to print debug information
|
|
396
|
-
|
|
397
|
-
Example:
|
|
398
|
-
>>> @trace_event_async("inference")
|
|
399
|
-
... async def process_input(self, text: str) -> str:
|
|
400
|
-
... return f"Processed: {text}"
|
|
401
|
-
|
|
402
|
-
Returns:
|
|
403
|
-
A decorator that wraps the async function and traces its execution
|
|
404
|
-
"""
|
|
405
|
-
warnings.warn(
|
|
406
|
-
"trace_event_async from synth_ai.tracing_v1 is deprecated. "
|
|
407
|
-
"Please use synth_ai.tracing_v2 instead. "
|
|
408
|
-
"Backend upload functionality is no longer supported in v1.",
|
|
409
|
-
DeprecationWarning,
|
|
410
|
-
stacklevel=2,
|
|
411
|
-
)
|
|
412
|
-
|
|
413
|
-
def decorator(func: Callable[P, R]) -> Callable[P, R]:
|
|
414
|
-
@wraps(func)
|
|
415
|
-
async def async_wrapper(*args, **kwargs):
|
|
416
|
-
# Determine the instance (self) if it's a method
|
|
417
|
-
if not hasattr(func, "__self__") or not func.__self__:
|
|
418
|
-
if not args:
|
|
419
|
-
raise ValueError("Instance method expected, but no arguments were passed.")
|
|
420
|
-
self_instance = args[0]
|
|
421
|
-
else:
|
|
422
|
-
self_instance = func.__self__
|
|
423
|
-
|
|
424
|
-
# Ensure required attributes are present
|
|
425
|
-
required_attrs = ["system_instance_id", "system_name"]
|
|
426
|
-
for attr in required_attrs:
|
|
427
|
-
if not hasattr(self_instance, attr):
|
|
428
|
-
raise ValueError(
|
|
429
|
-
f"Instance of class '{self_instance.__class__.__name__}' missing required attribute '{attr}'"
|
|
430
|
-
)
|
|
431
|
-
|
|
432
|
-
# Use context manager for setup/cleanup
|
|
433
|
-
with trace_context(
|
|
434
|
-
system_name=self_instance.system_name,
|
|
435
|
-
system_id=get_system_id(self_instance.system_name),
|
|
436
|
-
system_instance_id=self_instance.system_instance_id,
|
|
437
|
-
system_instance_metadata=getattr(self_instance, "system_instance_metadata", None),
|
|
438
|
-
):
|
|
439
|
-
# Initialize AsyncTrace
|
|
440
|
-
synth_tracker_async.initialize()
|
|
441
|
-
|
|
442
|
-
event = None
|
|
443
|
-
compute_began = time.time()
|
|
444
|
-
try:
|
|
445
|
-
if manage_event in ["create", "create_and_end"]:
|
|
446
|
-
# Create new event
|
|
447
|
-
context = get_current_context()
|
|
448
|
-
event = Event(
|
|
449
|
-
system_instance_id=context["system_instance_id"],
|
|
450
|
-
event_type=event_type,
|
|
451
|
-
opened=compute_began,
|
|
452
|
-
closed=None,
|
|
453
|
-
partition_index=0,
|
|
454
|
-
agent_compute_step=None,
|
|
455
|
-
environment_compute_steps=[],
|
|
456
|
-
system_name=context["system_name"],
|
|
457
|
-
system_id=context["system_id"],
|
|
458
|
-
)
|
|
459
|
-
if increment_partition:
|
|
460
|
-
event.partition_index = event_store.increment_partition(
|
|
461
|
-
context["system_name"],
|
|
462
|
-
context["system_id"],
|
|
463
|
-
context["system_instance_id"],
|
|
464
|
-
)
|
|
465
|
-
logger.debug(f"Incremented partition to: {event.partition_index}")
|
|
466
|
-
set_current_event(event, decorator_type="async")
|
|
467
|
-
|
|
468
|
-
# Automatically trace function inputs
|
|
469
|
-
bound_args = inspect.signature(func).bind(*args, **kwargs)
|
|
470
|
-
bound_args.apply_defaults()
|
|
471
|
-
for param, value in bound_args.arguments.items():
|
|
472
|
-
if param == "self":
|
|
473
|
-
continue
|
|
474
|
-
# print("Tracking state - 412")
|
|
475
|
-
# synth_tracker_async.track_state(
|
|
476
|
-
# variable_name=param,
|
|
477
|
-
# variable_value=value,
|
|
478
|
-
# origin=origin,
|
|
479
|
-
# io_type="input",
|
|
480
|
-
# )
|
|
481
|
-
|
|
482
|
-
# Execute the coroutine
|
|
483
|
-
result = await func(*args, **kwargs)
|
|
484
|
-
|
|
485
|
-
# Automatically trace function output
|
|
486
|
-
# track_result(result, synth_tracker_async, origin)
|
|
487
|
-
|
|
488
|
-
# Collect traced inputs and outputs
|
|
489
|
-
traced_inputs, traced_outputs = synth_tracker_async.get_traced_data()
|
|
490
|
-
|
|
491
|
-
compute_steps_by_origin: dict[
|
|
492
|
-
Literal["agent", "environment"], dict[str, list[Any]]
|
|
493
|
-
] = {
|
|
494
|
-
"agent": {"inputs": [], "outputs": []},
|
|
495
|
-
"environment": {"inputs": [], "outputs": []},
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
# Organize traced data by origin
|
|
499
|
-
for item in traced_inputs:
|
|
500
|
-
var_origin = item["origin"]
|
|
501
|
-
if "variable_value" in item and "variable_name" in item:
|
|
502
|
-
# Standard variable input
|
|
503
|
-
compute_steps_by_origin[var_origin]["inputs"].append(
|
|
504
|
-
ArbitraryInputs(
|
|
505
|
-
inputs={item["variable_name"]: item["variable_value"]}
|
|
506
|
-
)
|
|
507
|
-
)
|
|
508
|
-
elif "messages" in item:
|
|
509
|
-
# Message input from track_lm
|
|
510
|
-
compute_steps_by_origin[var_origin]["inputs"].append(
|
|
511
|
-
MessageInputs(messages=item["messages"])
|
|
512
|
-
)
|
|
513
|
-
# compute_steps_by_origin[var_origin]["inputs"].append(
|
|
514
|
-
# ArbitraryInputs(
|
|
515
|
-
# inputs={"model_name": item["model_name"]}
|
|
516
|
-
# )
|
|
517
|
-
# )
|
|
518
|
-
finetune = finetune_step or item["finetune"]
|
|
519
|
-
compute_steps_by_origin[var_origin]["finetune"] = finetune
|
|
520
|
-
|
|
521
|
-
model_name = item["model_name"]
|
|
522
|
-
model_params = item["model_params"]
|
|
523
|
-
compute_steps_by_origin[var_origin]["model_name"] = model_name
|
|
524
|
-
compute_steps_by_origin[var_origin]["model_params"] = model_params
|
|
525
|
-
else:
|
|
526
|
-
logger.warning(f"Unhandled traced input item: {item}")
|
|
527
|
-
|
|
528
|
-
for item in traced_outputs:
|
|
529
|
-
var_origin = item["origin"]
|
|
530
|
-
if "variable_value" in item and "variable_name" in item:
|
|
531
|
-
# Standard variable output
|
|
532
|
-
compute_steps_by_origin[var_origin]["outputs"].append(
|
|
533
|
-
ArbitraryOutputs(
|
|
534
|
-
outputs={item["variable_name"]: item["variable_value"]}
|
|
535
|
-
)
|
|
536
|
-
)
|
|
537
|
-
elif "messages" in item:
|
|
538
|
-
# Message output from track_lm
|
|
539
|
-
compute_steps_by_origin[var_origin]["outputs"].append(
|
|
540
|
-
MessageOutputs(messages=item["messages"])
|
|
541
|
-
)
|
|
542
|
-
else:
|
|
543
|
-
logger.warning(f"Unhandled traced output item: {item}")
|
|
544
|
-
|
|
545
|
-
compute_ended = time.time()
|
|
546
|
-
# Create compute steps grouped by origin
|
|
547
|
-
for var_origin in ["agent", "environment"]:
|
|
548
|
-
inputs = compute_steps_by_origin[var_origin]["inputs"]
|
|
549
|
-
outputs = compute_steps_by_origin[var_origin]["outputs"]
|
|
550
|
-
model_name = (
|
|
551
|
-
compute_steps_by_origin[var_origin]["model_name"]
|
|
552
|
-
if "model_name" in compute_steps_by_origin[var_origin]
|
|
553
|
-
else None
|
|
554
|
-
)
|
|
555
|
-
model_params = (
|
|
556
|
-
compute_steps_by_origin[var_origin]["model_params"]
|
|
557
|
-
if "model_params" in compute_steps_by_origin[var_origin]
|
|
558
|
-
else None
|
|
559
|
-
)
|
|
560
|
-
should_learn = (
|
|
561
|
-
compute_steps_by_origin[var_origin]["finetune"]
|
|
562
|
-
if "finetune" in compute_steps_by_origin[var_origin]
|
|
563
|
-
else False
|
|
564
|
-
)
|
|
565
|
-
if inputs or outputs:
|
|
566
|
-
event_order = (
|
|
567
|
-
1 + len(event.environment_compute_steps) + 1 if event else 1
|
|
568
|
-
)
|
|
569
|
-
compute_step = (
|
|
570
|
-
AgentComputeStep(
|
|
571
|
-
model_name=model_name,
|
|
572
|
-
model_params=model_params,
|
|
573
|
-
should_learn=should_learn,
|
|
574
|
-
event_order=event_order,
|
|
575
|
-
compute_began=compute_began,
|
|
576
|
-
compute_ended=compute_ended,
|
|
577
|
-
compute_input=inputs,
|
|
578
|
-
compute_output=outputs,
|
|
579
|
-
)
|
|
580
|
-
if var_origin == "agent"
|
|
581
|
-
else EnvironmentComputeStep(
|
|
582
|
-
event_order=event_order,
|
|
583
|
-
compute_began=compute_began,
|
|
584
|
-
compute_ended=compute_ended,
|
|
585
|
-
compute_input=inputs,
|
|
586
|
-
compute_output=outputs,
|
|
587
|
-
)
|
|
588
|
-
)
|
|
589
|
-
if event:
|
|
590
|
-
if var_origin == "agent":
|
|
591
|
-
event.agent_compute_step = compute_step
|
|
592
|
-
else:
|
|
593
|
-
event.environment_compute_steps.append(compute_step)
|
|
594
|
-
|
|
595
|
-
# Optionally log the function result
|
|
596
|
-
if log_result:
|
|
597
|
-
logger.info(f"Function result: {result}")
|
|
598
|
-
|
|
599
|
-
# Handle event management after function execution
|
|
600
|
-
if manage_event in ["end", "create_and_end"]:
|
|
601
|
-
context = get_current_context()
|
|
602
|
-
current_event = active_events_var.get().get(event_type)
|
|
603
|
-
if current_event:
|
|
604
|
-
current_event.closed = compute_ended
|
|
605
|
-
|
|
606
|
-
# Get the config to determine logging mode
|
|
607
|
-
config = get_tracing_config()
|
|
608
|
-
|
|
609
|
-
# If immediate logging is enabled, send the event now
|
|
610
|
-
if config.mode == LoggingMode.INSTANT:
|
|
611
|
-
client = AsyncImmediateLogClient(config)
|
|
612
|
-
await client.send_event(current_event, context)
|
|
613
|
-
|
|
614
|
-
# Always store in event_store as backup
|
|
615
|
-
event_store.add_event(
|
|
616
|
-
context["system_name"],
|
|
617
|
-
context["system_id"],
|
|
618
|
-
context["system_instance_id"],
|
|
619
|
-
current_event,
|
|
620
|
-
)
|
|
621
|
-
active_events = active_events_var.get()
|
|
622
|
-
del active_events[event_type]
|
|
623
|
-
active_events_var.set(active_events)
|
|
624
|
-
|
|
625
|
-
# Process retry queue after successful execution
|
|
626
|
-
await process_retry_queue_async()
|
|
627
|
-
|
|
628
|
-
return result
|
|
629
|
-
except Exception as e:
|
|
630
|
-
logger.error(f"Exception in traced function '{func.__name__}': {e}")
|
|
631
|
-
raise
|
|
632
|
-
|
|
633
|
-
return async_wrapper
|
|
634
|
-
|
|
635
|
-
return decorator
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
def trace_system(
|
|
639
|
-
origin: Literal["agent", "environment"],
|
|
640
|
-
event_type: str,
|
|
641
|
-
log_result: bool = False,
|
|
642
|
-
manage_event: Literal["create", "end", "lazy_end", None] = None,
|
|
643
|
-
increment_partition: bool = False,
|
|
644
|
-
verbose: bool = False,
|
|
645
|
-
) -> Callable:
|
|
646
|
-
"""
|
|
647
|
-
Decorator that chooses the correct tracing method (sync or async) based on
|
|
648
|
-
whether the wrapped function is synchronous or asynchronous.
|
|
649
|
-
|
|
650
|
-
Purpose is to keep track of inputs and outputs for compute steps for both sync and async functions.
|
|
651
|
-
"""
|
|
652
|
-
|
|
653
|
-
def decorator(func: Callable) -> Callable:
|
|
654
|
-
# Check if the function is async or sync
|
|
655
|
-
if inspect.iscoroutinefunction(func) or inspect.isasyncgenfunction(func):
|
|
656
|
-
# Use async tracing
|
|
657
|
-
# logger.debug("Using async tracing")
|
|
658
|
-
async_decorator = trace_event_async(
|
|
659
|
-
origin,
|
|
660
|
-
event_type,
|
|
661
|
-
log_result,
|
|
662
|
-
manage_event,
|
|
663
|
-
increment_partition,
|
|
664
|
-
verbose,
|
|
665
|
-
)
|
|
666
|
-
return async_decorator(func)
|
|
667
|
-
else:
|
|
668
|
-
# Use sync tracing
|
|
669
|
-
# logger.debug("Using sync tracing")
|
|
670
|
-
sync_decorator = trace_event_sync(
|
|
671
|
-
origin,
|
|
672
|
-
event_type,
|
|
673
|
-
log_result,
|
|
674
|
-
manage_event,
|
|
675
|
-
increment_partition,
|
|
676
|
-
verbose,
|
|
677
|
-
)
|
|
678
|
-
return sync_decorator(func)
|
|
679
|
-
|
|
680
|
-
return decorator
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
def track_result(
|
|
684
|
-
result: Any,
|
|
685
|
-
tracker: Union["SynthTrackerSync", "SynthTrackerAsync"],
|
|
686
|
-
origin: Literal["agent", "environment"],
|
|
687
|
-
) -> None:
|
|
688
|
-
# Helper function to track results, including tuple unpacking
|
|
689
|
-
if isinstance(result, tuple):
|
|
690
|
-
# Track each element of the tuple that matches valid types
|
|
691
|
-
for i, item in enumerate(result):
|
|
692
|
-
try:
|
|
693
|
-
print("Tracking state - 631")
|
|
694
|
-
tracker.track_state(variable_name=f"result_{i}", variable_value=item, origin=origin)
|
|
695
|
-
except Exception as e:
|
|
696
|
-
logger.warning(f"Could not track tuple element {i}: {str(e)}")
|
|
697
|
-
else:
|
|
698
|
-
# Track single result as before
|
|
699
|
-
try:
|
|
700
|
-
print("Tracking state - 640")
|
|
701
|
-
tracker.track_state(variable_name="result", variable_value=result, origin=origin)
|
|
702
|
-
except Exception as e:
|
|
703
|
-
logger.warning(f"Could not track result: {str(e)}")
|