payi 0.1.0a61__py3-none-any.whl → 0.1.0a63__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/instrument.py +21 -20
- {payi-0.1.0a61.dist-info → payi-0.1.0a63.dist-info}/METADATA +1 -1
- {payi-0.1.0a61.dist-info → payi-0.1.0a63.dist-info}/RECORD +6 -6
- {payi-0.1.0a61.dist-info → payi-0.1.0a63.dist-info}/WHEEL +0 -0
- {payi-0.1.0a61.dist-info → payi-0.1.0a63.dist-info}/licenses/LICENSE +0 -0
payi/_version.py
CHANGED
payi/lib/instrument.py
CHANGED
|
@@ -69,14 +69,11 @@ class _PayiInstrumentor:
|
|
|
69
69
|
prompt_and_response_logger: Optional[
|
|
70
70
|
Callable[[str, "dict[str, str]"], None]
|
|
71
71
|
] = None, # (request id, dict of data to store) -> None
|
|
72
|
+
global_config: Optional[PayiInstrumentConfig] = None,
|
|
72
73
|
):
|
|
73
74
|
self._payi: Optional[Payi] = payi
|
|
74
75
|
self._apayi: Optional[AsyncPayi] = apayi
|
|
75
76
|
|
|
76
|
-
if not self._payi and not self._apayi:
|
|
77
|
-
self._payi = Payi()
|
|
78
|
-
self._apayi = AsyncPayi()
|
|
79
|
-
|
|
80
77
|
self._context_stack: list[_Context] = [] # Stack of context dictionaries
|
|
81
78
|
self._log_prompt_and_response: bool = log_prompt_and_response
|
|
82
79
|
self._prompt_and_response_logger: Optional[Callable[[str, dict[str, str]], None]] = prompt_and_response_logger
|
|
@@ -89,6 +86,12 @@ class _PayiInstrumentor:
|
|
|
89
86
|
else:
|
|
90
87
|
self._instrument_specific(instruments)
|
|
91
88
|
|
|
89
|
+
if global_config and len(global_config) > 0:
|
|
90
|
+
context: _Context = {}
|
|
91
|
+
self._context_stack.append(context)
|
|
92
|
+
# init_context will update the currrent context stack location
|
|
93
|
+
self._init_context(context=context, parentState={}, **global_config)
|
|
94
|
+
|
|
92
95
|
def _instrument_all(self) -> None:
|
|
93
96
|
self._instrument_openai()
|
|
94
97
|
self._instrument_anthropic()
|
|
@@ -272,14 +275,14 @@ class _PayiInstrumentor:
|
|
|
272
275
|
context: _Context,
|
|
273
276
|
parentState: _ParentState,
|
|
274
277
|
proxy: bool,
|
|
275
|
-
limit_ids: Optional["list[str]"],
|
|
276
|
-
request_tags: Optional["list[str]"],
|
|
277
|
-
experience_name: Optional[str],
|
|
278
|
-
experience_id: Optional[str],
|
|
279
|
-
use_case_name: Optional[str],
|
|
280
|
-
use_case_id: Optional[str],
|
|
281
|
-
use_case_version: Optional[int],
|
|
282
|
-
user_id: Optional[str],
|
|
278
|
+
limit_ids: Optional["list[str]"] = None,
|
|
279
|
+
request_tags: Optional["list[str]"] = None,
|
|
280
|
+
experience_name: Optional[str] = None,
|
|
281
|
+
experience_id: Optional[str] = None,
|
|
282
|
+
use_case_name: Optional[str]= None,
|
|
283
|
+
use_case_id: Optional[str]= None,
|
|
284
|
+
use_case_version: Optional[int]= None,
|
|
285
|
+
user_id: Optional[str]= None,
|
|
283
286
|
) -> None:
|
|
284
287
|
context["proxy"] = proxy
|
|
285
288
|
|
|
@@ -1020,15 +1023,15 @@ def payi_instrument(
|
|
|
1020
1023
|
elif isinstance(p, AsyncPayi): # type: ignore
|
|
1021
1024
|
apayi_param = p
|
|
1022
1025
|
|
|
1023
|
-
|
|
1026
|
+
global_context_ingest: Optional[bool] = None
|
|
1024
1027
|
|
|
1025
|
-
if config
|
|
1028
|
+
if config is not None:
|
|
1026
1029
|
if "proxy" not in config:
|
|
1027
1030
|
config["proxy"] = False
|
|
1028
|
-
|
|
1031
|
+
global_context_ingest = config.get("proxy") == False
|
|
1029
1032
|
|
|
1030
|
-
#
|
|
1031
|
-
if not payi_param and not apayi_param and
|
|
1033
|
+
# Use default clients if not provided for global ingest instrumentation
|
|
1034
|
+
if not payi_param and not apayi_param and global_context_ingest:
|
|
1032
1035
|
payi_param = Payi()
|
|
1033
1036
|
apayi_param = AsyncPayi()
|
|
1034
1037
|
|
|
@@ -1039,11 +1042,9 @@ def payi_instrument(
|
|
|
1039
1042
|
instruments=instruments,
|
|
1040
1043
|
log_prompt_and_response=log_prompt_and_response,
|
|
1041
1044
|
prompt_and_response_logger=prompt_and_response_logger,
|
|
1045
|
+
global_config=config,
|
|
1042
1046
|
)
|
|
1043
1047
|
|
|
1044
|
-
if len(global_context) > 0:
|
|
1045
|
-
_instrumentor._context_stack.append(global_context)
|
|
1046
|
-
|
|
1047
1048
|
def ingest(
|
|
1048
1049
|
limit_ids: Optional["list[str]"] = None,
|
|
1049
1050
|
request_tags: Optional["list[str]"] = None,
|
|
@@ -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=5gn07SjbIInFCLWQqQ6R8QB9o4KeaJjOx8vNoUQgSGA,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
|
|
@@ -29,7 +29,7 @@ payi/lib/BedrockInstrumentor.py,sha256=UGJiPSjYEuVWLLQu4kUMVrZfx6YJhC3IX4JNoOdcJ
|
|
|
29
29
|
payi/lib/OpenAIInstrumentor.py,sha256=Zdjaj1l2vteujPp3Bt7zwwbveUEQx6CglB1QIniVzL8,6898
|
|
30
30
|
payi/lib/Stopwatch.py,sha256=7OJlxvr2Jyb6Zr1LYCYKczRB7rDVKkIR7gc4YoleNdE,764
|
|
31
31
|
payi/lib/helpers.py,sha256=C6asrzTVal4qbe8GVpDc74eM9SLa9LDEx2pWSPuapMU,3676
|
|
32
|
-
payi/lib/instrument.py,sha256=
|
|
32
|
+
payi/lib/instrument.py,sha256=RLuycwD3IFKKBqNcGY8V-cw4ATrwur82J9u48-57b1E,44143
|
|
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.0a63.dist-info/METADATA,sha256=mtsMIPCDOgNljt5rgY95i-0zIOzbsADs_SaFM6-DX-s,15290
|
|
139
|
+
payi-0.1.0a63.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
140
|
+
payi-0.1.0a63.dist-info/licenses/LICENSE,sha256=CQt03aM-P4a3Yg5qBg3JSLVoQS3smMyvx7tYg_6V7Gk,11334
|
|
141
|
+
payi-0.1.0a63.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|