agenta 0.26.0a0__tar.gz → 0.27.0__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 (209) hide show
  1. {agenta-0.26.0a0 → agenta-0.27.0}/PKG-INFO +5 -1
  2. agenta-0.27.0/agenta/__init__.py +50 -0
  3. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/cli/helper.py +5 -1
  4. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/__init__.py +14 -0
  5. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/apps/client.py +28 -20
  6. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/client.py +47 -16
  7. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/containers/client.py +5 -1
  8. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/__init__.py +2 -1
  9. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/client_wrapper.py +6 -6
  10. agenta-0.27.0/agenta/client/backend/core/file.py +65 -0
  11. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/http_client.py +45 -31
  12. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/pydantic_utilities.py +144 -29
  13. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/request_options.py +3 -0
  14. agenta-0.27.0/agenta/client/backend/core/serialization.py +276 -0
  15. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/evaluations/client.py +7 -2
  16. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/evaluators/client.py +349 -1
  17. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/observability/client.py +11 -2
  18. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/testsets/client.py +10 -10
  19. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/__init__.py +14 -0
  20. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/app.py +1 -0
  21. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/app_variant_response.py +3 -1
  22. agenta-0.27.0/agenta/client/backend/types/config_dto.py +32 -0
  23. agenta-0.27.0/agenta/client/backend/types/config_response_model.py +32 -0
  24. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/create_span.py +3 -2
  25. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/environment_output.py +1 -0
  26. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/environment_output_extended.py +1 -0
  27. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluation.py +1 -2
  28. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluator.py +2 -0
  29. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluator_config.py +1 -0
  30. agenta-0.27.0/agenta/client/backend/types/evaluator_mapping_output_interface.py +21 -0
  31. agenta-0.27.0/agenta/client/backend/types/evaluator_output_interface.py +21 -0
  32. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/human_evaluation.py +1 -2
  33. agenta-0.27.0/agenta/client/backend/types/lifecycle_dto.py +24 -0
  34. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/llm_tokens.py +2 -2
  35. agenta-0.27.0/agenta/client/backend/types/reference_dto.py +23 -0
  36. agenta-0.27.0/agenta/client/backend/types/reference_request_model.py +23 -0
  37. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/span.py +1 -0
  38. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/span_detail.py +7 -1
  39. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/test_set_output_response.py +5 -2
  40. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/trace_detail.py +7 -1
  41. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/with_pagination.py +4 -2
  42. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/variants/client.py +1565 -272
  43. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/docker/docker-assets/Dockerfile.cloud.template +1 -1
  44. agenta-0.27.0/agenta/sdk/__init__.py +64 -0
  45. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/sdk/agenta_init.py +85 -33
  46. agenta-0.27.0/agenta/sdk/context/routing.py +26 -0
  47. agenta-0.27.0/agenta/sdk/context/tracing.py +3 -0
  48. agenta-0.26.0a0/agenta/sdk/decorators/llm_entrypoint.py → agenta-0.27.0/agenta/sdk/decorators/routing.py +216 -191
  49. agenta-0.27.0/agenta/sdk/decorators/tracing.py +250 -0
  50. agenta-0.27.0/agenta/sdk/litellm/__init__.py +1 -0
  51. agenta-0.27.0/agenta/sdk/litellm/litellm.py +288 -0
  52. agenta-0.27.0/agenta/sdk/managers/__init__.py +6 -0
  53. agenta-0.27.0/agenta/sdk/managers/config.py +318 -0
  54. agenta-0.27.0/agenta/sdk/managers/deployment.py +45 -0
  55. agenta-0.27.0/agenta/sdk/managers/shared.py +639 -0
  56. agenta-0.27.0/agenta/sdk/managers/variant.py +182 -0
  57. agenta-0.27.0/agenta/sdk/router.py +8 -0
  58. agenta-0.27.0/agenta/sdk/tracing/__init__.py +1 -0
  59. agenta-0.27.0/agenta/sdk/tracing/attributes.py +141 -0
  60. agenta-0.27.0/agenta/sdk/tracing/context.py +24 -0
  61. agenta-0.27.0/agenta/sdk/tracing/conventions.py +49 -0
  62. agenta-0.27.0/agenta/sdk/tracing/exporters.py +65 -0
  63. agenta-0.27.0/agenta/sdk/tracing/inline.py +1252 -0
  64. agenta-0.27.0/agenta/sdk/tracing/processors.py +117 -0
  65. agenta-0.27.0/agenta/sdk/tracing/spans.py +136 -0
  66. agenta-0.27.0/agenta/sdk/tracing/tracing.py +233 -0
  67. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/sdk/types.py +49 -2
  68. agenta-0.27.0/agenta/sdk/utils/__init__.py +0 -0
  69. agenta-0.26.0a0/agenta/sdk/utils/helper/openai_cost.py → agenta-0.27.0/agenta/sdk/utils/costs.py +3 -0
  70. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/sdk/utils/debug.py +5 -5
  71. agenta-0.27.0/agenta/sdk/utils/exceptions.py +52 -0
  72. agenta-0.27.0/agenta/sdk/utils/globals.py +14 -0
  73. agenta-0.26.0a0/agenta/sdk/tracing/logger.py → agenta-0.27.0/agenta/sdk/utils/logging.py +3 -5
  74. agenta-0.27.0/agenta/sdk/utils/singleton.py +13 -0
  75. {agenta-0.26.0a0 → agenta-0.27.0}/pyproject.toml +16 -1
  76. agenta-0.26.0a0/agenta/__init__.py +0 -31
  77. agenta-0.26.0a0/agenta/client/backend/core/file.py +0 -43
  78. agenta-0.26.0a0/agenta/client/backend/core/serialization.py +0 -179
  79. agenta-0.26.0a0/agenta/sdk/__init__.py +0 -27
  80. agenta-0.26.0a0/agenta/sdk/config_manager.py +0 -205
  81. agenta-0.26.0a0/agenta/sdk/context.py +0 -41
  82. agenta-0.26.0a0/agenta/sdk/decorators/base.py +0 -10
  83. agenta-0.26.0a0/agenta/sdk/decorators/tracing.py +0 -131
  84. agenta-0.26.0a0/agenta/sdk/router.py +0 -15
  85. agenta-0.26.0a0/agenta/sdk/tracing/callbacks.py +0 -187
  86. agenta-0.26.0a0/agenta/sdk/tracing/llm_tracing.py +0 -617
  87. agenta-0.26.0a0/agenta/sdk/tracing/tasks_manager.py +0 -129
  88. agenta-0.26.0a0/agenta/sdk/tracing/tracing_context.py +0 -27
  89. agenta-0.26.0a0/agenta/sdk/utils/globals.py +0 -16
  90. {agenta-0.26.0a0 → agenta-0.27.0}/README.md +0 -0
  91. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/cli/evaluation_commands.py +0 -0
  92. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/cli/main.py +0 -0
  93. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/cli/telemetry.py +0 -0
  94. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/cli/variant_commands.py +0 -0
  95. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/cli/variant_configs.py +0 -0
  96. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/Readme.md +0 -0
  97. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/__init__.py +0 -0
  98. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/api.py +0 -0
  99. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/api_models.py +0 -0
  100. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/apps/__init__.py +0 -0
  101. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/bases/__init__.py +0 -0
  102. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/bases/client.py +0 -0
  103. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/configs/__init__.py +0 -0
  104. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/configs/client.py +0 -0
  105. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/containers/__init__.py +0 -0
  106. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/containers/types/__init__.py +0 -0
  107. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/containers/types/container_templates_response.py +0 -0
  108. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/api_error.py +0 -0
  109. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/datetime_utils.py +0 -0
  110. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/jsonable_encoder.py +0 -0
  111. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/query_encoder.py +0 -0
  112. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/core/remove_none_from_dict.py +0 -0
  113. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/environments/__init__.py +0 -0
  114. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/environments/client.py +0 -0
  115. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/errors/__init__.py +0 -0
  116. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/errors/unprocessable_entity_error.py +0 -0
  117. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/evaluations/__init__.py +0 -0
  118. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/evaluators/__init__.py +0 -0
  119. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/observability/__init__.py +0 -0
  120. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/testsets/__init__.py +0 -0
  121. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/aggregated_result.py +0 -0
  122. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/aggregated_result_evaluator_config.py +0 -0
  123. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/app_variant_revision.py +0 -0
  124. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/base_output.py +0 -0
  125. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/body_import_testset.py +0 -0
  126. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/config_db.py +0 -0
  127. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/correct_answer.py +0 -0
  128. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/create_app_output.py +0 -0
  129. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/create_trace_response.py +0 -0
  130. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/docker_env_vars.py +0 -0
  131. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/environment_revision.py +0 -0
  132. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/error.py +0 -0
  133. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluation_scenario.py +0 -0
  134. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluation_scenario_input.py +0 -0
  135. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluation_scenario_output.py +0 -0
  136. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluation_scenario_result.py +0 -0
  137. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluation_scenario_score_update.py +0 -0
  138. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluation_status_enum.py +0 -0
  139. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/evaluation_type.py +0 -0
  140. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/get_config_response.py +0 -0
  141. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/http_validation_error.py +0 -0
  142. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/human_evaluation_scenario.py +0 -0
  143. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/human_evaluation_scenario_input.py +0 -0
  144. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/human_evaluation_scenario_output.py +0 -0
  145. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/human_evaluation_scenario_update.py +0 -0
  146. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/human_evaluation_update.py +0 -0
  147. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/image.py +0 -0
  148. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/invite_request.py +0 -0
  149. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/list_api_keys_response.py +0 -0
  150. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/llm_run_rate_limit.py +0 -0
  151. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/lm_providers_enum.py +0 -0
  152. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/new_human_evaluation.py +0 -0
  153. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/new_testset.py +0 -0
  154. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/organization.py +0 -0
  155. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/organization_output.py +0 -0
  156. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/outputs.py +0 -0
  157. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/permission.py +0 -0
  158. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/result.py +0 -0
  159. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/score.py +0 -0
  160. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/simple_evaluation_output.py +0 -0
  161. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/span_status_code.py +0 -0
  162. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/span_variant.py +0 -0
  163. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/template.py +0 -0
  164. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/template_image_info.py +0 -0
  165. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/test_set_simple_response.py +0 -0
  166. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/update_app_output.py +0 -0
  167. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/uri.py +0 -0
  168. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/validation_error.py +0 -0
  169. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/validation_error_loc_item.py +0 -0
  170. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/variant_action.py +0 -0
  171. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/variant_action_enum.py +0 -0
  172. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/workspace_member_response.py +0 -0
  173. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/workspace_permission.py +0 -0
  174. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/workspace_response.py +0 -0
  175. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/workspace_role.py +0 -0
  176. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/types/workspace_role_response.py +0 -0
  177. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/variants/__init__.py +0 -0
  178. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/variants/types/__init__.py +0 -0
  179. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +0 -0
  180. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/client.py +0 -0
  181. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/client/exceptions.py +0 -0
  182. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/config.py +0 -0
  183. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/config.toml +0 -0
  184. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/docker/docker-assets/Dockerfile.template +0 -0
  185. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/docker/docker-assets/README.md +0 -0
  186. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/docker/docker-assets/entrypoint.sh +0 -0
  187. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/docker/docker-assets/lambda_function.py +0 -0
  188. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/docker/docker-assets/main.py +0 -0
  189. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/docker/docker_utils.py +0 -0
  190. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/sdk/assets.py +0 -0
  191. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/sdk/client.py +0 -0
  192. {agenta-0.26.0a0/agenta/sdk/tracing → agenta-0.27.0/agenta/sdk/context}/__init__.py +0 -0
  193. {agenta-0.26.0a0/agenta/sdk/utils → agenta-0.27.0/agenta/sdk/decorators}/__init__.py +0 -0
  194. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/sdk/utils/preinit.py +0 -0
  195. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/compose_email/README.md +0 -0
  196. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/compose_email/app.py +0 -0
  197. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/compose_email/env.example +0 -0
  198. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/compose_email/requirements.txt +0 -0
  199. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/compose_email/template.toml +0 -0
  200. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/extract_data_to_json/README.md +0 -0
  201. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/extract_data_to_json/app.py +0 -0
  202. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/extract_data_to_json/env.example +0 -0
  203. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
  204. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/extract_data_to_json/template.toml +0 -0
  205. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/simple_prompt/README.md +0 -0
  206. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/simple_prompt/app.py +0 -0
  207. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/simple_prompt/env.example +0 -0
  208. {agenta-0.26.0a0 → agenta-0.27.0}/agenta/templates/simple_prompt/requirements.txt +0 -0
  209. {agenta-0.26.0a0 → agenta-0.27.0}/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.26.0a0
3
+ Version: 0.27.0
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
@@ -23,6 +23,10 @@ Requires-Dist: fastapi (>=0.100.0)
23
23
  Requires-Dist: httpx (>=0.24,<0.28)
24
24
  Requires-Dist: importlib-metadata (>=8.0.0,<9.0)
25
25
  Requires-Dist: ipdb (>=0.13)
26
+ Requires-Dist: litellm (>=1.48.0,<2.0.0)
27
+ Requires-Dist: opentelemetry-api (>=1.27.0,<2.0.0)
28
+ Requires-Dist: opentelemetry-exporter-otlp (>=1.27.0,<2.0.0)
29
+ Requires-Dist: opentelemetry-sdk (>=1.27.0,<2.0.0)
26
30
  Requires-Dist: posthog (>=3.1.0,<4.0.0)
27
31
  Requires-Dist: pydantic (>=2)
28
32
  Requires-Dist: pymongo (>=4.6.3,<5.0.0)
@@ -0,0 +1,50 @@
1
+ from .sdk.utils.preinit import PreInitObject
2
+
3
+ import agenta.client.backend.types as client_types # pylint: disable=wrong-import-order
4
+
5
+ from .sdk.types import (
6
+ DictInput,
7
+ MultipleChoice,
8
+ FloatParam,
9
+ InFile,
10
+ IntParam,
11
+ MultipleChoiceParam,
12
+ GroupedMultipleChoiceParam,
13
+ MessagesInput,
14
+ TextParam,
15
+ FileInputURL,
16
+ BinaryParam,
17
+ Prompt,
18
+ )
19
+
20
+ from .sdk.utils.logging import log as logging
21
+ from .sdk.tracing import Tracing
22
+ from .sdk.decorators.tracing import instrument
23
+ from .sdk.tracing.conventions import Reference
24
+ from .sdk.decorators.routing import entrypoint, app, route
25
+ from .sdk.agenta_init import Config, AgentaSingleton, init as _init
26
+ from .sdk.utils.costs import calculate_token_usage
27
+ from .sdk.client import Agenta
28
+ from .sdk.litellm import litellm as callbacks
29
+ from .sdk.managers.config import ConfigManager
30
+ from .sdk.managers.variant import VariantManager
31
+ from .sdk.managers.deployment import DeploymentManager
32
+ from .sdk import assets as assets
33
+ from .sdk import tracer
34
+
35
+ config = PreInitObject("agenta.config", Config)
36
+ DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
37
+
38
+ types = client_types
39
+ tracing = None
40
+ api = None
41
+ async_api = None
42
+
43
+
44
+ def init(*args, **kwargs):
45
+ global api, async_api, tracing, config
46
+ _init(*args, **kwargs)
47
+
48
+ tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
49
+ api = DEFAULT_AGENTA_SINGLETON_INSTANCE.api # type: ignore
50
+ async_api = DEFAULT_AGENTA_SINGLETON_INSTANCE.async_api # type: ignore
@@ -15,6 +15,9 @@ import toml
15
15
  from agenta.client.backend.client import AgentaApi
16
16
 
17
17
  BACKEND_URL_SUFFIX = os.environ.get("BACKEND_URL_SUFFIX", "api")
18
+ POSTHOG_KEY = os.environ.get(
19
+ "POSTHOG_KEY", "phc_hmVSxIjTW1REBHXgj2aw4HW9X6CXb6FzerBgP9XenC7"
20
+ )
18
21
 
19
22
 
20
23
  def get_global_config(var_name: str) -> Optional[Any]:
@@ -111,7 +114,8 @@ def init_telemetry_config() -> None:
111
114
  ):
112
115
  set_global_config("telemetry_tracking_enabled", True)
113
116
  set_global_config(
114
- "telemetry_api_key", "phc_hmVSxIjTW1REBHXgj2aw4HW9X6CXb6FzerBgP9XenC7"
117
+ "telemetry_api_key",
118
+ POSTHOG_KEY,
115
119
  )
116
120
 
117
121
 
@@ -9,6 +9,8 @@ from .types import (
9
9
  BaseOutput,
10
10
  BodyImportTestset,
11
11
  ConfigDb,
12
+ ConfigDto,
13
+ ConfigResponseModel,
12
14
  CorrectAnswer,
13
15
  CreateAppOutput,
14
16
  CreateSpan,
@@ -28,6 +30,8 @@ from .types import (
28
30
  EvaluationType,
29
31
  Evaluator,
30
32
  EvaluatorConfig,
33
+ EvaluatorMappingOutputInterface,
34
+ EvaluatorOutputInterface,
31
35
  GetConfigResponse,
32
36
  HttpValidationError,
33
37
  HumanEvaluation,
@@ -38,6 +42,7 @@ from .types import (
38
42
  HumanEvaluationUpdate,
39
43
  Image,
40
44
  InviteRequest,
45
+ LifecycleDto,
41
46
  ListApiKeysResponse,
42
47
  LlmRunRateLimit,
43
48
  LlmTokens,
@@ -48,6 +53,8 @@ from .types import (
48
53
  OrganizationOutput,
49
54
  Outputs,
50
55
  Permission,
56
+ ReferenceDto,
57
+ ReferenceRequestModel,
51
58
  Result,
52
59
  Score,
53
60
  SimpleEvaluationOutput,
@@ -102,6 +109,8 @@ __all__ = [
102
109
  "BaseOutput",
103
110
  "BodyImportTestset",
104
111
  "ConfigDb",
112
+ "ConfigDto",
113
+ "ConfigResponseModel",
105
114
  "ContainerTemplatesResponse",
106
115
  "CorrectAnswer",
107
116
  "CreateAppOutput",
@@ -122,6 +131,8 @@ __all__ = [
122
131
  "EvaluationType",
123
132
  "Evaluator",
124
133
  "EvaluatorConfig",
134
+ "EvaluatorMappingOutputInterface",
135
+ "EvaluatorOutputInterface",
125
136
  "GetConfigResponse",
126
137
  "HttpValidationError",
127
138
  "HumanEvaluation",
@@ -132,6 +143,7 @@ __all__ = [
132
143
  "HumanEvaluationUpdate",
133
144
  "Image",
134
145
  "InviteRequest",
146
+ "LifecycleDto",
135
147
  "ListApiKeysResponse",
136
148
  "LlmRunRateLimit",
137
149
  "LlmTokens",
@@ -142,6 +154,8 @@ __all__ = [
142
154
  "OrganizationOutput",
143
155
  "Outputs",
144
156
  "Permission",
157
+ "ReferenceDto",
158
+ "ReferenceRequestModel",
145
159
  "Result",
146
160
  "Score",
147
161
  "SimpleEvaluationOutput",
@@ -176,7 +176,6 @@ class AppsClient:
176
176
  self,
177
177
  *,
178
178
  app_name: typing.Optional[str] = None,
179
- org_id: typing.Optional[str] = None,
180
179
  workspace_id: typing.Optional[str] = None,
181
180
  request_options: typing.Optional[RequestOptions] = None,
182
181
  ) -> typing.List[App]:
@@ -198,8 +197,6 @@ class AppsClient:
198
197
  ----------
199
198
  app_name : typing.Optional[str]
200
199
 
201
- org_id : typing.Optional[str]
202
-
203
200
  workspace_id : typing.Optional[str]
204
201
 
205
202
  request_options : typing.Optional[RequestOptions]
@@ -225,7 +222,6 @@ class AppsClient:
225
222
  method="GET",
226
223
  params={
227
224
  "app_name": app_name,
228
- "org_id": org_id,
229
225
  "workspace_id": workspace_id,
230
226
  },
231
227
  request_options=request_options,
@@ -258,8 +254,9 @@ class AppsClient:
258
254
  self,
259
255
  *,
260
256
  app_name: str,
261
- organization_id: typing.Optional[str] = OMIT,
257
+ project_id: typing.Optional[str] = OMIT,
262
258
  workspace_id: typing.Optional[str] = OMIT,
259
+ organization_id: typing.Optional[str] = OMIT,
263
260
  request_options: typing.Optional[RequestOptions] = None,
264
261
  ) -> CreateAppOutput:
265
262
  """
@@ -279,10 +276,12 @@ class AppsClient:
279
276
  ----------
280
277
  app_name : str
281
278
 
282
- organization_id : typing.Optional[str]
279
+ project_id : typing.Optional[str]
283
280
 
284
281
  workspace_id : typing.Optional[str]
285
282
 
283
+ organization_id : typing.Optional[str]
284
+
286
285
  request_options : typing.Optional[RequestOptions]
287
286
  Request-specific configuration.
288
287
 
@@ -308,8 +307,9 @@ class AppsClient:
308
307
  method="POST",
309
308
  json={
310
309
  "app_name": app_name,
311
- "organization_id": organization_id,
310
+ "project_id": project_id,
312
311
  "workspace_id": workspace_id,
312
+ "organization_id": organization_id,
313
313
  },
314
314
  request_options=request_options,
315
315
  omit=OMIT,
@@ -586,8 +586,9 @@ class AppsClient:
586
586
  app_name: str,
587
587
  template_id: str,
588
588
  env_vars: typing.Dict[str, str],
589
- organization_id: typing.Optional[str] = OMIT,
589
+ project_id: typing.Optional[str] = OMIT,
590
590
  workspace_id: typing.Optional[str] = OMIT,
591
+ organization_id: typing.Optional[str] = OMIT,
591
592
  request_options: typing.Optional[RequestOptions] = None,
592
593
  ) -> AppVariantResponse:
593
594
  """
@@ -611,10 +612,12 @@ class AppsClient:
611
612
 
612
613
  env_vars : typing.Dict[str, str]
613
614
 
614
- organization_id : typing.Optional[str]
615
+ project_id : typing.Optional[str]
615
616
 
616
617
  workspace_id : typing.Optional[str]
617
618
 
619
+ organization_id : typing.Optional[str]
620
+
618
621
  request_options : typing.Optional[RequestOptions]
619
622
  Request-specific configuration.
620
623
 
@@ -643,9 +646,10 @@ class AppsClient:
643
646
  json={
644
647
  "app_name": app_name,
645
648
  "template_id": template_id,
649
+ "project_id": project_id,
650
+ "workspace_id": workspace_id,
646
651
  "env_vars": env_vars,
647
652
  "organization_id": organization_id,
648
- "workspace_id": workspace_id,
649
653
  },
650
654
  request_options=request_options,
651
655
  omit=OMIT,
@@ -976,7 +980,6 @@ class AsyncAppsClient:
976
980
  self,
977
981
  *,
978
982
  app_name: typing.Optional[str] = None,
979
- org_id: typing.Optional[str] = None,
980
983
  workspace_id: typing.Optional[str] = None,
981
984
  request_options: typing.Optional[RequestOptions] = None,
982
985
  ) -> typing.List[App]:
@@ -998,8 +1001,6 @@ class AsyncAppsClient:
998
1001
  ----------
999
1002
  app_name : typing.Optional[str]
1000
1003
 
1001
- org_id : typing.Optional[str]
1002
-
1003
1004
  workspace_id : typing.Optional[str]
1004
1005
 
1005
1006
  request_options : typing.Optional[RequestOptions]
@@ -1033,7 +1034,6 @@ class AsyncAppsClient:
1033
1034
  method="GET",
1034
1035
  params={
1035
1036
  "app_name": app_name,
1036
- "org_id": org_id,
1037
1037
  "workspace_id": workspace_id,
1038
1038
  },
1039
1039
  request_options=request_options,
@@ -1066,8 +1066,9 @@ class AsyncAppsClient:
1066
1066
  self,
1067
1067
  *,
1068
1068
  app_name: str,
1069
- organization_id: typing.Optional[str] = OMIT,
1069
+ project_id: typing.Optional[str] = OMIT,
1070
1070
  workspace_id: typing.Optional[str] = OMIT,
1071
+ organization_id: typing.Optional[str] = OMIT,
1071
1072
  request_options: typing.Optional[RequestOptions] = None,
1072
1073
  ) -> CreateAppOutput:
1073
1074
  """
@@ -1087,10 +1088,12 @@ class AsyncAppsClient:
1087
1088
  ----------
1088
1089
  app_name : str
1089
1090
 
1090
- organization_id : typing.Optional[str]
1091
+ project_id : typing.Optional[str]
1091
1092
 
1092
1093
  workspace_id : typing.Optional[str]
1093
1094
 
1095
+ organization_id : typing.Optional[str]
1096
+
1094
1097
  request_options : typing.Optional[RequestOptions]
1095
1098
  Request-specific configuration.
1096
1099
 
@@ -1124,8 +1127,9 @@ class AsyncAppsClient:
1124
1127
  method="POST",
1125
1128
  json={
1126
1129
  "app_name": app_name,
1127
- "organization_id": organization_id,
1130
+ "project_id": project_id,
1128
1131
  "workspace_id": workspace_id,
1132
+ "organization_id": organization_id,
1129
1133
  },
1130
1134
  request_options=request_options,
1131
1135
  omit=OMIT,
@@ -1426,8 +1430,9 @@ class AsyncAppsClient:
1426
1430
  app_name: str,
1427
1431
  template_id: str,
1428
1432
  env_vars: typing.Dict[str, str],
1429
- organization_id: typing.Optional[str] = OMIT,
1433
+ project_id: typing.Optional[str] = OMIT,
1430
1434
  workspace_id: typing.Optional[str] = OMIT,
1435
+ organization_id: typing.Optional[str] = OMIT,
1431
1436
  request_options: typing.Optional[RequestOptions] = None,
1432
1437
  ) -> AppVariantResponse:
1433
1438
  """
@@ -1451,10 +1456,12 @@ class AsyncAppsClient:
1451
1456
 
1452
1457
  env_vars : typing.Dict[str, str]
1453
1458
 
1454
- organization_id : typing.Optional[str]
1459
+ project_id : typing.Optional[str]
1455
1460
 
1456
1461
  workspace_id : typing.Optional[str]
1457
1462
 
1463
+ organization_id : typing.Optional[str]
1464
+
1458
1465
  request_options : typing.Optional[RequestOptions]
1459
1466
  Request-specific configuration.
1460
1467
 
@@ -1491,9 +1498,10 @@ class AsyncAppsClient:
1491
1498
  json={
1492
1499
  "app_name": app_name,
1493
1500
  "template_id": template_id,
1501
+ "project_id": project_id,
1502
+ "workspace_id": workspace_id,
1494
1503
  "env_vars": env_vars,
1495
1504
  "organization_id": organization_id,
1496
- "workspace_id": workspace_id,
1497
1505
  },
1498
1506
  request_options=request_options,
1499
1507
  omit=OMIT,
@@ -24,6 +24,7 @@ from .core.jsonable_encoder import jsonable_encoder
24
24
  from .types.organization import Organization
25
25
  from .types.organization_output import OrganizationOutput
26
26
  from .types.invite_request import InviteRequest
27
+ from .core.serialization import convert_and_respect_annotation_metadata
27
28
  from .types.workspace_response import WorkspaceResponse
28
29
  import datetime as dt
29
30
  from .types.workspace_role_response import WorkspaceRoleResponse
@@ -88,13 +89,17 @@ class AgentaApi:
88
89
  self._client_wrapper = SyncClientWrapper(
89
90
  base_url=base_url,
90
91
  api_key=api_key,
91
- httpx_client=httpx_client
92
- if httpx_client is not None
93
- else httpx.Client(
94
- timeout=_defaulted_timeout, follow_redirects=follow_redirects
95
- )
96
- if follow_redirects is not None
97
- else httpx.Client(timeout=_defaulted_timeout),
92
+ httpx_client=(
93
+ httpx_client
94
+ if httpx_client is not None
95
+ else (
96
+ httpx.Client(
97
+ timeout=_defaulted_timeout, follow_redirects=follow_redirects
98
+ )
99
+ if follow_redirects is not None
100
+ else httpx.Client(timeout=_defaulted_timeout)
101
+ )
102
+ ),
98
103
  timeout=_defaulted_timeout,
99
104
  )
100
105
  self.observability = ObservabilityClient(client_wrapper=self._client_wrapper)
@@ -728,7 +733,11 @@ class AgentaApi:
728
733
  _response = self._client_wrapper.httpx_client.request(
729
734
  f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
730
735
  method="POST",
731
- json=request,
736
+ json=convert_and_respect_annotation_metadata(
737
+ object_=request,
738
+ annotation=typing.Sequence[InviteRequest],
739
+ direction="write",
740
+ ),
732
741
  request_options=request_options,
733
742
  omit=OMIT,
734
743
  )
@@ -843,6 +852,7 @@ class AgentaApi:
843
852
  org_id: str,
844
853
  workspace_id: str,
845
854
  *,
855
+ project_id: str,
846
856
  token: str,
847
857
  request_options: typing.Optional[RequestOptions] = None,
848
858
  ) -> typing.Optional[typing.Any]:
@@ -863,6 +873,8 @@ class AgentaApi:
863
873
 
864
874
  workspace_id : str
865
875
 
876
+ project_id : str
877
+
866
878
  token : str
867
879
 
868
880
  request_options : typing.Optional[RequestOptions]
@@ -884,12 +896,16 @@ class AgentaApi:
884
896
  client.accept_invitation(
885
897
  org_id="org_id",
886
898
  workspace_id="workspace_id",
899
+ project_id="project_id",
887
900
  token="token",
888
901
  )
889
902
  """
890
903
  _response = self._client_wrapper.httpx_client.request(
891
904
  f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
892
905
  method="POST",
906
+ params={
907
+ "project_id": project_id,
908
+ },
893
909
  json={
894
910
  "token": token,
895
911
  },
@@ -1603,13 +1619,17 @@ class AsyncAgentaApi:
1603
1619
  self._client_wrapper = AsyncClientWrapper(
1604
1620
  base_url=base_url,
1605
1621
  api_key=api_key,
1606
- httpx_client=httpx_client
1607
- if httpx_client is not None
1608
- else httpx.AsyncClient(
1609
- timeout=_defaulted_timeout, follow_redirects=follow_redirects
1610
- )
1611
- if follow_redirects is not None
1612
- else httpx.AsyncClient(timeout=_defaulted_timeout),
1622
+ httpx_client=(
1623
+ httpx_client
1624
+ if httpx_client is not None
1625
+ else (
1626
+ httpx.AsyncClient(
1627
+ timeout=_defaulted_timeout, follow_redirects=follow_redirects
1628
+ )
1629
+ if follow_redirects is not None
1630
+ else httpx.AsyncClient(timeout=_defaulted_timeout)
1631
+ )
1632
+ ),
1613
1633
  timeout=_defaulted_timeout,
1614
1634
  )
1615
1635
  self.observability = AsyncObservabilityClient(
@@ -2325,7 +2345,11 @@ class AsyncAgentaApi:
2325
2345
  _response = await self._client_wrapper.httpx_client.request(
2326
2346
  f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
2327
2347
  method="POST",
2328
- json=request,
2348
+ json=convert_and_respect_annotation_metadata(
2349
+ object_=request,
2350
+ annotation=typing.Sequence[InviteRequest],
2351
+ direction="write",
2352
+ ),
2329
2353
  request_options=request_options,
2330
2354
  omit=OMIT,
2331
2355
  )
@@ -2448,6 +2472,7 @@ class AsyncAgentaApi:
2448
2472
  org_id: str,
2449
2473
  workspace_id: str,
2450
2474
  *,
2475
+ project_id: str,
2451
2476
  token: str,
2452
2477
  request_options: typing.Optional[RequestOptions] = None,
2453
2478
  ) -> typing.Optional[typing.Any]:
@@ -2468,6 +2493,8 @@ class AsyncAgentaApi:
2468
2493
 
2469
2494
  workspace_id : str
2470
2495
 
2496
+ project_id : str
2497
+
2471
2498
  token : str
2472
2499
 
2473
2500
  request_options : typing.Optional[RequestOptions]
@@ -2494,6 +2521,7 @@ class AsyncAgentaApi:
2494
2521
  await client.accept_invitation(
2495
2522
  org_id="org_id",
2496
2523
  workspace_id="workspace_id",
2524
+ project_id="project_id",
2497
2525
  token="token",
2498
2526
  )
2499
2527
 
@@ -2503,6 +2531,9 @@ class AsyncAgentaApi:
2503
2531
  _response = await self._client_wrapper.httpx_client.request(
2504
2532
  f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
2505
2533
  method="POST",
2534
+ params={
2535
+ "project_id": project_id,
2536
+ },
2506
2537
  json={
2507
2538
  "token": token,
2508
2539
  },
@@ -387,7 +387,11 @@ class AsyncContainersClient:
387
387
  files={
388
388
  "tar_file": tar_file,
389
389
  },
390
- request_options=request_options,
390
+ request_options=(
391
+ {**request_options, "timeout_in_seconds": 600}
392
+ if request_options
393
+ else {"timeout_in_seconds": 600}
394
+ ),
391
395
  omit=OMIT,
392
396
  )
393
397
  try:
@@ -3,7 +3,7 @@
3
3
  from .api_error import ApiError
4
4
  from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
5
5
  from .datetime_utils import serialize_datetime
6
- from .file import File, convert_file_dict_to_httpx_tuples
6
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
7
7
  from .http_client import AsyncHttpClient, HttpClient
8
8
  from .jsonable_encoder import jsonable_encoder
9
9
  from .pydantic_utilities import (
@@ -43,4 +43,5 @@ __all__ = [
43
43
  "universal_field_validator",
44
44
  "universal_root_validator",
45
45
  "update_forward_refs",
46
+ "with_content_type",
46
47
  ]
@@ -40,9 +40,9 @@ class SyncClientWrapper(BaseClientWrapper):
40
40
  super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
41
41
  self.httpx_client = HttpClient(
42
42
  httpx_client=httpx_client,
43
- base_headers=self.get_headers(),
44
- base_timeout=self.get_timeout(),
45
- base_url=self.get_base_url(),
43
+ base_headers=self.get_headers,
44
+ base_timeout=self.get_timeout,
45
+ base_url=self.get_base_url,
46
46
  )
47
47
 
48
48
 
@@ -58,7 +58,7 @@ class AsyncClientWrapper(BaseClientWrapper):
58
58
  super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
59
59
  self.httpx_client = AsyncHttpClient(
60
60
  httpx_client=httpx_client,
61
- base_headers=self.get_headers(),
62
- base_timeout=self.get_timeout(),
63
- base_url=self.get_base_url(),
61
+ base_headers=self.get_headers,
62
+ base_timeout=self.get_timeout,
63
+ base_url=self.get_base_url,
64
64
  )
@@ -0,0 +1,65 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import IO, Dict, List, Mapping, Optional, Tuple, Union, cast
4
+
5
+ # File typing inspired by the flexibility of types within the httpx library
6
+ # https://github.com/encode/httpx/blob/master/httpx/_types.py
7
+ FileContent = Union[IO[bytes], bytes, str]
8
+ File = Union[
9
+ # file (or bytes)
10
+ FileContent,
11
+ # (filename, file (or bytes))
12
+ Tuple[Optional[str], FileContent],
13
+ # (filename, file (or bytes), content_type)
14
+ Tuple[Optional[str], FileContent, Optional[str]],
15
+ # (filename, file (or bytes), content_type, headers)
16
+ Tuple[
17
+ Optional[str],
18
+ FileContent,
19
+ Optional[str],
20
+ Mapping[str, str],
21
+ ],
22
+ ]
23
+
24
+
25
+ def convert_file_dict_to_httpx_tuples(
26
+ d: Dict[str, Union[File, List[File]]],
27
+ ) -> List[Tuple[str, File]]:
28
+ """
29
+ The format we use is a list of tuples, where the first element is the
30
+ name of the file and the second is the file object. Typically HTTPX wants
31
+ a dict, but to be able to send lists of files, you have to use the list
32
+ approach (which also works for non-lists)
33
+ https://github.com/encode/httpx/pull/1032
34
+ """
35
+
36
+ httpx_tuples = []
37
+ for key, file_like in d.items():
38
+ if isinstance(file_like, list):
39
+ for file_like_item in file_like:
40
+ httpx_tuples.append((key, file_like_item))
41
+ else:
42
+ httpx_tuples.append((key, file_like))
43
+ return httpx_tuples
44
+
45
+
46
+ def with_content_type(*, file: File, content_type: str) -> File:
47
+ """ """
48
+ if isinstance(file, tuple):
49
+ if len(file) == 2:
50
+ filename, content = cast(Tuple[Optional[str], FileContent], file) # type: ignore
51
+ return (filename, content, content_type)
52
+ elif len(file) == 3:
53
+ filename, content, _ = cast(
54
+ Tuple[Optional[str], FileContent, Optional[str]], file
55
+ ) # type: ignore
56
+ return (filename, content, content_type)
57
+ elif len(file) == 4:
58
+ filename, content, _, headers = cast( # type: ignore
59
+ Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
60
+ file,
61
+ )
62
+ return (filename, content, content_type, headers)
63
+ else:
64
+ raise ValueError(f"Unexpected tuple length: {len(file)}")
65
+ return (None, file, content_type)