payi 0.1.0a60__tar.gz → 0.1.0a62__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 payi might be problematic. Click here for more details.
- payi-0.1.0a62/.release-please-manifest.json +3 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/CHANGELOG.md +16 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/PKG-INFO +1 -1
- {payi-0.1.0a60 → payi-0.1.0a62}/pyproject.toml +1 -1
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_version.py +1 -1
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/lib/AnthropicInstrumentor.py +11 -11
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/lib/BedrockInstrumentor.py +15 -15
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/lib/OpenAIInstrumentor.py +16 -16
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/lib/helpers.py +16 -12
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/lib/instrument.py +61 -25
- payi-0.1.0a60/.release-please-manifest.json +0 -3
- {payi-0.1.0a60 → payi-0.1.0a62}/.gitignore +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/CONTRIBUTING.md +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/LICENSE +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/README.md +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/SECURITY.md +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/api.md +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/bin/check-release-environment +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/bin/publish-pypi +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/examples/.keep +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/mypy.ini +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/noxfile.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/release-please-config.json +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/requirements-dev.lock +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/requirements.lock +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_base_client.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_client.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_compat.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_constants.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_exceptions.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_files.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_models.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_qs.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_resource.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_streaming.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_types.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_utils/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_utils/_logs.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_utils/_proxy.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_utils/_reflection.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_utils/_streams.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_utils/_sync.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_utils/_transform.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_utils/_typing.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/_utils/_utils.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/lib/.keep +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/lib/Stopwatch.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/pagination.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/py.typed +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/categories/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/categories/categories.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/categories/resources.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/experiences/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/experiences/experiences.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/experiences/properties.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/experiences/types/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/experiences/types/limit_config.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/experiences/types/types.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/ingest.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/limits/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/limits/limits.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/limits/tags.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/requests/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/requests/properties.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/requests/requests.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/requests/result.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/use_cases/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/use_cases/definitions/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/use_cases/definitions/definitions.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/use_cases/definitions/kpis.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/use_cases/definitions/limit_config.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/use_cases/definitions/version.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/use_cases/kpis.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/use_cases/properties.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/resources/use_cases/use_cases.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/bulk_ingest_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/categories/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/categories/resource_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/categories/resource_list_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/category_delete_resource_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/category_delete_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/category_list_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/category_list_resources_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/category_resource_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/category_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/cost_data.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/cost_details.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/default_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/experience_instance_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/experiences/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/experiences/experience_type.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/experiences/property_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/experiences/type_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/experiences/type_list_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/experiences/type_update_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/experiences/types/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/experiences/types/limit_config_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/ingest_bulk_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/ingest_event_param.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/ingest_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/ingest_units_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limit_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limit_history_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limit_list_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limit_list_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limit_reset_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limit_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limit_update_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/limit_tags.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/tag_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/tag_create_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/tag_delete_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/tag_list_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/tag_remove_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/tag_remove_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/tag_update_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/limits/tag_update_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/pay_i_common_models_api_router_header_info_param.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/requests/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/requests/property_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/requests/request_result.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/requests_data.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/shared/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/shared/evaluation_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/shared/pay_i_common_models_budget_management_cost_details_base.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/shared/pay_i_common_models_budget_management_create_limit_base.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/shared/properties_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/shared_params/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/shared_params/pay_i_common_models_budget_management_create_limit_base.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/total_cost_data.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_case_instance_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definition_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definition_list_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definition_update_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/kpi_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/kpi_create_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/kpi_delete_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/kpi_list_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/kpi_list_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/kpi_retrieve_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/kpi_update_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/kpi_update_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/definitions/limit_config_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/kpi_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/kpi_list_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/kpi_list_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/kpi_update_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/property_create_params.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/src/payi/types/use_cases/use_case_definition.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/categories/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/categories/test_resources.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/experiences/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/experiences/test_properties.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/experiences/test_types.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/experiences/types/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/experiences/types/test_limit_config.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/limits/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/limits/test_tags.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/requests/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/requests/test_properties.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/requests/test_result.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/test_categories.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/test_experiences.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/test_ingest.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/test_limits.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/test_use_cases.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/use_cases/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/use_cases/definitions/__init__.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/use_cases/definitions/test_kpis.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/use_cases/definitions/test_limit_config.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/use_cases/definitions/test_version.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/use_cases/test_definitions.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/use_cases/test_kpis.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/api_resources/use_cases/test_properties.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/conftest.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/sample_file.txt +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_client.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_deepcopy.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_extract_files.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_files.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_models.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_qs.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_required_args.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_response.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_streaming.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_transform.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_utils/test_proxy.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/test_utils/test_typing.py +0 -0
- {payi-0.1.0a60 → payi-0.1.0a62}/tests/utils.py +0 -0
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.62 (2025-04-07)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.1.0-alpha.61...v0.1.0-alpha.62](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.61...v0.1.0-alpha.62)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* feat: auto generate use case id ([b50f807](https://github.com/Pay-i/pay-i-python/commit/b50f807b571c917d39f37a1879bf2ea7e7f5d29d))
|
|
10
|
+
|
|
11
|
+
## 0.1.0-alpha.61 (2025-04-07)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.1.0-alpha.60...v0.1.0-alpha.61](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.60...v0.1.0-alpha.61)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* feat(api): global instrumentation ([6977d0c](https://github.com/Pay-i/pay-i-python/commit/6977d0c78ffaa12bb43a439827b0fba08b258e55))
|
|
18
|
+
|
|
3
19
|
## 0.1.0-alpha.60 (2025-04-07)
|
|
4
20
|
|
|
5
21
|
Full Changelog: [v0.1.0-alpha.59...v0.1.0-alpha.60](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.59...v0.1.0-alpha.60)
|
|
@@ -7,12 +7,12 @@ from wrapt import wrap_function_wrapper # type: ignore
|
|
|
7
7
|
from payi.types import IngestUnitsParams
|
|
8
8
|
from payi.types.ingest_units_params import Units
|
|
9
9
|
|
|
10
|
-
from .instrument import
|
|
10
|
+
from .instrument import _IsStreaming, _PayiInstrumentor
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class AnthropicIntrumentor:
|
|
14
14
|
@staticmethod
|
|
15
|
-
def instrument(instrumentor:
|
|
15
|
+
def instrument(instrumentor: _PayiInstrumentor) -> None:
|
|
16
16
|
try:
|
|
17
17
|
import anthropic # type: ignore # noqa: F401 I001
|
|
18
18
|
|
|
@@ -45,9 +45,9 @@ class AnthropicIntrumentor:
|
|
|
45
45
|
return
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
@
|
|
48
|
+
@_PayiInstrumentor.payi_wrapper
|
|
49
49
|
def chat_wrapper(
|
|
50
|
-
instrumentor:
|
|
50
|
+
instrumentor: _PayiInstrumentor,
|
|
51
51
|
wrapped: Any,
|
|
52
52
|
instance: Any,
|
|
53
53
|
*args: Any,
|
|
@@ -58,16 +58,16 @@ def chat_wrapper(
|
|
|
58
58
|
process_chunk,
|
|
59
59
|
process_request,
|
|
60
60
|
process_synchronous_response,
|
|
61
|
-
|
|
61
|
+
_IsStreaming.kwargs,
|
|
62
62
|
wrapped,
|
|
63
63
|
instance,
|
|
64
64
|
args,
|
|
65
65
|
kwargs,
|
|
66
66
|
)
|
|
67
67
|
|
|
68
|
-
@
|
|
68
|
+
@_PayiInstrumentor.payi_awrapper
|
|
69
69
|
async def achat_wrapper(
|
|
70
|
-
instrumentor:
|
|
70
|
+
instrumentor: _PayiInstrumentor,
|
|
71
71
|
wrapped: Any,
|
|
72
72
|
instance: Any,
|
|
73
73
|
*args: Any,
|
|
@@ -78,7 +78,7 @@ async def achat_wrapper(
|
|
|
78
78
|
process_chunk,
|
|
79
79
|
process_request,
|
|
80
80
|
process_synchronous_response,
|
|
81
|
-
|
|
81
|
+
_IsStreaming.kwargs,
|
|
82
82
|
wrapped,
|
|
83
83
|
instance,
|
|
84
84
|
args,
|
|
@@ -93,7 +93,7 @@ def process_chunk(chunk: Any, ingest: IngestUnitsParams) -> None:
|
|
|
93
93
|
usage = chunk.message.usage
|
|
94
94
|
units = ingest["units"]
|
|
95
95
|
|
|
96
|
-
input =
|
|
96
|
+
input = _PayiInstrumentor.update_for_vision(usage.input_tokens, units)
|
|
97
97
|
|
|
98
98
|
units["text"] = Units(input=input, output=0)
|
|
99
99
|
|
|
@@ -124,7 +124,7 @@ def process_synchronous_response(response: Any, ingest: IngestUnitsParams, log_p
|
|
|
124
124
|
text_cache_read = usage.cache_read_input_tokens
|
|
125
125
|
units["text_cache_read"] = Units(input=text_cache_read, output=0)
|
|
126
126
|
|
|
127
|
-
input =
|
|
127
|
+
input = _PayiInstrumentor.update_for_vision(input, units)
|
|
128
128
|
|
|
129
129
|
units["text"] = Units(input=input, output=output)
|
|
130
130
|
|
|
@@ -165,4 +165,4 @@ def process_request(ingest: IngestUnitsParams, *args: Any, **kwargs: Any) -> Non
|
|
|
165
165
|
if not has_image or estimated_token_count == 0:
|
|
166
166
|
return
|
|
167
167
|
|
|
168
|
-
ingest["units"][
|
|
168
|
+
ingest["units"][_PayiInstrumentor.estimated_prompt_tokens] = Units(input=estimated_token_count, output=0)
|
|
@@ -8,12 +8,12 @@ from wrapt import ObjectProxy, wrap_function_wrapper # type: ignore
|
|
|
8
8
|
from payi.types.ingest_units_params import Units, IngestUnitsParams
|
|
9
9
|
from payi.types.pay_i_common_models_api_router_header_info_param import PayICommonModelsAPIRouterHeaderInfoParam
|
|
10
10
|
|
|
11
|
-
from .instrument import
|
|
11
|
+
from .instrument import _IsStreaming, _PayiInstrumentor
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class BedrockInstrumentor:
|
|
15
15
|
@staticmethod
|
|
16
|
-
def instrument(instrumentor:
|
|
16
|
+
def instrument(instrumentor: _PayiInstrumentor) -> None:
|
|
17
17
|
try:
|
|
18
18
|
import boto3 # type: ignore # noqa: F401 I001
|
|
19
19
|
|
|
@@ -33,8 +33,8 @@ class BedrockInstrumentor:
|
|
|
33
33
|
logging.debug(f"Error instrumenting bedrock: {e}")
|
|
34
34
|
return
|
|
35
35
|
|
|
36
|
-
@
|
|
37
|
-
def create_client_wrapper(instrumentor:
|
|
36
|
+
@_PayiInstrumentor.payi_wrapper
|
|
37
|
+
def create_client_wrapper(instrumentor: _PayiInstrumentor, wrapped: Any, instance: Any, *args: Any, **kwargs: Any) -> Any: # noqa: ARG001
|
|
38
38
|
if kwargs.get("service_name") != "bedrock-runtime":
|
|
39
39
|
return wrapped(*args, **kwargs)
|
|
40
40
|
|
|
@@ -55,7 +55,7 @@ class InvokeResponseWrapper(ObjectProxy): # type: ignore
|
|
|
55
55
|
def __init__(
|
|
56
56
|
self,
|
|
57
57
|
response: Any,
|
|
58
|
-
instrumentor:
|
|
58
|
+
instrumentor: _PayiInstrumentor,
|
|
59
59
|
ingest: IngestUnitsParams,
|
|
60
60
|
log_prompt_and_response: bool
|
|
61
61
|
) -> None:
|
|
@@ -95,7 +95,7 @@ class InvokeResponseWrapper(ObjectProxy): # type: ignore
|
|
|
95
95
|
|
|
96
96
|
return data
|
|
97
97
|
|
|
98
|
-
def wrap_invoke(instrumentor:
|
|
98
|
+
def wrap_invoke(instrumentor: _PayiInstrumentor, wrapped: Any) -> Any:
|
|
99
99
|
@wraps(wrapped)
|
|
100
100
|
def invoke_wrapper(*args: Any, **kwargs: 'dict[str, Any]') -> Any:
|
|
101
101
|
modelId:str = kwargs.get("modelId", "") # type: ignore
|
|
@@ -106,7 +106,7 @@ def wrap_invoke(instrumentor: PayiInstrumentor, wrapped: Any) -> Any:
|
|
|
106
106
|
None,
|
|
107
107
|
process_invoke_request,
|
|
108
108
|
process_synchronous_invoke_response,
|
|
109
|
-
|
|
109
|
+
_IsStreaming.false,
|
|
110
110
|
wrapped,
|
|
111
111
|
None,
|
|
112
112
|
args,
|
|
@@ -116,7 +116,7 @@ def wrap_invoke(instrumentor: PayiInstrumentor, wrapped: Any) -> Any:
|
|
|
116
116
|
|
|
117
117
|
return invoke_wrapper
|
|
118
118
|
|
|
119
|
-
def wrap_invoke_stream(instrumentor:
|
|
119
|
+
def wrap_invoke_stream(instrumentor: _PayiInstrumentor, wrapped: Any) -> Any:
|
|
120
120
|
@wraps(wrapped)
|
|
121
121
|
def invoke_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
122
122
|
modelId:str = kwargs.get("modelId", "") # type: ignore
|
|
@@ -127,7 +127,7 @@ def wrap_invoke_stream(instrumentor: PayiInstrumentor, wrapped: Any) -> Any:
|
|
|
127
127
|
process_invoke_streaming_anthropic_chunk if modelId.startswith("anthropic.") else process_invoke_streaming_llama_chunk,
|
|
128
128
|
process_invoke_request,
|
|
129
129
|
None,
|
|
130
|
-
|
|
130
|
+
_IsStreaming.true,
|
|
131
131
|
wrapped,
|
|
132
132
|
None,
|
|
133
133
|
args,
|
|
@@ -137,7 +137,7 @@ def wrap_invoke_stream(instrumentor: PayiInstrumentor, wrapped: Any) -> Any:
|
|
|
137
137
|
|
|
138
138
|
return invoke_wrapper
|
|
139
139
|
|
|
140
|
-
def wrap_converse(instrumentor:
|
|
140
|
+
def wrap_converse(instrumentor: _PayiInstrumentor, wrapped: Any) -> Any:
|
|
141
141
|
@wraps(wrapped)
|
|
142
142
|
def invoke_wrapper(*args: Any, **kwargs: 'dict[str, Any]') -> Any:
|
|
143
143
|
modelId:str = kwargs.get("modelId", "") # type: ignore
|
|
@@ -148,7 +148,7 @@ def wrap_converse(instrumentor: PayiInstrumentor, wrapped: Any) -> Any:
|
|
|
148
148
|
None,
|
|
149
149
|
process_converse_request,
|
|
150
150
|
process_synchronous_converse_response,
|
|
151
|
-
|
|
151
|
+
_IsStreaming.false,
|
|
152
152
|
wrapped,
|
|
153
153
|
None,
|
|
154
154
|
args,
|
|
@@ -158,7 +158,7 @@ def wrap_converse(instrumentor: PayiInstrumentor, wrapped: Any) -> Any:
|
|
|
158
158
|
|
|
159
159
|
return invoke_wrapper
|
|
160
160
|
|
|
161
|
-
def wrap_converse_stream(instrumentor:
|
|
161
|
+
def wrap_converse_stream(instrumentor: _PayiInstrumentor, wrapped: Any) -> Any:
|
|
162
162
|
@wraps(wrapped)
|
|
163
163
|
def invoke_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
164
164
|
modelId:str = kwargs.get("modelId", "") # type: ignore
|
|
@@ -169,7 +169,7 @@ def wrap_converse_stream(instrumentor: PayiInstrumentor, wrapped: Any) -> Any:
|
|
|
169
169
|
process_converse_streaming_chunk,
|
|
170
170
|
process_converse_request,
|
|
171
171
|
None,
|
|
172
|
-
|
|
172
|
+
_IsStreaming.true,
|
|
173
173
|
wrapped,
|
|
174
174
|
None,
|
|
175
175
|
args,
|
|
@@ -187,7 +187,7 @@ def process_invoke_streaming_anthropic_chunk(chunk: str, ingest: IngestUnitsPara
|
|
|
187
187
|
usage = chunk_dict['message']['usage']
|
|
188
188
|
units = ingest["units"]
|
|
189
189
|
|
|
190
|
-
input =
|
|
190
|
+
input = _PayiInstrumentor.update_for_vision(usage['input_tokens'], units)
|
|
191
191
|
|
|
192
192
|
units["text"] = Units(input=input, output=0)
|
|
193
193
|
|
|
@@ -215,7 +215,7 @@ def process_synchronous_invoke_response(
|
|
|
215
215
|
response: Any,
|
|
216
216
|
ingest: IngestUnitsParams,
|
|
217
217
|
log_prompt_and_response: bool,
|
|
218
|
-
instrumentor:
|
|
218
|
+
instrumentor: _PayiInstrumentor,
|
|
219
219
|
**kargs: Any) -> Any: # noqa: ARG001
|
|
220
220
|
|
|
221
221
|
metadata = response.get("ResponseMetadata", {})
|
|
@@ -9,7 +9,7 @@ from wrapt import wrap_function_wrapper # type: ignore
|
|
|
9
9
|
from payi.types import IngestUnitsParams
|
|
10
10
|
from payi.types.ingest_units_params import Units
|
|
11
11
|
|
|
12
|
-
from .instrument import
|
|
12
|
+
from .instrument import _IsStreaming, _PayiInstrumentor
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class OpenAiInstrumentor:
|
|
@@ -20,7 +20,7 @@ class OpenAiInstrumentor:
|
|
|
20
20
|
return isinstance(instance._client, (AsyncAzureOpenAI, AzureOpenAI))
|
|
21
21
|
|
|
22
22
|
@staticmethod
|
|
23
|
-
def instrument(instrumentor:
|
|
23
|
+
def instrument(instrumentor: _PayiInstrumentor) -> None:
|
|
24
24
|
try:
|
|
25
25
|
from openai import OpenAI # type: ignore # noqa: F401 I001
|
|
26
26
|
|
|
@@ -53,9 +53,9 @@ class OpenAiInstrumentor:
|
|
|
53
53
|
return
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
@
|
|
56
|
+
@_PayiInstrumentor.payi_wrapper
|
|
57
57
|
def embeddings_wrapper(
|
|
58
|
-
instrumentor:
|
|
58
|
+
instrumentor: _PayiInstrumentor,
|
|
59
59
|
wrapped: Any,
|
|
60
60
|
instance: Any,
|
|
61
61
|
*args: Any,
|
|
@@ -66,16 +66,16 @@ def embeddings_wrapper(
|
|
|
66
66
|
None, # process_chat_chunk,
|
|
67
67
|
None, # process_chat_request,
|
|
68
68
|
process_ebmeddings_synchronous_response,
|
|
69
|
-
|
|
69
|
+
_IsStreaming.false,
|
|
70
70
|
wrapped,
|
|
71
71
|
instance,
|
|
72
72
|
args,
|
|
73
73
|
kwargs,
|
|
74
74
|
)
|
|
75
75
|
|
|
76
|
-
@
|
|
76
|
+
@_PayiInstrumentor.payi_wrapper
|
|
77
77
|
async def aembeddings_wrapper(
|
|
78
|
-
instrumentor:
|
|
78
|
+
instrumentor: _PayiInstrumentor,
|
|
79
79
|
wrapped: Any,
|
|
80
80
|
instance: Any,
|
|
81
81
|
*args: Any,
|
|
@@ -86,16 +86,16 @@ async def aembeddings_wrapper(
|
|
|
86
86
|
None, # process_chat_chunk,
|
|
87
87
|
None, # process_chat_request,
|
|
88
88
|
process_ebmeddings_synchronous_response,
|
|
89
|
-
|
|
89
|
+
_IsStreaming.false,
|
|
90
90
|
wrapped,
|
|
91
91
|
instance,
|
|
92
92
|
args,
|
|
93
93
|
kwargs,
|
|
94
94
|
)
|
|
95
95
|
|
|
96
|
-
@
|
|
96
|
+
@_PayiInstrumentor.payi_wrapper
|
|
97
97
|
def chat_wrapper(
|
|
98
|
-
instrumentor:
|
|
98
|
+
instrumentor: _PayiInstrumentor,
|
|
99
99
|
wrapped: Any,
|
|
100
100
|
instance: Any,
|
|
101
101
|
*args: Any,
|
|
@@ -106,16 +106,16 @@ def chat_wrapper(
|
|
|
106
106
|
process_chat_chunk,
|
|
107
107
|
process_chat_request,
|
|
108
108
|
process_chat_synchronous_response,
|
|
109
|
-
|
|
109
|
+
_IsStreaming.kwargs,
|
|
110
110
|
wrapped,
|
|
111
111
|
instance,
|
|
112
112
|
args,
|
|
113
113
|
kwargs,
|
|
114
114
|
)
|
|
115
115
|
|
|
116
|
-
@
|
|
116
|
+
@_PayiInstrumentor.payi_awrapper
|
|
117
117
|
async def achat_wrapper(
|
|
118
|
-
instrumentor:
|
|
118
|
+
instrumentor: _PayiInstrumentor,
|
|
119
119
|
wrapped: Any,
|
|
120
120
|
instance: Any,
|
|
121
121
|
*args: Any,
|
|
@@ -126,7 +126,7 @@ async def achat_wrapper(
|
|
|
126
126
|
process_chat_chunk,
|
|
127
127
|
process_chat_request,
|
|
128
128
|
process_chat_synchronous_response,
|
|
129
|
-
|
|
129
|
+
_IsStreaming.kwargs,
|
|
130
130
|
wrapped,
|
|
131
131
|
instance,
|
|
132
132
|
args,
|
|
@@ -184,7 +184,7 @@ def add_usage_units(usage: "dict[str, Any]", units: "dict[str, Units]") -> None:
|
|
|
184
184
|
if input_cache != 0:
|
|
185
185
|
units["text_cache_read"] = Units(input=input_cache, output=0)
|
|
186
186
|
|
|
187
|
-
input =
|
|
187
|
+
input = _PayiInstrumentor.update_for_vision(input - input_cache, units)
|
|
188
188
|
|
|
189
189
|
units["text"] = Units(input=input, output=output)
|
|
190
190
|
|
|
@@ -221,4 +221,4 @@ def process_chat_request(ingest: IngestUnitsParams, *args: Any, **kwargs: Any) -
|
|
|
221
221
|
if not has_image or estimated_token_count == 0:
|
|
222
222
|
return
|
|
223
223
|
|
|
224
|
-
ingest["units"][
|
|
224
|
+
ingest["units"][_PayiInstrumentor.estimated_prompt_tokens] = Units(input=estimated_token_count, output=0)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import os
|
|
1
2
|
from typing import Dict, List, Union
|
|
2
3
|
|
|
3
4
|
PAYI_BASE_URL = "https://api.pay-i.com"
|
|
@@ -69,22 +70,25 @@ def create_headers(
|
|
|
69
70
|
headers.update({ PayiHeaderNames.use_case_version: str(use_case_version)})
|
|
70
71
|
return headers
|
|
71
72
|
|
|
73
|
+
def _resolve_payi_base_url(payi_base_url: Union[str, None]) -> str:
|
|
74
|
+
if payi_base_url:
|
|
75
|
+
return payi_base_url
|
|
76
|
+
|
|
77
|
+
payi_base_url = os.environ.get("PAYI_BASE_URL", None)
|
|
78
|
+
|
|
79
|
+
if payi_base_url:
|
|
80
|
+
return payi_base_url
|
|
81
|
+
|
|
82
|
+
return PAYI_BASE_URL
|
|
83
|
+
|
|
72
84
|
def payi_anthropic_url(payi_base_url: Union[str, None] = None) -> str:
|
|
73
|
-
|
|
74
|
-
payi_base_url = PAYI_BASE_URL
|
|
75
|
-
return payi_base_url + "/api/v1/proxy/anthropic"
|
|
85
|
+
return _resolve_payi_base_url(payi_base_url=payi_base_url) + "/api/v1/proxy/anthropic"
|
|
76
86
|
|
|
77
87
|
def payi_openai_url(payi_base_url: Union[str, None] = None) -> str:
|
|
78
|
-
|
|
79
|
-
payi_base_url = PAYI_BASE_URL
|
|
80
|
-
return payi_base_url + "/api/v1/proxy/openai/v1"
|
|
88
|
+
return _resolve_payi_base_url(payi_base_url=payi_base_url) + "/api/v1/proxy/openai/v1"
|
|
81
89
|
|
|
82
90
|
def payi_azure_openai_url(payi_base_url: Union[str, None] = None) -> str:
|
|
83
|
-
|
|
84
|
-
payi_base_url = PAYI_BASE_URL
|
|
85
|
-
return payi_base_url + "/api/v1/proxy/azure.openai"
|
|
91
|
+
return _resolve_payi_base_url(payi_base_url=payi_base_url) + "/api/v1/proxy/azure.openai"
|
|
86
92
|
|
|
87
93
|
def payi_aws_bedrock_url(payi_base_url: Union[str, None] = None) -> str:
|
|
88
|
-
|
|
89
|
-
payi_base_url = PAYI_BASE_URL
|
|
90
|
-
return payi_base_url + "/api/v1/proxy/aws.bedrock"
|
|
94
|
+
return _resolve_payi_base_url(payi_base_url=payi_base_url) + "/api/v1/proxy/aws.bedrock"
|
|
@@ -21,7 +21,18 @@ from .helpers import PayiCategories
|
|
|
21
21
|
from .Stopwatch import Stopwatch
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
class
|
|
24
|
+
class PayiInstrumentConfig(TypedDict, total=False):
|
|
25
|
+
proxy: bool
|
|
26
|
+
limit_ids: Optional["list[str]"]
|
|
27
|
+
request_tags: Optional["list[str]"]
|
|
28
|
+
experience_name: Optional[str]
|
|
29
|
+
experience_id: Optional[str]
|
|
30
|
+
use_case_name: Optional[str]
|
|
31
|
+
use_case_id: Optional[str]
|
|
32
|
+
use_case_version: Optional[int]
|
|
33
|
+
user_id: Optional[str]
|
|
34
|
+
|
|
35
|
+
class _Context(TypedDict, total=False):
|
|
25
36
|
proxy: bool
|
|
26
37
|
experience_name: Optional[str]
|
|
27
38
|
experience_id: Optional[str]
|
|
@@ -32,7 +43,7 @@ class Context(TypedDict, total=False):
|
|
|
32
43
|
request_tags: Optional['list[str]']
|
|
33
44
|
user_id: Optional[str]
|
|
34
45
|
|
|
35
|
-
class
|
|
46
|
+
class _ParentState(TypedDict, total=False):
|
|
36
47
|
experience_name: Optional[str]
|
|
37
48
|
experience_id: Optional[str]
|
|
38
49
|
use_case_name: Optional[str]
|
|
@@ -41,12 +52,12 @@ class ParentState(TypedDict, total=False):
|
|
|
41
52
|
limit_ids: Optional['list[str]']
|
|
42
53
|
request_tags: Optional['list[str]']
|
|
43
54
|
|
|
44
|
-
class
|
|
55
|
+
class _IsStreaming(Enum):
|
|
45
56
|
false = 0
|
|
46
57
|
true = 1
|
|
47
58
|
kwargs = 2
|
|
48
59
|
|
|
49
|
-
class
|
|
60
|
+
class _PayiInstrumentor:
|
|
50
61
|
estimated_prompt_tokens: str = "estimated_prompt_tokens"
|
|
51
62
|
|
|
52
63
|
def __init__(
|
|
@@ -61,7 +72,12 @@ class PayiInstrumentor:
|
|
|
61
72
|
):
|
|
62
73
|
self._payi: Optional[Payi] = payi
|
|
63
74
|
self._apayi: Optional[AsyncPayi] = apayi
|
|
64
|
-
|
|
75
|
+
|
|
76
|
+
if not self._payi and not self._apayi:
|
|
77
|
+
self._payi = Payi()
|
|
78
|
+
self._apayi = AsyncPayi()
|
|
79
|
+
|
|
80
|
+
self._context_stack: list[_Context] = [] # Stack of context dictionaries
|
|
65
81
|
self._log_prompt_and_response: bool = log_prompt_and_response
|
|
66
82
|
self._prompt_and_response_logger: Optional[Callable[[str, dict[str, str]], None]] = prompt_and_response_logger
|
|
67
83
|
|
|
@@ -233,9 +249,9 @@ class PayiInstrumentor:
|
|
|
233
249
|
|
|
234
250
|
def _setup_call_func(
|
|
235
251
|
self
|
|
236
|
-
) -> 'tuple[
|
|
237
|
-
context:
|
|
238
|
-
parentState:
|
|
252
|
+
) -> 'tuple[_Context, _ParentState]':
|
|
253
|
+
context: _Context = {}
|
|
254
|
+
parentState: _ParentState = {}
|
|
239
255
|
|
|
240
256
|
if len(self._context_stack) > 0:
|
|
241
257
|
# copy current context into the upcoming context
|
|
@@ -253,8 +269,8 @@ class PayiInstrumentor:
|
|
|
253
269
|
|
|
254
270
|
def _init_context(
|
|
255
271
|
self,
|
|
256
|
-
context:
|
|
257
|
-
parentState:
|
|
272
|
+
context: _Context,
|
|
273
|
+
parentState: _ParentState,
|
|
258
274
|
proxy: bool,
|
|
259
275
|
limit_ids: Optional["list[str]"],
|
|
260
276
|
request_tags: Optional["list[str]"],
|
|
@@ -395,12 +411,12 @@ class PayiInstrumentor:
|
|
|
395
411
|
if self._context_stack:
|
|
396
412
|
self._context_stack.pop()
|
|
397
413
|
|
|
398
|
-
def set_context(self, context:
|
|
414
|
+
def set_context(self, context: _Context) -> None:
|
|
399
415
|
# Update the current top of the stack with the provided context
|
|
400
416
|
if self._context_stack:
|
|
401
417
|
self._context_stack[-1].update(context)
|
|
402
418
|
|
|
403
|
-
def get_context(self) -> Optional[
|
|
419
|
+
def get_context(self) -> Optional[_Context]:
|
|
404
420
|
# Return the current top of the stack
|
|
405
421
|
return self._context_stack[-1] if self._context_stack else None
|
|
406
422
|
|
|
@@ -461,7 +477,7 @@ class PayiInstrumentor:
|
|
|
461
477
|
process_chunk: Optional[Callable[[Any, IngestUnitsParams], None]],
|
|
462
478
|
process_request: Optional[Callable[[IngestUnitsParams, Any, Any], None]],
|
|
463
479
|
process_synchronous_response: Any,
|
|
464
|
-
is_streaming:
|
|
480
|
+
is_streaming: _IsStreaming,
|
|
465
481
|
wrapped: Any,
|
|
466
482
|
instance: Any,
|
|
467
483
|
args: Any,
|
|
@@ -523,9 +539,9 @@ class PayiInstrumentor:
|
|
|
523
539
|
sw = Stopwatch()
|
|
524
540
|
stream: bool = False
|
|
525
541
|
|
|
526
|
-
if is_streaming ==
|
|
542
|
+
if is_streaming == _IsStreaming.kwargs:
|
|
527
543
|
stream = kwargs.get("stream", False)
|
|
528
|
-
elif is_streaming ==
|
|
544
|
+
elif is_streaming == _IsStreaming.true:
|
|
529
545
|
stream = True
|
|
530
546
|
else:
|
|
531
547
|
stream = False
|
|
@@ -581,7 +597,7 @@ class PayiInstrumentor:
|
|
|
581
597
|
process_chunk: Optional[Callable[[Any, IngestUnitsParams], None]],
|
|
582
598
|
process_request: Optional[Callable[[IngestUnitsParams, Any, Any], None]],
|
|
583
599
|
process_synchronous_response: Any,
|
|
584
|
-
is_streaming:
|
|
600
|
+
is_streaming: _IsStreaming,
|
|
585
601
|
wrapped: Any,
|
|
586
602
|
instance: Any,
|
|
587
603
|
args: Any,
|
|
@@ -652,9 +668,9 @@ class PayiInstrumentor:
|
|
|
652
668
|
sw = Stopwatch()
|
|
653
669
|
stream: bool = False
|
|
654
670
|
|
|
655
|
-
if is_streaming ==
|
|
671
|
+
if is_streaming == _IsStreaming.kwargs:
|
|
656
672
|
stream = kwargs.get("stream", False)
|
|
657
|
-
elif is_streaming ==
|
|
673
|
+
elif is_streaming == _IsStreaming.true:
|
|
658
674
|
stream = True
|
|
659
675
|
else:
|
|
660
676
|
stream = False
|
|
@@ -713,7 +729,7 @@ class PayiInstrumentor:
|
|
|
713
729
|
|
|
714
730
|
@staticmethod
|
|
715
731
|
def _update_headers(
|
|
716
|
-
context:
|
|
732
|
+
context: _Context,
|
|
717
733
|
extra_headers: "dict[str, str]",
|
|
718
734
|
) -> None:
|
|
719
735
|
limit_ids: Optional[list[str]] = context.get("limit_ids")
|
|
@@ -797,8 +813,8 @@ class PayiInstrumentor:
|
|
|
797
813
|
|
|
798
814
|
@staticmethod
|
|
799
815
|
def update_for_vision(input: int, units: 'dict[str, Units]') -> int:
|
|
800
|
-
if
|
|
801
|
-
prompt_token_estimate: int = units.pop(
|
|
816
|
+
if _PayiInstrumentor.estimated_prompt_tokens in units:
|
|
817
|
+
prompt_token_estimate: int = units.pop(_PayiInstrumentor.estimated_prompt_tokens)["input"] # type: ignore
|
|
802
818
|
vision = input - prompt_token_estimate
|
|
803
819
|
if (vision > 0):
|
|
804
820
|
units["vision"] = Units(input=vision, output=0)
|
|
@@ -843,7 +859,7 @@ class ChatStreamWrapper(ObjectProxy): # type: ignore
|
|
|
843
859
|
self,
|
|
844
860
|
response: Any,
|
|
845
861
|
instance: Any,
|
|
846
|
-
instrumentor:
|
|
862
|
+
instrumentor: _PayiInstrumentor,
|
|
847
863
|
ingest: IngestUnitsParams,
|
|
848
864
|
stopwatch: Stopwatch,
|
|
849
865
|
process_chunk: Optional[Callable[[Any, IngestUnitsParams], None]] = None,
|
|
@@ -977,13 +993,14 @@ class ChatStreamWrapper(ObjectProxy): # type: ignore
|
|
|
977
993
|
return json.dumps(chunk)
|
|
978
994
|
|
|
979
995
|
global _instrumentor
|
|
980
|
-
_instrumentor: Optional[
|
|
996
|
+
_instrumentor: Optional[_PayiInstrumentor] = None
|
|
981
997
|
|
|
982
998
|
def payi_instrument(
|
|
983
999
|
payi: Optional[Union[Payi, AsyncPayi, 'list[Union[Payi, AsyncPayi]]']] = None,
|
|
984
1000
|
instruments: Optional[Set[str]] = None,
|
|
985
1001
|
log_prompt_and_response: bool = True,
|
|
986
1002
|
prompt_and_response_logger: Optional[Callable[[str, "dict[str, str]"], None]] = None,
|
|
1003
|
+
config: Optional[PayiInstrumentConfig] = None,
|
|
987
1004
|
) -> None:
|
|
988
1005
|
global _instrumentor
|
|
989
1006
|
if _instrumentor:
|
|
@@ -1002,10 +1019,21 @@ def payi_instrument(
|
|
|
1002
1019
|
payi_param = p
|
|
1003
1020
|
elif isinstance(p, AsyncPayi): # type: ignore
|
|
1004
1021
|
apayi_param = p
|
|
1022
|
+
|
|
1023
|
+
global_context: _Context = {}
|
|
1005
1024
|
|
|
1006
|
-
|
|
1025
|
+
if config and len(config) > 0:
|
|
1026
|
+
if "proxy" not in config:
|
|
1027
|
+
config["proxy"] = False
|
|
1028
|
+
global_context = {**config}
|
|
1029
|
+
|
|
1030
|
+
# create the clients on their behalf if not provided for global ingest instrumentation
|
|
1031
|
+
if not payi_param and not apayi_param and len(global_context) > 0 and global_context.get("proxy", False):
|
|
1032
|
+
payi_param = Payi()
|
|
1033
|
+
apayi_param = AsyncPayi()
|
|
1007
1034
|
|
|
1008
|
-
|
|
1035
|
+
# allow for both payi and apayi to be None for the @proxy case
|
|
1036
|
+
_instrumentor = _PayiInstrumentor(
|
|
1009
1037
|
payi=payi_param,
|
|
1010
1038
|
apayi=apayi_param,
|
|
1011
1039
|
instruments=instruments,
|
|
@@ -1013,6 +1041,14 @@ def payi_instrument(
|
|
|
1013
1041
|
prompt_and_response_logger=prompt_and_response_logger,
|
|
1014
1042
|
)
|
|
1015
1043
|
|
|
1044
|
+
if len(global_context) > 0:
|
|
1045
|
+
if "use_case_name" in global_context and not "use_case_id" in global_context:
|
|
1046
|
+
global_context["use_case_id"] = str(uuid.uuid4())
|
|
1047
|
+
if "experience_name" in global_context and not "experience_id" in global_context:
|
|
1048
|
+
global_context["experience_id"] = str(uuid.uuid4())
|
|
1049
|
+
|
|
1050
|
+
_instrumentor._context_stack.append(global_context)
|
|
1051
|
+
|
|
1016
1052
|
def ingest(
|
|
1017
1053
|
limit_ids: Optional["list[str]"] = None,
|
|
1018
1054
|
request_tags: Optional["list[str]"] = None,
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|