agenta 0.20.0a13__tar.gz → 0.21.0a1__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.20.0a13 → agenta-0.21.0a1}/PKG-INFO +2 -1
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/__init__.py +2 -1
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/docker/docker_utils.py +2 -1
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/__init__.py +2 -0
- agenta-0.21.0a1/agenta/sdk/config_manager.py +205 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/decorators/llm_entrypoint.py +223 -55
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/types.py +7 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/pyproject.toml +2 -1
- {agenta-0.20.0a13 → agenta-0.21.0a1}/README.md +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/cli/evaluation_commands.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/cli/helper.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/cli/main.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/cli/telemetry.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/cli/variant_commands.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/cli/variant_configs.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/Readme.md +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/api.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/api_models.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/core/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/core/api_error.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/core/client_wrapper.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/core/datetime_utils.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/core/jsonable_encoder.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/core/remove_none_from_dict.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/errors/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/errors/unprocessable_entity_error.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/apps/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/apps/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/bases/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/bases/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/configs/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/configs/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/containers/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/containers/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/containers/types/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/containers/types/container_templates_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/environments/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/environments/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/evaluations/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/evaluations/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/evaluators/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/evaluators/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/observability/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/observability/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/testsets/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/testsets/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/variants/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/variants/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/variants/types/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/aggregated_result.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/aggregated_result_evaluator_config.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/app.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/app_variant_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/app_variant_revision.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/base_output.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/body_import_testset.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/config_db.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/create_app_output.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/create_span.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/create_trace_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/docker_env_vars.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/environment_output.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/environment_output_extended.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/environment_revision.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/error.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluation.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluation_scenario.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluation_scenario_input.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluation_scenario_output.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluation_scenario_result.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluation_scenario_score_update.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluation_status_enum.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluation_type.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluation_webhook.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluator.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/evaluator_config.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/feedback.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/get_config_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/http_validation_error.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/human_evaluation.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/human_evaluation_scenario.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/human_evaluation_scenario_input.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/human_evaluation_scenario_output.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/human_evaluation_scenario_update.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/human_evaluation_update.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/image.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/invite_request.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/list_api_keys_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/llm_run_rate_limit.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/llm_tokens.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/new_human_evaluation.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/new_testset.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/organization.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/organization_output.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/permission.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/result.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/score.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/simple_evaluation_output.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/span.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/span_detail.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/span_kind.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/span_status_code.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/span_variant.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/template.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/template_image_info.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/test_set_output_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/test_set_simple_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/trace_detail.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/uri.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/validation_error.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/validation_error_loc_item.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/variant_action.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/variant_action_enum.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/with_pagination.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/workspace_member_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/workspace_permission.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/workspace_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/workspace_role.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/backend/types/workspace_role_response.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/client/exceptions.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/config.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/config.toml +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/docker/docker-assets/Dockerfile.cloud.template +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/docker/docker-assets/Dockerfile.template +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/docker/docker-assets/README.md +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/docker/docker-assets/entrypoint.sh +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/docker/docker-assets/lambda_function.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/docker/docker-assets/main.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/agenta_init.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/client.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/context.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/decorators/base.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/decorators/tracing.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/router.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/tracing/__init__.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/tracing/callbacks.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/tracing/llm_tracing.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/tracing/logger.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/tracing/tasks_manager.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/tracing/tracing_context.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/utils/debug.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/utils/globals.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/utils/helper/openai_cost.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/sdk/utils/preinit.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/compose_email/README.md +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/compose_email/app.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/compose_email/env.example +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/compose_email/requirements.txt +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/compose_email/template.toml +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/extract_data_to_json/README.md +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/extract_data_to_json/app.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/extract_data_to_json/env.example +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/extract_data_to_json/template.toml +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/simple_prompt/README.md +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/simple_prompt/app.py +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/simple_prompt/env.example +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/agenta/templates/simple_prompt/requirements.txt +0 -0
- {agenta-0.20.0a13 → agenta-0.21.0a1}/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.
|
|
3
|
+
Version: 0.21.0a1
|
|
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
|
|
@@ -27,6 +27,7 @@ Requires-Dist: pydantic (>=2)
|
|
|
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)
|
|
30
|
+
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
30
31
|
Requires-Dist: questionary (>=1.10,<3.0)
|
|
31
32
|
Requires-Dist: toml (>=0.10.2,<0.11.0)
|
|
32
33
|
Project-URL: Documentation, https://docs.agenta.ai
|
|
@@ -3,6 +3,7 @@ from .sdk.context import get_contexts, save_context
|
|
|
3
3
|
from .sdk.types import (
|
|
4
4
|
Context,
|
|
5
5
|
DictInput,
|
|
6
|
+
MultipleChoice,
|
|
6
7
|
FloatParam,
|
|
7
8
|
InFile,
|
|
8
9
|
IntParam,
|
|
@@ -22,7 +23,7 @@ from .sdk.agenta_init import Config, AgentaSingleton, init
|
|
|
22
23
|
from .sdk.utils.helper.openai_cost import calculate_token_usage
|
|
23
24
|
from .sdk.client import Agenta
|
|
24
25
|
from .sdk.tracing import callbacks
|
|
25
|
-
|
|
26
|
+
from .sdk.config_manager import ConfigManager
|
|
26
27
|
|
|
27
28
|
config = PreInitObject("agenta.config", Config)
|
|
28
29
|
DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
|
|
@@ -3,12 +3,13 @@ import shutil
|
|
|
3
3
|
import tarfile
|
|
4
4
|
import tempfile
|
|
5
5
|
from pathlib import Path
|
|
6
|
+
import os
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
logger = logging.getLogger(__name__)
|
|
9
10
|
logger.setLevel(logging.DEBUG)
|
|
10
11
|
|
|
11
|
-
DEBUG = False
|
|
12
|
+
DEBUG = os.environ.get("AGENTA_CLI_DEBUG", False)
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def create_dockerfile(out_folder: Path) -> Path:
|
|
@@ -3,6 +3,7 @@ from .context import get_contexts, save_context
|
|
|
3
3
|
from .types import (
|
|
4
4
|
Context,
|
|
5
5
|
DictInput,
|
|
6
|
+
MultipleChoice,
|
|
6
7
|
FloatParam,
|
|
7
8
|
InFile,
|
|
8
9
|
IntParam,
|
|
@@ -19,6 +20,7 @@ from .decorators.tracing import instrument
|
|
|
19
20
|
from .decorators.llm_entrypoint import entrypoint, app, route
|
|
20
21
|
from .agenta_init import Config, AgentaSingleton, init
|
|
21
22
|
from .utils.helper.openai_cost import calculate_token_usage
|
|
23
|
+
from .config_manager import ConfigManager
|
|
22
24
|
|
|
23
25
|
config = PreInitObject("agenta.config", Config)
|
|
24
26
|
DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Optional, Type, TypeVar
|
|
5
|
+
|
|
6
|
+
import yaml
|
|
7
|
+
from pydantic import BaseModel, ValidationError
|
|
8
|
+
|
|
9
|
+
from agenta.client.backend.client import AgentaApi
|
|
10
|
+
from agenta.sdk.decorators.llm_entrypoint import route_context
|
|
11
|
+
|
|
12
|
+
from . import AgentaSingleton
|
|
13
|
+
|
|
14
|
+
T = TypeVar("T", bound=BaseModel)
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
singleton = AgentaSingleton()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ConfigManager:
|
|
21
|
+
client = None
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def get_from_route(schema: Type[T]) -> T:
|
|
25
|
+
"""
|
|
26
|
+
Retrieves the configuration from the route context and returns a config object.
|
|
27
|
+
|
|
28
|
+
This method checks the route context for configuration information and returns
|
|
29
|
+
an instance of the specified schema based on the available context data.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
schema (Type[T]): A Pydantic model class that defines the structure of the configuration.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
T: An instance of the specified schema populated with the configuration data.
|
|
36
|
+
|
|
37
|
+
Raises:
|
|
38
|
+
ValueError: If conflicting configuration sources are provided or if no valid
|
|
39
|
+
configuration source is found in the context.
|
|
40
|
+
|
|
41
|
+
Note:
|
|
42
|
+
The method prioritizes the inputs in the following way:
|
|
43
|
+
1. 'config' (i.e. when called explicitly from the playground)
|
|
44
|
+
2. 'environment'
|
|
45
|
+
3. 'variant'
|
|
46
|
+
Only one of these should be provided.
|
|
47
|
+
"""
|
|
48
|
+
context = route_context.get()
|
|
49
|
+
if ("config" in context and context["config"]) and (
|
|
50
|
+
("environment" in context and context["environment"])
|
|
51
|
+
or ("variant" in context and context["variant"])
|
|
52
|
+
):
|
|
53
|
+
raise ValueError(
|
|
54
|
+
"Either config, environment or variant must be provided. Not both."
|
|
55
|
+
)
|
|
56
|
+
if "config" in context and context["config"]:
|
|
57
|
+
return schema(**context["config"])
|
|
58
|
+
elif "environment" in context and context["environment"]:
|
|
59
|
+
return ConfigManager.get_from_backend(
|
|
60
|
+
schema, environment=context["environment"]
|
|
61
|
+
)
|
|
62
|
+
elif "variant" in context and context["variant"]:
|
|
63
|
+
return ConfigManager.get_from_backend(schema, variant=context["variant"])
|
|
64
|
+
else:
|
|
65
|
+
raise ValueError("Either config, environment or variant must be provided")
|
|
66
|
+
|
|
67
|
+
@staticmethod
|
|
68
|
+
def get_from_backend(
|
|
69
|
+
schema: Type[T],
|
|
70
|
+
environment: Optional[str] = None,
|
|
71
|
+
version: Optional[str] = None,
|
|
72
|
+
variant: Optional[str] = None,
|
|
73
|
+
) -> T:
|
|
74
|
+
"""
|
|
75
|
+
Pulls the parameters for the app variant from the server and returns a config object.
|
|
76
|
+
|
|
77
|
+
This method retrieves the configuration from the backend server based on the provided
|
|
78
|
+
environment or variant. It then validates and returns the configuration as an instance
|
|
79
|
+
of the specified schema.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
schema (Type[T]): A Pydantic model class that defines the structure of the configuration.
|
|
83
|
+
environment (Optional[str]): The environment name to fetch the configuration for.
|
|
84
|
+
Must be one of "development", "production", or "staging".
|
|
85
|
+
version (Optional[str]): Currently not implemented. Will raise NotImplementedError if provided.
|
|
86
|
+
variant (Optional[str]): The variant name to fetch the configuration for.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
T: An instance of the specified schema populated with the configuration data.
|
|
90
|
+
|
|
91
|
+
Raises:
|
|
92
|
+
ValueError: If neither environment nor variant is provided.
|
|
93
|
+
NotImplementedError: If a specific version is requested (not yet implemented).
|
|
94
|
+
ValidationError: If the retrieved configuration data doesn't match the schema.
|
|
95
|
+
Exception: For any other errors during the process (e.g., API communication issues).
|
|
96
|
+
|
|
97
|
+
Note:
|
|
98
|
+
Either environment or variant must be provided, but not both.
|
|
99
|
+
"""
|
|
100
|
+
if not ConfigManager.client:
|
|
101
|
+
try:
|
|
102
|
+
ConfigManager.client = AgentaApi(
|
|
103
|
+
base_url=singleton.host + "/api",
|
|
104
|
+
api_key=singleton.api_key if singleton.api_key else "",
|
|
105
|
+
)
|
|
106
|
+
except Exception as ex:
|
|
107
|
+
logger.error(
|
|
108
|
+
"Failed to initialize Agenta client with error: %s", str(ex)
|
|
109
|
+
)
|
|
110
|
+
raise
|
|
111
|
+
if not environment and not variant:
|
|
112
|
+
raise ValueError("Either environment or variant must be provided")
|
|
113
|
+
try:
|
|
114
|
+
if environment:
|
|
115
|
+
if version:
|
|
116
|
+
raise NotImplementedError(
|
|
117
|
+
"Getting config for a specific version is not implemented yet."
|
|
118
|
+
)
|
|
119
|
+
else:
|
|
120
|
+
assert environment in [
|
|
121
|
+
"development",
|
|
122
|
+
"production",
|
|
123
|
+
"staging",
|
|
124
|
+
], "Environment must be either development, production or staging"
|
|
125
|
+
config = ConfigManager.client.configs.get_config(
|
|
126
|
+
base_id=singleton.base_id, environment_name=environment
|
|
127
|
+
)
|
|
128
|
+
elif variant:
|
|
129
|
+
config = ConfigManager.client.configs.get_config(
|
|
130
|
+
base_id=singleton.base_id, config_name=variant
|
|
131
|
+
)
|
|
132
|
+
except Exception as ex:
|
|
133
|
+
logger.error(
|
|
134
|
+
"Failed to pull the configuration from the server with error: %s",
|
|
135
|
+
str(ex),
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
try:
|
|
139
|
+
result = schema(**config.parameters)
|
|
140
|
+
except ValidationError as ex:
|
|
141
|
+
logger.error("Failed to validate the configuration with error: %s", str(ex))
|
|
142
|
+
raise
|
|
143
|
+
return result
|
|
144
|
+
|
|
145
|
+
@staticmethod
|
|
146
|
+
def get_from_yaml(filename: str, schema: Type[T]) -> T:
|
|
147
|
+
"""
|
|
148
|
+
Loads configuration from a YAML file and returns a config object.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
filename (str): The name of the YAML file to load.
|
|
152
|
+
schema (Type[T]): A Pydantic model class that defines the structure of the configuration.
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
T: An instance of the specified schema populated with the configuration data.
|
|
156
|
+
|
|
157
|
+
Raises:
|
|
158
|
+
FileNotFoundError: If the specified file doesn't exist.
|
|
159
|
+
ValidationError: If the loaded configuration data doesn't match the schema.
|
|
160
|
+
"""
|
|
161
|
+
file_path = Path(filename)
|
|
162
|
+
if not file_path.exists():
|
|
163
|
+
raise FileNotFoundError(f"Config file not found: {filename}")
|
|
164
|
+
|
|
165
|
+
with open(file_path, "r") as file:
|
|
166
|
+
config_data = yaml.safe_load(file)
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
return schema(**config_data)
|
|
170
|
+
except ValidationError as ex:
|
|
171
|
+
logger.error(
|
|
172
|
+
f"Failed to validate the configuration from {filename} with error: {str(ex)}"
|
|
173
|
+
)
|
|
174
|
+
raise
|
|
175
|
+
|
|
176
|
+
@staticmethod
|
|
177
|
+
def get_from_json(filename: str, schema: Type[T]) -> T:
|
|
178
|
+
"""
|
|
179
|
+
Loads configuration from a JSON file and returns a config object.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
filename (str): The name of the JSON file to load.
|
|
183
|
+
schema (Type[T]): A Pydantic model class that defines the structure of the configuration.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
T: An instance of the specified schema populated with the configuration data.
|
|
187
|
+
|
|
188
|
+
Raises:
|
|
189
|
+
FileNotFoundError: If the specified file doesn't exist.
|
|
190
|
+
ValidationError: If the loaded configuration data doesn't match the schema.
|
|
191
|
+
"""
|
|
192
|
+
file_path = Path(filename)
|
|
193
|
+
if not file_path.exists():
|
|
194
|
+
raise FileNotFoundError(f"Config file not found: {filename}")
|
|
195
|
+
|
|
196
|
+
with open(file_path, "r") as file:
|
|
197
|
+
config_data = json.load(file)
|
|
198
|
+
|
|
199
|
+
try:
|
|
200
|
+
return schema(**config_data)
|
|
201
|
+
except ValidationError as ex:
|
|
202
|
+
logger.error(
|
|
203
|
+
f"Failed to validate the configuration from {filename} with error: {str(ex)}"
|
|
204
|
+
)
|
|
205
|
+
raise
|