agenta 0.27.5a1__tar.gz → 0.27.6__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.27.5a1 → agenta-0.27.6}/PKG-INFO +5 -3
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/__init__.py +6 -29
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/__init__.py +4 -8
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/agenta_init.py +3 -10
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/decorators/routing.py +3 -27
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/decorators/tracing.py +7 -31
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/litellm/litellm.py +25 -36
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/tracing/exporters.py +1 -1
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/tracing/processors.py +1 -1
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/tracing/tracing.py +1 -7
- {agenta-0.27.5a1 → agenta-0.27.6}/pyproject.toml +4 -1
- agenta-0.27.5a1/agenta/sdk/middleware/auth.py +0 -142
- agenta-0.27.5a1/agenta/sdk/middleware/cache.py +0 -43
- agenta-0.27.5a1/agenta/sdk/utils/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/README.md +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/cli/evaluation_commands.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/cli/helper.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/cli/main.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/cli/telemetry.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/cli/variant_commands.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/cli/variant_configs.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/Readme.md +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/api.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/api_models.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/apps/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/apps/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/bases/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/bases/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/configs/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/configs/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/containers/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/containers/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/containers/types/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/containers/types/container_templates_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/api_error.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/client_wrapper.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/datetime_utils.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/file.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/http_client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/jsonable_encoder.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/pydantic_utilities.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/query_encoder.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/remove_none_from_dict.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/request_options.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/core/serialization.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/environments/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/environments/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/errors/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/errors/unprocessable_entity_error.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/evaluations/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/evaluations/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/evaluators/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/evaluators/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/observability/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/observability/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/testsets/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/testsets/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/aggregated_result.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/aggregated_result_evaluator_config.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/app.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/app_variant_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/app_variant_revision.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/base_output.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/body_import_testset.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/config_db.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/config_dto.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/config_response_model.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/correct_answer.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/create_app_output.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/create_span.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/create_trace_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/docker_env_vars.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/environment_output.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/environment_output_extended.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/environment_revision.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/error.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluation.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluation_scenario.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluation_scenario_input.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluation_scenario_output.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluation_scenario_result.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluation_scenario_score_update.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluation_status_enum.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluation_type.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluator.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluator_config.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluator_mapping_output_interface.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/evaluator_output_interface.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/get_config_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/http_validation_error.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/human_evaluation.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/human_evaluation_scenario.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/human_evaluation_scenario_input.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/human_evaluation_scenario_output.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/human_evaluation_scenario_update.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/human_evaluation_update.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/image.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/invite_request.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/lifecycle_dto.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/list_api_keys_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/llm_run_rate_limit.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/llm_tokens.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/lm_providers_enum.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/new_human_evaluation.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/new_testset.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/organization.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/organization_output.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/outputs.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/permission.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/reference_dto.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/reference_request_model.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/result.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/score.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/simple_evaluation_output.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/span.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/span_detail.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/span_status_code.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/span_variant.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/template.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/template_image_info.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/test_set_output_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/test_set_simple_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/trace_detail.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/update_app_output.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/uri.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/validation_error.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/validation_error_loc_item.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/variant_action.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/variant_action_enum.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/with_pagination.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/workspace_member_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/workspace_permission.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/workspace_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/workspace_role.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/types/workspace_role_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/variants/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/variants/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/variants/types/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/client/exceptions.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/config.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/config.toml +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/docker/docker-assets/Dockerfile.cloud.template +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/docker/docker-assets/Dockerfile.template +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/docker/docker-assets/README.md +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/docker/docker-assets/entrypoint.sh +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/docker/docker-assets/lambda_function.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/docker/docker-assets/main.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/docker/docker_utils.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/assets.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/client.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/context/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/context/routing.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/context/tracing.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/decorators/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/litellm/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/managers/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/managers/config.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/managers/deployment.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/managers/shared.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/managers/variant.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/router.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/tracing/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/tracing/attributes.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/tracing/context.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/tracing/conventions.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/tracing/inline.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/tracing/spans.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/types.py +0 -0
- {agenta-0.27.5a1/agenta/sdk/middleware → agenta-0.27.6/agenta/sdk/utils}/__init__.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/utils/costs.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/utils/debug.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/utils/exceptions.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/utils/globals.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/utils/logging.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/utils/preinit.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/sdk/utils/singleton.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/compose_email/README.md +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/compose_email/app.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/compose_email/env.example +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/compose_email/requirements.txt +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/compose_email/template.toml +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/extract_data_to_json/README.md +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/extract_data_to_json/app.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/extract_data_to_json/env.example +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/extract_data_to_json/template.toml +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/simple_prompt/README.md +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/simple_prompt/app.py +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/simple_prompt/env.example +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/agenta/templates/simple_prompt/requirements.txt +0 -0
- {agenta-0.27.5a1 → agenta-0.27.6}/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.27.
|
|
3
|
+
Version: 0.27.6
|
|
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
|
|
@@ -13,8 +13,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
17
|
Classifier: Topic :: Software Development :: Libraries
|
|
19
18
|
Requires-Dist: cachetools (>=5.3.3,<6.0.0)
|
|
20
19
|
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
@@ -22,13 +21,16 @@ Requires-Dist: docker (>=6.1.1,<8.0.0)
|
|
|
22
21
|
Requires-Dist: fastapi (>=0.100.0)
|
|
23
22
|
Requires-Dist: httpx (>=0.24,<0.28)
|
|
24
23
|
Requires-Dist: importlib-metadata (>=8.0.0,<9.0)
|
|
24
|
+
Requires-Dist: ipdb (>=0.13)
|
|
25
25
|
Requires-Dist: litellm (>=1.48.0,<2.0.0)
|
|
26
26
|
Requires-Dist: opentelemetry-api (>=1.27.0,<2.0.0)
|
|
27
27
|
Requires-Dist: opentelemetry-exporter-otlp (>=1.27.0,<2.0.0)
|
|
28
28
|
Requires-Dist: opentelemetry-sdk (>=1.27.0,<2.0.0)
|
|
29
29
|
Requires-Dist: posthog (>=3.1.0,<4.0.0)
|
|
30
30
|
Requires-Dist: pydantic (>=2)
|
|
31
|
+
Requires-Dist: pymongo (>=4.6.3,<5.0.0)
|
|
31
32
|
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
|
|
33
|
+
Requires-Dist: python-multipart (>=0.0.6,<0.0.10)
|
|
32
34
|
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
33
35
|
Requires-Dist: questionary (>=1.10,<3.0)
|
|
34
36
|
Requires-Dist: toml (>=0.10.2,<0.11.0)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Any, Callable, Optional
|
|
2
|
-
|
|
3
1
|
from .sdk.utils.preinit import PreInitObject
|
|
4
2
|
|
|
5
3
|
import agenta.client.backend.types as client_types # pylint: disable=wrong-import-order
|
|
@@ -20,7 +18,7 @@ from .sdk.types import (
|
|
|
20
18
|
)
|
|
21
19
|
|
|
22
20
|
from .sdk.utils.logging import log as logging
|
|
23
|
-
from .sdk.tracing import Tracing
|
|
21
|
+
from .sdk.tracing import Tracing
|
|
24
22
|
from .sdk.decorators.tracing import instrument
|
|
25
23
|
from .sdk.tracing.conventions import Reference
|
|
26
24
|
from .sdk.decorators.routing import entrypoint, app, route
|
|
@@ -38,36 +36,15 @@ config = PreInitObject("agenta.config", Config)
|
|
|
38
36
|
DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
|
|
39
37
|
|
|
40
38
|
types = client_types
|
|
41
|
-
|
|
39
|
+
tracing = None
|
|
42
40
|
api = None
|
|
43
41
|
async_api = None
|
|
44
42
|
|
|
45
|
-
tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
|
|
46
|
-
tracer = get_tracer(tracing)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def init(
|
|
50
|
-
host: Optional[str] = None,
|
|
51
|
-
api_key: Optional[str] = None,
|
|
52
|
-
config_fname: Optional[str] = None,
|
|
53
|
-
redact: Optional[Callable[..., Any]] = None,
|
|
54
|
-
redact_on_error: Optional[bool] = True,
|
|
55
|
-
# DEPRECATING
|
|
56
|
-
app_id: Optional[str] = None,
|
|
57
|
-
):
|
|
58
|
-
global api, async_api, tracing, tracer # pylint: disable=global-statement
|
|
59
43
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
config_fname=config_fname,
|
|
64
|
-
redact=redact,
|
|
65
|
-
redact_on_error=redact_on_error,
|
|
66
|
-
app_id=app_id,
|
|
67
|
-
)
|
|
44
|
+
def init(*args, **kwargs):
|
|
45
|
+
global api, async_api, tracing, config
|
|
46
|
+
_init(*args, **kwargs)
|
|
68
47
|
|
|
48
|
+
tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
|
|
69
49
|
api = DEFAULT_AGENTA_SINGLETON_INSTANCE.api # type: ignore
|
|
70
50
|
async_api = DEFAULT_AGENTA_SINGLETON_INSTANCE.async_api # type: ignore
|
|
71
|
-
|
|
72
|
-
tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
|
|
73
|
-
tracer = get_tracer(tracing)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional
|
|
1
|
+
from typing import Optional
|
|
2
2
|
|
|
3
3
|
from .utils.preinit import PreInitObject # always the first import!
|
|
4
4
|
|
|
@@ -43,21 +43,17 @@ tracer = get_tracer(tracing)
|
|
|
43
43
|
|
|
44
44
|
def init(
|
|
45
45
|
host: Optional[str] = None,
|
|
46
|
+
app_id: Optional[str] = None,
|
|
46
47
|
api_key: Optional[str] = None,
|
|
47
48
|
config_fname: Optional[str] = None,
|
|
48
|
-
redact: Optional[Callable[..., Any]] = None,
|
|
49
|
-
redact_on_error: Optional[bool] = True,
|
|
50
|
-
# DEPRECATING
|
|
51
|
-
app_id: Optional[str] = None,
|
|
52
49
|
):
|
|
53
|
-
global api, async_api, tracing, tracer
|
|
50
|
+
global api, async_api, tracing, tracer
|
|
54
51
|
|
|
55
52
|
_init(
|
|
56
53
|
host=host,
|
|
57
54
|
api_key=api_key,
|
|
58
55
|
config_fname=config_fname,
|
|
59
|
-
|
|
60
|
-
redact_on_error=redact_on_error,
|
|
56
|
+
# DEPRECATING
|
|
61
57
|
app_id=app_id,
|
|
62
58
|
)
|
|
63
59
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import toml
|
|
3
3
|
from os import getenv
|
|
4
|
-
from typing import Optional
|
|
4
|
+
from typing import Optional
|
|
5
5
|
from importlib.metadata import version
|
|
6
6
|
|
|
7
7
|
from agenta.sdk.utils.logging import log
|
|
@@ -36,8 +36,6 @@ class AgentaSingleton:
|
|
|
36
36
|
host: Optional[str] = None,
|
|
37
37
|
api_key: Optional[str] = None,
|
|
38
38
|
config_fname: Optional[str] = None,
|
|
39
|
-
redact: Optional[Callable[..., Any]] = None,
|
|
40
|
-
redact_on_error: Optional[bool] = True,
|
|
41
39
|
# DEPRECATING
|
|
42
40
|
app_id: Optional[str] = None,
|
|
43
41
|
) -> None:
|
|
@@ -93,8 +91,6 @@ class AgentaSingleton:
|
|
|
93
91
|
|
|
94
92
|
self.tracing = Tracing(
|
|
95
93
|
url=f"{self.host}/api/observability/v1/otlp/traces", # type: ignore
|
|
96
|
-
redact=redact,
|
|
97
|
-
redact_on_error=redact_on_error,
|
|
98
94
|
)
|
|
99
95
|
|
|
100
96
|
self.tracing.configure(
|
|
@@ -262,9 +258,7 @@ def init(
|
|
|
262
258
|
host: Optional[str] = None,
|
|
263
259
|
api_key: Optional[str] = None,
|
|
264
260
|
config_fname: Optional[str] = None,
|
|
265
|
-
|
|
266
|
-
redact_on_error: Optional[bool] = True,
|
|
267
|
-
# DEPRECATING
|
|
261
|
+
# DEPRECATED
|
|
268
262
|
app_id: Optional[str] = None,
|
|
269
263
|
):
|
|
270
264
|
"""Main function to initialize the agenta sdk.
|
|
@@ -295,8 +289,7 @@ def init(
|
|
|
295
289
|
host=host,
|
|
296
290
|
api_key=api_key,
|
|
297
291
|
config_fname=config_fname,
|
|
298
|
-
|
|
299
|
-
redact_on_error=redact_on_error,
|
|
292
|
+
# DEPRECATED
|
|
300
293
|
app_id=app_id,
|
|
301
294
|
)
|
|
302
295
|
|
|
@@ -14,10 +14,9 @@ from os import environ
|
|
|
14
14
|
from fastapi.middleware.cors import CORSMiddleware
|
|
15
15
|
from fastapi import Body, FastAPI, UploadFile, HTTPException
|
|
16
16
|
|
|
17
|
-
from agenta.sdk.middleware.auth import AuthorizationMiddleware
|
|
18
17
|
from agenta.sdk.context.routing import routing_context_manager, routing_context
|
|
19
18
|
from agenta.sdk.context.tracing import tracing_context
|
|
20
|
-
from agenta.sdk.router import router
|
|
19
|
+
from agenta.sdk.router import router as router
|
|
21
20
|
from agenta.sdk.utils.exceptions import suppress
|
|
22
21
|
from agenta.sdk.utils.logging import log
|
|
23
22
|
from agenta.sdk.types import (
|
|
@@ -51,9 +50,6 @@ app.add_middleware(
|
|
|
51
50
|
allow_headers=["*"],
|
|
52
51
|
)
|
|
53
52
|
|
|
54
|
-
_MIDDLEWARES = True
|
|
55
|
-
|
|
56
|
-
|
|
57
53
|
app.include_router(router, prefix="")
|
|
58
54
|
|
|
59
55
|
|
|
@@ -125,26 +121,6 @@ class entrypoint:
|
|
|
125
121
|
route_path="",
|
|
126
122
|
config_schema: Optional[BaseModel] = None,
|
|
127
123
|
):
|
|
128
|
-
### --- Update Middleware --- #
|
|
129
|
-
try:
|
|
130
|
-
global _MIDDLEWARES # pylint: disable=global-statement
|
|
131
|
-
|
|
132
|
-
if _MIDDLEWARES:
|
|
133
|
-
app.add_middleware(
|
|
134
|
-
AuthorizationMiddleware,
|
|
135
|
-
host=ag.DEFAULT_AGENTA_SINGLETON_INSTANCE.host,
|
|
136
|
-
resource_id=ag.DEFAULT_AGENTA_SINGLETON_INSTANCE.app_id,
|
|
137
|
-
resource_type="application",
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
_MIDDLEWARES = False
|
|
141
|
-
|
|
142
|
-
except: # pylint: disable=bare-except
|
|
143
|
-
log.error("------------------------------------")
|
|
144
|
-
log.error("Agenta SDK - failed to secure route: %s", route_path)
|
|
145
|
-
log.error("------------------------------------")
|
|
146
|
-
### --- Update Middleware --- #
|
|
147
|
-
|
|
148
124
|
DEFAULT_PATH = "generate"
|
|
149
125
|
PLAYGROUND_PATH = "/playground"
|
|
150
126
|
RUN_PATH = "/run"
|
|
@@ -354,9 +330,9 @@ class entrypoint:
|
|
|
354
330
|
*args,
|
|
355
331
|
**func_params,
|
|
356
332
|
):
|
|
357
|
-
log.info("---------------------------")
|
|
333
|
+
log.info(f"---------------------------")
|
|
358
334
|
log.info(f"Agenta SDK - running route: {repr(self.route_path or '/')}")
|
|
359
|
-
log.info("---------------------------")
|
|
335
|
+
log.info(f"---------------------------")
|
|
360
336
|
|
|
361
337
|
tracing_context.set(routing_context.get())
|
|
362
338
|
|
|
@@ -19,8 +19,6 @@ class instrument: # pylint: disable=invalid-name
|
|
|
19
19
|
config: Optional[Dict[str, Any]] = None,
|
|
20
20
|
ignore_inputs: Optional[bool] = None,
|
|
21
21
|
ignore_outputs: Optional[bool] = None,
|
|
22
|
-
redact: Optional[Callable[..., Any]] = None,
|
|
23
|
-
redact_on_error: Optional[bool] = True,
|
|
24
22
|
max_depth: Optional[int] = 2,
|
|
25
23
|
# DEPRECATING
|
|
26
24
|
kind: str = "task",
|
|
@@ -31,8 +29,6 @@ class instrument: # pylint: disable=invalid-name
|
|
|
31
29
|
self.config = config
|
|
32
30
|
self.ignore_inputs = ignore_inputs
|
|
33
31
|
self.ignore_outputs = ignore_outputs
|
|
34
|
-
self.redact = redact
|
|
35
|
-
self.redact_on_error = redact_on_error
|
|
36
32
|
self.max_depth = max_depth
|
|
37
33
|
|
|
38
34
|
def __call__(self, func: Callable[..., Any]):
|
|
@@ -113,10 +109,12 @@ class instrument: # pylint: disable=invalid-name
|
|
|
113
109
|
)
|
|
114
110
|
|
|
115
111
|
_inputs = self._redact(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
self._parse(
|
|
113
|
+
func,
|
|
114
|
+
*args,
|
|
115
|
+
**kwargs,
|
|
116
|
+
),
|
|
117
|
+
self.ignore_inputs,
|
|
120
118
|
)
|
|
121
119
|
span.set_attributes(
|
|
122
120
|
attributes={"inputs": _inputs},
|
|
@@ -155,12 +153,7 @@ class instrument: # pylint: disable=invalid-name
|
|
|
155
153
|
namespace="metrics.unit.tokens",
|
|
156
154
|
)
|
|
157
155
|
|
|
158
|
-
_outputs = self._redact(
|
|
159
|
-
name=span.name,
|
|
160
|
-
field="outputs",
|
|
161
|
-
io=self._patch(result),
|
|
162
|
-
ignore=self.ignore_outputs,
|
|
163
|
-
)
|
|
156
|
+
_outputs = self._redact(self._patch(result), self.ignore_outputs)
|
|
164
157
|
span.set_attributes(
|
|
165
158
|
attributes={"outputs": _outputs},
|
|
166
159
|
namespace="data",
|
|
@@ -199,9 +192,6 @@ class instrument: # pylint: disable=invalid-name
|
|
|
199
192
|
|
|
200
193
|
def _redact(
|
|
201
194
|
self,
|
|
202
|
-
*,
|
|
203
|
-
name: str,
|
|
204
|
-
field: str,
|
|
205
195
|
io: Dict[str, Any],
|
|
206
196
|
ignore: Union[List[str], bool] = False,
|
|
207
197
|
) -> Dict[str, Any]:
|
|
@@ -230,20 +220,6 @@ class instrument: # pylint: disable=invalid-name
|
|
|
230
220
|
)
|
|
231
221
|
}
|
|
232
222
|
|
|
233
|
-
if self.redact is not None:
|
|
234
|
-
try:
|
|
235
|
-
io = self.redact(name, field, io)
|
|
236
|
-
except: # pylint: disable=bare-except
|
|
237
|
-
if self.redact_on_error:
|
|
238
|
-
io = {}
|
|
239
|
-
|
|
240
|
-
if ag.tracing.redact is not None:
|
|
241
|
-
try:
|
|
242
|
-
io = ag.tracing.redact(name, field, io)
|
|
243
|
-
except: # pylint: disable=bare-except
|
|
244
|
-
if ag.tracing.redact_on_error:
|
|
245
|
-
io = {}
|
|
246
|
-
|
|
247
223
|
return io
|
|
248
224
|
|
|
249
225
|
def _patch(
|
|
@@ -89,20 +89,16 @@ def litellm_handler():
|
|
|
89
89
|
log.error("LiteLLM callback error: span not found.")
|
|
90
90
|
return
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
result = []
|
|
94
|
-
for choice in response_obj.choices:
|
|
95
|
-
message = choice.message.__dict__
|
|
96
|
-
result.append(message)
|
|
92
|
+
result = kwargs.get("complete_streaming_response")
|
|
97
93
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
namespace="data",
|
|
102
|
-
)
|
|
94
|
+
outputs = (
|
|
95
|
+
{"__default__": result} if not isinstance(result, dict) else result
|
|
96
|
+
)
|
|
103
97
|
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
self.span.set_attributes(
|
|
99
|
+
attributes={"outputs": outputs},
|
|
100
|
+
namespace="data",
|
|
101
|
+
)
|
|
106
102
|
|
|
107
103
|
self.span.set_attributes(
|
|
108
104
|
attributes={"total": kwargs.get("response_cost")},
|
|
@@ -198,20 +194,16 @@ def litellm_handler():
|
|
|
198
194
|
log.error("LiteLLM callback error: span not found.")
|
|
199
195
|
return
|
|
200
196
|
|
|
201
|
-
|
|
202
|
-
result = []
|
|
203
|
-
for choice in response_obj.choices:
|
|
204
|
-
message = choice.message.__dict__
|
|
205
|
-
result.append(message)
|
|
197
|
+
result = kwargs.get("complete_streaming_response")
|
|
206
198
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
namespace="data",
|
|
211
|
-
)
|
|
199
|
+
outputs = (
|
|
200
|
+
{"__default__": result} if not isinstance(result, dict) else result
|
|
201
|
+
)
|
|
212
202
|
|
|
213
|
-
|
|
214
|
-
|
|
203
|
+
self.span.set_attributes(
|
|
204
|
+
attributes={"outputs": outputs},
|
|
205
|
+
namespace="data",
|
|
206
|
+
)
|
|
215
207
|
|
|
216
208
|
self.span.set_attributes(
|
|
217
209
|
attributes={"total": kwargs.get("response_cost")},
|
|
@@ -244,20 +236,17 @@ def litellm_handler():
|
|
|
244
236
|
log.error("LiteLLM callback error: span not found.")
|
|
245
237
|
return
|
|
246
238
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
for choice in response_obj.choices:
|
|
250
|
-
message = choice.message.__dict__
|
|
251
|
-
result.append(message)
|
|
239
|
+
# result = kwargs.get("complete_streaming_response")
|
|
240
|
+
result = response_obj.choices[0].message.content
|
|
252
241
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
namespace="data",
|
|
257
|
-
)
|
|
242
|
+
outputs = (
|
|
243
|
+
{"__default__": result} if not isinstance(result, dict) else result
|
|
244
|
+
)
|
|
258
245
|
|
|
259
|
-
|
|
260
|
-
|
|
246
|
+
self.span.set_attributes(
|
|
247
|
+
attributes={"outputs": outputs},
|
|
248
|
+
namespace="data",
|
|
249
|
+
)
|
|
261
250
|
|
|
262
251
|
self.span.set_attributes(
|
|
263
252
|
attributes={"total": kwargs.get("response_cost")},
|
|
@@ -58,7 +58,7 @@ class InlineTraceExporter(SpanExporter):
|
|
|
58
58
|
return trace
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
OTLPSpanExporter._MAX_RETRY_TIMEOUT = 2
|
|
61
|
+
OTLPSpanExporter._MAX_RETRY_TIMEOUT = 2
|
|
62
62
|
|
|
63
63
|
ConsoleExporter = ConsoleSpanExporter
|
|
64
64
|
InlineExporter = InlineTraceExporter
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional, Any, Dict
|
|
1
|
+
from typing import Optional, Any, Dict
|
|
2
2
|
from enum import Enum
|
|
3
3
|
|
|
4
4
|
from httpx import get as check
|
|
@@ -32,8 +32,6 @@ class Tracing(metaclass=Singleton):
|
|
|
32
32
|
def __init__(
|
|
33
33
|
self,
|
|
34
34
|
url: str,
|
|
35
|
-
redact: Optional[Callable[..., Any]] = None,
|
|
36
|
-
redact_on_error: Optional[bool] = True,
|
|
37
35
|
) -> None:
|
|
38
36
|
# ENDPOINT (OTLP)
|
|
39
37
|
self.otlp_url = url
|
|
@@ -51,10 +49,6 @@ class Tracing(metaclass=Singleton):
|
|
|
51
49
|
# INLINE SPANS for INLINE TRACES (INLINE PROCESSOR)
|
|
52
50
|
self.inline_spans: Dict[str, Any] = dict()
|
|
53
51
|
|
|
54
|
-
# REDACT
|
|
55
|
-
self.redact = redact
|
|
56
|
-
self.redact_on_error = redact_on_error
|
|
57
|
-
|
|
58
52
|
# PUBLIC
|
|
59
53
|
|
|
60
54
|
def configure(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "agenta"
|
|
3
|
-
version = "0.27.
|
|
3
|
+
version = "0.27.6"
|
|
4
4
|
description = "The SDK for agenta is an open-source LLMOps platform."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = ["Mahmoud Mabrouk <mahmoud@agenta.ai>"]
|
|
@@ -26,11 +26,14 @@ click = "^8.1.3"
|
|
|
26
26
|
fastapi = ">=0.100.0"
|
|
27
27
|
toml = "^0.10.2"
|
|
28
28
|
questionary = ">=1.10,<3.0"
|
|
29
|
+
ipdb = ">=0.13"
|
|
29
30
|
python-dotenv = "^1.0.0"
|
|
31
|
+
python-multipart = ">=0.0.6,<0.0.10"
|
|
30
32
|
importlib-metadata = ">=8.0.0,<9.0"
|
|
31
33
|
posthog = "^3.1.0"
|
|
32
34
|
pydantic = ">=2"
|
|
33
35
|
httpx = ">=0.24, <0.28"
|
|
36
|
+
pymongo = "^4.6.3"
|
|
34
37
|
cachetools = "^5.3.3"
|
|
35
38
|
pyyaml = "^6.0.2"
|
|
36
39
|
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
from typing import Callable, Optional
|
|
2
|
-
from os import environ
|
|
3
|
-
from uuid import UUID
|
|
4
|
-
from json import dumps
|
|
5
|
-
from traceback import format_exc
|
|
6
|
-
|
|
7
|
-
import httpx
|
|
8
|
-
from starlette.middleware.base import BaseHTTPMiddleware
|
|
9
|
-
from fastapi import FastAPI, Request, Response
|
|
10
|
-
|
|
11
|
-
from agenta.sdk.utils.logging import log
|
|
12
|
-
from agenta.sdk.middleware.cache import TTLLRUCache
|
|
13
|
-
|
|
14
|
-
AGENTA_SDK_AUTH_CACHE_CAPACITY = environ.get(
|
|
15
|
-
"AGENTA_SDK_AUTH_CACHE_CAPACITY",
|
|
16
|
-
512,
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
AGENTA_SDK_AUTH_CACHE_TTL = environ.get(
|
|
20
|
-
"AGENTA_SDK_AUTH_CACHE_TTL",
|
|
21
|
-
15 * 60, # 15 minutes
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
AGENTA_SDK_AUTH_CACHE = str(environ.get("AGENTA_SDK_AUTH_CACHE", True)).lower() in (
|
|
25
|
-
"true",
|
|
26
|
-
"1",
|
|
27
|
-
"t",
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
AGENTA_UNAUTHORIZED_EXECUTION_ALLOWED = str(
|
|
31
|
-
environ.get("AGENTA_UNAUTHORIZED_EXECUTION_ALLOWED", False)
|
|
32
|
-
).lower() in ("true", "1", "t")
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class Deny(Response):
|
|
36
|
-
def __init__(self) -> None:
|
|
37
|
-
super().__init__(status_code=401, content="Unauthorized")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
cache = TTLLRUCache(
|
|
41
|
-
capacity=AGENTA_SDK_AUTH_CACHE_CAPACITY,
|
|
42
|
-
ttl=AGENTA_SDK_AUTH_CACHE_TTL,
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class AuthorizationMiddleware(BaseHTTPMiddleware):
|
|
47
|
-
def __init__(
|
|
48
|
-
self,
|
|
49
|
-
app: FastAPI,
|
|
50
|
-
host: str,
|
|
51
|
-
resource_id: UUID,
|
|
52
|
-
resource_type: str,
|
|
53
|
-
):
|
|
54
|
-
super().__init__(app)
|
|
55
|
-
|
|
56
|
-
self.host = host
|
|
57
|
-
self.resource_id = resource_id
|
|
58
|
-
self.resource_type = resource_type
|
|
59
|
-
|
|
60
|
-
async def dispatch(
|
|
61
|
-
self,
|
|
62
|
-
request: Request,
|
|
63
|
-
call_next: Callable,
|
|
64
|
-
project_id: Optional[UUID] = None,
|
|
65
|
-
):
|
|
66
|
-
if AGENTA_UNAUTHORIZED_EXECUTION_ALLOWED:
|
|
67
|
-
return await call_next(request)
|
|
68
|
-
|
|
69
|
-
try:
|
|
70
|
-
authorization = (
|
|
71
|
-
request.headers.get("Authorization")
|
|
72
|
-
or request.headers.get("authorization")
|
|
73
|
-
or None
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
headers = {"Authorization": authorization} if authorization else None
|
|
77
|
-
|
|
78
|
-
cookies = {"sAccessToken": request.cookies.get("sAccessToken")}
|
|
79
|
-
|
|
80
|
-
params = {
|
|
81
|
-
"action": "run_service",
|
|
82
|
-
"resource_type": self.resource_type,
|
|
83
|
-
"resource_id": self.resource_id,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if project_id:
|
|
87
|
-
params["project_id"] = project_id
|
|
88
|
-
|
|
89
|
-
_hash = dumps(
|
|
90
|
-
{
|
|
91
|
-
"headers": headers,
|
|
92
|
-
"cookies": cookies,
|
|
93
|
-
"params": params,
|
|
94
|
-
},
|
|
95
|
-
sort_keys=True,
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
policy = None
|
|
99
|
-
if AGENTA_SDK_AUTH_CACHE:
|
|
100
|
-
policy = cache.get(_hash)
|
|
101
|
-
|
|
102
|
-
if not policy:
|
|
103
|
-
async with httpx.AsyncClient() as client:
|
|
104
|
-
response = await client.get(
|
|
105
|
-
f"{self.host}/api/permissions/verify",
|
|
106
|
-
headers=headers,
|
|
107
|
-
cookies=cookies,
|
|
108
|
-
params=params,
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
if response.status_code != 200:
|
|
112
|
-
cache.put(_hash, {"effect": "deny"})
|
|
113
|
-
return Deny()
|
|
114
|
-
|
|
115
|
-
auth = response.json()
|
|
116
|
-
|
|
117
|
-
if auth.get("effect") != "allow":
|
|
118
|
-
cache.put(_hash, {"effect": "deny"})
|
|
119
|
-
return Deny()
|
|
120
|
-
|
|
121
|
-
policy = {
|
|
122
|
-
"effect": "allow",
|
|
123
|
-
"credentials": auth.get("credentials"),
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
cache.put(_hash, policy)
|
|
127
|
-
|
|
128
|
-
if policy.get("effect") == "deny":
|
|
129
|
-
return Deny()
|
|
130
|
-
|
|
131
|
-
request.state.credentials = policy.get("credentials")
|
|
132
|
-
|
|
133
|
-
return await call_next(request)
|
|
134
|
-
|
|
135
|
-
except: # pylint: disable=bare-except
|
|
136
|
-
log.error("------------------------------------------------------")
|
|
137
|
-
log.error("Agenta SDK - handling auth middleware exception below:")
|
|
138
|
-
log.error("------------------------------------------------------")
|
|
139
|
-
log.error(format_exc().strip("\n"))
|
|
140
|
-
log.error("------------------------------------------------------")
|
|
141
|
-
|
|
142
|
-
return Deny()
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
from time import time
|
|
2
|
-
from collections import OrderedDict
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class TTLLRUCache:
|
|
6
|
-
def __init__(self, capacity: int, ttl: int):
|
|
7
|
-
self.cache = OrderedDict()
|
|
8
|
-
self.capacity = capacity
|
|
9
|
-
self.ttl = ttl
|
|
10
|
-
|
|
11
|
-
def get(self, key):
|
|
12
|
-
# CACHE
|
|
13
|
-
if key not in self.cache:
|
|
14
|
-
return None
|
|
15
|
-
|
|
16
|
-
value, expiry = self.cache[key]
|
|
17
|
-
# -----
|
|
18
|
-
|
|
19
|
-
# TTL
|
|
20
|
-
if time() > expiry:
|
|
21
|
-
del self.cache[key]
|
|
22
|
-
|
|
23
|
-
return None
|
|
24
|
-
# ---
|
|
25
|
-
|
|
26
|
-
# LRU
|
|
27
|
-
self.cache.move_to_end(key)
|
|
28
|
-
# ---
|
|
29
|
-
|
|
30
|
-
return value
|
|
31
|
-
|
|
32
|
-
def put(self, key, value):
|
|
33
|
-
# CACHE
|
|
34
|
-
if key in self.cache:
|
|
35
|
-
del self.cache[key]
|
|
36
|
-
# CACHE & LRU
|
|
37
|
-
elif len(self.cache) >= self.capacity:
|
|
38
|
-
self.cache.popitem(last=False)
|
|
39
|
-
# -----------
|
|
40
|
-
|
|
41
|
-
# TTL
|
|
42
|
-
self.cache[key] = (value, time() + self.ttl)
|
|
43
|
-
# ---
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|