payi 0.1.0a34__tar.gz → 0.1.0a36__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.0a36/.release-please-manifest.json +3 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/CHANGELOG.md +47 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/PKG-INFO +12 -12
- {payi-0.1.0a34 → payi-0.1.0a36}/README.md +10 -11
- {payi-0.1.0a34 → payi-0.1.0a36}/api.md +50 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/mypy.ini +1 -1
- {payi-0.1.0a34 → payi-0.1.0a36}/pyproject.toml +5 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/requirements-dev.lock +7 -5
- {payi-0.1.0a34 → payi-0.1.0a36}/requirements.lock +4 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_base_client.py +6 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_models.py +9 -5
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_response.py +9 -3
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_version.py +1 -1
- payi-0.1.0a36/src/payi/lib/AnthropicInstrumentor.py +97 -0
- payi-0.1.0a36/src/payi/lib/Instruments.py +7 -0
- payi-0.1.0a36/src/payi/lib/OpenAIInstrumentor.py +89 -0
- payi-0.1.0a36/src/payi/lib/Stopwatch.py +27 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/lib/helpers.py +14 -9
- payi-0.1.0a36/src/payi/lib/instrument.py +514 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/billing_models.py +2 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/categories/categories.py +2 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/categories/resources.py +2 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/experiences/__init__.py +0 -14
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/experiences/experiences.py +2 -34
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/experiences/properties.py +4 -4
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/experiences/types.py +2 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/ingest.py +45 -47
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/limits/limits.py +2 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/limits/tags.py +2 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/price_modifiers.py +2 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/requests/properties.py +4 -4
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/requests/requests.py +2 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/experiences/__init__.py +0 -2
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/ingest_bulk_params.py +1 -1
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/ingest_event_param.py +18 -8
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/ingest_units_params.py +19 -8
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limit_history_response.py +1 -1
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/shared/evaluation_response.py +0 -1
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/test_ingest.py +28 -10
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_client.py +28 -17
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_models.py +10 -0
- payi-0.1.0a34/.release-please-manifest.json +0 -3
- payi-0.1.0a34/src/payi/resources/experiences/csat.py +0 -188
- payi-0.1.0a34/src/payi/types/experiences/csat_create_params.py +0 -14
- payi-0.1.0a34/src/payi/types/experiences/csat_response.py +0 -10
- payi-0.1.0a34/tests/api_resources/experiences/test_csat.py +0 -124
- {payi-0.1.0a34 → payi-0.1.0a36}/.gitignore +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/CONTRIBUTING.md +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/LICENSE +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/SECURITY.md +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/bin/check-release-environment +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/bin/publish-pypi +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/examples/.keep +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/noxfile.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/release-please-config.json +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_client.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_compat.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_constants.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_exceptions.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_files.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_qs.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_resource.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_streaming.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_types.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_utils/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_utils/_logs.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_utils/_proxy.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_utils/_reflection.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_utils/_streams.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_utils/_sync.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_utils/_transform.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_utils/_typing.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/_utils/_utils.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/lib/.keep +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/py.typed +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/categories/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/limits/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/resources/requests/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/billing_model.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/billing_model_create_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/billing_model_list_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/billing_model_update_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/bulk_ingest_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/categories/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/categories/resource_create_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/categories/resource_list_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/category_delete_resource_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/category_delete_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/category_list_resources_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/category_list_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/category_resource_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/category_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/cost_data.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/cost_details.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/default_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/experience_instance_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/experiences/experience_type.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/experiences/properties_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/experiences/property_create_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/experiences/type_create_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/experiences/type_list_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/experiences/type_list_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/experiences/type_update_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/ingest_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limit_create_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limit_list_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limit_reset_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limit_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limit_update_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/limit_tags.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/tag_create_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/tag_create_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/tag_delete_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/tag_list_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/tag_remove_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/tag_remove_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/tag_update_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/limits/tag_update_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/paged_limit_list.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/price_modifier.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/price_modifier_create_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/price_modifier_retrieve_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/price_modifier_update_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/requests/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/requests/property_create_params.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/requests_data.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/shared/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/src/payi/types/total_cost_data.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/categories/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/categories/test_resources.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/experiences/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/experiences/test_properties.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/experiences/test_types.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/limits/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/limits/test_tags.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/requests/__init__.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/requests/test_properties.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/test_billing_models.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/test_categories.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/test_experiences.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/test_limits.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/api_resources/test_price_modifiers.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/conftest.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/sample_file.txt +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_deepcopy.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_extract_files.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_files.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_qs.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_required_args.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_response.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_streaming.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_transform.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_utils/test_proxy.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/test_utils/test_typing.py +0 -0
- {payi-0.1.0a34 → payi-0.1.0a36}/tests/utils.py +0 -0
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.36 (2025-01-28)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.1.0-alpha.35...v0.1.0-alpha.36](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.35...v0.1.0-alpha.36)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* **tests:** make test_get_platform less flaky ([#181](https://github.com/Pay-i/pay-i-python/issues/181)) ([86d5b4a](https://github.com/Pay-i/pay-i-python/commit/86d5b4aa623c276776f0bdba5fa936d5408c6ab3))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Chores
|
|
13
|
+
|
|
14
|
+
* **internal:** avoid pytest-asyncio deprecation warning ([#182](https://github.com/Pay-i/pay-i-python/issues/182)) ([38bb22c](https://github.com/Pay-i/pay-i-python/commit/38bb22ca2fa0f6dd88942b4744f9b0ffee030d5c))
|
|
15
|
+
* **internal:** codegen related update ([#178](https://github.com/Pay-i/pay-i-python/issues/178)) ([315a2c5](https://github.com/Pay-i/pay-i-python/commit/315a2c576e14d51239590f3bfc53872a288559c7))
|
|
16
|
+
* **internal:** codegen related update ([#183](https://github.com/Pay-i/pay-i-python/issues/183)) ([00fdbe7](https://github.com/Pay-i/pay-i-python/commit/00fdbe791e16fa12e73e1203dd0ab02270127e27))
|
|
17
|
+
* **internal:** codegen related update ([#184](https://github.com/Pay-i/pay-i-python/issues/184)) ([bf04c0e](https://github.com/Pay-i/pay-i-python/commit/bf04c0e4707fc2218da6fa6e676fd6c2e85bff07))
|
|
18
|
+
* **internal:** codegen related update ([#185](https://github.com/Pay-i/pay-i-python/issues/185)) ([e0d7ab1](https://github.com/Pay-i/pay-i-python/commit/e0d7ab154ce6d0a60095d8740b9ba5949a37aa00))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Documentation
|
|
22
|
+
|
|
23
|
+
* **raw responses:** fix duplicate `the` ([#180](https://github.com/Pay-i/pay-i-python/issues/180)) ([ef72f36](https://github.com/Pay-i/pay-i-python/commit/ef72f367b02d8a71b6ef108a8e3544be77d5bd60))
|
|
24
|
+
|
|
25
|
+
## 0.1.0-alpha.35 (2025-01-12)
|
|
26
|
+
|
|
27
|
+
Full Changelog: [v0.1.0-alpha.34...v0.1.0-alpha.35](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.34...v0.1.0-alpha.35)
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* **api:** manual updates ([#175](https://github.com/Pay-i/pay-i-python/issues/175)) ([3dd351e](https://github.com/Pay-i/pay-i-python/commit/3dd351ecb7d7c34ce73d8a26590000fb4dc38dbc))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* **client:** only call .close() when needed ([#172](https://github.com/Pay-i/pay-i-python/issues/172)) ([75baf12](https://github.com/Pay-i/pay-i-python/commit/75baf1247d05a1b8a02fcfc4aa1342a11ef882b2))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Chores
|
|
40
|
+
|
|
41
|
+
* **internal:** bump httpx dependency ([#171](https://github.com/Pay-i/pay-i-python/issues/171)) ([e7bf93a](https://github.com/Pay-i/pay-i-python/commit/e7bf93a87ae1bec99ee4f0fd049b2e4c8f6ef68d))
|
|
42
|
+
* **internal:** codegen related update ([#169](https://github.com/Pay-i/pay-i-python/issues/169)) ([03a0803](https://github.com/Pay-i/pay-i-python/commit/03a0803e49689e31d3d7b42d2da7ed9e886434a8))
|
|
43
|
+
* **internal:** codegen related update ([#174](https://github.com/Pay-i/pay-i-python/issues/174)) ([21d0af0](https://github.com/Pay-i/pay-i-python/commit/21d0af0f6b7a15efa62f9c514681f61fa1f9ddb8))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Documentation
|
|
47
|
+
|
|
48
|
+
* fix typos ([#173](https://github.com/Pay-i/pay-i-python/issues/173)) ([3d97187](https://github.com/Pay-i/pay-i-python/commit/3d971877582257b349fa59bc83535b6cc3374c43))
|
|
49
|
+
|
|
3
50
|
## 0.1.0-alpha.34 (2025-01-06)
|
|
4
51
|
|
|
5
52
|
Full Changelog: [v0.1.0-alpha.33...v0.1.0-alpha.34](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.33...v0.1.0-alpha.34)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: payi
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0a36
|
|
4
4
|
Summary: The official Python library for the payi API
|
|
5
5
|
Project-URL: Homepage, https://github.com/Pay-i/pay-i-python
|
|
6
6
|
Project-URL: Repository, https://github.com/Pay-i/pay-i-python
|
|
@@ -28,6 +28,7 @@ Requires-Dist: httpx<1,>=0.23.0
|
|
|
28
28
|
Requires-Dist: pydantic<3,>=1.9.0
|
|
29
29
|
Requires-Dist: sniffio
|
|
30
30
|
Requires-Dist: typing-extensions<5,>=4.10
|
|
31
|
+
Requires-Dist: wrapt>=1.17.2
|
|
31
32
|
Description-Content-Type: text/markdown
|
|
32
33
|
|
|
33
34
|
# Payi Python API library
|
|
@@ -65,7 +66,7 @@ client = Payi(
|
|
|
65
66
|
|
|
66
67
|
limit_response = client.limits.create(
|
|
67
68
|
limit_name="x",
|
|
68
|
-
max=
|
|
69
|
+
max=1,
|
|
69
70
|
)
|
|
70
71
|
print(limit_response.request_id)
|
|
71
72
|
```
|
|
@@ -92,7 +93,7 @@ client = AsyncPayi(
|
|
|
92
93
|
async def main() -> None:
|
|
93
94
|
limit_response = await client.limits.create(
|
|
94
95
|
limit_name="x",
|
|
95
|
-
max=
|
|
96
|
+
max=1,
|
|
96
97
|
)
|
|
97
98
|
print(limit_response.request_id)
|
|
98
99
|
|
|
@@ -129,7 +130,7 @@ client = Payi()
|
|
|
129
130
|
try:
|
|
130
131
|
client.limits.create(
|
|
131
132
|
limit_name="x",
|
|
132
|
-
max=
|
|
133
|
+
max=1,
|
|
133
134
|
)
|
|
134
135
|
except payi.APIConnectionError as e:
|
|
135
136
|
print("The server could not be reached")
|
|
@@ -142,7 +143,7 @@ except payi.APIStatusError as e:
|
|
|
142
143
|
print(e.response)
|
|
143
144
|
```
|
|
144
145
|
|
|
145
|
-
Error codes are as
|
|
146
|
+
Error codes are as follows:
|
|
146
147
|
|
|
147
148
|
| Status Code | Error Type |
|
|
148
149
|
| ----------- | -------------------------- |
|
|
@@ -175,7 +176,7 @@ client = Payi(
|
|
|
175
176
|
# Or, configure per-request:
|
|
176
177
|
client.with_options(max_retries=5).limits.create(
|
|
177
178
|
limit_name="x",
|
|
178
|
-
max=
|
|
179
|
+
max=1,
|
|
179
180
|
)
|
|
180
181
|
```
|
|
181
182
|
|
|
@@ -201,7 +202,7 @@ client = Payi(
|
|
|
201
202
|
# Override per-request:
|
|
202
203
|
client.with_options(timeout=5.0).limits.create(
|
|
203
204
|
limit_name="x",
|
|
204
|
-
max=
|
|
205
|
+
max=1,
|
|
205
206
|
)
|
|
206
207
|
```
|
|
207
208
|
|
|
@@ -245,7 +246,7 @@ from payi import Payi
|
|
|
245
246
|
client = Payi()
|
|
246
247
|
response = client.limits.with_raw_response.create(
|
|
247
248
|
limit_name="x",
|
|
248
|
-
max=
|
|
249
|
+
max=1,
|
|
249
250
|
)
|
|
250
251
|
print(response.headers.get('X-My-Header'))
|
|
251
252
|
|
|
@@ -266,7 +267,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi
|
|
|
266
267
|
```python
|
|
267
268
|
with client.limits.with_streaming_response.create(
|
|
268
269
|
limit_name="x",
|
|
269
|
-
max=
|
|
270
|
+
max=1,
|
|
270
271
|
) as response:
|
|
271
272
|
print(response.headers.get("X-My-Header"))
|
|
272
273
|
|
|
@@ -285,8 +286,7 @@ If you need to access undocumented endpoints, params, or response properties, th
|
|
|
285
286
|
#### Undocumented endpoints
|
|
286
287
|
|
|
287
288
|
To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
|
|
288
|
-
http verbs. Options on the client will be respected (such as retries)
|
|
289
|
-
request.
|
|
289
|
+
http verbs. Options on the client will be respected (such as retries) when making this request.
|
|
290
290
|
|
|
291
291
|
```py
|
|
292
292
|
import httpx
|
|
@@ -358,7 +358,7 @@ with Payi() as client:
|
|
|
358
358
|
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
|
359
359
|
|
|
360
360
|
1. Changes that only affect static types, without breaking runtime behavior.
|
|
361
|
-
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_
|
|
361
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
362
362
|
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
363
363
|
|
|
364
364
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
@@ -33,7 +33,7 @@ client = Payi(
|
|
|
33
33
|
|
|
34
34
|
limit_response = client.limits.create(
|
|
35
35
|
limit_name="x",
|
|
36
|
-
max=
|
|
36
|
+
max=1,
|
|
37
37
|
)
|
|
38
38
|
print(limit_response.request_id)
|
|
39
39
|
```
|
|
@@ -60,7 +60,7 @@ client = AsyncPayi(
|
|
|
60
60
|
async def main() -> None:
|
|
61
61
|
limit_response = await client.limits.create(
|
|
62
62
|
limit_name="x",
|
|
63
|
-
max=
|
|
63
|
+
max=1,
|
|
64
64
|
)
|
|
65
65
|
print(limit_response.request_id)
|
|
66
66
|
|
|
@@ -97,7 +97,7 @@ client = Payi()
|
|
|
97
97
|
try:
|
|
98
98
|
client.limits.create(
|
|
99
99
|
limit_name="x",
|
|
100
|
-
max=
|
|
100
|
+
max=1,
|
|
101
101
|
)
|
|
102
102
|
except payi.APIConnectionError as e:
|
|
103
103
|
print("The server could not be reached")
|
|
@@ -110,7 +110,7 @@ except payi.APIStatusError as e:
|
|
|
110
110
|
print(e.response)
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
Error codes are as
|
|
113
|
+
Error codes are as follows:
|
|
114
114
|
|
|
115
115
|
| Status Code | Error Type |
|
|
116
116
|
| ----------- | -------------------------- |
|
|
@@ -143,7 +143,7 @@ client = Payi(
|
|
|
143
143
|
# Or, configure per-request:
|
|
144
144
|
client.with_options(max_retries=5).limits.create(
|
|
145
145
|
limit_name="x",
|
|
146
|
-
max=
|
|
146
|
+
max=1,
|
|
147
147
|
)
|
|
148
148
|
```
|
|
149
149
|
|
|
@@ -169,7 +169,7 @@ client = Payi(
|
|
|
169
169
|
# Override per-request:
|
|
170
170
|
client.with_options(timeout=5.0).limits.create(
|
|
171
171
|
limit_name="x",
|
|
172
|
-
max=
|
|
172
|
+
max=1,
|
|
173
173
|
)
|
|
174
174
|
```
|
|
175
175
|
|
|
@@ -213,7 +213,7 @@ from payi import Payi
|
|
|
213
213
|
client = Payi()
|
|
214
214
|
response = client.limits.with_raw_response.create(
|
|
215
215
|
limit_name="x",
|
|
216
|
-
max=
|
|
216
|
+
max=1,
|
|
217
217
|
)
|
|
218
218
|
print(response.headers.get('X-My-Header'))
|
|
219
219
|
|
|
@@ -234,7 +234,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi
|
|
|
234
234
|
```python
|
|
235
235
|
with client.limits.with_streaming_response.create(
|
|
236
236
|
limit_name="x",
|
|
237
|
-
max=
|
|
237
|
+
max=1,
|
|
238
238
|
) as response:
|
|
239
239
|
print(response.headers.get("X-My-Header"))
|
|
240
240
|
|
|
@@ -253,8 +253,7 @@ If you need to access undocumented endpoints, params, or response properties, th
|
|
|
253
253
|
#### Undocumented endpoints
|
|
254
254
|
|
|
255
255
|
To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
|
|
256
|
-
http verbs. Options on the client will be respected (such as retries)
|
|
257
|
-
request.
|
|
256
|
+
http verbs. Options on the client will be respected (such as retries) when making this request.
|
|
258
257
|
|
|
259
258
|
```py
|
|
260
259
|
import httpx
|
|
@@ -326,7 +325,7 @@ with Payi() as client:
|
|
|
326
325
|
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
|
327
326
|
|
|
328
327
|
1. Changes that only affect static types, without breaking runtime behavior.
|
|
329
|
-
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_
|
|
328
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
330
329
|
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
331
330
|
|
|
332
331
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
@@ -126,3 +126,53 @@ Methods:
|
|
|
126
126
|
- <code title="patch /api/v1/experiences/types/{experience_name}">client.experiences.types.<a href="./src/payi/resources/experiences/types.py">update</a>(experience_name, \*\*<a href="src/payi/types/experiences/type_update_params.py">params</a>) -> <a href="./src/payi/types/experiences/experience_type.py">ExperienceType</a></code>
|
|
127
127
|
- <code title="get /api/v1/experiences/types">client.experiences.types.<a href="./src/payi/resources/experiences/types.py">list</a>(\*\*<a href="src/payi/types/experiences/type_list_params.py">params</a>) -> <a href="./src/payi/types/experiences/type_list_response.py">TypeListResponse</a></code>
|
|
128
128
|
- <code title="delete /api/v1/experiences/types/{experience_name}">client.experiences.types.<a href="./src/payi/resources/experiences/types.py">delete</a>(experience_name) -> <a href="./src/payi/types/experiences/experience_type.py">ExperienceType</a></code>
|
|
129
|
+
|
|
130
|
+
## Properties
|
|
131
|
+
|
|
132
|
+
Types:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from payi.types.experiences import PropertiesResponse
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Methods:
|
|
139
|
+
|
|
140
|
+
- <code title="post /api/v1/experiences/instances/{experience_id}/properties">client.experiences.properties.<a href="./src/payi/resources/experiences/properties.py">create</a>(experience_id, \*\*<a href="src/payi/types/experiences/property_create_params.py">params</a>) -> <a href="./src/payi/types/experience_instance_response.py">ExperienceInstanceResponse</a></code>
|
|
141
|
+
|
|
142
|
+
# BillingModels
|
|
143
|
+
|
|
144
|
+
Types:
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from payi.types import BillingModel, BillingModelListResponse
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Methods:
|
|
151
|
+
|
|
152
|
+
- <code title="post /api/v1/billing-model">client.billing_models.<a href="./src/payi/resources/billing_models.py">create</a>(\*\*<a href="src/payi/types/billing_model_create_params.py">params</a>) -> <a href="./src/payi/types/billing_model.py">BillingModel</a></code>
|
|
153
|
+
- <code title="get /api/v1/billing-model/{billing_model_id}">client.billing_models.<a href="./src/payi/resources/billing_models.py">retrieve</a>(billing_model_id) -> <a href="./src/payi/types/billing_model.py">BillingModel</a></code>
|
|
154
|
+
- <code title="put /api/v1/billing-model/{billing_model_id}">client.billing_models.<a href="./src/payi/resources/billing_models.py">update</a>(billing_model_id, \*\*<a href="src/payi/types/billing_model_update_params.py">params</a>) -> <a href="./src/payi/types/billing_model.py">BillingModel</a></code>
|
|
155
|
+
- <code title="get /api/v1/billing-model">client.billing_models.<a href="./src/payi/resources/billing_models.py">list</a>() -> <a href="./src/payi/types/billing_model_list_response.py">BillingModelListResponse</a></code>
|
|
156
|
+
- <code title="put /api/v1/billing-model/{billing_model_id}/default">client.billing_models.<a href="./src/payi/resources/billing_models.py">set_default</a>(billing_model_id) -> <a href="./src/payi/types/billing_model.py">BillingModel</a></code>
|
|
157
|
+
|
|
158
|
+
# PriceModifiers
|
|
159
|
+
|
|
160
|
+
Types:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from payi.types import PriceModifier, PriceModifierRetrieveResponse
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Methods:
|
|
167
|
+
|
|
168
|
+
- <code title="post /api/v1/price-modifier">client.price_modifiers.<a href="./src/payi/resources/price_modifiers.py">create</a>(\*\*<a href="src/payi/types/price_modifier_create_params.py">params</a>) -> <a href="./src/payi/types/price_modifier.py">PriceModifier</a></code>
|
|
169
|
+
- <code title="get /api/v1/price-modifier/{billing_model_id}">client.price_modifiers.<a href="./src/payi/resources/price_modifiers.py">retrieve</a>(billing_model_id) -> <a href="./src/payi/types/price_modifier_retrieve_response.py">PriceModifierRetrieveResponse</a></code>
|
|
170
|
+
- <code title="put /api/v1/price-modifier">client.price_modifiers.<a href="./src/payi/resources/price_modifiers.py">update</a>(\*\*<a href="src/payi/types/price_modifier_update_params.py">params</a>) -> <a href="./src/payi/types/price_modifier.py">PriceModifier</a></code>
|
|
171
|
+
|
|
172
|
+
# Requests
|
|
173
|
+
|
|
174
|
+
## Properties
|
|
175
|
+
|
|
176
|
+
Methods:
|
|
177
|
+
|
|
178
|
+
- <code title="post /api/v1/requests/{request_id}/properties">client.requests.properties.<a href="./src/payi/resources/requests/properties.py">create</a>(request_id, \*\*<a href="src/payi/types/requests/property_create_params.py">params</a>) -> <a href="./src/payi/types/experiences/properties_response.py">PropertiesResponse</a></code>
|
|
@@ -41,7 +41,7 @@ cache_fine_grained = True
|
|
|
41
41
|
# ```
|
|
42
42
|
# Changing this codegen to make mypy happy would increase complexity
|
|
43
43
|
# and would not be worth it.
|
|
44
|
-
disable_error_code = func-returns-value
|
|
44
|
+
disable_error_code = func-returns-value,overload-cannot-match
|
|
45
45
|
|
|
46
46
|
# https://github.com/python/mypy/issues/12162
|
|
47
47
|
[mypy.overrides]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "payi"
|
|
3
|
-
version = "0.1.0-alpha.
|
|
3
|
+
version = "0.1.0-alpha.36"
|
|
4
4
|
description = "The official Python library for the payi API"
|
|
5
5
|
dynamic = ["readme"]
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -14,6 +14,7 @@ dependencies = [
|
|
|
14
14
|
"anyio>=3.5.0, <5",
|
|
15
15
|
"distro>=1.7.0, <2",
|
|
16
16
|
"sniffio",
|
|
17
|
+
"wrapt>=1.17.2",
|
|
17
18
|
]
|
|
18
19
|
requires-python = ">= 3.8"
|
|
19
20
|
classifiers = [
|
|
@@ -54,7 +55,8 @@ dev-dependencies = [
|
|
|
54
55
|
"dirty-equals>=0.6.0",
|
|
55
56
|
"importlib-metadata>=6.7.0",
|
|
56
57
|
"rich>=13.7.1",
|
|
57
|
-
"nest_asyncio==1.6.0"
|
|
58
|
+
"nest_asyncio==1.6.0",
|
|
59
|
+
"wrapt",
|
|
58
60
|
]
|
|
59
61
|
|
|
60
62
|
[tool.rye.scripts]
|
|
@@ -129,6 +131,7 @@ testpaths = ["tests"]
|
|
|
129
131
|
addopts = "--tb=short"
|
|
130
132
|
xfail_strict = true
|
|
131
133
|
asyncio_mode = "auto"
|
|
134
|
+
asyncio_default_fixture_loop_scope = "session"
|
|
132
135
|
filterwarnings = [
|
|
133
136
|
"error"
|
|
134
137
|
]
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
# all-features: true
|
|
8
8
|
# with-sources: false
|
|
9
9
|
# generate-hashes: false
|
|
10
|
+
# universal: false
|
|
10
11
|
|
|
11
12
|
-e file:.
|
|
12
13
|
annotated-types==0.6.0
|
|
@@ -35,7 +36,7 @@ h11==0.14.0
|
|
|
35
36
|
# via httpcore
|
|
36
37
|
httpcore==1.0.2
|
|
37
38
|
# via httpx
|
|
38
|
-
httpx==0.
|
|
39
|
+
httpx==0.28.1
|
|
39
40
|
# via payi
|
|
40
41
|
# via respx
|
|
41
42
|
idna==3.4
|
|
@@ -48,7 +49,7 @@ markdown-it-py==3.0.0
|
|
|
48
49
|
# via rich
|
|
49
50
|
mdurl==0.1.2
|
|
50
51
|
# via markdown-it-py
|
|
51
|
-
mypy==1.
|
|
52
|
+
mypy==1.14.1
|
|
52
53
|
mypy-extensions==1.0.0
|
|
53
54
|
# via mypy
|
|
54
55
|
nest-asyncio==1.6.0
|
|
@@ -68,7 +69,7 @@ pydantic-core==2.27.1
|
|
|
68
69
|
# via pydantic
|
|
69
70
|
pygments==2.18.0
|
|
70
71
|
# via rich
|
|
71
|
-
pyright==1.1.
|
|
72
|
+
pyright==1.1.392.post0
|
|
72
73
|
pytest==8.3.3
|
|
73
74
|
# via pytest-asyncio
|
|
74
75
|
pytest-asyncio==0.24.0
|
|
@@ -76,7 +77,7 @@ python-dateutil==2.8.2
|
|
|
76
77
|
# via time-machine
|
|
77
78
|
pytz==2023.3.post1
|
|
78
79
|
# via dirty-equals
|
|
79
|
-
respx==0.
|
|
80
|
+
respx==0.22.0
|
|
80
81
|
rich==13.7.1
|
|
81
82
|
ruff==0.6.9
|
|
82
83
|
setuptools==68.2.2
|
|
@@ -85,7 +86,6 @@ six==1.16.0
|
|
|
85
86
|
# via python-dateutil
|
|
86
87
|
sniffio==1.3.0
|
|
87
88
|
# via anyio
|
|
88
|
-
# via httpx
|
|
89
89
|
# via payi
|
|
90
90
|
time-machine==2.9.0
|
|
91
91
|
tomli==2.0.2
|
|
@@ -100,5 +100,7 @@ typing-extensions==4.12.2
|
|
|
100
100
|
# via pyright
|
|
101
101
|
virtualenv==20.24.5
|
|
102
102
|
# via nox
|
|
103
|
+
wrapt==1.17.2
|
|
104
|
+
# via payi
|
|
103
105
|
zipp==3.17.0
|
|
104
106
|
# via importlib-metadata
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
# all-features: true
|
|
8
8
|
# with-sources: false
|
|
9
9
|
# generate-hashes: false
|
|
10
|
+
# universal: false
|
|
10
11
|
|
|
11
12
|
-e file:.
|
|
12
13
|
annotated-types==0.6.0
|
|
@@ -25,7 +26,7 @@ h11==0.14.0
|
|
|
25
26
|
# via httpcore
|
|
26
27
|
httpcore==1.0.2
|
|
27
28
|
# via httpx
|
|
28
|
-
httpx==0.
|
|
29
|
+
httpx==0.28.1
|
|
29
30
|
# via payi
|
|
30
31
|
idna==3.4
|
|
31
32
|
# via anyio
|
|
@@ -36,10 +37,11 @@ pydantic-core==2.27.1
|
|
|
36
37
|
# via pydantic
|
|
37
38
|
sniffio==1.3.0
|
|
38
39
|
# via anyio
|
|
39
|
-
# via httpx
|
|
40
40
|
# via payi
|
|
41
41
|
typing-extensions==4.12.2
|
|
42
42
|
# via anyio
|
|
43
43
|
# via payi
|
|
44
44
|
# via pydantic
|
|
45
45
|
# via pydantic-core
|
|
46
|
+
wrapt==1.17.2
|
|
47
|
+
# via payi
|
|
@@ -767,6 +767,9 @@ else:
|
|
|
767
767
|
|
|
768
768
|
class SyncHttpxClientWrapper(DefaultHttpxClient):
|
|
769
769
|
def __del__(self) -> None:
|
|
770
|
+
if self.is_closed:
|
|
771
|
+
return
|
|
772
|
+
|
|
770
773
|
try:
|
|
771
774
|
self.close()
|
|
772
775
|
except Exception:
|
|
@@ -1334,6 +1337,9 @@ else:
|
|
|
1334
1337
|
|
|
1335
1338
|
class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
|
|
1336
1339
|
def __del__(self) -> None:
|
|
1340
|
+
if self.is_closed:
|
|
1341
|
+
return
|
|
1342
|
+
|
|
1337
1343
|
try:
|
|
1338
1344
|
# TODO(someday): support non asyncio runtimes here
|
|
1339
1345
|
asyncio.get_running_loop().create_task(self.aclose())
|
|
@@ -179,14 +179,14 @@ class BaseModel(pydantic.BaseModel):
|
|
|
179
179
|
@classmethod
|
|
180
180
|
@override
|
|
181
181
|
def construct( # pyright: ignore[reportIncompatibleMethodOverride]
|
|
182
|
-
|
|
182
|
+
__cls: Type[ModelT],
|
|
183
183
|
_fields_set: set[str] | None = None,
|
|
184
184
|
**values: object,
|
|
185
185
|
) -> ModelT:
|
|
186
|
-
m =
|
|
186
|
+
m = __cls.__new__(__cls)
|
|
187
187
|
fields_values: dict[str, object] = {}
|
|
188
188
|
|
|
189
|
-
config = get_model_config(
|
|
189
|
+
config = get_model_config(__cls)
|
|
190
190
|
populate_by_name = (
|
|
191
191
|
config.allow_population_by_field_name
|
|
192
192
|
if isinstance(config, _ConfigProtocol)
|
|
@@ -196,7 +196,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
196
196
|
if _fields_set is None:
|
|
197
197
|
_fields_set = set()
|
|
198
198
|
|
|
199
|
-
model_fields = get_model_fields(
|
|
199
|
+
model_fields = get_model_fields(__cls)
|
|
200
200
|
for name, field in model_fields.items():
|
|
201
201
|
key = field.alias
|
|
202
202
|
if key is None or (key not in values and populate_by_name):
|
|
@@ -488,7 +488,11 @@ def construct_type(*, value: object, type_: object) -> object:
|
|
|
488
488
|
_, items_type = get_args(type_) # Dict[_, items_type]
|
|
489
489
|
return {key: construct_type(value=item, type_=items_type) for key, item in value.items()}
|
|
490
490
|
|
|
491
|
-
if
|
|
491
|
+
if (
|
|
492
|
+
not is_literal_type(type_)
|
|
493
|
+
and inspect.isclass(origin)
|
|
494
|
+
and (issubclass(origin, BaseModel) or issubclass(origin, GenericModel))
|
|
495
|
+
):
|
|
492
496
|
if is_list(value):
|
|
493
497
|
return [cast(Any, type_).construct(**entry) if is_mapping(entry) else entry for entry in value]
|
|
494
498
|
|
|
@@ -136,6 +136,8 @@ class BaseAPIResponse(Generic[R]):
|
|
|
136
136
|
if cast_to and is_annotated_type(cast_to):
|
|
137
137
|
cast_to = extract_type_arg(cast_to, 0)
|
|
138
138
|
|
|
139
|
+
origin = get_origin(cast_to) or cast_to
|
|
140
|
+
|
|
139
141
|
if self._is_sse_stream:
|
|
140
142
|
if to:
|
|
141
143
|
if not is_stream_class_type(to):
|
|
@@ -195,8 +197,6 @@ class BaseAPIResponse(Generic[R]):
|
|
|
195
197
|
if cast_to == bool:
|
|
196
198
|
return cast(R, response.text.lower() == "true")
|
|
197
199
|
|
|
198
|
-
origin = get_origin(cast_to) or cast_to
|
|
199
|
-
|
|
200
200
|
if origin == APIResponse:
|
|
201
201
|
raise RuntimeError("Unexpected state - cast_to is `APIResponse`")
|
|
202
202
|
|
|
@@ -210,7 +210,13 @@ class BaseAPIResponse(Generic[R]):
|
|
|
210
210
|
raise ValueError(f"Subclasses of httpx.Response cannot be passed to `cast_to`")
|
|
211
211
|
return cast(R, response)
|
|
212
212
|
|
|
213
|
-
if
|
|
213
|
+
if (
|
|
214
|
+
inspect.isclass(
|
|
215
|
+
origin # pyright: ignore[reportUnknownArgumentType]
|
|
216
|
+
)
|
|
217
|
+
and not issubclass(origin, BaseModel)
|
|
218
|
+
and issubclass(origin, pydantic.BaseModel)
|
|
219
|
+
):
|
|
214
220
|
raise TypeError("Pydantic models must subclass our base model type, e.g. `from payi import BaseModel`")
|
|
215
221
|
|
|
216
222
|
if (
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from wrapt import wrap_function_wrapper # type: ignore
|
|
5
|
+
|
|
6
|
+
from payi.types import IngestUnitsParams
|
|
7
|
+
from payi.types.ingest_units_params import Units
|
|
8
|
+
|
|
9
|
+
from .instrument import PayiInstrumentor
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AnthropicIntrumentor:
|
|
13
|
+
@staticmethod
|
|
14
|
+
def instrument(instrumentor: PayiInstrumentor) -> None:
|
|
15
|
+
try:
|
|
16
|
+
import anthropic # type: ignore # noqa: F401 I001
|
|
17
|
+
|
|
18
|
+
# wrap_function_wrapper(
|
|
19
|
+
# "anthropic.resources.completions",
|
|
20
|
+
# "Completions.create",
|
|
21
|
+
# chat_wrapper(instrumentor),
|
|
22
|
+
# )
|
|
23
|
+
|
|
24
|
+
wrap_function_wrapper(
|
|
25
|
+
"anthropic.resources.messages",
|
|
26
|
+
"Messages.create",
|
|
27
|
+
chat_wrapper(instrumentor),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
wrap_function_wrapper(
|
|
31
|
+
"anthropic.resources.messages",
|
|
32
|
+
"Messages.stream",
|
|
33
|
+
chat_wrapper(instrumentor),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
except Exception as e:
|
|
37
|
+
logging.debug(f"Error instrumenting anthropic: {e}")
|
|
38
|
+
return
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@PayiInstrumentor.payi_wrapper
|
|
42
|
+
def chat_wrapper(
|
|
43
|
+
instrumentor: PayiInstrumentor,
|
|
44
|
+
wrapped: Any,
|
|
45
|
+
instance: Any,
|
|
46
|
+
args: Any,
|
|
47
|
+
kwargs: Any,
|
|
48
|
+
) -> Any:
|
|
49
|
+
return instrumentor.chat_wrapper(
|
|
50
|
+
"system.anthropic",
|
|
51
|
+
process_chunk,
|
|
52
|
+
process_synchronous_response,
|
|
53
|
+
wrapped,
|
|
54
|
+
instance,
|
|
55
|
+
args,
|
|
56
|
+
kwargs,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def process_chunk(chunk: Any, ingest: IngestUnitsParams) -> None:
|
|
61
|
+
if chunk.type == "message_start":
|
|
62
|
+
usage = chunk.message.usage
|
|
63
|
+
units = ingest["units"]
|
|
64
|
+
|
|
65
|
+
units["text"] = Units(input=usage.input_tokens, output=0)
|
|
66
|
+
|
|
67
|
+
if hasattr(usage, "cache_creation_input_tokens") and usage.cache_creation_input_tokens > 0:
|
|
68
|
+
text_cache_write = usage.cache_creation_input_tokens
|
|
69
|
+
units["text_cache_write"] = Units(input=text_cache_write, output=0)
|
|
70
|
+
|
|
71
|
+
if hasattr(usage, "cache_read_input_tokens") and usage.cache_read_input_tokens > 0:
|
|
72
|
+
text_cache_read = usage.cache_read_input_tokens
|
|
73
|
+
units["text_cache_read"] = Units(input=text_cache_read, output=0)
|
|
74
|
+
|
|
75
|
+
elif chunk.type == "message_delta":
|
|
76
|
+
usage = chunk.usage
|
|
77
|
+
ingest["units"]["text"]["output"] = usage.output_tokens
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def process_synchronous_response(response: Any, ingest: IngestUnitsParams, log_prompt_and_response: bool) -> None:
|
|
81
|
+
usage = response.usage
|
|
82
|
+
input = usage.input_tokens
|
|
83
|
+
ouptut = usage.output_tokens
|
|
84
|
+
units: dict[str, Units] = ingest["units"]
|
|
85
|
+
|
|
86
|
+
if hasattr(usage, "cache_creation_input_tokens") and usage.cache_creation_input_tokens > 0:
|
|
87
|
+
text_cache_write = usage.cache_creation_input_tokens
|
|
88
|
+
units["text_cache_write"] = Units(input=text_cache_write, output=0)
|
|
89
|
+
|
|
90
|
+
if hasattr(usage, "cache_read_input_tokens") and usage.cache_read_input_tokens > 0:
|
|
91
|
+
text_cache_read = usage.cache_read_input_tokens
|
|
92
|
+
units["text_cache_read"] = Units(input=text_cache_read, output=0)
|
|
93
|
+
|
|
94
|
+
units["text"] = Units(input=input, output=ouptut)
|
|
95
|
+
|
|
96
|
+
if log_prompt_and_response:
|
|
97
|
+
ingest["provider_response_json"] = response.to_json()
|