payi 0.1.0a45__py3-none-any.whl → 0.1.0a46__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 CHANGED
@@ -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.46" # 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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: payi
3
- Version: 0.1.0a45
3
+ Version: 0.1.0a46
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
@@ -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=VC4OQPU9XobR2EdEK-EBM6augnkc71ZliJY4u8c_IoY,165
14
+ payi/_version.py,sha256=ml75PCr3anMJW3fkTojqOUY2T3iVxRGV0E2gWIEhotQ,165
15
15
  payi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  payi/_utils/__init__.py,sha256=PNZ_QJuzZEgyYXqkO1HVhGkj5IU9bglVUcw7H-Knjzw,2062
17
17
  payi/_utils/_logs.py,sha256=fmnf5D9TOgkgZKfgYmSa3PiUc3SZgkchn6CzJUeo0SQ,768
@@ -26,7 +26,7 @@ payi/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
26
26
  payi/lib/AnthropicInstrumentor.py,sha256=1dJTFs5WfPxbIjWcYV2tP3kiYc4g3WyyyR4XWQ-WI_g,5300
27
27
  payi/lib/BedrockInstrumentor.py,sha256=B5deT8TcUvOsRdIewbbHtsxTS7_oHJ05ZUIdFziWf8E,10082
28
28
  payi/lib/Instruments.py,sha256=bapmVS9jbHtFknXCKDzsFFWvf5XLtzEpdlvI7iEWY-o,147
29
- payi/lib/OpenAIInstrumentor.py,sha256=Xn0gWnQUS6UkY3mn3vFFa8wqSbC9QaDGKpBdD9j7aGU,5019
29
+ payi/lib/OpenAIInstrumentor.py,sha256=rxu5wOUBZaGwFjUoUhk5UDeTcYSmmO6BVgnXL4yYb08,6613
30
30
  payi/lib/Stopwatch.py,sha256=7OJlxvr2Jyb6Zr1LYCYKczRB7rDVKkIR7gc4YoleNdE,764
31
31
  payi/lib/helpers.py,sha256=ZgkY8UE2YRc7ok2Pmxg_T9UMqKI8D8542JY3CP8RZCM,1597
32
32
  payi/lib/instrument.py,sha256=rQCBCyFicTtOjuASwTtCEGvDoffUUgYQoYcuiSlVUlk,35356
@@ -113,7 +113,7 @@ payi/types/requests/request_result.py,sha256=phYQiqhwNaR9igP-Fhs34Y-__dlT7L4wq-r
113
113
  payi/types/shared/__init__.py,sha256=-xz5dxK5LBjLnsi2LpLq5btaGDFp-mSjJ0y2qKy0Yus,264
114
114
  payi/types/shared/evaluation_response.py,sha256=ejEToMA57PUu1SldEtJ5z9r4fAO3U0tvdjbsyIoVX1s,214
115
115
  payi/types/shared/pay_i_common_models_budget_management_cost_details_base.py,sha256=XmIzJXy4zAi-mfrDvEXiYjO3qF1EvugGUl-Gijj4TA4,268
116
- payi-0.1.0a45.dist-info/METADATA,sha256=FMnDJJt7RDH8Yrlfsx7KnDDNOQITK1TSQoAIEygqBWQ,12660
117
- payi-0.1.0a45.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
118
- payi-0.1.0a45.dist-info/licenses/LICENSE,sha256=CQt03aM-P4a3Yg5qBg3JSLVoQS3smMyvx7tYg_6V7Gk,11334
119
- payi-0.1.0a45.dist-info/RECORD,,
116
+ payi-0.1.0a46.dist-info/METADATA,sha256=4jSFupUbO3KTCTYi_UCy_-lvzGZ3hGi57g-J57Wi_1E,12660
117
+ payi-0.1.0a46.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
118
+ payi-0.1.0a46.dist-info/licenses/LICENSE,sha256=CQt03aM-P4a3Yg5qBg3JSLVoQS3smMyvx7tYg_6V7Gk,11334
119
+ payi-0.1.0a46.dist-info/RECORD,,