payi 0.1.0a45__tar.gz → 0.1.0a47__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.

Files changed (169) hide show
  1. payi-0.1.0a47/.release-please-manifest.json +3 -0
  2. {payi-0.1.0a45 → payi-0.1.0a47}/CHANGELOG.md +17 -0
  3. {payi-0.1.0a45 → payi-0.1.0a47}/PKG-INFO +1 -1
  4. {payi-0.1.0a45 → payi-0.1.0a47}/pyproject.toml +1 -1
  5. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_version.py +1 -1
  6. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/lib/OpenAIInstrumentor.py +59 -5
  7. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/lib/helpers.py +14 -6
  8. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/lib/instrument.py +50 -30
  9. payi-0.1.0a45/.release-please-manifest.json +0 -3
  10. {payi-0.1.0a45 → payi-0.1.0a47}/.gitignore +0 -0
  11. {payi-0.1.0a45 → payi-0.1.0a47}/CONTRIBUTING.md +0 -0
  12. {payi-0.1.0a45 → payi-0.1.0a47}/LICENSE +0 -0
  13. {payi-0.1.0a45 → payi-0.1.0a47}/README.md +0 -0
  14. {payi-0.1.0a45 → payi-0.1.0a47}/SECURITY.md +0 -0
  15. {payi-0.1.0a45 → payi-0.1.0a47}/api.md +0 -0
  16. {payi-0.1.0a45 → payi-0.1.0a47}/bin/check-release-environment +0 -0
  17. {payi-0.1.0a45 → payi-0.1.0a47}/bin/publish-pypi +0 -0
  18. {payi-0.1.0a45 → payi-0.1.0a47}/examples/.keep +0 -0
  19. {payi-0.1.0a45 → payi-0.1.0a47}/mypy.ini +0 -0
  20. {payi-0.1.0a45 → payi-0.1.0a47}/noxfile.py +0 -0
  21. {payi-0.1.0a45 → payi-0.1.0a47}/release-please-config.json +0 -0
  22. {payi-0.1.0a45 → payi-0.1.0a47}/requirements-dev.lock +0 -0
  23. {payi-0.1.0a45 → payi-0.1.0a47}/requirements.lock +0 -0
  24. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/__init__.py +0 -0
  25. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_base_client.py +0 -0
  26. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_client.py +0 -0
  27. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_compat.py +0 -0
  28. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_constants.py +0 -0
  29. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_exceptions.py +0 -0
  30. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_files.py +0 -0
  31. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_models.py +0 -0
  32. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_qs.py +0 -0
  33. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_resource.py +0 -0
  34. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_response.py +0 -0
  35. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_streaming.py +0 -0
  36. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_types.py +0 -0
  37. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_utils/__init__.py +0 -0
  38. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_utils/_logs.py +0 -0
  39. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_utils/_proxy.py +0 -0
  40. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_utils/_reflection.py +0 -0
  41. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_utils/_streams.py +0 -0
  42. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_utils/_sync.py +0 -0
  43. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_utils/_transform.py +0 -0
  44. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_utils/_typing.py +0 -0
  45. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/_utils/_utils.py +0 -0
  46. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/lib/.keep +0 -0
  47. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/lib/AnthropicInstrumentor.py +0 -0
  48. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/lib/BedrockInstrumentor.py +0 -0
  49. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/lib/Instruments.py +0 -0
  50. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/lib/Stopwatch.py +0 -0
  51. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/py.typed +0 -0
  52. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/__init__.py +0 -0
  53. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/billing_models.py +0 -0
  54. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/categories/__init__.py +0 -0
  55. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/categories/categories.py +0 -0
  56. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/categories/resources.py +0 -0
  57. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/experiences/__init__.py +0 -0
  58. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/experiences/experiences.py +0 -0
  59. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/experiences/properties.py +0 -0
  60. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/experiences/types/__init__.py +0 -0
  61. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/experiences/types/limit_config.py +0 -0
  62. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/experiences/types/types.py +0 -0
  63. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/ingest.py +0 -0
  64. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/limits/__init__.py +0 -0
  65. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/limits/limits.py +0 -0
  66. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/limits/tags.py +0 -0
  67. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/price_modifiers.py +0 -0
  68. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/requests/__init__.py +0 -0
  69. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/requests/properties.py +0 -0
  70. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/requests/requests.py +0 -0
  71. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/resources/requests/result.py +0 -0
  72. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/__init__.py +0 -0
  73. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/billing_model.py +0 -0
  74. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/billing_model_create_params.py +0 -0
  75. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/billing_model_list_response.py +0 -0
  76. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/billing_model_update_params.py +0 -0
  77. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/bulk_ingest_response.py +0 -0
  78. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/categories/__init__.py +0 -0
  79. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/categories/resource_create_params.py +0 -0
  80. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/categories/resource_list_response.py +0 -0
  81. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/category_delete_resource_response.py +0 -0
  82. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/category_delete_response.py +0 -0
  83. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/category_list_resources_response.py +0 -0
  84. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/category_list_response.py +0 -0
  85. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/category_resource_response.py +0 -0
  86. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/category_response.py +0 -0
  87. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/cost_data.py +0 -0
  88. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/cost_details.py +0 -0
  89. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/default_response.py +0 -0
  90. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experience_instance_response.py +0 -0
  91. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/__init__.py +0 -0
  92. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/experience_type.py +0 -0
  93. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/properties_response.py +0 -0
  94. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/property_create_params.py +0 -0
  95. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/type_create_params.py +0 -0
  96. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/type_list_params.py +0 -0
  97. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/type_list_response.py +0 -0
  98. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/type_update_params.py +0 -0
  99. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/types/__init__.py +0 -0
  100. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/experiences/types/limit_config_create_params.py +0 -0
  101. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/ingest_bulk_params.py +0 -0
  102. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/ingest_event_param.py +0 -0
  103. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/ingest_response.py +0 -0
  104. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/ingest_units_params.py +0 -0
  105. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limit_create_params.py +0 -0
  106. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limit_history_response.py +0 -0
  107. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limit_list_params.py +0 -0
  108. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limit_reset_params.py +0 -0
  109. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limit_response.py +0 -0
  110. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limit_update_params.py +0 -0
  111. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/__init__.py +0 -0
  112. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/limit_tags.py +0 -0
  113. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/tag_create_params.py +0 -0
  114. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/tag_create_response.py +0 -0
  115. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/tag_delete_response.py +0 -0
  116. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/tag_list_response.py +0 -0
  117. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/tag_remove_params.py +0 -0
  118. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/tag_remove_response.py +0 -0
  119. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/tag_update_params.py +0 -0
  120. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/limits/tag_update_response.py +0 -0
  121. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/paged_limit_list.py +0 -0
  122. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/pay_i_common_models_api_router_header_info_param.py +0 -0
  123. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/price_modifier.py +0 -0
  124. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/price_modifier_create_params.py +0 -0
  125. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/price_modifier_retrieve_response.py +0 -0
  126. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/price_modifier_update_params.py +0 -0
  127. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/requests/__init__.py +0 -0
  128. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/requests/property_create_params.py +0 -0
  129. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/requests/request_result.py +0 -0
  130. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/requests_data.py +0 -0
  131. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/shared/__init__.py +0 -0
  132. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/shared/evaluation_response.py +0 -0
  133. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/shared/pay_i_common_models_budget_management_cost_details_base.py +0 -0
  134. {payi-0.1.0a45 → payi-0.1.0a47}/src/payi/types/total_cost_data.py +0 -0
  135. {payi-0.1.0a45 → payi-0.1.0a47}/tests/__init__.py +0 -0
  136. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/__init__.py +0 -0
  137. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/categories/__init__.py +0 -0
  138. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/categories/test_resources.py +0 -0
  139. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/experiences/__init__.py +0 -0
  140. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/experiences/test_properties.py +0 -0
  141. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/experiences/test_types.py +0 -0
  142. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/experiences/types/__init__.py +0 -0
  143. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/experiences/types/test_limit_config.py +0 -0
  144. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/limits/__init__.py +0 -0
  145. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/limits/test_tags.py +0 -0
  146. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/requests/__init__.py +0 -0
  147. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/requests/test_properties.py +0 -0
  148. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/requests/test_result.py +0 -0
  149. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/test_billing_models.py +0 -0
  150. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/test_categories.py +0 -0
  151. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/test_experiences.py +0 -0
  152. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/test_ingest.py +0 -0
  153. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/test_limits.py +0 -0
  154. {payi-0.1.0a45 → payi-0.1.0a47}/tests/api_resources/test_price_modifiers.py +0 -0
  155. {payi-0.1.0a45 → payi-0.1.0a47}/tests/conftest.py +0 -0
  156. {payi-0.1.0a45 → payi-0.1.0a47}/tests/sample_file.txt +0 -0
  157. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_client.py +0 -0
  158. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_deepcopy.py +0 -0
  159. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_extract_files.py +0 -0
  160. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_files.py +0 -0
  161. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_models.py +0 -0
  162. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_qs.py +0 -0
  163. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_required_args.py +0 -0
  164. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_response.py +0 -0
  165. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_streaming.py +0 -0
  166. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_transform.py +0 -0
  167. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_utils/test_proxy.py +0 -0
  168. {payi-0.1.0a45 → payi-0.1.0a47}/tests/test_utils/test_typing.py +0 -0
  169. {payi-0.1.0a45 → payi-0.1.0a47}/tests/utils.py +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.1.0-alpha.47"
3
+ }
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0-alpha.47 (2025-02-08)
4
+
5
+ Full Changelog: [v0.1.0-alpha.46...v0.1.0-alpha.47](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.46...v0.1.0-alpha.47)
6
+
7
+ ### Features
8
+
9
+ * chore: single header names declaration ([e4f634c](https://github.com/Pay-i/pay-i-python/commit/e4f634ce5c903133278aeb29cb1a98262bcd3e0f))
10
+ * fix linter ([912b631](https://github.com/Pay-i/pay-i-python/commit/912b6314aaa4075a79aeb378aeb9e93fff47019e))
11
+
12
+ ## 0.1.0-alpha.46 (2025-02-06)
13
+
14
+ Full Changelog: [v0.1.0-alpha.45...v0.1.0-alpha.46](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.45...v0.1.0-alpha.46)
15
+
16
+ ### Features
17
+
18
+ * feat: OpenAI embeddings instrumentation ([8649277](https://github.com/Pay-i/pay-i-python/commit/864927729c11c54b4505123ee9c8c3ac6fec2304))
19
+
3
20
  ## 0.1.0-alpha.45 (2025-02-06)
4
21
 
5
22
  Full Changelog: [v0.1.0-alpha.44...v0.1.0-alpha.45](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.44...v0.1.0-alpha.45)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: payi
3
- Version: 0.1.0a45
3
+ Version: 0.1.0a47
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "payi"
3
- version = "0.1.0-alpha.45"
3
+ version = "0.1.0-alpha.47"
4
4
  description = "The official Python library for the payi API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "payi"
4
- __version__ = "0.1.0-alpha.45" # x-release-please-version
4
+ __version__ = "0.1.0-alpha.47" # x-release-please-version
@@ -23,7 +23,7 @@ class OpenAiInstrumentor:
23
23
  def instrument(instrumentor: PayiInstrumentor) -> None:
24
24
  try:
25
25
  from openai import OpenAI # type: ignore # noqa: F401 I001
26
-
26
+
27
27
  wrap_function_wrapper(
28
28
  "openai.resources.chat.completions",
29
29
  "Completions.create",
@@ -36,11 +36,63 @@ class OpenAiInstrumentor:
36
36
  achat_wrapper(instrumentor),
37
37
  )
38
38
 
39
+ wrap_function_wrapper(
40
+ "openai.resources.embeddings",
41
+ "Embeddings.create",
42
+ embeddings_wrapper(instrumentor),
43
+ )
44
+
45
+ wrap_function_wrapper(
46
+ "openai.resources.embeddings",
47
+ "AsyncEmbeddings.create",
48
+ aembeddings_wrapper(instrumentor),
49
+ )
50
+
39
51
  except Exception as e:
40
52
  logging.debug(f"Error instrumenting openai: {e}")
41
53
  return
42
54
 
43
55
 
56
+ @PayiInstrumentor.payi_wrapper
57
+ def embeddings_wrapper(
58
+ instrumentor: PayiInstrumentor,
59
+ wrapped: Any,
60
+ instance: Any,
61
+ *args: Any,
62
+ **kwargs: Any,
63
+ ) -> Any:
64
+ return instrumentor.chat_wrapper(
65
+ "system.openai",
66
+ None, # process_chat_chunk,
67
+ None, # process_chat_request,
68
+ process_ebmeddings_synchronous_response,
69
+ IsStreaming.false,
70
+ wrapped,
71
+ instance,
72
+ args,
73
+ kwargs,
74
+ )
75
+
76
+ @PayiInstrumentor.payi_wrapper
77
+ async def aembeddings_wrapper(
78
+ instrumentor: PayiInstrumentor,
79
+ wrapped: Any,
80
+ instance: Any,
81
+ *args: Any,
82
+ **kwargs: Any,
83
+ ) -> Any:
84
+ return await instrumentor.achat_wrapper(
85
+ "system.openai",
86
+ None, # process_chat_chunk,
87
+ None, # process_chat_request,
88
+ process_ebmeddings_synchronous_response,
89
+ IsStreaming.false,
90
+ wrapped,
91
+ instance,
92
+ args,
93
+ kwargs,
94
+ )
95
+
44
96
  @PayiInstrumentor.payi_wrapper
45
97
  def chat_wrapper(
46
98
  instrumentor: PayiInstrumentor,
@@ -52,7 +104,7 @@ def chat_wrapper(
52
104
  return instrumentor.chat_wrapper(
53
105
  "system.openai",
54
106
  process_chat_chunk,
55
- process_request,
107
+ process_chat_request,
56
108
  process_chat_synchronous_response,
57
109
  IsStreaming.kwargs,
58
110
  wrapped,
@@ -72,7 +124,7 @@ async def achat_wrapper(
72
124
  return await instrumentor.achat_wrapper(
73
125
  "system.openai",
74
126
  process_chat_chunk,
75
- process_request,
127
+ process_chat_request,
76
128
  process_chat_synchronous_response,
77
129
  IsStreaming.kwargs,
78
130
  wrapped,
@@ -81,11 +133,13 @@ async def achat_wrapper(
81
133
  kwargs,
82
134
  )
83
135
 
136
+ def process_ebmeddings_synchronous_response(response: str, ingest: IngestUnitsParams, log_prompt_and_response: bool, **kwargs: Any) -> Any: # noqa: ARG001
137
+ return process_chat_synchronous_response(response, ingest, log_prompt_and_response, **kwargs)
84
138
 
85
139
  def process_chat_synchronous_response(response: str, ingest: IngestUnitsParams, log_prompt_and_response: bool, **kwargs: Any) -> Any: # noqa: ARG001
86
140
  response_dict = model_to_dict(response)
87
141
 
88
- add_usage_units(response_dict["usage"], ingest["units"])
142
+ add_usage_units(response_dict.get("usage", {}), ingest["units"])
89
143
 
90
144
  if log_prompt_and_response:
91
145
  ingest["provider_response_json"] = [json.dumps(response_dict)]
@@ -136,7 +190,7 @@ def has_image_and_get_texts(encoding: tiktoken.Encoding, content: Union[str, 'li
136
190
  token_count = sum(len(encoding.encode(item.get("text", ""))) for item in content if item.get("type") == "text")
137
191
  return has_image, token_count
138
192
 
139
- def process_request(ingest: IngestUnitsParams, *args: Any, **kwargs: Any) -> None: # noqa: ARG001
193
+ def process_chat_request(ingest: IngestUnitsParams, *args: Any, **kwargs: Any) -> None: # noqa: ARG001
140
194
  messages = kwargs.get("messages")
141
195
  if not messages or len(messages) == 0:
142
196
  return
@@ -1,14 +1,22 @@
1
- # Step 1: Define the new methods outside of the Payi class definition
2
1
  from typing import Dict, List, Union
3
2
 
4
3
 
4
+ class PayiHeaderNames:
5
+ limit_ids:str = "xProxy-Limit-IDs"
6
+ request_tags:str = "xProxy-Request-Tags"
7
+ experience_id:str = "xProxy-Experience-ID"
8
+ experience_name:str = "xProxy-Experience-Name"
9
+ user_id:str = "xProxy-User-ID"
10
+ route_as_resource:str = "xProxy-RouteAs-Resource"
11
+ provider_base_uri = "xProxy-Provider-BaseUri"
12
+
5
13
  def create_limit_header_from_ids(limit_ids: List[str]) -> Dict[str, str]:
6
14
  if not isinstance(limit_ids, list): # type: ignore
7
15
  raise TypeError("limit_ids must be a list")
8
16
 
9
17
  valid_ids = [id.strip() for id in limit_ids if isinstance(id, str) and id.strip()] # type: ignore
10
18
 
11
- return {"xProxy-Limit-IDs": ",".join(valid_ids)} if valid_ids else {}
19
+ return { PayiHeaderNames.limit_ids: ",".join(valid_ids) } if valid_ids else {}
12
20
 
13
21
 
14
22
  def create_request_header_from_tags(request_tags: List[str]) -> Dict[str, str]:
@@ -17,7 +25,7 @@ def create_request_header_from_tags(request_tags: List[str]) -> Dict[str, str]:
17
25
 
18
26
  valid_tags = [tag.strip() for tag in request_tags if isinstance(tag, str) and tag.strip()] # type: ignore
19
27
 
20
- return {"xProxy-Request-Tags": ",".join(valid_tags)} if valid_tags else {}
28
+ return { PayiHeaderNames.request_tags: ",".join(valid_tags) } if valid_tags else {}
21
29
 
22
30
 
23
31
  def create_headers(
@@ -34,10 +42,10 @@ def create_headers(
34
42
  if request_tags:
35
43
  headers.update(create_request_header_from_tags(request_tags))
36
44
  if user_id:
37
- headers.update({"xProxy-User-ID": user_id})
45
+ headers.update({ PayiHeaderNames.user_id: user_id})
38
46
  if experience_id:
39
- headers.update({"xProxy-Experience-Id": experience_id})
47
+ headers.update({ PayiHeaderNames.experience_id: experience_id})
40
48
  if experience_name:
41
- headers.update({"xProxy-Experience-Name": experience_name})
49
+ headers.update({ PayiHeaderNames.experience_name: experience_name})
42
50
 
43
51
  return headers
@@ -5,13 +5,14 @@ import inspect
5
5
  import logging
6
6
  import traceback
7
7
  from enum import Enum
8
- from typing import Any, Set, Union, Callable, Optional
8
+ from typing import Any, Set, Union, Callable, Optional, TypedDict
9
9
 
10
10
  import nest_asyncio # type: ignore
11
11
  from wrapt import ObjectProxy # type: ignore
12
12
 
13
13
  from payi import Payi, AsyncPayi
14
14
  from payi.types import IngestUnitsParams
15
+ from payi.lib.helpers import PayiHeaderNames
15
16
  from payi.types.ingest_response import IngestResponse
16
17
  from payi.types.ingest_units_params import Units
17
18
  from payi.types.pay_i_common_models_api_router_header_info_param import PayICommonModelsAPIRouterHeaderInfoParam
@@ -20,6 +21,14 @@ from .Stopwatch import Stopwatch
20
21
  from .Instruments import Instruments
21
22
 
22
23
 
24
+ class Context(TypedDict, total=False):
25
+ proxy: bool
26
+ experience_name: Optional[str]
27
+ experience_id: Optional[str]
28
+ limit_ids: Optional['list[str]']
29
+ request_tags: Optional['list[str]']
30
+ user_id: Optional[str]
31
+
23
32
  class IsStreaming(Enum):
24
33
  false = 0
25
34
  true = 1
@@ -40,7 +49,7 @@ class PayiInstrumentor:
40
49
  ):
41
50
  self._payi: Optional[Payi] = payi
42
51
  self._apayi: Optional[AsyncPayi] = apayi
43
- self._context_stack: list[dict[str, Any]] = [] # Stack of context dictionaries
52
+ self._context_stack: list[Context] = [] # Stack of context dictionaries
44
53
  self._log_prompt_and_response: bool = log_prompt_and_response
45
54
  self._prompt_and_response_logger: Optional[Callable[[str, dict[str, str]], None]] = prompt_and_response_logger
46
55
 
@@ -212,22 +221,23 @@ class PayiInstrumentor:
212
221
 
213
222
  def _setup_call_func(
214
223
  self
215
- ) -> 'tuple[dict[str, Any], Optional[str], Optional[str]]':
224
+ ) -> 'tuple[Context, Optional[str], Optional[str]]':
225
+ context: Context = {}
226
+
216
227
  if len(self._context_stack) > 0:
217
228
  # copy current context into the upcoming context
218
229
  context = self._context_stack[-1].copy()
219
- context.pop("proxy", None)
220
- previous_experience_name = context["experience_name"]
221
- previous_experience_id = context["experience_id"]
230
+ context.pop("proxy")
231
+ previous_experience_name = context.get("experience_name", None)
232
+ previous_experience_id = context.get("experience_id", None)
222
233
  else:
223
- context = {}
224
234
  previous_experience_name = None
225
235
  previous_experience_id = None
226
236
  return (context, previous_experience_name, previous_experience_id)
227
237
 
228
238
  def _init_context(
229
239
  self,
230
- context: "dict[str, Any]",
240
+ context: Context,
231
241
  previous_experience_name: Optional[str],
232
242
  previous_experience_id: Optional[str],
233
243
  proxy: bool,
@@ -329,12 +339,12 @@ class PayiInstrumentor:
329
339
  if self._context_stack:
330
340
  self._context_stack.pop()
331
341
 
332
- def set_context(self, context: "dict[str, Any]") -> None:
342
+ def set_context(self, context: Context) -> None:
333
343
  # Update the current top of the stack with the provided context
334
344
  if self._context_stack:
335
345
  self._context_stack[-1].update(context)
336
346
 
337
- def get_context(self) -> Optional["dict[str, Any]"]:
347
+ def get_context(self) -> Optional[Context]:
338
348
  # Return the current top of the stack
339
349
  return self._context_stack[-1] if self._context_stack else None
340
350
 
@@ -345,11 +355,11 @@ class PayiInstrumentor:
345
355
  ingest_extra_headers: "dict[str, str]", # do not coflict potential kwargs["extra_headers"]
346
356
  **kwargs: Any,
347
357
  ) -> None:
348
- limit_ids = ingest_extra_headers.pop("xProxy-Limit-IDs", None)
349
- request_tags = ingest_extra_headers.pop("xProxy-Request-Tags", None)
350
- experience_name = ingest_extra_headers.pop("xProxy-Experience-Name", None)
351
- experience_id = ingest_extra_headers.pop("xProxy-Experience-ID", None)
352
- user_id = ingest_extra_headers.pop("xProxy-User-ID", None)
358
+ limit_ids = ingest_extra_headers.pop(PayiHeaderNames.limit_ids, None)
359
+ request_tags = ingest_extra_headers.pop(PayiHeaderNames.request_tags, None)
360
+ experience_name = ingest_extra_headers.pop(PayiHeaderNames.experience_name, None)
361
+ experience_id = ingest_extra_headers.pop(PayiHeaderNames.experience_id, None)
362
+ user_id = ingest_extra_headers.pop(PayiHeaderNames.user_id, None)
353
363
 
354
364
  if limit_ids:
355
365
  ingest["limit_ids"] = limit_ids.split(",")
@@ -414,7 +424,7 @@ class PayiInstrumentor:
414
424
  from .OpenAIInstrumentor import OpenAiInstrumentor # noqa: I001
415
425
 
416
426
  if OpenAiInstrumentor.is_azure(instance):
417
- resource = extra_headers.pop("xProxy-RouteAs-Resource", None)
427
+ resource = extra_headers.pop(PayiHeaderNames.route_as_resource, None)
418
428
  if not resource:
419
429
  logging.error("Azure OpenAI route as resource not found, not ingesting")
420
430
  return await wrapped(*args, **kwargs)
@@ -532,7 +542,7 @@ class PayiInstrumentor:
532
542
  if category == "system.openai" and instance and hasattr(instance, "_client"):
533
543
  from .OpenAIInstrumentor import OpenAiInstrumentor
534
544
  if OpenAiInstrumentor.is_azure(instance):
535
- resource = extra_headers.pop("xProxy-RouteAs-Resource", None)
545
+ resource = extra_headers.pop(PayiHeaderNames.route_as_resource, None)
536
546
  if not resource:
537
547
  logging.error("Azure OpenAI route as resource not found, not ingesting")
538
548
  return wrapped(*args, **kwargs)
@@ -614,7 +624,7 @@ class PayiInstrumentor:
614
624
 
615
625
  @staticmethod
616
626
  def _update_headers(
617
- context: "dict[str, Any]",
627
+ context: Context,
618
628
  extra_headers: "dict[str, str]",
619
629
  ) -> None:
620
630
  limit_ids: Optional[list[str]] = context.get("limit_ids")
@@ -625,38 +635,48 @@ class PayiInstrumentor:
625
635
 
626
636
  # Merge limits from the decorator and extra headers
627
637
  if limit_ids is not None:
628
- existing_limit_ids = extra_headers.get("xProxy-Limit-IDs", None)
638
+ existing_limit_ids = extra_headers.get(PayiHeaderNames.limit_ids, None)
629
639
 
630
640
  if not existing_limit_ids:
631
- extra_headers["xProxy-Limit-IDs"] = ",".join(limit_ids)
641
+ extra_headers[PayiHeaderNames.limit_ids] = ",".join(limit_ids)
632
642
  else:
633
643
  existing_ids = existing_limit_ids.split(',')
634
644
  combined_ids = list(set(existing_ids + limit_ids))
635
- extra_headers["xProxy-Limit-IDs"] = ",".join(combined_ids)
645
+ extra_headers[PayiHeaderNames.limit_ids] = ",".join(combined_ids)
636
646
 
637
647
  # Merge request from the decorator and extra headers
638
648
  if request_tags is not None:
639
- existing_request_tags = extra_headers.get("xProxy-Request-Tags", None)
649
+ existing_request_tags = extra_headers.get(PayiHeaderNames.request_tags, None)
640
650
 
641
651
  if not existing_request_tags:
642
- extra_headers["xProxy-Request-Tags"] = ",".join(request_tags)
652
+ extra_headers[PayiHeaderNames.request_tags] = ",".join(request_tags)
643
653
  else:
644
654
  existing_tags = existing_request_tags.split(',')
645
655
  combined_tags = list(set(existing_tags + request_tags))
646
- extra_headers["xProxy-Request-Tags"] = ",".join(combined_tags)
656
+ extra_headers[PayiHeaderNames.request_tags] = ",".join(combined_tags)
647
657
 
648
658
  # inner extra_headers user_id takes precedence over outer decorator user_id
649
- if user_id is not None and extra_headers.get("xProxy-User-ID", None) is None:
650
- extra_headers["xProxy-User-ID"] = user_id
659
+ if user_id is not None and extra_headers.get(PayiHeaderNames.user_id, None) is None:
660
+ extra_headers[PayiHeaderNames.user_id] = user_id
651
661
 
652
662
  # inner extra_headers experience_name and experience_id take precedence over outer decorator experience_name and experience_id
653
663
  # if either inner value is specified, ignore outer decorator values
654
- if extra_headers.get("xProxy-Experience-Name", None) is None and extra_headers.get("xProxy-Experience-ID", None) is None:
655
- if experience_name is not None:
656
- extra_headers["xProxy-Experience-Name"] = experience_name
664
+ if PayiHeaderNames.experience_name not in extra_headers and PayiHeaderNames.experience_id not in extra_headers:
657
665
 
666
+ # use both decorator values
667
+ if experience_name is not None:
668
+ extra_headers[PayiHeaderNames.experience_name] = experience_name
658
669
  if experience_id is not None:
659
- extra_headers["xProxy-Experience-ID"] = experience_id
670
+ extra_headers[PayiHeaderNames.experience_id] = experience_id
671
+
672
+ elif PayiHeaderNames.experience_id in extra_headers and PayiHeaderNames.experience_name not in extra_headers:
673
+ # use the decorator experience name and the inner experience id
674
+ if experience_name is not None:
675
+ extra_headers[PayiHeaderNames.experience_name] = experience_name
676
+
677
+ else:
678
+ # use the inner experience name and id as-is
679
+ ...
660
680
 
661
681
  @staticmethod
662
682
  def update_for_vision(input: int, units: 'dict[str, Units]') -> int:
@@ -1,3 +0,0 @@
1
- {
2
- ".": "0.1.0-alpha.45"
3
- }
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
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
File without changes
File without changes
File without changes
File without changes