payi 0.1.0a65__py3-none-any.whl → 0.1.0a66__py3-none-any.whl
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/_version.py +1 -1
- payi/lib/helpers.py +3 -0
- payi/lib/instrument.py +9 -6
- {payi-0.1.0a65.dist-info → payi-0.1.0a66.dist-info}/METADATA +1 -1
- {payi-0.1.0a65.dist-info → payi-0.1.0a66.dist-info}/RECORD +7 -7
- {payi-0.1.0a65.dist-info → payi-0.1.0a66.dist-info}/WHEEL +0 -0
- {payi-0.1.0a65.dist-info → payi-0.1.0a66.dist-info}/licenses/LICENSE +0 -0
payi/_version.py
CHANGED
payi/lib/helpers.py
CHANGED
|
@@ -50,6 +50,7 @@ def create_headers(
|
|
|
50
50
|
use_case_name: Union[str, None] = None,
|
|
51
51
|
use_case_version: Union[int, None] = None,
|
|
52
52
|
route_as_resource: Union[str, None] = None,
|
|
53
|
+
resource_scope: Union[str, None] = None,
|
|
53
54
|
) -> Dict[str, str]:
|
|
54
55
|
headers: Dict[str, str] = {}
|
|
55
56
|
|
|
@@ -71,6 +72,8 @@ def create_headers(
|
|
|
71
72
|
headers.update({ PayiHeaderNames.use_case_version: str(use_case_version)})
|
|
72
73
|
if route_as_resource:
|
|
73
74
|
headers.update({ PayiHeaderNames.route_as_resource: route_as_resource})
|
|
75
|
+
if resource_scope:
|
|
76
|
+
headers.update({ PayiHeaderNames.resource_scope: resource_scope })
|
|
74
77
|
return headers
|
|
75
78
|
|
|
76
79
|
def _resolve_payi_base_url(payi_base_url: Union[str, None]) -> str:
|
payi/lib/instrument.py
CHANGED
|
@@ -6,6 +6,7 @@ import logging
|
|
|
6
6
|
import traceback
|
|
7
7
|
from enum import Enum
|
|
8
8
|
from typing import Any, Set, Union, Callable, Optional, TypedDict
|
|
9
|
+
from datetime import datetime, timezone
|
|
9
10
|
|
|
10
11
|
import nest_asyncio # type: ignore
|
|
11
12
|
from wrapt import ObjectProxy # type: ignore
|
|
@@ -38,7 +39,7 @@ class _ProviderRequest:
|
|
|
38
39
|
|
|
39
40
|
class PayiInstrumentConfig(TypedDict, total=False):
|
|
40
41
|
proxy: bool
|
|
41
|
-
|
|
42
|
+
global_instrumentation: bool
|
|
42
43
|
limit_ids: Optional["list[str]"]
|
|
43
44
|
experience_name: Optional[str]
|
|
44
45
|
experience_id: Optional[str]
|
|
@@ -89,9 +90,9 @@ class _PayiInstrumentor:
|
|
|
89
90
|
else:
|
|
90
91
|
self._instrument_specific(instruments)
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
global_instrumentation = global_config.pop("global_instrumentation", True) if global_config else True
|
|
93
94
|
|
|
94
|
-
if
|
|
95
|
+
if global_instrumentation:
|
|
95
96
|
if global_config is None:
|
|
96
97
|
global_config = {}
|
|
97
98
|
if "proxy" not in global_config:
|
|
@@ -447,7 +448,7 @@ class _PayiInstrumentor:
|
|
|
447
448
|
self,
|
|
448
449
|
ingest: IngestUnitsParams,
|
|
449
450
|
ingest_extra_headers: "dict[str, str]", # do not coflict potential kwargs["extra_headers"]
|
|
450
|
-
|
|
451
|
+
kwargs: Any,
|
|
451
452
|
) -> None:
|
|
452
453
|
limit_ids = ingest_extra_headers.pop(PayiHeaderNames.limit_ids, None)
|
|
453
454
|
request_tags = ingest_extra_headers.pop(PayiHeaderNames.request_tags, None)
|
|
@@ -494,6 +495,8 @@ class _PayiInstrumentor:
|
|
|
494
495
|
if self._log_prompt_and_response:
|
|
495
496
|
ingest["provider_request_json"] = json.dumps(provider_prompt)
|
|
496
497
|
|
|
498
|
+
ingest["event_timestamp"] = datetime.now(timezone.utc)
|
|
499
|
+
|
|
497
500
|
async def achat_wrapper(
|
|
498
501
|
self,
|
|
499
502
|
category: str,
|
|
@@ -567,7 +570,7 @@ class _PayiInstrumentor:
|
|
|
567
570
|
stream = False
|
|
568
571
|
|
|
569
572
|
try:
|
|
570
|
-
self._prepare_ingest(provider._ingest, extra_headers,
|
|
573
|
+
self._prepare_ingest(provider._ingest, extra_headers, kwargs)
|
|
571
574
|
sw.start()
|
|
572
575
|
response = await wrapped(*args, **kwargs)
|
|
573
576
|
|
|
@@ -691,7 +694,7 @@ class _PayiInstrumentor:
|
|
|
691
694
|
stream = False
|
|
692
695
|
|
|
693
696
|
try:
|
|
694
|
-
self._prepare_ingest(provider._ingest, extra_headers,
|
|
697
|
+
self._prepare_ingest(provider._ingest, extra_headers, kwargs)
|
|
695
698
|
sw.start()
|
|
696
699
|
response = wrapped(*args, **kwargs)
|
|
697
700
|
|
|
@@ -11,7 +11,7 @@ payi/_resource.py,sha256=j2jIkTr8OIC8sU6-05nxSaCyj4MaFlbZrwlyg4_xJos,1088
|
|
|
11
11
|
payi/_response.py,sha256=CfrNS_3wbL8o9dRyRVfZQ5E1GUlA4CUIUEK8olmfGqE,28777
|
|
12
12
|
payi/_streaming.py,sha256=Z_wIyo206T6Jqh2rolFg2VXZgX24PahLmpURp0-NssU,10092
|
|
13
13
|
payi/_types.py,sha256=2mbMK86K3W1aMTW7sOGQ-VND6-A2IuXKm8p4sYFztBU,6141
|
|
14
|
-
payi/_version.py,sha256=
|
|
14
|
+
payi/_version.py,sha256=77vTya8M6fJti_3rBW5AsXnf12UvkIi7HHixVB3nD24,165
|
|
15
15
|
payi/pagination.py,sha256=k2356QGPOUSjRF2vHpwLBdF6P-2vnQzFfRIJQAHGQ7A,1258
|
|
16
16
|
payi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
payi/_utils/__init__.py,sha256=PNZ_QJuzZEgyYXqkO1HVhGkj5IU9bglVUcw7H-Knjzw,2062
|
|
@@ -28,8 +28,8 @@ payi/lib/AnthropicInstrumentor.py,sha256=OivTBeTnwVYDaaoGDj2V77JmjEb2aKQ6Se295VA
|
|
|
28
28
|
payi/lib/BedrockInstrumentor.py,sha256=CDfZ_IDEuQ2PrLcmtKGOX69sPhiKqKNIoZ2c0W0mIR8,10595
|
|
29
29
|
payi/lib/OpenAIInstrumentor.py,sha256=_LV_IqWBAqvBlzbYQHolVmGioTn60-zUkNgp179rIFk,8305
|
|
30
30
|
payi/lib/Stopwatch.py,sha256=7OJlxvr2Jyb6Zr1LYCYKczRB7rDVKkIR7gc4YoleNdE,764
|
|
31
|
-
payi/lib/helpers.py,sha256=
|
|
32
|
-
payi/lib/instrument.py,sha256=
|
|
31
|
+
payi/lib/helpers.py,sha256=ar9so8_sJaEV_Ned-XvCl-JTe5cRoYlL9JQJwp4ZvyQ,3973
|
|
32
|
+
payi/lib/instrument.py,sha256=879NVtiGSbaumaLFAWBurKMR81NPMHKUMBflB7dEEzY,43153
|
|
33
33
|
payi/resources/__init__.py,sha256=1rtrPLWbNt8oJGOp6nwPumKLJ-ftez0B6qwLFyfcoP4,2972
|
|
34
34
|
payi/resources/ingest.py,sha256=ifKMKylIkfCF-uGFPttr_VG3vWxsqntOOBrrU4_g1zk,21627
|
|
35
35
|
payi/resources/categories/__init__.py,sha256=w5gMiPdBSzJA_qfoVtFBElaoe8wGf_O63R7R1Spr6Gk,1093
|
|
@@ -135,7 +135,7 @@ payi/types/use_cases/definitions/kpi_retrieve_response.py,sha256=uQXliSvS3k-yDYw
|
|
|
135
135
|
payi/types/use_cases/definitions/kpi_update_params.py,sha256=jbawdWAdMnsTWVH0qfQGb8W7_TXe3lq4zjSRu44d8p8,373
|
|
136
136
|
payi/types/use_cases/definitions/kpi_update_response.py,sha256=zLyEoT0S8d7XHsnXZYT8tM7yDw0Aze0Mk-_Z6QeMtc8,459
|
|
137
137
|
payi/types/use_cases/definitions/limit_config_create_params.py,sha256=pzQza_16N3z8cFNEKr6gPbFvuGFrwNuGxAYb--Kbo2M,449
|
|
138
|
-
payi-0.1.
|
|
139
|
-
payi-0.1.
|
|
140
|
-
payi-0.1.
|
|
141
|
-
payi-0.1.
|
|
138
|
+
payi-0.1.0a66.dist-info/METADATA,sha256=TdtcpW-1Tv0gvxyq4EBdXLCKZ2A_lSolRCvabKP9F3Q,15290
|
|
139
|
+
payi-0.1.0a66.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
140
|
+
payi-0.1.0a66.dist-info/licenses/LICENSE,sha256=CQt03aM-P4a3Yg5qBg3JSLVoQS3smMyvx7tYg_6V7Gk,11334
|
|
141
|
+
payi-0.1.0a66.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|