agenta 0.14.14a1__tar.gz → 0.15.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 (167) hide show
  1. {agenta-0.14.14a1 → agenta-0.15.0}/PKG-INFO +3 -3
  2. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/__init__.py +6 -3
  3. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/client.py +8 -6
  4. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/create_span.py +1 -1
  5. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/docker/docker-assets/Dockerfile.cloud.template +1 -1
  6. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/__init__.py +6 -4
  7. agenta-0.15.0/agenta/sdk/agenta_init.py +256 -0
  8. agenta-0.15.0/agenta/sdk/decorators/base.py +10 -0
  9. agenta-0.15.0/agenta/sdk/decorators/llm_entrypoint.py +499 -0
  10. agenta-0.15.0/agenta/sdk/decorators/tracing.py +98 -0
  11. agenta-0.15.0/agenta/sdk/tracing/llm_tracing.py +239 -0
  12. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/tracing/logger.py +1 -1
  13. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/tracing/tasks_manager.py +1 -3
  14. agenta-0.15.0/agenta/sdk/types.py +212 -0
  15. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/utils/globals.py +3 -1
  16. {agenta-0.14.14a1 → agenta-0.15.0}/pyproject.toml +3 -3
  17. agenta-0.14.14a1/agenta/sdk/agenta_decorator.py +0 -570
  18. agenta-0.14.14a1/agenta/sdk/agenta_init.py +0 -244
  19. agenta-0.14.14a1/agenta/sdk/tracing/decorators.py +0 -41
  20. agenta-0.14.14a1/agenta/sdk/tracing/llm_tracing.py +0 -220
  21. agenta-0.14.14a1/agenta/sdk/types.py +0 -193
  22. {agenta-0.14.14a1 → agenta-0.15.0}/README.md +0 -0
  23. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/cli/evaluation_commands.py +0 -0
  24. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/cli/helper.py +0 -0
  25. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/cli/main.py +0 -0
  26. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/cli/telemetry.py +0 -0
  27. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/cli/variant_commands.py +0 -0
  28. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/cli/variant_configs.py +0 -0
  29. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/Readme.md +0 -0
  30. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/__init__.py +0 -0
  31. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/api.py +0 -0
  32. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/api_models.py +0 -0
  33. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/__init__.py +0 -0
  34. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/core/__init__.py +0 -0
  35. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/core/api_error.py +0 -0
  36. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/core/client_wrapper.py +0 -0
  37. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/core/datetime_utils.py +0 -0
  38. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/core/jsonable_encoder.py +0 -0
  39. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/core/remove_none_from_dict.py +0 -0
  40. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/errors/__init__.py +0 -0
  41. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/errors/unprocessable_entity_error.py +0 -0
  42. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/__init__.py +0 -0
  43. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/apps/__init__.py +0 -0
  44. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/apps/client.py +0 -0
  45. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/bases/__init__.py +0 -0
  46. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/bases/client.py +0 -0
  47. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/configs/__init__.py +0 -0
  48. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/configs/client.py +0 -0
  49. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/containers/__init__.py +0 -0
  50. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/containers/client.py +0 -0
  51. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/containers/types/__init__.py +0 -0
  52. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/containers/types/container_templates_response.py +0 -0
  53. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/environments/__init__.py +0 -0
  54. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/environments/client.py +0 -0
  55. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/evaluations/__init__.py +0 -0
  56. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/evaluations/client.py +0 -0
  57. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/evaluators/__init__.py +0 -0
  58. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/evaluators/client.py +0 -0
  59. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/observability/__init__.py +0 -0
  60. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/observability/client.py +0 -0
  61. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/testsets/__init__.py +0 -0
  62. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/testsets/client.py +0 -0
  63. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/variants/__init__.py +0 -0
  64. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/variants/client.py +0 -0
  65. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/variants/types/__init__.py +0 -0
  66. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -0
  67. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/__init__.py +0 -0
  68. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/aggregated_result.py +0 -0
  69. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/aggregated_result_evaluator_config.py +0 -0
  70. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/app.py +0 -0
  71. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/app_variant_response.py +0 -0
  72. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/app_variant_revision.py +0 -0
  73. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/base_output.py +0 -0
  74. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/body_import_testset.py +0 -0
  75. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/config_db.py +0 -0
  76. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/create_app_output.py +0 -0
  77. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/create_trace_response.py +0 -0
  78. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/docker_env_vars.py +0 -0
  79. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/environment_output.py +0 -0
  80. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/environment_output_extended.py +0 -0
  81. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/environment_revision.py +0 -0
  82. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/error.py +0 -0
  83. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluation.py +0 -0
  84. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluation_scenario.py +0 -0
  85. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluation_scenario_input.py +0 -0
  86. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluation_scenario_output.py +0 -0
  87. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluation_scenario_result.py +0 -0
  88. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluation_scenario_score_update.py +0 -0
  89. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluation_status_enum.py +0 -0
  90. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluation_type.py +0 -0
  91. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluation_webhook.py +0 -0
  92. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluator.py +0 -0
  93. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/evaluator_config.py +0 -0
  94. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/feedback.py +0 -0
  95. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/get_config_response.py +0 -0
  96. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/http_validation_error.py +0 -0
  97. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/human_evaluation.py +0 -0
  98. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/human_evaluation_scenario.py +0 -0
  99. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/human_evaluation_scenario_input.py +0 -0
  100. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/human_evaluation_scenario_output.py +0 -0
  101. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/human_evaluation_scenario_update.py +0 -0
  102. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/human_evaluation_update.py +0 -0
  103. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/image.py +0 -0
  104. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/invite_request.py +0 -0
  105. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/list_api_keys_response.py +0 -0
  106. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/llm_run_rate_limit.py +0 -0
  107. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/llm_tokens.py +0 -0
  108. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/new_human_evaluation.py +0 -0
  109. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/new_testset.py +0 -0
  110. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/organization.py +0 -0
  111. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/organization_output.py +0 -0
  112. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/permission.py +0 -0
  113. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/result.py +0 -0
  114. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/score.py +0 -0
  115. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/simple_evaluation_output.py +0 -0
  116. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/span.py +0 -0
  117. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/span_detail.py +0 -0
  118. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/span_kind.py +0 -0
  119. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/span_status_code.py +0 -0
  120. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/span_variant.py +0 -0
  121. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/template.py +0 -0
  122. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/template_image_info.py +0 -0
  123. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/test_set_output_response.py +0 -0
  124. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/test_set_simple_response.py +0 -0
  125. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/trace_detail.py +0 -0
  126. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/uri.py +0 -0
  127. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/validation_error.py +0 -0
  128. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/validation_error_loc_item.py +0 -0
  129. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/variant_action.py +0 -0
  130. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/variant_action_enum.py +0 -0
  131. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/with_pagination.py +0 -0
  132. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/workspace_member_response.py +0 -0
  133. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/workspace_permission.py +0 -0
  134. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/workspace_response.py +0 -0
  135. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/workspace_role.py +0 -0
  136. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/backend/types/workspace_role_response.py +0 -0
  137. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/client.py +0 -0
  138. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/client/exceptions.py +0 -0
  139. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/config.py +0 -0
  140. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/config.toml +0 -0
  141. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/docker/docker-assets/Dockerfile.template +0 -0
  142. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/docker/docker-assets/README.md +0 -0
  143. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/docker/docker-assets/entrypoint.sh +0 -0
  144. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/docker/docker-assets/lambda_function.py +0 -0
  145. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/docker/docker-assets/main.py +0 -0
  146. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/docker/docker_utils.py +0 -0
  147. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/client.py +0 -0
  148. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/context.py +0 -0
  149. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/router.py +0 -0
  150. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/tracing/context_manager.py +0 -0
  151. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/utils/helper/openai_cost.py +0 -0
  152. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/sdk/utils/preinit.py +0 -0
  153. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/compose_email/README.md +0 -0
  154. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/compose_email/app.py +0 -0
  155. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/compose_email/env.example +0 -0
  156. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/compose_email/requirements.txt +0 -0
  157. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/compose_email/template.toml +0 -0
  158. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/extract_data_to_json/README.md +0 -0
  159. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/extract_data_to_json/app.py +0 -0
  160. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/extract_data_to_json/env.example +0 -0
  161. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
  162. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/extract_data_to_json/template.toml +0 -0
  163. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/simple_prompt/README.md +0 -0
  164. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/simple_prompt/app.py +0 -0
  165. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/simple_prompt/env.example +0 -0
  166. {agenta-0.14.14a1 → agenta-0.15.0}/agenta/templates/simple_prompt/requirements.txt +0 -0
  167. {agenta-0.14.14a1 → agenta-0.15.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.14.14a1
3
+ Version: 0.15.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
@@ -18,12 +18,12 @@ Classifier: Topic :: Software Development :: Libraries
18
18
  Requires-Dist: cachetools (>=5.3.3,<6.0.0)
19
19
  Requires-Dist: click (>=8.1.3,<9.0.0)
20
20
  Requires-Dist: docker (>=6.1.1,<8.0.0)
21
- Requires-Dist: fastapi (>=0.111.0,<0.112.0)
21
+ Requires-Dist: fastapi (>=0.96.1)
22
22
  Requires-Dist: httpx (>=0.24,<0.28)
23
23
  Requires-Dist: importlib-metadata (>=6.7,<8.0)
24
24
  Requires-Dist: ipdb (>=0.13)
25
25
  Requires-Dist: posthog (>=3.1.0,<4.0.0)
26
- Requires-Dist: pydantic (>=2.7.1,<3.0.0)
26
+ Requires-Dist: pydantic (==1.10.13)
27
27
  Requires-Dist: pymongo (>=4.6.3,<5.0.0)
28
28
  Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
29
29
  Requires-Dist: python-multipart (>=0.0.6,<0.0.10)
@@ -1,5 +1,4 @@
1
1
  from .sdk.utils.preinit import PreInitObject
2
- from .sdk.agenta_decorator import app, entrypoint
3
2
  from .sdk.context import get_contexts, save_context
4
3
  from .sdk.types import (
5
4
  Context,
@@ -14,9 +13,13 @@ from .sdk.types import (
14
13
  FileInputURL,
15
14
  BinaryParam,
16
15
  )
17
- from .sdk.tracing.decorators import span
18
- from .sdk.agenta_init import Config, init, llm_tracing
16
+ from .sdk.tracing.llm_tracing import Tracing
17
+ from .sdk.decorators.tracing import instrument
18
+ from .sdk.decorators.llm_entrypoint import entrypoint, app
19
+ from .sdk.agenta_init import Config, AgentaSingleton, init
19
20
  from .sdk.utils.helper.openai_cost import calculate_token_usage
20
21
  from .sdk.client import Agenta
21
22
 
22
23
  config = PreInitObject("agenta.config", Config)
24
+ DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
25
+ tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
@@ -56,9 +56,9 @@ class AgentaApi:
56
56
  self._client_wrapper = SyncClientWrapper(
57
57
  base_url=base_url,
58
58
  api_key=api_key,
59
- httpx_client=httpx.Client(timeout=timeout)
60
- if httpx_client is None
61
- else httpx_client,
59
+ httpx_client=(
60
+ httpx.Client(timeout=timeout) if httpx_client is None else httpx_client
61
+ ),
62
62
  )
63
63
  self.observability = ObservabilityClient(client_wrapper=self._client_wrapper)
64
64
  self.apps = AppsClient(client_wrapper=self._client_wrapper)
@@ -1037,9 +1037,11 @@ class AsyncAgentaApi:
1037
1037
  self._client_wrapper = AsyncClientWrapper(
1038
1038
  base_url=base_url,
1039
1039
  api_key=api_key,
1040
- httpx_client=httpx.AsyncClient(timeout=timeout)
1041
- if httpx_client is None
1042
- else httpx_client,
1040
+ httpx_client=(
1041
+ httpx.AsyncClient(timeout=timeout)
1042
+ if httpx_client is None
1043
+ else httpx_client
1044
+ ),
1043
1045
  )
1044
1046
  self.observability = AsyncObservabilityClient(
1045
1047
  client_wrapper=self._client_wrapper
@@ -53,6 +53,6 @@ class CreateSpan(pydantic.BaseModel):
53
53
  return super().dict(**kwargs_with_defaults)
54
54
 
55
55
  class Config:
56
- frozen = True
56
+ frozen = False
57
57
  smart_union = True
58
58
  json_encoders = {dt.datetime: serialize_datetime}
@@ -2,7 +2,7 @@ FROM public.ecr.aws/s2t9a1r1/agentaai/lambda_templates_public:main
2
2
 
3
3
  COPY requirements.txt ${LAMBDA_TASK_ROOT}
4
4
  RUN pip install --no-cache-dir --disable-pip-version-check -U agenta
5
- RUN pip install --no-cache-dir --disable-pip-version-check -r requirements.txt
5
+ RUN pip install --no-cache-dir --disable-pip-version-check -U -r requirements.txt
6
6
  RUN pip install --no-cache-dir --disable-pip-version-check mangum
7
7
  COPY . ${LAMBDA_TASK_ROOT}
8
8
 
@@ -1,6 +1,4 @@
1
1
  from .utils.preinit import PreInitObject # always the first import!
2
- from . import agenta_decorator, context, types, utils # noqa: F401
3
- from .agenta_decorator import app, entrypoint
4
2
  from .context import get_contexts, save_context
5
3
  from .types import (
6
4
  Context,
@@ -15,9 +13,13 @@ from .types import (
15
13
  FileInputURL,
16
14
  BinaryParam,
17
15
  )
18
- from .tracing.decorators import span
19
- from .agenta_init import Config, init, llm_tracing
16
+ from .tracing.llm_tracing import Tracing
17
+ from .decorators.tracing import instrument
18
+ from .decorators.llm_entrypoint import entrypoint, app
19
+ from .agenta_init import Config, AgentaSingleton, init
20
20
  from .utils.helper.openai_cost import calculate_token_usage
21
21
 
22
22
 
23
23
  config = PreInitObject("agenta.config", Config)
24
+ DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
25
+ tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
@@ -0,0 +1,256 @@
1
+ import os
2
+ import logging
3
+ import toml
4
+ from typing import Optional
5
+
6
+ from agenta.sdk.utils.globals import set_global
7
+ from agenta.client.backend.client import AgentaApi
8
+ from agenta.sdk.tracing.llm_tracing import Tracing
9
+ from agenta.client.exceptions import APIRequestError
10
+
11
+
12
+ logger = logging.getLogger(__name__)
13
+ logger.setLevel(logging.DEBUG)
14
+
15
+
16
+ class AgentaSingleton:
17
+ """Singleton class to save all the "global variables" for the sdk."""
18
+
19
+ _instance = None
20
+ setup = None
21
+ config = None
22
+ tracing: Optional[Tracing] = None
23
+
24
+ def __new__(cls):
25
+ if not cls._instance:
26
+ cls._instance = super(AgentaSingleton, cls).__new__(cls)
27
+ return cls._instance
28
+
29
+ @property
30
+ def client(self):
31
+ """API Backend client.
32
+
33
+ Returns:
34
+ AgentaAPI: instance of agenta api backend
35
+ """
36
+
37
+ return AgentaApi(base_url=self.host + "/api", api_key=self.api_key)
38
+
39
+ def init(
40
+ self,
41
+ app_id: Optional[str] = None,
42
+ host: Optional[str] = None,
43
+ api_key: Optional[str] = None,
44
+ config_fname: Optional[str] = None,
45
+ ) -> None:
46
+ """Main function to initialize the singleton.
47
+
48
+ Initializes the singleton with the given `app_id`, `host`, and `api_key`. The order of precedence for these variables is:
49
+ 1. Explicit argument provided in the function call.
50
+ 2. Value from the configuration file specified by `config_fname`.
51
+ 3. Environment variables.
52
+
53
+ Examples:
54
+ ag.init(app_id="xxxx", api_key="xxx")
55
+ ag.init(config_fname="config.toml")
56
+ ag.init() #assuming env vars are set
57
+
58
+ Args:
59
+ app_id (Optional[str]): ID of the Agenta application. Defaults to None. If not provided, will look for "app_id" in the config file, then "AGENTA_APP_ID" in environment variables.
60
+ host (Optional[str]): Host name of the backend server. Defaults to None. If not provided, will look for "backend_host" in the config file, then "AGENTA_HOST" in environment variables.
61
+ api_key (Optional[str]): API Key to use with the host of the backend server. Defaults to None. If not provided, will look for "api_key" in the config file, then "AGENTA_API_KEY" in environment variables.
62
+ config_fname (Optional[str]): Path to the configuration file (relative or absolute). Defaults to None.
63
+
64
+ Raises:
65
+ ValueError: If `app_id` is not specified either as an argument, in the config file, or in the environment variables.
66
+ """
67
+ config = {}
68
+ if config_fname:
69
+ config = toml.load(config_fname)
70
+
71
+ self.app_id = app_id or config.get("app_id") or os.environ.get("AGENTA_APP_ID")
72
+ self.host = (
73
+ host
74
+ or config.get("backend_host")
75
+ or os.environ.get("AGENTA_HOST", "https://cloud.agenta.ai")
76
+ )
77
+ self.api_key = (
78
+ api_key or config.get("api_key") or os.environ.get("AGENTA_API_KEY")
79
+ )
80
+
81
+ if not self.app_id:
82
+ raise ValueError(
83
+ "App ID must be specified. You can provide it in one of the following ways:\n"
84
+ "1. As an argument when calling ag.init(app_id='your_app_id').\n"
85
+ "2. In the configuration file specified by config_fname.\n"
86
+ "3. As an environment variable 'AGENTA_APP_ID'."
87
+ )
88
+ self.base_id = os.environ.get("AGENTA_BASE_ID")
89
+ if self.base_id is None:
90
+ print(
91
+ "Warning: Your configuration will not be saved permanently since base_id is not provided."
92
+ )
93
+
94
+ self.config = Config(base_id=self.base_id, host=self.host) # type: ignore
95
+
96
+
97
+ class Config:
98
+ def __init__(self, base_id: str, host: str, api_key: str = ""):
99
+ self.base_id = base_id
100
+ self.host = host
101
+
102
+ if base_id is None or host is None:
103
+ self.persist = False
104
+ else:
105
+ self.persist = True
106
+ self.client = AgentaApi(base_url=self.host + "/api", api_key=api_key)
107
+
108
+ def register_default(self, overwrite=False, **kwargs):
109
+ """alias for default"""
110
+ return self.default(overwrite=overwrite, **kwargs)
111
+
112
+ def default(self, overwrite=False, **kwargs):
113
+ """Saves the default parameters to the app_name and base_name in case they are not already saved.
114
+ Args:
115
+ overwrite: Whether to overwrite the existing configuration or not
116
+ **kwargs: A dict containing the parameters
117
+ """
118
+ self.set(
119
+ **kwargs
120
+ ) # In case there is no connectivity, we still can use the default values
121
+ try:
122
+ self.push(config_name="default", overwrite=overwrite, **kwargs)
123
+ except Exception as ex:
124
+ logger.warning(
125
+ "Unable to push the default configuration to the server. %s", str(ex)
126
+ )
127
+
128
+ def push(self, config_name: str, overwrite=True, **kwargs):
129
+ """Pushes the parameters for the app variant to the server
130
+ Args:
131
+ config_name: Name of the configuration to push to
132
+ overwrite: Whether to overwrite the existing configuration or not
133
+ **kwargs: A dict containing the parameters
134
+ """
135
+ if not self.persist:
136
+ return
137
+ try:
138
+ self.client.configs.save_config(
139
+ base_id=self.base_id,
140
+ config_name=config_name,
141
+ parameters=kwargs,
142
+ overwrite=overwrite,
143
+ )
144
+ except Exception as ex:
145
+ logger.warning(
146
+ "Failed to push the configuration to the server with error: %s", ex
147
+ )
148
+
149
+ def pull(
150
+ self, config_name: str = "default", environment_name: Optional[str] = None
151
+ ):
152
+ """Pulls the parameters for the app variant from the server and sets them to the config"""
153
+ if not self.persist and (
154
+ config_name != "default" or environment_name is not None
155
+ ):
156
+ raise ValueError(
157
+ "Cannot pull the configuration from the server since the app_name and base_name are not provided."
158
+ )
159
+ if self.persist:
160
+ try:
161
+ if environment_name:
162
+ config = self.client.configs.get_config(
163
+ base_id=self.base_id, environment_name=environment_name
164
+ )
165
+
166
+ else:
167
+ config = self.client.configs.get_config(
168
+ base_id=self.base_id,
169
+ config_name=config_name,
170
+ )
171
+ except Exception as ex:
172
+ logger.warning(
173
+ "Failed to pull the configuration from the server with error: %s",
174
+ str(ex),
175
+ )
176
+ try:
177
+ self.set(**{"current_version": config.current_version, **config.parameters})
178
+ except Exception as ex:
179
+ logger.warning("Failed to set the configuration with error: %s", str(ex))
180
+
181
+ def all(self):
182
+ """Returns all the parameters for the app variant"""
183
+ return {
184
+ k: v
185
+ for k, v in self.__dict__.items()
186
+ if k
187
+ not in [
188
+ "app_name",
189
+ "base_name",
190
+ "host",
191
+ "base_id",
192
+ "api_key",
193
+ "persist",
194
+ "client",
195
+ ]
196
+ }
197
+
198
+ # function to set the parameters for the app variant
199
+ def set(self, **kwargs):
200
+ """Sets the parameters for the app variant
201
+
202
+ Args:
203
+ **kwargs: A dict containing the parameters
204
+ """
205
+ for key, value in kwargs.items():
206
+ setattr(self, key, value)
207
+
208
+ def dump(self):
209
+ """Returns all the information about the current version in the configuration.
210
+
211
+ Raises:
212
+ NotImplementedError: _description_
213
+ """
214
+
215
+ raise NotImplementedError()
216
+
217
+
218
+ def init(
219
+ app_id: Optional[str] = None,
220
+ host: Optional[str] = None,
221
+ api_key: Optional[str] = None,
222
+ config_fname: Optional[str] = None,
223
+ max_workers: Optional[int] = None,
224
+ ):
225
+ """Main function to initialize the agenta sdk.
226
+
227
+ Initializes agenta with the given `app_id`, `host`, and `api_key`. The order of precedence for these variables is:
228
+ 1. Explicit argument provided in the function call.
229
+ 2. Value from the configuration file specified by `config_fname`.
230
+ 3. Environment variables.
231
+
232
+ - `app_id` is a required parameter (to be specified in one of the above ways)
233
+ - `host` is optional and defaults to "https://cloud.agenta.ai"
234
+ - `api_key` is optional and defaults to "". It is required only when using cloud or enterprise version of agenta.
235
+
236
+
237
+ Args:
238
+ app_id (Optional[str]): ID of the Agenta application. Defaults to None. If not provided, will look for "app_id" in the config file, then "AGENTA_APP_ID" in environment variables.
239
+ host (Optional[str]): Host name of the backend server. Defaults to None. If not provided, will look for "backend_host" in the config file, then "AGENTA_HOST" in environment variables.
240
+ api_key (Optional[str]): API Key to use with the host of the backend server. Defaults to None. If not provided, will look for "api_key" in the config file, then "AGENTA_API_KEY" in environment variables.
241
+ config_fname (Optional[str]): Path to the configuration file. Defaults to None.
242
+
243
+ Raises:
244
+ ValueError: If `app_id` is not specified either as an argument, in the config file, or in the environment variables.
245
+ """
246
+
247
+ singleton = AgentaSingleton()
248
+
249
+ singleton.init(app_id=app_id, host=host, api_key=api_key, config_fname=config_fname)
250
+ tracing = Tracing(
251
+ host=singleton.host, # type: ignore
252
+ app_id=singleton.app_id, # type: ignore
253
+ api_key=singleton.api_key,
254
+ max_workers=max_workers,
255
+ )
256
+ set_global(setup=singleton.setup, config=singleton.config, tracing=tracing)
@@ -0,0 +1,10 @@
1
+ # Stdlib Imports
2
+ from typing import Any, Callable
3
+
4
+
5
+ class BaseDecorator:
6
+ def __init__(self):
7
+ pass
8
+
9
+ def __call__(self, func: Callable[..., Any]) -> Callable[..., Any]:
10
+ raise NotImplementedError