agenta 0.27.0a1__tar.gz → 0.27.0a5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of agenta might be problematic. Click here for more details.

Files changed (185) hide show
  1. {agenta-0.27.0a1 → agenta-0.27.0a5}/PKG-INFO +1 -1
  2. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/decorators/routing.py +126 -130
  3. agenta-0.27.0a5/agenta/sdk/decorators/tracing.py +241 -0
  4. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/tracing/attributes.py +7 -2
  5. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/tracing/context.py +5 -2
  6. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/tracing/conventions.py +10 -8
  7. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/tracing/exporters.py +5 -5
  8. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/tracing/inline.py +16 -87
  9. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/tracing/processors.py +21 -7
  10. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/tracing/spans.py +16 -4
  11. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/tracing/tracing.py +58 -30
  12. {agenta-0.27.0a1 → agenta-0.27.0a5}/pyproject.toml +1 -1
  13. agenta-0.27.0a1/agenta/sdk/decorators/tracing.py +0 -289
  14. {agenta-0.27.0a1 → agenta-0.27.0a5}/README.md +0 -0
  15. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/__init__.py +0 -0
  16. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/cli/evaluation_commands.py +0 -0
  17. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/cli/helper.py +0 -0
  18. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/cli/main.py +0 -0
  19. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/cli/telemetry.py +0 -0
  20. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/cli/variant_commands.py +0 -0
  21. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/cli/variant_configs.py +0 -0
  22. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/Readme.md +0 -0
  23. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/__init__.py +0 -0
  24. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/api.py +0 -0
  25. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/api_models.py +0 -0
  26. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/__init__.py +0 -0
  27. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/apps/__init__.py +0 -0
  28. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/apps/client.py +0 -0
  29. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/bases/__init__.py +0 -0
  30. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/bases/client.py +0 -0
  31. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/client.py +0 -0
  32. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/configs/__init__.py +0 -0
  33. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/configs/client.py +0 -0
  34. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/containers/__init__.py +0 -0
  35. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/containers/client.py +0 -0
  36. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/containers/types/__init__.py +0 -0
  37. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/containers/types/container_templates_response.py +0 -0
  38. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/__init__.py +0 -0
  39. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/api_error.py +0 -0
  40. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/client_wrapper.py +0 -0
  41. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/datetime_utils.py +0 -0
  42. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/file.py +0 -0
  43. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/http_client.py +0 -0
  44. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/jsonable_encoder.py +0 -0
  45. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/pydantic_utilities.py +0 -0
  46. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/query_encoder.py +0 -0
  47. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/remove_none_from_dict.py +0 -0
  48. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/request_options.py +0 -0
  49. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/core/serialization.py +0 -0
  50. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/environments/__init__.py +0 -0
  51. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/environments/client.py +0 -0
  52. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/errors/__init__.py +0 -0
  53. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/errors/unprocessable_entity_error.py +0 -0
  54. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/evaluations/__init__.py +0 -0
  55. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/evaluations/client.py +0 -0
  56. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/evaluators/__init__.py +0 -0
  57. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/evaluators/client.py +0 -0
  58. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/observability/__init__.py +0 -0
  59. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/observability/client.py +0 -0
  60. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/testsets/__init__.py +0 -0
  61. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/testsets/client.py +0 -0
  62. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/__init__.py +0 -0
  63. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/aggregated_result.py +0 -0
  64. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/aggregated_result_evaluator_config.py +0 -0
  65. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/app.py +0 -0
  66. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/app_variant_response.py +0 -0
  67. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/app_variant_revision.py +0 -0
  68. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/base_output.py +0 -0
  69. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/body_import_testset.py +0 -0
  70. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/config_db.py +0 -0
  71. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/correct_answer.py +0 -0
  72. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/create_app_output.py +0 -0
  73. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/create_span.py +0 -0
  74. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/create_trace_response.py +0 -0
  75. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/docker_env_vars.py +0 -0
  76. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/environment_output.py +0 -0
  77. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/environment_output_extended.py +0 -0
  78. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/environment_revision.py +0 -0
  79. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/error.py +0 -0
  80. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluation.py +0 -0
  81. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluation_scenario.py +0 -0
  82. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluation_scenario_input.py +0 -0
  83. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluation_scenario_output.py +0 -0
  84. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluation_scenario_result.py +0 -0
  85. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluation_scenario_score_update.py +0 -0
  86. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluation_status_enum.py +0 -0
  87. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluation_type.py +0 -0
  88. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluator.py +0 -0
  89. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/evaluator_config.py +0 -0
  90. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/get_config_response.py +0 -0
  91. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/http_validation_error.py +0 -0
  92. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/human_evaluation.py +0 -0
  93. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/human_evaluation_scenario.py +0 -0
  94. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/human_evaluation_scenario_input.py +0 -0
  95. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/human_evaluation_scenario_output.py +0 -0
  96. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/human_evaluation_scenario_update.py +0 -0
  97. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/human_evaluation_update.py +0 -0
  98. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/image.py +0 -0
  99. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/invite_request.py +0 -0
  100. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/list_api_keys_response.py +0 -0
  101. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/llm_run_rate_limit.py +0 -0
  102. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/llm_tokens.py +0 -0
  103. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/lm_providers_enum.py +0 -0
  104. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/new_human_evaluation.py +0 -0
  105. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/new_testset.py +0 -0
  106. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/organization.py +0 -0
  107. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/organization_output.py +0 -0
  108. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/outputs.py +0 -0
  109. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/permission.py +0 -0
  110. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/result.py +0 -0
  111. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/score.py +0 -0
  112. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/simple_evaluation_output.py +0 -0
  113. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/span.py +0 -0
  114. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/span_detail.py +0 -0
  115. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/span_status_code.py +0 -0
  116. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/span_variant.py +0 -0
  117. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/template.py +0 -0
  118. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/template_image_info.py +0 -0
  119. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/test_set_output_response.py +0 -0
  120. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/test_set_simple_response.py +0 -0
  121. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/trace_detail.py +0 -0
  122. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/update_app_output.py +0 -0
  123. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/uri.py +0 -0
  124. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/validation_error.py +0 -0
  125. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/validation_error_loc_item.py +0 -0
  126. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/variant_action.py +0 -0
  127. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/variant_action_enum.py +0 -0
  128. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/with_pagination.py +0 -0
  129. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/workspace_member_response.py +0 -0
  130. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/workspace_permission.py +0 -0
  131. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/workspace_response.py +0 -0
  132. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/workspace_role.py +0 -0
  133. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/types/workspace_role_response.py +0 -0
  134. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/variants/__init__.py +0 -0
  135. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/variants/client.py +0 -0
  136. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/variants/types/__init__.py +0 -0
  137. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +0 -0
  138. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/client.py +0 -0
  139. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/client/exceptions.py +0 -0
  140. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/config.py +0 -0
  141. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/config.toml +0 -0
  142. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/docker/docker-assets/Dockerfile.cloud.template +0 -0
  143. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/docker/docker-assets/Dockerfile.template +0 -0
  144. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/docker/docker-assets/README.md +0 -0
  145. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/docker/docker-assets/entrypoint.sh +0 -0
  146. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/docker/docker-assets/lambda_function.py +0 -0
  147. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/docker/docker-assets/main.py +0 -0
  148. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/docker/docker_utils.py +0 -0
  149. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/__init__.py +0 -0
  150. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/agenta_init.py +0 -0
  151. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/assets.py +0 -0
  152. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/client.py +0 -0
  153. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/config_manager.py +0 -0
  154. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/context/__init__.py +0 -0
  155. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/context/routing.py +0 -0
  156. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/context/tracing.py +0 -0
  157. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/decorators/__init__.py +0 -0
  158. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/litellm/__init__.py +0 -0
  159. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/litellm/litellm.py +0 -0
  160. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/router.py +0 -0
  161. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/tracing/__init__.py +0 -0
  162. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/types.py +0 -0
  163. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/utils/__init__.py +0 -0
  164. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/utils/costs.py +0 -0
  165. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/utils/debug.py +0 -0
  166. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/utils/exceptions.py +0 -0
  167. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/utils/globals.py +0 -0
  168. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/utils/logging.py +0 -0
  169. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/utils/preinit.py +0 -0
  170. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/sdk/utils/singleton.py +0 -0
  171. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/compose_email/README.md +0 -0
  172. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/compose_email/app.py +0 -0
  173. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/compose_email/env.example +0 -0
  174. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/compose_email/requirements.txt +0 -0
  175. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/compose_email/template.toml +0 -0
  176. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/extract_data_to_json/README.md +0 -0
  177. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/extract_data_to_json/app.py +0 -0
  178. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/extract_data_to_json/env.example +0 -0
  179. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
  180. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/extract_data_to_json/template.toml +0 -0
  181. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/simple_prompt/README.md +0 -0
  182. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/simple_prompt/app.py +0 -0
  183. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/simple_prompt/env.example +0 -0
  184. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/simple_prompt/requirements.txt +0 -0
  185. {agenta-0.27.0a1 → agenta-0.27.0a5}/agenta/templates/simple_prompt/template.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: agenta
3
- Version: 0.27.0a1
3
+ Version: 0.27.0a5
4
4
  Summary: The SDK for agenta is an open-source LLMOps platform.
5
5
  Home-page: https://agenta.ai
6
6
  Keywords: LLMOps,LLM,evaluation,prompt engineering
@@ -1,17 +1,18 @@
1
- import json
2
- import inspect
3
- import argparse
4
- import asyncio
5
- import traceback
6
- import functools
1
+ from typing import Type, Any, Callable, Dict, Optional, Tuple, List
2
+ from annotated_types import Ge, Le, Gt, Lt
3
+ from pydantic import BaseModel, HttpUrl, ValidationError
4
+ from json import dumps
5
+ from inspect import signature, iscoroutinefunction, Signature, Parameter, _empty
6
+ from argparse import ArgumentParser
7
+ from functools import wraps
8
+ from asyncio import sleep, get_event_loop
9
+ from traceback import format_exc, format_exception
7
10
  from pathlib import Path
8
11
  from tempfile import NamedTemporaryFile
9
- from typing import Any, Callable, Dict, Optional, Tuple, List
12
+
10
13
  from fastapi.middleware.cors import CORSMiddleware
11
14
  from fastapi import Body, FastAPI, UploadFile, HTTPException
12
15
 
13
- import agenta as ag
14
-
15
16
  from agenta.sdk.context.routing import routing_context_manager, routing_context
16
17
  from agenta.sdk.context.tracing import tracing_context
17
18
  from agenta.sdk.router import router as router
@@ -31,16 +32,8 @@ from agenta.sdk.types import (
31
32
  BaseResponse,
32
33
  BinaryParam,
33
34
  )
34
- import pydantic
35
-
36
- from pydantic import BaseModel
37
- from typing import Type
38
- from annotated_types import Ge, Le, Gt, Lt
39
-
40
- from pydantic import BaseModel, HttpUrl
41
-
42
- from traceback import format_exc
43
35
 
36
+ import agenta as ag
44
37
 
45
38
  app = FastAPI()
46
39
 
@@ -130,12 +123,12 @@ class entrypoint:
130
123
  DEFAULT_PATH = "generate"
131
124
  PLAYGROUND_PATH = "/playground"
132
125
  RUN_PATH = "/run"
133
- func_signature = inspect.signature(func)
126
+ func_signature = signature(func)
134
127
  try:
135
128
  config = (
136
129
  config_schema() if config_schema else None
137
130
  ) # we initialize the config object to be able to use it
138
- except pydantic.ValidationError as e:
131
+ except ValidationError as e:
139
132
  raise ValueError(
140
133
  f"Error initializing config_schema. Please ensure all required fields have default values: {str(e)}"
141
134
  ) from e
@@ -150,7 +143,7 @@ class entrypoint:
150
143
  self.route_path = route_path
151
144
 
152
145
  ### --- Playground --- #
153
- @functools.wraps(func)
146
+ @wraps(func)
154
147
  async def wrapper(*args, **kwargs) -> Any:
155
148
  func_params, api_config_params = self.split_kwargs(kwargs, config_params)
156
149
  self.ingest_files(func_params, ingestible_files)
@@ -212,8 +205,8 @@ class entrypoint:
212
205
  )
213
206
  ### ---------------------------- #
214
207
 
215
- ### --- Deployed / Published --- #
216
- @functools.wraps(func)
208
+ ### --- Deployed --- #
209
+ @wraps(func)
217
210
  async def wrapper_deployed(*args, **kwargs) -> Any:
218
211
  func_params = {
219
212
  k: v for k, v in kwargs.items() if k not in ["config", "environment"]
@@ -252,7 +245,7 @@ class entrypoint:
252
245
 
253
246
  route_deployed = f"{RUN_PATH}{route_path}"
254
247
  app.post(route_deployed, response_model=BaseResponse)(wrapper_deployed)
255
- ### ---------------------------- #
248
+ ### ---------------- #
256
249
 
257
250
  ### --- Update OpenAPI --- #
258
251
  app.openapi_schema = None # Forces FastAPI to re-generate the schema
@@ -283,8 +276,8 @@ class entrypoint:
283
276
 
284
277
  def extract_ingestible_files(
285
278
  self,
286
- func_signature: inspect.Signature,
287
- ) -> Dict[str, inspect.Parameter]:
279
+ func_signature: Signature,
280
+ ) -> Dict[str, Parameter]:
288
281
  """Extract parameters annotated as InFile from function signature."""
289
282
 
290
283
  return {
@@ -311,7 +304,7 @@ class entrypoint:
311
304
  def ingest_files(
312
305
  self,
313
306
  func_params: Dict[str, Any],
314
- ingestible_files: Dict[str, inspect.Parameter],
307
+ ingestible_files: Dict[str, Parameter],
315
308
  ) -> None:
316
309
  """Ingest files specified in function parameters."""
317
310
 
@@ -319,6 +312,65 @@ class entrypoint:
319
312
  if name in func_params and func_params[name] is not None:
320
313
  func_params[name] = self.ingest_file(func_params[name])
321
314
 
315
+ async def execute_function(
316
+ self,
317
+ func: Callable[..., Any],
318
+ inline_trace,
319
+ *args,
320
+ **func_params,
321
+ ):
322
+ log.info(f"---------------------------")
323
+ log.info(f"Agenta SDK - running route: {repr(self.route_path or '/')}")
324
+ log.info(f"---------------------------")
325
+
326
+ tracing_context.set(routing_context.get())
327
+
328
+ try:
329
+ result = (
330
+ await func(*args, **func_params["params"])
331
+ if iscoroutinefunction(func)
332
+ else func(*args, **func_params["params"])
333
+ )
334
+
335
+ return await self.handle_success(result, inline_trace)
336
+
337
+ except Exception as error:
338
+ self.handle_failure(error)
339
+
340
+ async def handle_success(self, result: Any, inline_trace: bool):
341
+ data = None
342
+ trace = dict()
343
+
344
+ with suppress():
345
+ data = self.patch_result(result)
346
+
347
+ if inline_trace:
348
+ trace = await self.fetch_inline_trace(inline_trace)
349
+
350
+ log.info(f"----------------------------------")
351
+ log.info(f"Agenta SDK - exiting with success: 200")
352
+ log.info(f"----------------------------------")
353
+
354
+ return BaseResponse(data=data, trace=trace)
355
+
356
+ def handle_failure(self, error: Exception):
357
+ log.error("--------------------------------------------------")
358
+ log.error("Agenta SDK - handling application exception below:")
359
+ log.error("--------------------------------------------------")
360
+ log.error(format_exc().strip("\n"))
361
+ log.error("--------------------------------------------------")
362
+
363
+ status_code = error.status_code if hasattr(error, "status_code") else 500
364
+ message = str(error)
365
+ stacktrace = format_exception(error, value=error, tb=error.__traceback__) # type: ignore
366
+ detail = {"message": message, "stacktrace": stacktrace}
367
+
368
+ log.error(f"----------------------------------")
369
+ log.error(f"Agenta SDK - exiting with failure: {status_code}")
370
+ log.error(f"----------------------------------")
371
+
372
+ raise HTTPException(status_code=status_code, detail=detail)
373
+
322
374
  def patch_result(self, result: Any):
323
375
  """
324
376
  Patch the result to only include the message if the result is a FuncResponse-style dictionary with message, cost, and usage keys.
@@ -356,92 +408,39 @@ class entrypoint:
356
408
 
357
409
  return data
358
410
 
359
- async def execute_function(
360
- self,
361
- func: Callable[..., Any],
362
- inline_trace,
363
- *args,
364
- **func_params,
365
- ):
366
- log.info(f"---------------------------")
367
- log.info(
368
- f"Agenta SDK - running route: {repr(self.route_path if self.route_path != '' else '/')}"
369
- )
370
- log.info(f"---------------------------")
371
-
372
- tracing_context.set(routing_context.get())
373
-
411
+ async def fetch_inline_trace(self, inline_trace):
374
412
  WAIT_FOR_SPANS = True
375
413
  TIMEOUT = 1
376
414
  TIMESTEP = 0.1
377
415
  FINALSTEP = 0.001
378
416
  NOFSTEPS = TIMEOUT / TIMESTEP
379
417
 
380
- data = None
381
- trace = {}
418
+ trace = None
382
419
 
383
- try:
384
- result = (
385
- await func(*args, **func_params["params"])
386
- if inspect.iscoroutinefunction(func)
387
- else func(*args, **func_params["params"])
388
- )
389
- data = self.patch_result(result)
390
- except Exception as e:
391
- log.error("--------------------------------------------------")
392
- log.error("Agenta SDK - handling application exception below:")
393
- log.error("--------------------------------------------------")
394
- log.error(format_exc().strip("\n"))
395
- log.error("--------------------------------------------------")
396
-
397
- self.handle_exception(e)
398
-
399
- with suppress():
400
- root_context: Dict[str, Any] = tracing_context.get().get("root")
401
-
402
- trace_id = root_context.get("trace_id") if root_context else None
403
-
404
- if trace_id is not None:
405
- if inline_trace:
406
- if WAIT_FOR_SPANS:
407
- remaining_steps = NOFSTEPS
408
-
409
- while (
410
- not ag.tracing.is_inline_trace_ready(trace_id)
411
- and remaining_steps > 0
412
- ):
413
- await asyncio.sleep(TIMESTEP)
420
+ root_context: Dict[str, Any] = tracing_context.get().get("root")
414
421
 
415
- remaining_steps -= 1
422
+ trace_id = root_context.get("trace_id") if root_context else None
416
423
 
417
- await asyncio.sleep(FINALSTEP)
424
+ if trace_id is not None:
425
+ if inline_trace:
426
+ if WAIT_FOR_SPANS:
427
+ remaining_steps = NOFSTEPS
418
428
 
419
- trace = ag.tracing.get_inline_trace(trace_id)
420
- else:
421
- trace = {"trace_id": trace_id}
422
-
423
- response = BaseResponse(data=data, trace=trace)
424
-
425
- log.info(f"----------------------------------")
426
- log.info(f"Agenta SDK - exiting successfully: 200")
427
- log.info(f"----------------------------------")
429
+ while (
430
+ not ag.tracing.is_inline_trace_ready(trace_id)
431
+ and remaining_steps > 0
432
+ ):
433
+ await sleep(TIMESTEP)
428
434
 
429
- return response
435
+ remaining_steps -= 1
430
436
 
431
- def handle_exception(self, e: Exception):
432
- status_code = e.status_code if hasattr(e, "status_code") else 500
433
- message = str(e)
434
- stacktrace = traceback.format_exception(e, value=e, tb=e.__traceback__) # type: ignore
435
- detail = {"message": message, "stacktrace": stacktrace}
437
+ await sleep(FINALSTEP)
436
438
 
437
- log.error(f"----------------------------------------")
438
- log.error(f"Agenta SDK - exiting with HTTPException: {status_code}")
439
- log.error(f"----------------------------------------")
439
+ trace = ag.tracing.get_inline_trace(trace_id)
440
+ else:
441
+ trace = {"trace_id": trace_id}
440
442
 
441
- raise HTTPException(
442
- status_code=status_code,
443
- detail=detail,
444
- )
443
+ return trace
445
444
 
446
445
  def update_wrapper_signature(
447
446
  self, wrapper: Callable[..., Any], updated_params: List
@@ -451,25 +450,25 @@ class entrypoint:
451
450
 
452
451
  Args:
453
452
  wrapper (callable): A callable object, such as a function or a method, that requires a signature update.
454
- updated_params (List[inspect.Parameter]): A list of `inspect.Parameter` objects representing the updated parameters
453
+ updated_params (List[Parameter]): A list of `Parameter` objects representing the updated parameters
455
454
  for the wrapper function.
456
455
  """
457
456
 
458
- wrapper_signature = inspect.signature(wrapper)
457
+ wrapper_signature = signature(wrapper)
459
458
  wrapper_signature = wrapper_signature.replace(parameters=updated_params)
460
459
  wrapper.__signature__ = wrapper_signature # type: ignore
461
460
 
462
461
  def update_function_signature(
463
462
  self,
464
463
  wrapper: Callable[..., Any],
465
- func_signature: inspect.Signature,
464
+ func_signature: Signature,
466
465
  config_class: Type[BaseModel], # TODO: change to our type
467
466
  config_dict: Dict[str, Any],
468
- ingestible_files: Dict[str, inspect.Parameter],
467
+ ingestible_files: Dict[str, Parameter],
469
468
  ) -> None:
470
469
  """Update the function signature to include new parameters."""
471
470
 
472
- updated_params: List[inspect.Parameter] = []
471
+ updated_params: List[Parameter] = []
473
472
  if config_class:
474
473
  self.add_config_params_to_parser(updated_params, config_class)
475
474
  else:
@@ -480,21 +479,21 @@ class entrypoint:
480
479
  def update_deployed_function_signature(
481
480
  self,
482
481
  wrapper: Callable[..., Any],
483
- func_signature: inspect.Signature,
484
- ingestible_files: Dict[str, inspect.Parameter],
482
+ func_signature: Signature,
483
+ ingestible_files: Dict[str, Parameter],
485
484
  ) -> None:
486
485
  """Update the function signature to include new parameters."""
487
486
 
488
- updated_params: List[inspect.Parameter] = []
487
+ updated_params: List[Parameter] = []
489
488
  self.add_func_params_to_parser(updated_params, func_signature, ingestible_files)
490
489
  for param in [
491
490
  "config",
492
491
  "environment",
493
492
  ]: # we add the config and environment parameters
494
493
  updated_params.append(
495
- inspect.Parameter(
494
+ Parameter(
496
495
  name=param,
497
- kind=inspect.Parameter.KEYWORD_ONLY,
496
+ kind=Parameter.KEYWORD_ONLY,
498
497
  default=Body(None),
499
498
  annotation=str,
500
499
  )
@@ -508,9 +507,9 @@ class entrypoint:
508
507
  for name, field in config_class.__fields__.items():
509
508
  assert field.default is not None, f"Field {name} has no default value"
510
509
  updated_params.append(
511
- inspect.Parameter(
510
+ Parameter(
512
511
  name=name,
513
- kind=inspect.Parameter.KEYWORD_ONLY,
512
+ kind=Parameter.KEYWORD_ONLY,
514
513
  annotation=field.annotation.__name__,
515
514
  default=Body(field.default),
516
515
  )
@@ -525,9 +524,9 @@ class entrypoint:
525
524
  len(param.__class__.__bases__) == 1
526
525
  ), f"Inherited standard type of {param.__class__} needs to be one."
527
526
  updated_params.append(
528
- inspect.Parameter(
527
+ Parameter(
529
528
  name=name,
530
- kind=inspect.Parameter.KEYWORD_ONLY,
529
+ kind=Parameter.KEYWORD_ONLY,
531
530
  default=Body(param),
532
531
  annotation=param.__class__.__bases__[
533
532
  0
@@ -540,23 +539,23 @@ class entrypoint:
540
539
  def add_func_params_to_parser(
541
540
  self,
542
541
  updated_params: list,
543
- func_signature: inspect.Signature,
544
- ingestible_files: Dict[str, inspect.Parameter],
542
+ func_signature: Signature,
543
+ ingestible_files: Dict[str, Parameter],
545
544
  ) -> None:
546
545
  """Add function parameters to function signature."""
547
546
  for name, param in func_signature.parameters.items():
548
547
  if name in ingestible_files:
549
548
  updated_params.append(
550
- inspect.Parameter(name, param.kind, annotation=UploadFile)
549
+ Parameter(name, param.kind, annotation=UploadFile)
551
550
  )
552
551
  else:
553
552
  assert (
554
553
  len(param.default.__class__.__bases__) == 1
555
554
  ), f"Inherited standard type of {param.default.__class__} needs to be one."
556
555
  updated_params.append(
557
- inspect.Parameter(
556
+ Parameter(
558
557
  name,
559
- inspect.Parameter.KEYWORD_ONLY,
558
+ Parameter.KEYWORD_ONLY,
560
559
  default=Body(..., embed=True),
561
560
  annotation=param.default.__class__.__bases__[
562
561
  0
@@ -585,7 +584,7 @@ class entrypoint:
585
584
  def handle_terminal_run(
586
585
  self,
587
586
  func: Callable,
588
- func_params: Dict[str, inspect.Parameter],
587
+ func_params: Dict[str, Parameter],
589
588
  config_params: Dict[str, Any],
590
589
  ingestible_files: Dict,
591
590
  ):
@@ -599,7 +598,7 @@ class entrypoint:
599
598
  """
600
599
 
601
600
  # For required parameters, we add them as arguments
602
- parser = argparse.ArgumentParser()
601
+ parser = ArgumentParser()
603
602
  for name, param in func_params.items():
604
603
  if name in ingestible_files:
605
604
  parser.add_argument(name, type=str)
@@ -644,7 +643,7 @@ class entrypoint:
644
643
  }
645
644
  )
646
645
 
647
- loop = asyncio.get_event_loop()
646
+ loop = get_event_loop()
648
647
 
649
648
  with routing_context_manager(
650
649
  config=args_config_params,
@@ -674,13 +673,13 @@ class entrypoint:
674
673
  if SHOW_DATA:
675
674
  log.info(" ")
676
675
  log.info(f"data:")
677
- log.info(json.dumps(result.data, indent=2))
676
+ log.info(dumps(result.data, indent=2))
678
677
 
679
678
  if SHOW_TRACE:
680
679
  log.info(" ")
681
680
  log.info(f"trace:")
682
681
  log.info(f"----------------")
683
- log.info(json.dumps(result.trace.get("spans", []), indent=2))
682
+ log.info(dumps(result.trace.get("spans", []), indent=2))
684
683
  log.info(f"----------------")
685
684
 
686
685
  log.info("\n==========================\n")
@@ -890,10 +889,7 @@ class entrypoint:
890
889
  subschema["maximum"] = param_val.maxval # type: ignore
891
890
  subschema["default"] = param_val
892
891
 
893
- elif (
894
- isinstance(param_val, inspect.Parameter)
895
- and param_val.annotation is DictInput
896
- ):
892
+ elif isinstance(param_val, Parameter) and param_val.annotation is DictInput:
897
893
  subschema = find_in_schema(
898
894
  param_val.annotation.__schema_type_properties__(),
899
895
  schema_to_override,
@@ -912,7 +908,7 @@ class entrypoint:
912
908
  subschema["default"] = param_val
913
909
 
914
910
  elif (
915
- isinstance(param_val, inspect.Parameter)
911
+ isinstance(param_val, Parameter)
916
912
  and param_val.annotation is MessagesInput
917
913
  ):
918
914
  subschema = find_in_schema(
@@ -924,7 +920,7 @@ class entrypoint:
924
920
  subschema["default"] = param_val.default
925
921
 
926
922
  elif (
927
- isinstance(param_val, inspect.Parameter)
923
+ isinstance(param_val, Parameter)
928
924
  and param_val.annotation is FileInputURL
929
925
  ):
930
926
  subschema = find_in_schema(
@@ -948,6 +944,6 @@ class entrypoint:
948
944
  "title": str(param_name).capitalize(),
949
945
  "type": get_type_from_param(param_val),
950
946
  }
951
- if param_val.default != inspect._empty:
947
+ if param_val.default != _empty:
952
948
  subschema["default"] = param_val.default # type: ignore
953
949
  schema_to_override[param_name] = subschema