agenta 0.14.12__tar.gz → 0.14.12a1__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 (164) hide show
  1. {agenta-0.14.12 → agenta-0.14.12a1}/PKG-INFO +1 -1
  2. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/__init__.py +5 -3
  3. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/client.py +8 -6
  4. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/create_span.py +1 -1
  5. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/__init__.py +4 -4
  6. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/agenta_init.py +66 -70
  7. agenta-0.14.12a1/agenta/sdk/decorators/base.py +10 -0
  8. agenta-0.14.12a1/agenta/sdk/decorators/llm_entrypoint.py +485 -0
  9. agenta-0.14.12a1/agenta/sdk/decorators/tracing.py +80 -0
  10. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/tracing/llm_tracing.py +87 -65
  11. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/tracing/tasks_manager.py +1 -3
  12. {agenta-0.14.12 → agenta-0.14.12a1}/pyproject.toml +1 -1
  13. agenta-0.14.12/agenta/sdk/agenta_decorator.py +0 -501
  14. agenta-0.14.12/agenta/sdk/tracing/decorators.py +0 -41
  15. {agenta-0.14.12 → agenta-0.14.12a1}/README.md +0 -0
  16. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/cli/evaluation_commands.py +0 -0
  17. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/cli/helper.py +0 -0
  18. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/cli/main.py +0 -0
  19. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/cli/telemetry.py +0 -0
  20. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/cli/variant_commands.py +0 -0
  21. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/cli/variant_configs.py +0 -0
  22. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/Readme.md +0 -0
  23. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/__init__.py +0 -0
  24. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/api.py +0 -0
  25. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/api_models.py +0 -0
  26. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/__init__.py +0 -0
  27. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/core/__init__.py +0 -0
  28. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/core/api_error.py +0 -0
  29. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/core/client_wrapper.py +0 -0
  30. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/core/datetime_utils.py +0 -0
  31. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/core/jsonable_encoder.py +0 -0
  32. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/core/remove_none_from_dict.py +0 -0
  33. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/errors/__init__.py +0 -0
  34. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/errors/unprocessable_entity_error.py +0 -0
  35. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/__init__.py +0 -0
  36. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/apps/__init__.py +0 -0
  37. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/apps/client.py +0 -0
  38. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/bases/__init__.py +0 -0
  39. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/bases/client.py +0 -0
  40. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/configs/__init__.py +0 -0
  41. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/configs/client.py +0 -0
  42. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/containers/__init__.py +0 -0
  43. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/containers/client.py +0 -0
  44. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/containers/types/__init__.py +0 -0
  45. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/containers/types/container_templates_response.py +0 -0
  46. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/environments/__init__.py +0 -0
  47. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/environments/client.py +0 -0
  48. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/evaluations/__init__.py +0 -0
  49. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/evaluations/client.py +0 -0
  50. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/evaluators/__init__.py +0 -0
  51. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/evaluators/client.py +0 -0
  52. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/observability/__init__.py +0 -0
  53. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/observability/client.py +0 -0
  54. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/testsets/__init__.py +0 -0
  55. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/testsets/client.py +0 -0
  56. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/variants/__init__.py +0 -0
  57. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/variants/client.py +0 -0
  58. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/variants/types/__init__.py +0 -0
  59. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -0
  60. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/__init__.py +0 -0
  61. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/aggregated_result.py +0 -0
  62. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/aggregated_result_evaluator_config.py +0 -0
  63. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/app.py +0 -0
  64. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/app_variant_response.py +0 -0
  65. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/app_variant_revision.py +0 -0
  66. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/base_output.py +0 -0
  67. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/body_import_testset.py +0 -0
  68. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/config_db.py +0 -0
  69. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/create_app_output.py +0 -0
  70. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/create_trace_response.py +0 -0
  71. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/docker_env_vars.py +0 -0
  72. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/environment_output.py +0 -0
  73. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/environment_output_extended.py +0 -0
  74. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/environment_revision.py +0 -0
  75. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/error.py +0 -0
  76. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluation.py +0 -0
  77. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluation_scenario.py +0 -0
  78. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluation_scenario_input.py +0 -0
  79. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluation_scenario_output.py +0 -0
  80. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluation_scenario_result.py +0 -0
  81. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluation_scenario_score_update.py +0 -0
  82. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluation_status_enum.py +0 -0
  83. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluation_type.py +0 -0
  84. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluation_webhook.py +0 -0
  85. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluator.py +0 -0
  86. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/evaluator_config.py +0 -0
  87. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/feedback.py +0 -0
  88. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/get_config_response.py +0 -0
  89. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/http_validation_error.py +0 -0
  90. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/human_evaluation.py +0 -0
  91. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/human_evaluation_scenario.py +0 -0
  92. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/human_evaluation_scenario_input.py +0 -0
  93. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/human_evaluation_scenario_output.py +0 -0
  94. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/human_evaluation_scenario_update.py +0 -0
  95. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/human_evaluation_update.py +0 -0
  96. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/image.py +0 -0
  97. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/invite_request.py +0 -0
  98. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/list_api_keys_response.py +0 -0
  99. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/llm_run_rate_limit.py +0 -0
  100. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/llm_tokens.py +0 -0
  101. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/new_human_evaluation.py +0 -0
  102. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/new_testset.py +0 -0
  103. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/organization.py +0 -0
  104. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/organization_output.py +0 -0
  105. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/permission.py +0 -0
  106. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/result.py +0 -0
  107. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/score.py +0 -0
  108. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/simple_evaluation_output.py +0 -0
  109. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/span.py +0 -0
  110. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/span_detail.py +0 -0
  111. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/span_kind.py +0 -0
  112. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/span_status_code.py +0 -0
  113. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/span_variant.py +0 -0
  114. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/template.py +0 -0
  115. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/template_image_info.py +0 -0
  116. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/test_set_output_response.py +0 -0
  117. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/test_set_simple_response.py +0 -0
  118. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/trace_detail.py +0 -0
  119. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/uri.py +0 -0
  120. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/validation_error.py +0 -0
  121. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/validation_error_loc_item.py +0 -0
  122. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/variant_action.py +0 -0
  123. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/variant_action_enum.py +0 -0
  124. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/with_pagination.py +0 -0
  125. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/workspace_member_response.py +0 -0
  126. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/workspace_permission.py +0 -0
  127. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/workspace_response.py +0 -0
  128. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/workspace_role.py +0 -0
  129. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/backend/types/workspace_role_response.py +0 -0
  130. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/client.py +0 -0
  131. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/client/exceptions.py +0 -0
  132. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/config.py +0 -0
  133. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/config.toml +0 -0
  134. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/docker/docker-assets/Dockerfile.cloud.template +1 -1
  135. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/docker/docker-assets/Dockerfile.template +1 -1
  136. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/docker/docker-assets/README.md +0 -0
  137. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/docker/docker-assets/entrypoint.sh +0 -0
  138. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/docker/docker-assets/lambda_function.py +0 -0
  139. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/docker/docker-assets/main.py +0 -0
  140. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/docker/docker_utils.py +0 -0
  141. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/client.py +0 -0
  142. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/context.py +0 -0
  143. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/router.py +0 -0
  144. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/tracing/context_manager.py +0 -0
  145. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/tracing/logger.py +0 -0
  146. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/types.py +0 -0
  147. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/utils/globals.py +0 -0
  148. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/utils/helper/openai_cost.py +0 -0
  149. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/sdk/utils/preinit.py +0 -0
  150. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/compose_email/README.md +0 -0
  151. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/compose_email/app.py +0 -0
  152. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/compose_email/env.example +0 -0
  153. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/compose_email/requirements.txt +0 -0
  154. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/compose_email/template.toml +0 -0
  155. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/extract_data_to_json/README.md +0 -0
  156. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/extract_data_to_json/app.py +0 -0
  157. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/extract_data_to_json/env.example +0 -0
  158. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
  159. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/extract_data_to_json/template.toml +0 -0
  160. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/simple_prompt/README.md +0 -0
  161. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/simple_prompt/app.py +0 -0
  162. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/simple_prompt/env.example +0 -0
  163. {agenta-0.14.12 → agenta-0.14.12a1}/agenta/templates/simple_prompt/requirements.txt +0 -0
  164. {agenta-0.14.12 → agenta-0.14.12a1}/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.12
3
+ Version: 0.14.12a1
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,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,8 +13,11 @@ 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 import tracing
18
+ from .sdk.decorators.tracing import instrument
19
+ from .sdk.decorators.llm_entrypoint import entrypoint
20
+ from .sdk.agenta_init import Config, init
19
21
  from .sdk.utils.helper.openai_cost import calculate_token_usage
20
22
  from .sdk.client import Agenta
21
23
 
@@ -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}
@@ -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,8 +13,10 @@ 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
19
+ from .agenta_init import Config, init
20
20
  from .utils.helper.openai_cost import calculate_token_usage
21
21
 
22
22
 
@@ -1,11 +1,9 @@
1
1
  import os
2
2
  import logging
3
- from typing import Any, Optional
4
-
5
- from .utils.globals import set_global
3
+ from typing import Optional, Any
6
4
 
5
+ from agenta.sdk.utils.globals import set_global
7
6
  from agenta.client.backend.client import AgentaApi
8
- from agenta.sdk.tracing.llm_tracing import Tracing
9
7
  from agenta.client.exceptions import APIRequestError
10
8
 
11
9
 
@@ -13,18 +11,6 @@ logger = logging.getLogger(__name__)
13
11
  logger.setLevel(logging.DEBUG)
14
12
 
15
13
 
16
- BACKEND_URL_SUFFIX = os.environ.get("BACKEND_URL_SUFFIX", "api")
17
- CLIENT_API_KEY = os.environ.get("AGENTA_API_KEY")
18
- CLIENT_HOST = os.environ.get("AGENTA_HOST", "http://localhost")
19
-
20
- # initialize the client with the backend url and api key
21
- backend_url = f"{CLIENT_HOST}/{BACKEND_URL_SUFFIX}"
22
- client = AgentaApi(
23
- base_url=backend_url,
24
- api_key=CLIENT_API_KEY if CLIENT_API_KEY else "",
25
- )
26
-
27
-
28
14
  class AgentaSingleton:
29
15
  """Singleton class to save all the "global variables" for the sdk."""
30
16
 
@@ -37,6 +23,16 @@ class AgentaSingleton:
37
23
  cls._instance = super(AgentaSingleton, cls).__new__(cls)
38
24
  return cls._instance
39
25
 
26
+ @property
27
+ def client(self):
28
+ """Builds sdk client instance.
29
+
30
+ Returns:
31
+ AgentaAPI: instance of agenta api backend
32
+ """
33
+
34
+ return AgentaApi(base_url=self.host + "/api", api_key=self.api_key)
35
+
40
36
  def init(
41
37
  self,
42
38
  app_name: Optional[str] = None,
@@ -49,53 +45,51 @@ class AgentaSingleton:
49
45
  ) -> None:
50
46
  """Main function to initialize the singleton.
51
47
 
52
- Initializes the singleton with the given `app_name`, `base_name`, and `host`. If any of these arguments are not provided,
53
- the function will look for them in environment variables.
48
+ Initializes the singleton with the given `app_name`, `base_name`, and `host`.
49
+ If any of these arguments are not provided, the function will look for them
50
+ in environment variables.
54
51
 
55
52
  Args:
56
- app_name (Optional[str]): Name of the Agenta application. Defaults to None. If not provided, will look for "AGENTA_APP_NAME" in environment variables.
57
- base_name (Optional[str]): Base name for the Agenta setup. Defaults to None. If not provided, will look for "AGENTA_BASE_NAME" in environment variables.
58
- host (Optional[str]): Host name of the backend server. Defaults to None. If not provided, will look for "AGENTA_HOST" in environment variables.
53
+ app_name (Optional[str]): Name of the application. Defaults to None.
54
+ base_name (Optional[str]): Base name for the setup. Defaults to None.
55
+ api_key (Optional[str]): API Key to use with the host. Defaults to None.
56
+ base_id (Optional[str]): Base ID for the setup. Defaults to None.
57
+ app_id (Optional[str]): App ID. Defaults to None.
58
+ host (Optional[str]): Host name of the backend server. Defaults to "http://localhost".
59
59
  kwargs (Any): Additional keyword arguments.
60
60
 
61
61
  Raises:
62
- ValueError: If `app_name`, `base_name`, or `host` are not specified either as arguments or in the environment variables.
62
+ ValueError: If `app_name`, `base_name`, or `host` are not specified either as arguments
63
+ or in the environment variables.
63
64
  """
64
- if app_name is None:
65
- app_name = os.environ.get("AGENTA_APP_NAME")
66
- if base_name is None:
67
- base_name = os.environ.get("AGENTA_BASE_NAME")
68
- if api_key is None:
69
- api_key = os.environ.get("AGENTA_API_KEY")
70
- if base_id is None:
71
- base_id = os.environ.get("AGENTA_BASE_ID")
72
- if host is None:
73
- host = os.environ.get("AGENTA_HOST", "http://localhost")
74
-
75
- if base_id is None:
76
- if app_name is None or base_name is None:
77
- print(
78
- f"Warning: Your configuration will not be saved permanently since app_name and base_name are not provided."
65
+
66
+ self.app_name = app_name or os.environ.get("AGENTA_APP_NAME")
67
+ self.base_name = base_name or os.environ.get("AGENTA_BASE_NAME")
68
+ self.api_key = api_key or os.environ.get("AGENTA_API_KEY")
69
+ self.base_id = base_id or os.environ.get("AGENTA_BASE_ID")
70
+ self.app_id = app_id or os.environ.get("AGENTA_APP_ID")
71
+ self.host = host or os.environ.get("AGENTA_HOST", "http://localhost")
72
+
73
+ if not self.app_id and (not self.app_name or not self.base_name):
74
+ print(
75
+ f"Warning: Your configuration will not be saved permanently since app_name and base_name are not provided."
76
+ )
77
+
78
+ if not self.base_id and self.app_name and self.base_name:
79
+ try:
80
+ self.app_id = self.get_app(self.app_name)
81
+ self.base_id = self.get_app_base(self.app_id, self.base_name)
82
+ except Exception as ex:
83
+ raise APIRequestError(
84
+ f"Failed to get base id and/or app_id from the server with error: {ex}"
79
85
  )
80
- else:
81
- try:
82
- app_id = self.get_app(app_name)
83
- base_id = self.get_app_base(app_id, base_name)
84
- except Exception as ex:
85
- raise APIRequestError(
86
- f"Failed to get base id and/or app_id from the server with error: {ex}"
87
- )
88
86
 
89
- self.base_id = base_id
90
- self.host = host
91
- self.app_id = os.environ.get("AGENTA_APP_ID") if app_id is None else app_id
92
87
  self.variant_id = os.environ.get("AGENTA_VARIANT_ID")
93
88
  self.variant_name = os.environ.get("AGENTA_VARIANT_NAME")
94
- self.api_key = api_key
95
- self.config = Config(base_id=base_id, host=host)
89
+ self.config = Config(base_id=self.base_id, host=self.host)
96
90
 
97
91
  def get_app(self, app_name: str) -> str:
98
- apps = client.apps.list_apps(app_name=app_name)
92
+ apps = self.client.apps.list_apps(app_name=app_name)
99
93
  if len(apps) == 0:
100
94
  raise APIRequestError(f"App with name {app_name} not found")
101
95
 
@@ -103,7 +97,7 @@ class AgentaSingleton:
103
97
  return app_id
104
98
 
105
99
  def get_app_base(self, app_id: str, base_name: str) -> str:
106
- bases = client.bases.list_bases(app_id=app_id, base_name=base_name)
100
+ bases = self.client.bases.list_bases(app_id=app_id, base_name=base_name)
107
101
  if len(bases) == 0:
108
102
  raise APIRequestError(f"No base was found for the app {app_id}")
109
103
  return bases[0].base_id
@@ -122,11 +116,23 @@ class Config:
122
116
  def __init__(self, base_id, host):
123
117
  self.base_id = base_id
124
118
  self.host = host
119
+
125
120
  if base_id is None or host is None:
126
121
  self.persist = False
127
122
  else:
128
123
  self.persist = True
129
124
 
125
+ @property
126
+ def client(self):
127
+ """Builds sdk client instance.
128
+
129
+ Returns:
130
+ AgentaAPI: instance of agenta api backend
131
+ """
132
+
133
+ sdk_client = SDKClient(api_key=self.api_key, host=self.host) # type: ignore
134
+ return sdk_client._build_sdk_client()
135
+
130
136
  def register_default(self, overwrite=False, **kwargs):
131
137
  """alias for default"""
132
138
  return self.default(overwrite=overwrite, **kwargs)
@@ -157,7 +163,7 @@ class Config:
157
163
  if not self.persist:
158
164
  return
159
165
  try:
160
- client.configs.save_config(
166
+ self.client.configs.save_config(
161
167
  base_id=self.base_id,
162
168
  config_name=config_name,
163
169
  parameters=kwargs,
@@ -168,7 +174,9 @@ class Config:
168
174
  "Failed to push the configuration to the server with error: " + str(ex)
169
175
  )
170
176
 
171
- def pull(self, config_name: str = "default", environment_name: str = None):
177
+ def pull(
178
+ self, config_name: str = "default", environment_name: Optional[str] = None
179
+ ):
172
180
  """Pulls the parameters for the app variant from the server and sets them to the config"""
173
181
  if not self.persist and (
174
182
  config_name != "default" or environment_name is not None
@@ -179,12 +187,12 @@ class Config:
179
187
  if self.persist:
180
188
  try:
181
189
  if environment_name:
182
- config = client.configs.get_config(
190
+ config = self.client.configs.get_config(
183
191
  base_id=self.base_id, environment_name=environment_name
184
192
  )
185
193
 
186
194
  else:
187
- config = client.configs.get_config(
195
+ config = self.client.configs.get_config(
188
196
  base_id=self.base_id,
189
197
  config_name=config_name,
190
198
  )
@@ -225,20 +233,8 @@ def init(app_name=None, base_name=None, **kwargs):
225
233
  app_name: _description_. Defaults to None.
226
234
  base_name: _description_. Defaults to None.
227
235
  """
236
+
228
237
  singleton = AgentaSingleton()
238
+
229
239
  singleton.init(app_name=app_name, base_name=base_name, **kwargs)
230
240
  set_global(setup=singleton.setup, config=singleton.config)
231
-
232
-
233
- def llm_tracing(max_workers: Optional[int] = None) -> Tracing:
234
- """Function to start llm tracing."""
235
-
236
- singleton = AgentaSingleton()
237
- return Tracing(
238
- base_url=singleton.host,
239
- app_id=singleton.app_id, # type: ignore
240
- variant_id=singleton.variant_id, # type: ignore
241
- variant_name=singleton.variant_name,
242
- api_key=singleton.api_key,
243
- max_workers=max_workers,
244
- )
@@ -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