payi 0.1.0a86__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 +41 -1
- 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 +51 -221
- {payi-0.1.0a86.dist-info → payi-0.1.0a87.dist-info}/METADATA +1 -1
- {payi-0.1.0a86.dist-info → payi-0.1.0a87.dist-info}/RECORD +12 -11
- {payi-0.1.0a86.dist-info → payi-0.1.0a87.dist-info}/WHEEL +0 -0
- {payi-0.1.0a86.dist-info → payi-0.1.0a87.dist-info}/licenses/LICENSE +0 -0
payi/lib/instrument.py
CHANGED
|
@@ -4,14 +4,12 @@ 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
|
|
@@ -20,7 +18,7 @@ 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]
|
|
@@ -312,7 +328,13 @@ class _PayiInstrumentor:
|
|
|
312
328
|
|
|
313
329
|
return log_ingest_units
|
|
314
330
|
|
|
315
|
-
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
|
+
|
|
316
338
|
if int(ingest_units.get("http_status_code") or 0) < 400:
|
|
317
339
|
units = ingest_units.get("units", {})
|
|
318
340
|
if not units or all(unit.get("input", 0) == 0 and unit.get("output", 0) == 0 for unit in units.values()):
|
|
@@ -350,14 +372,15 @@ class _PayiInstrumentor:
|
|
|
350
372
|
if removeBlockedId:
|
|
351
373
|
self._blocked_limits.discard(limit_id)
|
|
352
374
|
|
|
353
|
-
async def _aingest_units(self,
|
|
375
|
+
async def _aingest_units(self, request: _ProviderRequest) -> Optional[IngestResponse]:
|
|
354
376
|
ingest_response: Optional[IngestResponse] = None
|
|
355
|
-
|
|
377
|
+
ingest_units = request._ingest
|
|
378
|
+
|
|
356
379
|
self._logger.debug(f"_aingest_units")
|
|
357
380
|
|
|
358
381
|
# return early if there are no units to ingest and on a successul ingest request
|
|
359
382
|
log_data: 'dict[str,str]' = {}
|
|
360
|
-
if not self._process_ingest_units(
|
|
383
|
+
if not self._process_ingest_units(request, log_data):
|
|
361
384
|
self._logger.debug(f"_aingest_units: exit early")
|
|
362
385
|
return None
|
|
363
386
|
|
|
@@ -407,7 +430,7 @@ class _PayiInstrumentor:
|
|
|
407
430
|
except Exception as e:
|
|
408
431
|
self._logger.error(f"Error calling async use_cases.definitions.create synchronously: {e}")
|
|
409
432
|
|
|
410
|
-
def _call_aingest_sync(self,
|
|
433
|
+
def _call_aingest_sync(self, request: _ProviderRequest) -> Optional[IngestResponse]:
|
|
411
434
|
try:
|
|
412
435
|
loop = asyncio.get_running_loop()
|
|
413
436
|
except RuntimeError:
|
|
@@ -416,22 +439,23 @@ class _PayiInstrumentor:
|
|
|
416
439
|
try:
|
|
417
440
|
if loop and loop.is_running():
|
|
418
441
|
nest_asyncio.apply(loop) # type: ignore
|
|
419
|
-
return asyncio.run(self._aingest_units(
|
|
442
|
+
return asyncio.run(self._aingest_units(request))
|
|
420
443
|
else:
|
|
421
444
|
# When there's no running loop, create a new one
|
|
422
|
-
return asyncio.run(self._aingest_units(
|
|
445
|
+
return asyncio.run(self._aingest_units(request))
|
|
423
446
|
except Exception as e:
|
|
424
447
|
self._logger.error(f"Error calling aingest_units synchronously: {e}")
|
|
425
448
|
return None
|
|
426
449
|
|
|
427
|
-
def _ingest_units(self,
|
|
450
|
+
def _ingest_units(self, request: _ProviderRequest) -> Optional[IngestResponse]:
|
|
428
451
|
ingest_response: Optional[IngestResponse] = None
|
|
429
|
-
|
|
452
|
+
ingest_units = request._ingest
|
|
453
|
+
|
|
430
454
|
self._logger.debug(f"_ingest_units")
|
|
431
455
|
|
|
432
456
|
# return early if there are no units to ingest and on a successul ingest request
|
|
433
457
|
log_data: 'dict[str,str]' = {}
|
|
434
|
-
if not self._process_ingest_units(
|
|
458
|
+
if not self._process_ingest_units(request, log_data):
|
|
435
459
|
self._logger.debug(f"_ingest_units: exit early")
|
|
436
460
|
return None
|
|
437
461
|
|
|
@@ -452,7 +476,7 @@ class _PayiInstrumentor:
|
|
|
452
476
|
return ingest_response
|
|
453
477
|
elif self._apayi:
|
|
454
478
|
# task runs async. aingest_units will invoke the callback and post process
|
|
455
|
-
ingest_response = self._call_aingest_sync(
|
|
479
|
+
ingest_response = self._call_aingest_sync(request)
|
|
456
480
|
self._logger.debug(f"_ingest_units: apayi success ({ingest_response})")
|
|
457
481
|
return ingest_response
|
|
458
482
|
else:
|
|
@@ -477,8 +501,6 @@ class _PayiInstrumentor:
|
|
|
477
501
|
self,
|
|
478
502
|
proxy: Optional[bool] = None,
|
|
479
503
|
limit_ids: Optional["list[str]"] = None,
|
|
480
|
-
experience_name: Optional[str] = None,
|
|
481
|
-
experience_id: Optional[str] = None,
|
|
482
504
|
use_case_name: Optional[str]= None,
|
|
483
505
|
use_case_id: Optional[str]= None,
|
|
484
506
|
use_case_version: Optional[int]= None,
|
|
@@ -497,28 +519,6 @@ class _PayiInstrumentor:
|
|
|
497
519
|
parent_proxy = parent_context.get("proxy", self._proxy_default)
|
|
498
520
|
context["proxy"] = proxy if proxy else parent_proxy
|
|
499
521
|
|
|
500
|
-
parent_experience_name = parent_context.get("experience_name", None)
|
|
501
|
-
parent_experience_id = parent_context.get("experience_id", None)
|
|
502
|
-
|
|
503
|
-
if experience_name is None:
|
|
504
|
-
# If no experience_name specified, use previous values
|
|
505
|
-
context["experience_name"] = parent_experience_name
|
|
506
|
-
context["experience_id"] = parent_experience_id
|
|
507
|
-
elif len(experience_name) == 0:
|
|
508
|
-
# Empty string explicitly blocks inheriting from the parent state
|
|
509
|
-
context["experience_name"] = None
|
|
510
|
-
context["experience_id"] = None
|
|
511
|
-
else:
|
|
512
|
-
# Check if experience_name is the same as the previous one
|
|
513
|
-
if experience_name == parent_experience_name:
|
|
514
|
-
# Same experience name, use previous ID unless new one specified
|
|
515
|
-
context["experience_name"] = experience_name
|
|
516
|
-
context["experience_id"] = experience_id if experience_id else parent_experience_id
|
|
517
|
-
else:
|
|
518
|
-
# Different experience name, use specified ID or generate one
|
|
519
|
-
context["experience_name"] = experience_name
|
|
520
|
-
context["experience_id"] = experience_id if experience_id else str(uuid.uuid4())
|
|
521
|
-
|
|
522
522
|
parent_use_case_name = parent_context.get("use_case_name", None)
|
|
523
523
|
parent_use_case_id = parent_context.get("use_case_id", None)
|
|
524
524
|
parent_use_case_version = parent_context.get("use_case_version", None)
|
|
@@ -583,8 +583,6 @@ class _PayiInstrumentor:
|
|
|
583
583
|
func: Any,
|
|
584
584
|
proxy: Optional[bool],
|
|
585
585
|
limit_ids: Optional["list[str]"],
|
|
586
|
-
experience_name: Optional[str],
|
|
587
|
-
experience_id: Optional[str],
|
|
588
586
|
use_case_name: Optional[str],
|
|
589
587
|
use_case_id: Optional[str],
|
|
590
588
|
use_case_version: Optional[int],
|
|
@@ -596,8 +594,6 @@ class _PayiInstrumentor:
|
|
|
596
594
|
self._init_current_context(
|
|
597
595
|
proxy=proxy,
|
|
598
596
|
limit_ids=limit_ids,
|
|
599
|
-
experience_name=experience_name,
|
|
600
|
-
experience_id=experience_id,
|
|
601
597
|
use_case_name=use_case_name,
|
|
602
598
|
use_case_id=use_case_id,
|
|
603
599
|
use_case_version=use_case_version,
|
|
@@ -609,8 +605,6 @@ class _PayiInstrumentor:
|
|
|
609
605
|
func: Any,
|
|
610
606
|
proxy: Optional[bool],
|
|
611
607
|
limit_ids: Optional["list[str]"],
|
|
612
|
-
experience_name: Optional[str],
|
|
613
|
-
experience_id: Optional[str],
|
|
614
608
|
use_case_name: Optional[str],
|
|
615
609
|
use_case_id: Optional[str],
|
|
616
610
|
use_case_version: Optional[int],
|
|
@@ -622,8 +616,6 @@ class _PayiInstrumentor:
|
|
|
622
616
|
self._init_current_context(
|
|
623
617
|
proxy=proxy,
|
|
624
618
|
limit_ids=limit_ids,
|
|
625
|
-
experience_name=experience_name,
|
|
626
|
-
experience_id=experience_id,
|
|
627
619
|
use_case_name=use_case_name,
|
|
628
620
|
use_case_id=use_case_id,
|
|
629
621
|
use_case_version=use_case_version,
|
|
@@ -659,9 +651,6 @@ class _PayiInstrumentor:
|
|
|
659
651
|
limit_ids = ingest_extra_headers.pop(PayiHeaderNames.limit_ids, None)
|
|
660
652
|
request_tags = ingest_extra_headers.pop(PayiHeaderNames.request_tags, None)
|
|
661
653
|
|
|
662
|
-
experience_name = ingest_extra_headers.pop(PayiHeaderNames.experience_name, None)
|
|
663
|
-
experience_id = ingest_extra_headers.pop(PayiHeaderNames.experience_id, None)
|
|
664
|
-
|
|
665
654
|
use_case_name = ingest_extra_headers.pop(PayiHeaderNames.use_case_name, None)
|
|
666
655
|
use_case_id = ingest_extra_headers.pop(PayiHeaderNames.use_case_id, None)
|
|
667
656
|
use_case_version = ingest_extra_headers.pop(PayiHeaderNames.use_case_version, None)
|
|
@@ -673,10 +662,6 @@ class _PayiInstrumentor:
|
|
|
673
662
|
request._ingest["limit_ids"] = limit_ids.split(",")
|
|
674
663
|
if request_tags:
|
|
675
664
|
request._ingest["request_tags"] = request_tags.split(",")
|
|
676
|
-
if experience_name:
|
|
677
|
-
request._ingest["experience_name"] = experience_name
|
|
678
|
-
if experience_id:
|
|
679
|
-
request._ingest["experience_id"] = experience_id
|
|
680
665
|
if use_case_name:
|
|
681
666
|
request._ingest["use_case_name"] = use_case_name
|
|
682
667
|
if use_case_id:
|
|
@@ -784,7 +769,7 @@ class _PayiInstrumentor:
|
|
|
784
769
|
|
|
785
770
|
if request.process_exception(e, kwargs):
|
|
786
771
|
request._ingest["end_to_end_latency_ms"] = duration
|
|
787
|
-
await self._aingest_units(request
|
|
772
|
+
await self._aingest_units(request)
|
|
788
773
|
|
|
789
774
|
raise e
|
|
790
775
|
|
|
@@ -828,7 +813,7 @@ class _PayiInstrumentor:
|
|
|
828
813
|
self._logger.debug(f"async_invoke_wrapper: process sync response return")
|
|
829
814
|
return return_result
|
|
830
815
|
|
|
831
|
-
await self._aingest_units(request
|
|
816
|
+
await self._aingest_units(request)
|
|
832
817
|
|
|
833
818
|
self._logger.debug(f"async_invoke_wrapper: finished")
|
|
834
819
|
return response
|
|
@@ -907,7 +892,7 @@ class _PayiInstrumentor:
|
|
|
907
892
|
|
|
908
893
|
if request.process_exception(e, kwargs):
|
|
909
894
|
request._ingest["end_to_end_latency_ms"] = duration
|
|
910
|
-
self._ingest_units(request
|
|
895
|
+
self._ingest_units(request)
|
|
911
896
|
|
|
912
897
|
raise e
|
|
913
898
|
|
|
@@ -960,7 +945,7 @@ class _PayiInstrumentor:
|
|
|
960
945
|
self._logger.debug(f"invoke_wrapper: process sync response return")
|
|
961
946
|
return return_result
|
|
962
947
|
|
|
963
|
-
self._ingest_units(request
|
|
948
|
+
self._ingest_units(request)
|
|
964
949
|
|
|
965
950
|
self._logger.debug(f"invoke_wrapper: finished")
|
|
966
951
|
return response
|
|
@@ -982,9 +967,6 @@ class _PayiInstrumentor:
|
|
|
982
967
|
) -> None:
|
|
983
968
|
context_limit_ids: Optional[list[str]] = context.get("limit_ids")
|
|
984
969
|
|
|
985
|
-
context_experience_name: Optional[str] = context.get("experience_name")
|
|
986
|
-
context_experience_id: Optional[str] = context.get("experience_id")
|
|
987
|
-
|
|
988
970
|
context_use_case_name: Optional[str] = context.get("use_case_name")
|
|
989
971
|
context_use_case_id: Optional[str] = context.get("use_case_id")
|
|
990
972
|
context_use_case_version: Optional[int] = context.get("use_case_version")
|
|
@@ -1043,20 +1025,6 @@ class _PayiInstrumentor:
|
|
|
1043
1025
|
if context_use_case_step is not None:
|
|
1044
1026
|
extra_headers[PayiHeaderNames.use_case_step] = str(context_use_case_step)
|
|
1045
1027
|
|
|
1046
|
-
if PayiHeaderNames.experience_name in extra_headers:
|
|
1047
|
-
headers_experience_name = extra_headers.get(PayiHeaderNames.experience_name, None)
|
|
1048
|
-
if headers_experience_name is None or len(headers_experience_name) == 0:
|
|
1049
|
-
# headers_experience_name is empty, remove all experience related headers
|
|
1050
|
-
extra_headers.pop(PayiHeaderNames.experience_name, None)
|
|
1051
|
-
extra_headers.pop(PayiHeaderNames.experience_id, None)
|
|
1052
|
-
else:
|
|
1053
|
-
# leave the value in extra_headers
|
|
1054
|
-
...
|
|
1055
|
-
elif context_experience_name is not None:
|
|
1056
|
-
extra_headers[PayiHeaderNames.experience_name] = context_experience_name
|
|
1057
|
-
if context_experience_id is not None:
|
|
1058
|
-
extra_headers[PayiHeaderNames.experience_id] = context_experience_id
|
|
1059
|
-
|
|
1060
1028
|
if PayiHeaderNames.request_tags not in extra_headers and context_request_tags:
|
|
1061
1029
|
extra_headers[PayiHeaderNames.request_tags] = ",".join(context_request_tags)
|
|
1062
1030
|
|
|
@@ -1281,7 +1249,7 @@ class _StreamIteratorWrapper(ObjectProxy): # type: ignore
|
|
|
1281
1249
|
|
|
1282
1250
|
self._process_stop_iteration()
|
|
1283
1251
|
|
|
1284
|
-
await self._instrumentor._aingest_units(self._request
|
|
1252
|
+
await self._instrumentor._aingest_units(self._request)
|
|
1285
1253
|
self._ingested = True
|
|
1286
1254
|
|
|
1287
1255
|
def _stop_iteration(self) -> None:
|
|
@@ -1290,7 +1258,7 @@ class _StreamIteratorWrapper(ObjectProxy): # type: ignore
|
|
|
1290
1258
|
return
|
|
1291
1259
|
|
|
1292
1260
|
self._process_stop_iteration()
|
|
1293
|
-
self._instrumentor._ingest_units(self._request
|
|
1261
|
+
self._instrumentor._ingest_units(self._request)
|
|
1294
1262
|
self._ingested = True
|
|
1295
1263
|
|
|
1296
1264
|
@staticmethod
|
|
@@ -1433,7 +1401,7 @@ class _GeneratorWrapper: # type: ignore
|
|
|
1433
1401
|
|
|
1434
1402
|
self._process_stop_iteration()
|
|
1435
1403
|
|
|
1436
|
-
self._instrumentor._ingest_units(self._request
|
|
1404
|
+
self._instrumentor._ingest_units(self._request)
|
|
1437
1405
|
self._ingested = True
|
|
1438
1406
|
|
|
1439
1407
|
async def _astop_iteration(self) -> None:
|
|
@@ -1443,7 +1411,7 @@ class _GeneratorWrapper: # type: ignore
|
|
|
1443
1411
|
|
|
1444
1412
|
self._process_stop_iteration()
|
|
1445
1413
|
|
|
1446
|
-
await self._instrumentor._aingest_units(self._request
|
|
1414
|
+
await self._instrumentor._aingest_units(self._request)
|
|
1447
1415
|
self._ingested = True
|
|
1448
1416
|
|
|
1449
1417
|
def _process_stop_iteration(self) -> None:
|
|
@@ -1524,8 +1492,6 @@ def track(
|
|
|
1524
1492
|
func,
|
|
1525
1493
|
proxy,
|
|
1526
1494
|
limit_ids,
|
|
1527
|
-
None, # experience_name,
|
|
1528
|
-
None, #experience_id,
|
|
1529
1495
|
use_case_name,
|
|
1530
1496
|
use_case_id,
|
|
1531
1497
|
use_case_version,
|
|
@@ -1546,8 +1512,6 @@ def track(
|
|
|
1546
1512
|
func,
|
|
1547
1513
|
proxy,
|
|
1548
1514
|
limit_ids,
|
|
1549
|
-
None, # experience_name,
|
|
1550
|
-
None, # experience_id,
|
|
1551
1515
|
use_case_name,
|
|
1552
1516
|
use_case_id,
|
|
1553
1517
|
use_case_version,
|
|
@@ -1590,138 +1554,4 @@ def track_context(
|
|
|
1590
1554
|
context["price_as_resource"] = price_as_resource
|
|
1591
1555
|
context["resource_scope"] = resource_scope
|
|
1592
1556
|
|
|
1593
|
-
return _TrackContext(context)
|
|
1594
|
-
|
|
1595
|
-
@deprecated("@ingest() is deprecated. Use @track() instead")
|
|
1596
|
-
def ingest(
|
|
1597
|
-
limit_ids: Optional["list[str]"] = None,
|
|
1598
|
-
experience_name: Optional[str] = None,
|
|
1599
|
-
experience_id: Optional[str] = None,
|
|
1600
|
-
use_case_name: Optional[str] = None,
|
|
1601
|
-
use_case_id: Optional[str] = None,
|
|
1602
|
-
use_case_version: Optional[int] = None,
|
|
1603
|
-
user_id: Optional[str] = None,
|
|
1604
|
-
) -> Any:
|
|
1605
|
-
warnings.warn(
|
|
1606
|
-
"@ingest is deprecated and will be removed in a future version. Use @track instead.",
|
|
1607
|
-
DeprecationWarning,
|
|
1608
|
-
stacklevel=2
|
|
1609
|
-
|
|
1610
|
-
)
|
|
1611
|
-
|
|
1612
|
-
def _ingest(func: Any) -> Any:
|
|
1613
|
-
import asyncio
|
|
1614
|
-
if asyncio.iscoroutinefunction(func):
|
|
1615
|
-
async def awrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1616
|
-
if not _instrumentor:
|
|
1617
|
-
_g_logger.debug(f"ingest: call no instrumentor!")
|
|
1618
|
-
return await func(*args, **kwargs)
|
|
1619
|
-
|
|
1620
|
-
_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})")
|
|
1621
|
-
|
|
1622
|
-
# Call the instrumentor's _call_func for async functions
|
|
1623
|
-
return await _instrumentor._acall_func(
|
|
1624
|
-
func,
|
|
1625
|
-
False,
|
|
1626
|
-
limit_ids,
|
|
1627
|
-
experience_name,
|
|
1628
|
-
experience_id,
|
|
1629
|
-
use_case_name,
|
|
1630
|
-
use_case_id,
|
|
1631
|
-
use_case_version,
|
|
1632
|
-
user_id,
|
|
1633
|
-
*args,
|
|
1634
|
-
**kwargs,
|
|
1635
|
-
)
|
|
1636
|
-
return awrapper
|
|
1637
|
-
else:
|
|
1638
|
-
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1639
|
-
if not _instrumentor:
|
|
1640
|
-
_g_logger.debug(f"ingest: call no instrumentor!")
|
|
1641
|
-
return func(*args, **kwargs)
|
|
1642
|
-
|
|
1643
|
-
_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})")
|
|
1644
|
-
|
|
1645
|
-
return _instrumentor._call_func(
|
|
1646
|
-
func,
|
|
1647
|
-
False,
|
|
1648
|
-
limit_ids,
|
|
1649
|
-
experience_name,
|
|
1650
|
-
experience_id,
|
|
1651
|
-
use_case_name,
|
|
1652
|
-
use_case_id,
|
|
1653
|
-
use_case_version,
|
|
1654
|
-
user_id,
|
|
1655
|
-
*args,
|
|
1656
|
-
**kwargs,
|
|
1657
|
-
)
|
|
1658
|
-
return wrapper
|
|
1659
|
-
|
|
1660
|
-
return _ingest
|
|
1661
|
-
|
|
1662
|
-
@deprecated("@proxy() is deprecated. Use @track() instead")
|
|
1663
|
-
def proxy(
|
|
1664
|
-
limit_ids: Optional["list[str]"] = None,
|
|
1665
|
-
experience_name: Optional[str] = None,
|
|
1666
|
-
experience_id: Optional[str] = None,
|
|
1667
|
-
use_case_id: Optional[str] = None,
|
|
1668
|
-
use_case_name: Optional[str] = None,
|
|
1669
|
-
use_case_version: Optional[int] = None,
|
|
1670
|
-
user_id: Optional[str] = None,
|
|
1671
|
-
) -> Any:
|
|
1672
|
-
warnings.warn(
|
|
1673
|
-
"@proxy is deprecated and will be removed in a future version. Use @track instead.",
|
|
1674
|
-
DeprecationWarning,
|
|
1675
|
-
stacklevel=2
|
|
1676
|
-
)
|
|
1677
|
-
|
|
1678
|
-
def _proxy(func: Any) -> Any:
|
|
1679
|
-
import asyncio
|
|
1680
|
-
if asyncio.iscoroutinefunction(func):
|
|
1681
|
-
async def _proxy_awrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1682
|
-
if not _instrumentor:
|
|
1683
|
-
_g_logger.debug(f"proxy: call no instrumentor!")
|
|
1684
|
-
return await func(*args, **kwargs)
|
|
1685
|
-
|
|
1686
|
-
_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})")
|
|
1687
|
-
|
|
1688
|
-
return await _instrumentor._call_func(
|
|
1689
|
-
func,
|
|
1690
|
-
True,
|
|
1691
|
-
limit_ids,
|
|
1692
|
-
experience_name,
|
|
1693
|
-
experience_id,
|
|
1694
|
-
use_case_name,
|
|
1695
|
-
use_case_id,
|
|
1696
|
-
use_case_version,
|
|
1697
|
-
user_id,
|
|
1698
|
-
*args,
|
|
1699
|
-
**kwargs
|
|
1700
|
-
)
|
|
1701
|
-
|
|
1702
|
-
return _proxy_awrapper
|
|
1703
|
-
else:
|
|
1704
|
-
def _proxy_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1705
|
-
if not _instrumentor:
|
|
1706
|
-
_g_logger.debug(f"proxy: call no instrumentor!")
|
|
1707
|
-
return func(*args, **kwargs)
|
|
1708
|
-
|
|
1709
|
-
_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})")
|
|
1710
|
-
|
|
1711
|
-
return _instrumentor._call_func(
|
|
1712
|
-
func,
|
|
1713
|
-
True,
|
|
1714
|
-
limit_ids,
|
|
1715
|
-
experience_name,
|
|
1716
|
-
experience_id,
|
|
1717
|
-
use_case_name,
|
|
1718
|
-
use_case_id,
|
|
1719
|
-
use_case_version,
|
|
1720
|
-
user_id,
|
|
1721
|
-
*args,
|
|
1722
|
-
**kwargs
|
|
1723
|
-
)
|
|
1724
|
-
|
|
1725
|
-
return _proxy_wrapper
|
|
1726
|
-
|
|
1727
|
-
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
|