agenta 0.14.11__tar.gz → 0.14.12a0__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.
- {agenta-0.14.11 → agenta-0.14.12a0}/PKG-INFO +2 -2
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/__init__.py +4 -3
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/client.py +8 -6
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/create_span.py +1 -1
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/__init__.py +4 -4
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/agenta_init.py +66 -70
- agenta-0.14.12a0/agenta/sdk/decorators/base.py +10 -0
- agenta-0.14.12a0/agenta/sdk/decorators/llm_entrypoint.py +485 -0
- agenta-0.14.12a0/agenta/sdk/decorators/tracing.py +84 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/tracing/llm_tracing.py +87 -65
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/tracing/tasks_manager.py +1 -3
- {agenta-0.14.11 → agenta-0.14.12a0}/pyproject.toml +2 -2
- agenta-0.14.11/agenta/sdk/agenta_decorator.py +0 -501
- agenta-0.14.11/agenta/sdk/tracing/decorators.py +0 -41
- {agenta-0.14.11 → agenta-0.14.12a0}/README.md +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/cli/evaluation_commands.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/cli/helper.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/cli/main.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/cli/telemetry.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/cli/variant_commands.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/cli/variant_configs.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/Readme.md +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/api.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/api_models.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/core/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/core/api_error.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/core/client_wrapper.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/core/datetime_utils.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/core/jsonable_encoder.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/core/remove_none_from_dict.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/errors/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/errors/unprocessable_entity_error.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/apps/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/apps/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/bases/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/bases/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/configs/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/configs/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/containers/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/containers/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/containers/types/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/containers/types/container_templates_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/environments/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/environments/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/evaluations/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/evaluations/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/evaluators/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/evaluators/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/observability/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/observability/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/testsets/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/testsets/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/variants/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/variants/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/variants/types/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/__init__.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/aggregated_result.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/aggregated_result_evaluator_config.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/app.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/app_variant_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/app_variant_revision.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/base_output.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/body_import_testset.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/config_db.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/create_app_output.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/create_trace_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/docker_env_vars.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/environment_output.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/environment_output_extended.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/environment_revision.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/error.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluation.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluation_scenario.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluation_scenario_input.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluation_scenario_output.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluation_scenario_result.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluation_scenario_score_update.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluation_status_enum.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluation_type.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluation_webhook.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluator.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/evaluator_config.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/feedback.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/get_config_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/http_validation_error.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/human_evaluation.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/human_evaluation_scenario.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/human_evaluation_scenario_input.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/human_evaluation_scenario_output.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/human_evaluation_scenario_update.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/human_evaluation_update.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/image.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/invite_request.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/list_api_keys_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/llm_run_rate_limit.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/llm_tokens.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/new_human_evaluation.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/new_testset.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/organization.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/organization_output.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/permission.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/result.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/score.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/simple_evaluation_output.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/span.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/span_detail.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/span_kind.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/span_status_code.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/span_variant.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/template.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/template_image_info.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/test_set_output_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/test_set_simple_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/trace_detail.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/uri.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/validation_error.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/validation_error_loc_item.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/variant_action.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/variant_action_enum.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/with_pagination.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/workspace_member_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/workspace_permission.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/workspace_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/workspace_role.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/backend/types/workspace_role_response.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/client/exceptions.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/config.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/config.toml +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/docker/docker-assets/Dockerfile.cloud.template +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/docker/docker-assets/Dockerfile.template +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/docker/docker-assets/README.md +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/docker/docker-assets/entrypoint.sh +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/docker/docker-assets/lambda_function.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/docker/docker-assets/main.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/docker/docker_utils.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/client.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/context.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/router.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/tracing/context_manager.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/tracing/logger.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/types.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/utils/globals.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/utils/helper/openai_cost.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/sdk/utils/preinit.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/compose_email/README.md +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/compose_email/app.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/compose_email/env.example +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/compose_email/requirements.txt +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/compose_email/template.toml +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/extract_data_to_json/README.md +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/extract_data_to_json/app.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/extract_data_to_json/env.example +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/extract_data_to_json/template.toml +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/simple_prompt/README.md +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/simple_prompt/app.py +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/simple_prompt/env.example +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/agenta/templates/simple_prompt/requirements.txt +0 -0
- {agenta-0.14.11 → agenta-0.14.12a0}/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.
|
|
3
|
+
Version: 0.14.12a0
|
|
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,7 +23,7 @@ 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 (==
|
|
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,8 +13,10 @@ from .sdk.types import (
|
|
|
14
13
|
FileInputURL,
|
|
15
14
|
BinaryParam,
|
|
16
15
|
)
|
|
17
|
-
from .sdk.tracing.
|
|
18
|
-
from .sdk.
|
|
16
|
+
from .sdk.tracing.llm_tracing import Tracing
|
|
17
|
+
from .sdk.decorators.tracing import instrument, tracing
|
|
18
|
+
from .sdk.decorators.llm_entrypoint import entrypoint
|
|
19
|
+
from .sdk.agenta_init import Config, init
|
|
19
20
|
from .sdk.utils.helper.openai_cost import calculate_token_usage
|
|
20
21
|
from .sdk.client import Agenta
|
|
21
22
|
|
|
@@ -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=
|
|
60
|
-
|
|
61
|
-
|
|
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=
|
|
1041
|
-
|
|
1042
|
-
|
|
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
|
|
@@ -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.
|
|
19
|
-
from .
|
|
16
|
+
from .tracing.llm_tracing import Tracing
|
|
17
|
+
from .decorators.tracing import instrument, tracing
|
|
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
|
|
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`.
|
|
53
|
-
the function will look for them
|
|
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
|
|
57
|
-
base_name (Optional[str]): Base name for the
|
|
58
|
-
|
|
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
|
|
62
|
+
ValueError: If `app_name`, `base_name`, or `host` are not specified either as arguments
|
|
63
|
+
or in the environment variables.
|
|
63
64
|
"""
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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.
|
|
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(
|
|
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
|
-
)
|