payi 0.1.0a85__py3-none-any.whl → 0.1.0a87__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/AnthropicInstrumentor.py +56 -3
- payi/lib/BedrockInstrumentor.py +90 -16
- payi/lib/GoogleGenAiInstrumentor.py +11 -62
- payi/lib/OpenAIInstrumentor.py +56 -2
- payi/lib/VertexInstrumentor.py +10 -196
- payi/lib/VertexRequest.py +237 -0
- payi/lib/instrument.py +54 -222
- {payi-0.1.0a85.dist-info → payi-0.1.0a87.dist-info}/METADATA +1 -1
- {payi-0.1.0a85.dist-info → payi-0.1.0a87.dist-info}/RECORD +12 -11
- {payi-0.1.0a85.dist-info → payi-0.1.0a87.dist-info}/WHEEL +0 -0
- {payi-0.1.0a85.dist-info → payi-0.1.0a87.dist-info}/licenses/LICENSE +0 -0
payi/lib/instrument.py
CHANGED
|
@@ -4,23 +4,21 @@ import uuid
|
|
|
4
4
|
import asyncio
|
|
5
5
|
import inspect
|
|
6
6
|
import logging
|
|
7
|
-
import warnings
|
|
8
7
|
import traceback
|
|
9
8
|
from abc import abstractmethod
|
|
10
9
|
from enum import Enum
|
|
11
10
|
from typing import Any, Set, Union, Callable, Optional, Sequence, TypedDict
|
|
12
11
|
from datetime import datetime, timezone
|
|
13
12
|
from dataclasses import dataclass
|
|
14
|
-
from typing_extensions import deprecated
|
|
15
13
|
|
|
16
14
|
import nest_asyncio # type: ignore
|
|
17
15
|
from wrapt import ObjectProxy # type: ignore
|
|
18
16
|
|
|
19
|
-
from payi import Payi, AsyncPayi
|
|
17
|
+
from payi import Payi, AsyncPayi, __version__ as _payi_version
|
|
20
18
|
from payi.types import IngestUnitsParams
|
|
21
19
|
from payi.lib.helpers import PayiHeaderNames
|
|
22
20
|
from payi.types.ingest_response import IngestResponse
|
|
23
|
-
from payi.types.ingest_units_params import Units
|
|
21
|
+
from payi.types.ingest_units_params import Units, ProviderResponseFunctionCall
|
|
24
22
|
from payi.types.pay_i_common_models_api_router_header_info_param import PayICommonModelsAPIRouterHeaderInfoParam
|
|
25
23
|
|
|
26
24
|
from .helpers import PayiCategories
|
|
@@ -49,6 +47,9 @@ class _ProviderRequest:
|
|
|
49
47
|
self._streaming_type: '_StreamingType' = streaming_type
|
|
50
48
|
self._is_aws_client: Optional[bool] = is_aws_client
|
|
51
49
|
self._is_google_vertex_or_genai_client: Optional[bool] = is_google_vertex_or_genai_client
|
|
50
|
+
self._function_call_builder: Optional[dict[int, ProviderResponseFunctionCall]] = None
|
|
51
|
+
self._building_function_response: bool = False
|
|
52
|
+
self._function_calls: Optional[list[ProviderResponseFunctionCall]] = None
|
|
52
53
|
|
|
53
54
|
def process_chunk(self, _chunk: Any) -> _ChunkResult:
|
|
54
55
|
return _ChunkResult(send_chunk_to_caller=True)
|
|
@@ -110,12 +111,29 @@ class _ProviderRequest:
|
|
|
110
111
|
# use a non existent http status code so when presented to the user, the origin is clear
|
|
111
112
|
self._ingest["http_status_code"] = 299
|
|
112
113
|
|
|
114
|
+
def add_streaming_function_call(self, index: int, name: Optional[str], arguments: Optional[str]) -> None:
|
|
115
|
+
if not self._function_call_builder:
|
|
116
|
+
self._function_call_builder = {}
|
|
117
|
+
|
|
118
|
+
if not index in self._function_call_builder:
|
|
119
|
+
self._function_call_builder[index] = ProviderResponseFunctionCall(name=name or "", arguments=arguments or "")
|
|
120
|
+
else:
|
|
121
|
+
function = self._function_call_builder[index]
|
|
122
|
+
if name:
|
|
123
|
+
function["name"] = function["name"] + name
|
|
124
|
+
if arguments:
|
|
125
|
+
function["arguments"] = (function.get("arguments", "") or "") + arguments
|
|
126
|
+
|
|
127
|
+
def add_synchronous_function_call(self, name: str, arguments: Optional[str]) -> None:
|
|
128
|
+
if not self._function_calls:
|
|
129
|
+
self._function_calls = []
|
|
130
|
+
self._ingest["provider_response_function_calls"] = self._function_calls
|
|
131
|
+
self._function_calls.append(ProviderResponseFunctionCall(name=name, arguments=arguments))
|
|
132
|
+
|
|
113
133
|
class PayiInstrumentConfig(TypedDict, total=False):
|
|
114
134
|
proxy: bool
|
|
115
135
|
global_instrumentation: bool
|
|
116
136
|
limit_ids: Optional["list[str]"]
|
|
117
|
-
experience_name: Optional[str] = deprecated("experience_name is deprecated, use use_case_name instead") # type: ignore
|
|
118
|
-
experience_id: Optional[str] = deprecated("experience_id is deprecated, use use_case_id instead") # type: ignore
|
|
119
137
|
use_case_name: Optional[str]
|
|
120
138
|
use_case_id: Optional[str]
|
|
121
139
|
use_case_version: Optional[int]
|
|
@@ -123,8 +141,6 @@ class PayiInstrumentConfig(TypedDict, total=False):
|
|
|
123
141
|
|
|
124
142
|
class _Context(TypedDict, total=False):
|
|
125
143
|
proxy: Optional[bool]
|
|
126
|
-
experience_name: Optional[str]
|
|
127
|
-
experience_id: Optional[str]
|
|
128
144
|
use_case_name: Optional[str]
|
|
129
145
|
use_case_id: Optional[str]
|
|
130
146
|
use_case_version: Optional[int]
|
|
@@ -182,6 +198,8 @@ class _PayiInstrumentor:
|
|
|
182
198
|
global _g_logger
|
|
183
199
|
self._logger: logging.Logger = logger if logger else _g_logger
|
|
184
200
|
|
|
201
|
+
self._logger.info(f"Pay-i instrumentor version: {_payi_version}")
|
|
202
|
+
|
|
185
203
|
self._payi: Optional[Payi] = payi
|
|
186
204
|
self._apayi: Optional[AsyncPayi] = apayi
|
|
187
205
|
|
|
@@ -310,7 +328,13 @@ class _PayiInstrumentor:
|
|
|
310
328
|
|
|
311
329
|
return log_ingest_units
|
|
312
330
|
|
|
313
|
-
def _process_ingest_units(self,
|
|
331
|
+
def _process_ingest_units(self, request: _ProviderRequest, log_data: 'dict[str, str]') -> bool:
|
|
332
|
+
ingest_units = request._ingest
|
|
333
|
+
|
|
334
|
+
if request._function_call_builder:
|
|
335
|
+
# convert the function call builder to a list of function calls
|
|
336
|
+
ingest_units["provider_response_function_calls"] = list(request._function_call_builder.values())
|
|
337
|
+
|
|
314
338
|
if int(ingest_units.get("http_status_code") or 0) < 400:
|
|
315
339
|
units = ingest_units.get("units", {})
|
|
316
340
|
if not units or all(unit.get("input", 0) == 0 and unit.get("output", 0) == 0 for unit in units.values()):
|
|
@@ -348,14 +372,15 @@ class _PayiInstrumentor:
|
|
|
348
372
|
if removeBlockedId:
|
|
349
373
|
self._blocked_limits.discard(limit_id)
|
|
350
374
|
|
|
351
|
-
async def _aingest_units(self,
|
|
375
|
+
async def _aingest_units(self, request: _ProviderRequest) -> Optional[IngestResponse]:
|
|
352
376
|
ingest_response: Optional[IngestResponse] = None
|
|
353
|
-
|
|
377
|
+
ingest_units = request._ingest
|
|
378
|
+
|
|
354
379
|
self._logger.debug(f"_aingest_units")
|
|
355
380
|
|
|
356
381
|
# return early if there are no units to ingest and on a successul ingest request
|
|
357
382
|
log_data: 'dict[str,str]' = {}
|
|
358
|
-
if not self._process_ingest_units(
|
|
383
|
+
if not self._process_ingest_units(request, log_data):
|
|
359
384
|
self._logger.debug(f"_aingest_units: exit early")
|
|
360
385
|
return None
|
|
361
386
|
|
|
@@ -405,7 +430,7 @@ class _PayiInstrumentor:
|
|
|
405
430
|
except Exception as e:
|
|
406
431
|
self._logger.error(f"Error calling async use_cases.definitions.create synchronously: {e}")
|
|
407
432
|
|
|
408
|
-
def _call_aingest_sync(self,
|
|
433
|
+
def _call_aingest_sync(self, request: _ProviderRequest) -> Optional[IngestResponse]:
|
|
409
434
|
try:
|
|
410
435
|
loop = asyncio.get_running_loop()
|
|
411
436
|
except RuntimeError:
|
|
@@ -414,22 +439,23 @@ class _PayiInstrumentor:
|
|
|
414
439
|
try:
|
|
415
440
|
if loop and loop.is_running():
|
|
416
441
|
nest_asyncio.apply(loop) # type: ignore
|
|
417
|
-
return asyncio.run(self._aingest_units(
|
|
442
|
+
return asyncio.run(self._aingest_units(request))
|
|
418
443
|
else:
|
|
419
444
|
# When there's no running loop, create a new one
|
|
420
|
-
return asyncio.run(self._aingest_units(
|
|
445
|
+
return asyncio.run(self._aingest_units(request))
|
|
421
446
|
except Exception as e:
|
|
422
447
|
self._logger.error(f"Error calling aingest_units synchronously: {e}")
|
|
423
448
|
return None
|
|
424
449
|
|
|
425
|
-
def _ingest_units(self,
|
|
450
|
+
def _ingest_units(self, request: _ProviderRequest) -> Optional[IngestResponse]:
|
|
426
451
|
ingest_response: Optional[IngestResponse] = None
|
|
427
|
-
|
|
452
|
+
ingest_units = request._ingest
|
|
453
|
+
|
|
428
454
|
self._logger.debug(f"_ingest_units")
|
|
429
455
|
|
|
430
456
|
# return early if there are no units to ingest and on a successul ingest request
|
|
431
457
|
log_data: 'dict[str,str]' = {}
|
|
432
|
-
if not self._process_ingest_units(
|
|
458
|
+
if not self._process_ingest_units(request, log_data):
|
|
433
459
|
self._logger.debug(f"_ingest_units: exit early")
|
|
434
460
|
return None
|
|
435
461
|
|
|
@@ -450,7 +476,7 @@ class _PayiInstrumentor:
|
|
|
450
476
|
return ingest_response
|
|
451
477
|
elif self._apayi:
|
|
452
478
|
# task runs async. aingest_units will invoke the callback and post process
|
|
453
|
-
ingest_response = self._call_aingest_sync(
|
|
479
|
+
ingest_response = self._call_aingest_sync(request)
|
|
454
480
|
self._logger.debug(f"_ingest_units: apayi success ({ingest_response})")
|
|
455
481
|
return ingest_response
|
|
456
482
|
else:
|
|
@@ -475,8 +501,6 @@ class _PayiInstrumentor:
|
|
|
475
501
|
self,
|
|
476
502
|
proxy: Optional[bool] = None,
|
|
477
503
|
limit_ids: Optional["list[str]"] = None,
|
|
478
|
-
experience_name: Optional[str] = None,
|
|
479
|
-
experience_id: Optional[str] = None,
|
|
480
504
|
use_case_name: Optional[str]= None,
|
|
481
505
|
use_case_id: Optional[str]= None,
|
|
482
506
|
use_case_version: Optional[int]= None,
|
|
@@ -495,28 +519,6 @@ class _PayiInstrumentor:
|
|
|
495
519
|
parent_proxy = parent_context.get("proxy", self._proxy_default)
|
|
496
520
|
context["proxy"] = proxy if proxy else parent_proxy
|
|
497
521
|
|
|
498
|
-
parent_experience_name = parent_context.get("experience_name", None)
|
|
499
|
-
parent_experience_id = parent_context.get("experience_id", None)
|
|
500
|
-
|
|
501
|
-
if experience_name is None:
|
|
502
|
-
# If no experience_name specified, use previous values
|
|
503
|
-
context["experience_name"] = parent_experience_name
|
|
504
|
-
context["experience_id"] = parent_experience_id
|
|
505
|
-
elif len(experience_name) == 0:
|
|
506
|
-
# Empty string explicitly blocks inheriting from the parent state
|
|
507
|
-
context["experience_name"] = None
|
|
508
|
-
context["experience_id"] = None
|
|
509
|
-
else:
|
|
510
|
-
# Check if experience_name is the same as the previous one
|
|
511
|
-
if experience_name == parent_experience_name:
|
|
512
|
-
# Same experience name, use previous ID unless new one specified
|
|
513
|
-
context["experience_name"] = experience_name
|
|
514
|
-
context["experience_id"] = experience_id if experience_id else parent_experience_id
|
|
515
|
-
else:
|
|
516
|
-
# Different experience name, use specified ID or generate one
|
|
517
|
-
context["experience_name"] = experience_name
|
|
518
|
-
context["experience_id"] = experience_id if experience_id else str(uuid.uuid4())
|
|
519
|
-
|
|
520
522
|
parent_use_case_name = parent_context.get("use_case_name", None)
|
|
521
523
|
parent_use_case_id = parent_context.get("use_case_id", None)
|
|
522
524
|
parent_use_case_version = parent_context.get("use_case_version", None)
|
|
@@ -581,8 +583,6 @@ class _PayiInstrumentor:
|
|
|
581
583
|
func: Any,
|
|
582
584
|
proxy: Optional[bool],
|
|
583
585
|
limit_ids: Optional["list[str]"],
|
|
584
|
-
experience_name: Optional[str],
|
|
585
|
-
experience_id: Optional[str],
|
|
586
586
|
use_case_name: Optional[str],
|
|
587
587
|
use_case_id: Optional[str],
|
|
588
588
|
use_case_version: Optional[int],
|
|
@@ -594,8 +594,6 @@ class _PayiInstrumentor:
|
|
|
594
594
|
self._init_current_context(
|
|
595
595
|
proxy=proxy,
|
|
596
596
|
limit_ids=limit_ids,
|
|
597
|
-
experience_name=experience_name,
|
|
598
|
-
experience_id=experience_id,
|
|
599
597
|
use_case_name=use_case_name,
|
|
600
598
|
use_case_id=use_case_id,
|
|
601
599
|
use_case_version=use_case_version,
|
|
@@ -607,8 +605,6 @@ class _PayiInstrumentor:
|
|
|
607
605
|
func: Any,
|
|
608
606
|
proxy: Optional[bool],
|
|
609
607
|
limit_ids: Optional["list[str]"],
|
|
610
|
-
experience_name: Optional[str],
|
|
611
|
-
experience_id: Optional[str],
|
|
612
608
|
use_case_name: Optional[str],
|
|
613
609
|
use_case_id: Optional[str],
|
|
614
610
|
use_case_version: Optional[int],
|
|
@@ -620,8 +616,6 @@ class _PayiInstrumentor:
|
|
|
620
616
|
self._init_current_context(
|
|
621
617
|
proxy=proxy,
|
|
622
618
|
limit_ids=limit_ids,
|
|
623
|
-
experience_name=experience_name,
|
|
624
|
-
experience_id=experience_id,
|
|
625
619
|
use_case_name=use_case_name,
|
|
626
620
|
use_case_id=use_case_id,
|
|
627
621
|
use_case_version=use_case_version,
|
|
@@ -657,9 +651,6 @@ class _PayiInstrumentor:
|
|
|
657
651
|
limit_ids = ingest_extra_headers.pop(PayiHeaderNames.limit_ids, None)
|
|
658
652
|
request_tags = ingest_extra_headers.pop(PayiHeaderNames.request_tags, None)
|
|
659
653
|
|
|
660
|
-
experience_name = ingest_extra_headers.pop(PayiHeaderNames.experience_name, None)
|
|
661
|
-
experience_id = ingest_extra_headers.pop(PayiHeaderNames.experience_id, None)
|
|
662
|
-
|
|
663
654
|
use_case_name = ingest_extra_headers.pop(PayiHeaderNames.use_case_name, None)
|
|
664
655
|
use_case_id = ingest_extra_headers.pop(PayiHeaderNames.use_case_id, None)
|
|
665
656
|
use_case_version = ingest_extra_headers.pop(PayiHeaderNames.use_case_version, None)
|
|
@@ -671,10 +662,6 @@ class _PayiInstrumentor:
|
|
|
671
662
|
request._ingest["limit_ids"] = limit_ids.split(",")
|
|
672
663
|
if request_tags:
|
|
673
664
|
request._ingest["request_tags"] = request_tags.split(",")
|
|
674
|
-
if experience_name:
|
|
675
|
-
request._ingest["experience_name"] = experience_name
|
|
676
|
-
if experience_id:
|
|
677
|
-
request._ingest["experience_id"] = experience_id
|
|
678
665
|
if use_case_name:
|
|
679
666
|
request._ingest["use_case_name"] = use_case_name
|
|
680
667
|
if use_case_id:
|
|
@@ -782,7 +769,7 @@ class _PayiInstrumentor:
|
|
|
782
769
|
|
|
783
770
|
if request.process_exception(e, kwargs):
|
|
784
771
|
request._ingest["end_to_end_latency_ms"] = duration
|
|
785
|
-
await self._aingest_units(request
|
|
772
|
+
await self._aingest_units(request)
|
|
786
773
|
|
|
787
774
|
raise e
|
|
788
775
|
|
|
@@ -826,7 +813,7 @@ class _PayiInstrumentor:
|
|
|
826
813
|
self._logger.debug(f"async_invoke_wrapper: process sync response return")
|
|
827
814
|
return return_result
|
|
828
815
|
|
|
829
|
-
await self._aingest_units(request
|
|
816
|
+
await self._aingest_units(request)
|
|
830
817
|
|
|
831
818
|
self._logger.debug(f"async_invoke_wrapper: finished")
|
|
832
819
|
return response
|
|
@@ -905,7 +892,7 @@ class _PayiInstrumentor:
|
|
|
905
892
|
|
|
906
893
|
if request.process_exception(e, kwargs):
|
|
907
894
|
request._ingest["end_to_end_latency_ms"] = duration
|
|
908
|
-
self._ingest_units(request
|
|
895
|
+
self._ingest_units(request)
|
|
909
896
|
|
|
910
897
|
raise e
|
|
911
898
|
|
|
@@ -958,7 +945,7 @@ class _PayiInstrumentor:
|
|
|
958
945
|
self._logger.debug(f"invoke_wrapper: process sync response return")
|
|
959
946
|
return return_result
|
|
960
947
|
|
|
961
|
-
self._ingest_units(request
|
|
948
|
+
self._ingest_units(request)
|
|
962
949
|
|
|
963
950
|
self._logger.debug(f"invoke_wrapper: finished")
|
|
964
951
|
return response
|
|
@@ -980,9 +967,6 @@ class _PayiInstrumentor:
|
|
|
980
967
|
) -> None:
|
|
981
968
|
context_limit_ids: Optional[list[str]] = context.get("limit_ids")
|
|
982
969
|
|
|
983
|
-
context_experience_name: Optional[str] = context.get("experience_name")
|
|
984
|
-
context_experience_id: Optional[str] = context.get("experience_id")
|
|
985
|
-
|
|
986
970
|
context_use_case_name: Optional[str] = context.get("use_case_name")
|
|
987
971
|
context_use_case_id: Optional[str] = context.get("use_case_id")
|
|
988
972
|
context_use_case_version: Optional[int] = context.get("use_case_version")
|
|
@@ -1041,20 +1025,6 @@ class _PayiInstrumentor:
|
|
|
1041
1025
|
if context_use_case_step is not None:
|
|
1042
1026
|
extra_headers[PayiHeaderNames.use_case_step] = str(context_use_case_step)
|
|
1043
1027
|
|
|
1044
|
-
if PayiHeaderNames.experience_name in extra_headers:
|
|
1045
|
-
headers_experience_name = extra_headers.get(PayiHeaderNames.experience_name, None)
|
|
1046
|
-
if headers_experience_name is None or len(headers_experience_name) == 0:
|
|
1047
|
-
# headers_experience_name is empty, remove all experience related headers
|
|
1048
|
-
extra_headers.pop(PayiHeaderNames.experience_name, None)
|
|
1049
|
-
extra_headers.pop(PayiHeaderNames.experience_id, None)
|
|
1050
|
-
else:
|
|
1051
|
-
# leave the value in extra_headers
|
|
1052
|
-
...
|
|
1053
|
-
elif context_experience_name is not None:
|
|
1054
|
-
extra_headers[PayiHeaderNames.experience_name] = context_experience_name
|
|
1055
|
-
if context_experience_id is not None:
|
|
1056
|
-
extra_headers[PayiHeaderNames.experience_id] = context_experience_id
|
|
1057
|
-
|
|
1058
1028
|
if PayiHeaderNames.request_tags not in extra_headers and context_request_tags:
|
|
1059
1029
|
extra_headers[PayiHeaderNames.request_tags] = ",".join(context_request_tags)
|
|
1060
1030
|
|
|
@@ -1279,7 +1249,7 @@ class _StreamIteratorWrapper(ObjectProxy): # type: ignore
|
|
|
1279
1249
|
|
|
1280
1250
|
self._process_stop_iteration()
|
|
1281
1251
|
|
|
1282
|
-
await self._instrumentor._aingest_units(self._request
|
|
1252
|
+
await self._instrumentor._aingest_units(self._request)
|
|
1283
1253
|
self._ingested = True
|
|
1284
1254
|
|
|
1285
1255
|
def _stop_iteration(self) -> None:
|
|
@@ -1288,7 +1258,7 @@ class _StreamIteratorWrapper(ObjectProxy): # type: ignore
|
|
|
1288
1258
|
return
|
|
1289
1259
|
|
|
1290
1260
|
self._process_stop_iteration()
|
|
1291
|
-
self._instrumentor._ingest_units(self._request
|
|
1261
|
+
self._instrumentor._ingest_units(self._request)
|
|
1292
1262
|
self._ingested = True
|
|
1293
1263
|
|
|
1294
1264
|
@staticmethod
|
|
@@ -1431,7 +1401,7 @@ class _GeneratorWrapper: # type: ignore
|
|
|
1431
1401
|
|
|
1432
1402
|
self._process_stop_iteration()
|
|
1433
1403
|
|
|
1434
|
-
self._instrumentor._ingest_units(self._request
|
|
1404
|
+
self._instrumentor._ingest_units(self._request)
|
|
1435
1405
|
self._ingested = True
|
|
1436
1406
|
|
|
1437
1407
|
async def _astop_iteration(self) -> None:
|
|
@@ -1441,7 +1411,7 @@ class _GeneratorWrapper: # type: ignore
|
|
|
1441
1411
|
|
|
1442
1412
|
self._process_stop_iteration()
|
|
1443
1413
|
|
|
1444
|
-
await self._instrumentor._aingest_units(self._request
|
|
1414
|
+
await self._instrumentor._aingest_units(self._request)
|
|
1445
1415
|
self._ingested = True
|
|
1446
1416
|
|
|
1447
1417
|
def _process_stop_iteration(self) -> None:
|
|
@@ -1522,8 +1492,6 @@ def track(
|
|
|
1522
1492
|
func,
|
|
1523
1493
|
proxy,
|
|
1524
1494
|
limit_ids,
|
|
1525
|
-
None, # experience_name,
|
|
1526
|
-
None, #experience_id,
|
|
1527
1495
|
use_case_name,
|
|
1528
1496
|
use_case_id,
|
|
1529
1497
|
use_case_version,
|
|
@@ -1544,8 +1512,6 @@ def track(
|
|
|
1544
1512
|
func,
|
|
1545
1513
|
proxy,
|
|
1546
1514
|
limit_ids,
|
|
1547
|
-
None, # experience_name,
|
|
1548
|
-
None, # experience_id,
|
|
1549
1515
|
use_case_name,
|
|
1550
1516
|
use_case_id,
|
|
1551
1517
|
use_case_version,
|
|
@@ -1588,138 +1554,4 @@ def track_context(
|
|
|
1588
1554
|
context["price_as_resource"] = price_as_resource
|
|
1589
1555
|
context["resource_scope"] = resource_scope
|
|
1590
1556
|
|
|
1591
|
-
return _TrackContext(context)
|
|
1592
|
-
|
|
1593
|
-
@deprecated("@ingest() is deprecated. Use @track() instead")
|
|
1594
|
-
def ingest(
|
|
1595
|
-
limit_ids: Optional["list[str]"] = None,
|
|
1596
|
-
experience_name: Optional[str] = None,
|
|
1597
|
-
experience_id: Optional[str] = None,
|
|
1598
|
-
use_case_name: Optional[str] = None,
|
|
1599
|
-
use_case_id: Optional[str] = None,
|
|
1600
|
-
use_case_version: Optional[int] = None,
|
|
1601
|
-
user_id: Optional[str] = None,
|
|
1602
|
-
) -> Any:
|
|
1603
|
-
warnings.warn(
|
|
1604
|
-
"@ingest is deprecated and will be removed in a future version. Use @track instead.",
|
|
1605
|
-
DeprecationWarning,
|
|
1606
|
-
stacklevel=2
|
|
1607
|
-
|
|
1608
|
-
)
|
|
1609
|
-
|
|
1610
|
-
def _ingest(func: Any) -> Any:
|
|
1611
|
-
import asyncio
|
|
1612
|
-
if asyncio.iscoroutinefunction(func):
|
|
1613
|
-
async def awrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1614
|
-
if not _instrumentor:
|
|
1615
|
-
_g_logger.debug(f"ingest: call no instrumentor!")
|
|
1616
|
-
return await func(*args, **kwargs)
|
|
1617
|
-
|
|
1618
|
-
_instrumentor._logger.debug(f"ingest: call async function (limit_ids={limit_ids}, experience_name={experience_name}, experience_id={experience_id}, use_case_name={use_case_name}, use_case_id={use_case_id}, use_case_version={use_case_version}, user_id={user_id})")
|
|
1619
|
-
|
|
1620
|
-
# Call the instrumentor's _call_func for async functions
|
|
1621
|
-
return await _instrumentor._acall_func(
|
|
1622
|
-
func,
|
|
1623
|
-
False,
|
|
1624
|
-
limit_ids,
|
|
1625
|
-
experience_name,
|
|
1626
|
-
experience_id,
|
|
1627
|
-
use_case_name,
|
|
1628
|
-
use_case_id,
|
|
1629
|
-
use_case_version,
|
|
1630
|
-
user_id,
|
|
1631
|
-
*args,
|
|
1632
|
-
**kwargs,
|
|
1633
|
-
)
|
|
1634
|
-
return awrapper
|
|
1635
|
-
else:
|
|
1636
|
-
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1637
|
-
if not _instrumentor:
|
|
1638
|
-
_g_logger.debug(f"ingest: call no instrumentor!")
|
|
1639
|
-
return func(*args, **kwargs)
|
|
1640
|
-
|
|
1641
|
-
_instrumentor._logger.debug(f"ingest: call sync function (limit_ids={limit_ids}, experience_name={experience_name}, experience_id={experience_id}, use_case_name={use_case_name}, use_case_id={use_case_id}, use_case_version={use_case_version}, user_id={user_id})")
|
|
1642
|
-
|
|
1643
|
-
return _instrumentor._call_func(
|
|
1644
|
-
func,
|
|
1645
|
-
False,
|
|
1646
|
-
limit_ids,
|
|
1647
|
-
experience_name,
|
|
1648
|
-
experience_id,
|
|
1649
|
-
use_case_name,
|
|
1650
|
-
use_case_id,
|
|
1651
|
-
use_case_version,
|
|
1652
|
-
user_id,
|
|
1653
|
-
*args,
|
|
1654
|
-
**kwargs,
|
|
1655
|
-
)
|
|
1656
|
-
return wrapper
|
|
1657
|
-
|
|
1658
|
-
return _ingest
|
|
1659
|
-
|
|
1660
|
-
@deprecated("@proxy() is deprecated. Use @track() instead")
|
|
1661
|
-
def proxy(
|
|
1662
|
-
limit_ids: Optional["list[str]"] = None,
|
|
1663
|
-
experience_name: Optional[str] = None,
|
|
1664
|
-
experience_id: Optional[str] = None,
|
|
1665
|
-
use_case_id: Optional[str] = None,
|
|
1666
|
-
use_case_name: Optional[str] = None,
|
|
1667
|
-
use_case_version: Optional[int] = None,
|
|
1668
|
-
user_id: Optional[str] = None,
|
|
1669
|
-
) -> Any:
|
|
1670
|
-
warnings.warn(
|
|
1671
|
-
"@proxy is deprecated and will be removed in a future version. Use @track instead.",
|
|
1672
|
-
DeprecationWarning,
|
|
1673
|
-
stacklevel=2
|
|
1674
|
-
)
|
|
1675
|
-
|
|
1676
|
-
def _proxy(func: Any) -> Any:
|
|
1677
|
-
import asyncio
|
|
1678
|
-
if asyncio.iscoroutinefunction(func):
|
|
1679
|
-
async def _proxy_awrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1680
|
-
if not _instrumentor:
|
|
1681
|
-
_g_logger.debug(f"proxy: call no instrumentor!")
|
|
1682
|
-
return await func(*args, **kwargs)
|
|
1683
|
-
|
|
1684
|
-
_instrumentor._logger.debug(f"proxy: call async function (limit_ids={limit_ids}, experience_name={experience_name}, experience_id={experience_id}, use_case_name={use_case_name}, use_case_id={use_case_id}, use_case_version={use_case_version}, user_id={user_id})")
|
|
1685
|
-
|
|
1686
|
-
return await _instrumentor._call_func(
|
|
1687
|
-
func,
|
|
1688
|
-
True,
|
|
1689
|
-
limit_ids,
|
|
1690
|
-
experience_name,
|
|
1691
|
-
experience_id,
|
|
1692
|
-
use_case_name,
|
|
1693
|
-
use_case_id,
|
|
1694
|
-
use_case_version,
|
|
1695
|
-
user_id,
|
|
1696
|
-
*args,
|
|
1697
|
-
**kwargs
|
|
1698
|
-
)
|
|
1699
|
-
|
|
1700
|
-
return _proxy_awrapper
|
|
1701
|
-
else:
|
|
1702
|
-
def _proxy_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1703
|
-
if not _instrumentor:
|
|
1704
|
-
_g_logger.debug(f"proxy: call no instrumentor!")
|
|
1705
|
-
return func(*args, **kwargs)
|
|
1706
|
-
|
|
1707
|
-
_instrumentor._logger.debug(f"proxy: call sync function (limit_ids={limit_ids}, experience_name={experience_name}, experience_id={experience_id}, use_case_name={use_case_name}, use_case_id={use_case_id}, use_case_version={use_case_version}, user_id={user_id})")
|
|
1708
|
-
|
|
1709
|
-
return _instrumentor._call_func(
|
|
1710
|
-
func,
|
|
1711
|
-
True,
|
|
1712
|
-
limit_ids,
|
|
1713
|
-
experience_name,
|
|
1714
|
-
experience_id,
|
|
1715
|
-
use_case_name,
|
|
1716
|
-
use_case_id,
|
|
1717
|
-
use_case_version,
|
|
1718
|
-
user_id,
|
|
1719
|
-
*args,
|
|
1720
|
-
**kwargs
|
|
1721
|
-
)
|
|
1722
|
-
|
|
1723
|
-
return _proxy_wrapper
|
|
1724
|
-
|
|
1725
|
-
return _proxy
|
|
1557
|
+
return _TrackContext(context)
|
|
@@ -11,7 +11,7 @@ payi/_resource.py,sha256=j2jIkTr8OIC8sU6-05nxSaCyj4MaFlbZrwlyg4_xJos,1088
|
|
|
11
11
|
payi/_response.py,sha256=rh9oJAvCKcPwQFm4iqH_iVrmK8bNx--YP_A2a4kN1OU,28776
|
|
12
12
|
payi/_streaming.py,sha256=Z_wIyo206T6Jqh2rolFg2VXZgX24PahLmpURp0-NssU,10092
|
|
13
13
|
payi/_types.py,sha256=7jE5MoQQFVoVxw5vVzvZ2Ao0kcjfNOGsBgyJfLBEnMo,6195
|
|
14
|
-
payi/_version.py,sha256=
|
|
14
|
+
payi/_version.py,sha256=l3X3JyFMcoR926tX1lDq0JrRFo1YLeW7UgVqr8mbkNg,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
|
|
@@ -25,14 +25,15 @@ payi/_utils/_transform.py,sha256=n7kskEWz6o__aoNvhFoGVyDoalNe6mJwp-g7BWkdj88,156
|
|
|
25
25
|
payi/_utils/_typing.py,sha256=D0DbbNu8GnYQTSICnTSHDGsYXj8TcAKyhejb0XcnjtY,4602
|
|
26
26
|
payi/_utils/_utils.py,sha256=ts4CiiuNpFiGB6YMdkQRh2SZvYvsl7mAF-JWHCcLDf4,12312
|
|
27
27
|
payi/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
|
|
28
|
-
payi/lib/AnthropicInstrumentor.py,sha256=
|
|
29
|
-
payi/lib/BedrockInstrumentor.py,sha256=
|
|
30
|
-
payi/lib/GoogleGenAiInstrumentor.py,sha256=
|
|
31
|
-
payi/lib/OpenAIInstrumentor.py,sha256=
|
|
28
|
+
payi/lib/AnthropicInstrumentor.py,sha256=rpp1MUP2bvCNvVPAHn1xrzvupuIWR0pm4P8t1dR_m70,13103
|
|
29
|
+
payi/lib/BedrockInstrumentor.py,sha256=Q-QggkVWOQPI84O4I30zirIIKJcU4Qj9YhflGznK8cE,17070
|
|
30
|
+
payi/lib/GoogleGenAiInstrumentor.py,sha256=DLbmlwmyOwooe7FuBkEAO_Z3xjPKpvQyO4VwLBeZnn4,8477
|
|
31
|
+
payi/lib/OpenAIInstrumentor.py,sha256=Eiy6dGEuHKjPannndbt1E1dVF0FkDvtJy6tIZoYHY2A,20822
|
|
32
32
|
payi/lib/Stopwatch.py,sha256=7OJlxvr2Jyb6Zr1LYCYKczRB7rDVKkIR7gc4YoleNdE,764
|
|
33
|
-
payi/lib/VertexInstrumentor.py,sha256=
|
|
33
|
+
payi/lib/VertexInstrumentor.py,sha256=IdahkOgB6ReBGpdgGCrBHplAFwK3KZ_XaRgFXVTodRU,7136
|
|
34
|
+
payi/lib/VertexRequest.py,sha256=xKBURJHx4_bXMM8AijtRAjH8t-QukRLx6AIwsCw33Y0,9986
|
|
34
35
|
payi/lib/helpers.py,sha256=K1KAfWrpPT1UUGNxspLe1lHzQjP3XV5Pkh9IU4pKMok,4624
|
|
35
|
-
payi/lib/instrument.py,sha256=
|
|
36
|
+
payi/lib/instrument.py,sha256=qGTnLEppOsuGU8G0mQRwfoosBIJ_sZP-b1FabCmI5wc,60696
|
|
36
37
|
payi/resources/__init__.py,sha256=1rtrPLWbNt8oJGOp6nwPumKLJ-ftez0B6qwLFyfcoP4,2972
|
|
37
38
|
payi/resources/ingest.py,sha256=Z4WHv-INZoIlBzFw4o1j_PHykDsNACpkkF42Kik0UMg,23758
|
|
38
39
|
payi/resources/categories/__init__.py,sha256=WeotN_d-0Ri8ohsrNPbve7RyViD9_N0NA9DrV3WYg3w,1701
|
|
@@ -144,7 +145,7 @@ payi/types/use_cases/definitions/kpi_retrieve_response.py,sha256=uQXliSvS3k-yDYw
|
|
|
144
145
|
payi/types/use_cases/definitions/kpi_update_params.py,sha256=jbawdWAdMnsTWVH0qfQGb8W7_TXe3lq4zjSRu44d8p8,373
|
|
145
146
|
payi/types/use_cases/definitions/kpi_update_response.py,sha256=zLyEoT0S8d7XHsnXZYT8tM7yDw0Aze0Mk-_Z6QeMtc8,459
|
|
146
147
|
payi/types/use_cases/definitions/limit_config_create_params.py,sha256=pzQza_16N3z8cFNEKr6gPbFvuGFrwNuGxAYb--Kbo2M,449
|
|
147
|
-
payi-0.1.
|
|
148
|
-
payi-0.1.
|
|
149
|
-
payi-0.1.
|
|
150
|
-
payi-0.1.
|
|
148
|
+
payi-0.1.0a87.dist-info/METADATA,sha256=5OWuzVOlr2NbysdSDp3QLfFGUSRPIS9H-76cvI-8KB4,15180
|
|
149
|
+
payi-0.1.0a87.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
150
|
+
payi-0.1.0a87.dist-info/licenses/LICENSE,sha256=CQt03aM-P4a3Yg5qBg3JSLVoQS3smMyvx7tYg_6V7Gk,11334
|
|
151
|
+
payi-0.1.0a87.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|