paid-python 0.6.0__py3-none-any.whl → 1.0.0a0__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.
- paid/__init__.py +31 -0
- paid/client.py +1 -472
- paid/core/client_wrapper.py +3 -2
- paid/customers/__init__.py +3 -0
- paid/customers/client.py +428 -4
- paid/customers/raw_client.py +594 -2
- paid/customers/types/__init__.py +8 -0
- paid/customers/types/customers_check_entitlement_request_view.py +5 -0
- paid/customers/types/customers_check_entitlement_response.py +22 -0
- paid/orders/client.py +435 -0
- paid/orders/raw_client.py +695 -0
- paid/plans/client.py +71 -0
- paid/plans/raw_client.py +121 -2
- paid/types/__init__.py +28 -0
- paid/types/cancel_renewal_response.py +49 -0
- paid/types/contact_create_for_customer.py +37 -0
- paid/types/invoice.py +75 -0
- paid/types/invoice_status.py +5 -0
- paid/types/payment_method.py +58 -0
- paid/types/payment_method_card.py +49 -0
- paid/types/payment_method_type.py +5 -0
- paid/types/payment_method_us_bank_account.py +36 -0
- paid/types/payment_method_us_bank_account_account_type.py +5 -0
- paid/types/plan_plan_products_item.py +6 -0
- paid/types/plan_with_features.py +69 -0
- paid/types/plan_with_features_features_item.py +34 -0
- paid/types/proration_attribute_update.py +44 -0
- paid/types/proration_detail.py +49 -0
- paid/types/proration_upgrade_response.py +73 -0
- paid/types/signal_v_2.py +5 -5
- paid/usage/client.py +6 -6
- {paid_python-0.6.0.dist-info → paid_python-1.0.0a0.dist-info}/METADATA +6 -4
- {paid_python-0.6.0.dist-info → paid_python-1.0.0a0.dist-info}/RECORD +35 -36
- opentelemetry/instrumentation/openai/__init__.py +0 -54
- opentelemetry/instrumentation/openai/shared/__init__.py +0 -399
- opentelemetry/instrumentation/openai/shared/audio_wrappers.py +0 -247
- opentelemetry/instrumentation/openai/shared/chat_wrappers.py +0 -1192
- opentelemetry/instrumentation/openai/shared/completion_wrappers.py +0 -292
- opentelemetry/instrumentation/openai/shared/config.py +0 -15
- opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +0 -311
- opentelemetry/instrumentation/openai/shared/event_emitter.py +0 -108
- opentelemetry/instrumentation/openai/shared/event_models.py +0 -41
- opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +0 -68
- opentelemetry/instrumentation/openai/shared/span_utils.py +0 -0
- opentelemetry/instrumentation/openai/utils.py +0 -213
- opentelemetry/instrumentation/openai/v0/__init__.py +0 -176
- opentelemetry/instrumentation/openai/v1/__init__.py +0 -394
- opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +0 -329
- opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +0 -134
- opentelemetry/instrumentation/openai/v1/responses_wrappers.py +0 -1113
- opentelemetry/instrumentation/openai/version.py +0 -1
- {paid_python-0.6.0.dist-info → paid_python-1.0.0a0.dist-info}/LICENSE +0 -0
- {paid_python-0.6.0.dist-info → paid_python-1.0.0a0.dist-info}/WHEEL +0 -0
paid/__init__.py
CHANGED
|
@@ -11,8 +11,10 @@ from .types import (
|
|
|
11
11
|
AgentUpdate,
|
|
12
12
|
ApiError,
|
|
13
13
|
BillingFrequency,
|
|
14
|
+
CancelRenewalResponse,
|
|
14
15
|
ChargeType,
|
|
15
16
|
Contact,
|
|
17
|
+
ContactCreateForCustomer,
|
|
16
18
|
CostAmount,
|
|
17
19
|
CostTrace,
|
|
18
20
|
CostTracesResponse,
|
|
@@ -22,6 +24,8 @@ from .types import (
|
|
|
22
24
|
CustomerUpdate,
|
|
23
25
|
EntitlementUsage,
|
|
24
26
|
Error,
|
|
27
|
+
Invoice,
|
|
28
|
+
InvoiceStatus,
|
|
25
29
|
Order,
|
|
26
30
|
OrderLine,
|
|
27
31
|
OrderLineAttribute,
|
|
@@ -29,10 +33,17 @@ from .types import (
|
|
|
29
33
|
OrderLineAttributePricing,
|
|
30
34
|
OrderLineCreate,
|
|
31
35
|
PaginationMeta,
|
|
36
|
+
PaymentMethod,
|
|
37
|
+
PaymentMethodCard,
|
|
38
|
+
PaymentMethodType,
|
|
39
|
+
PaymentMethodUsBankAccount,
|
|
40
|
+
PaymentMethodUsBankAccountAccountType,
|
|
32
41
|
Plan,
|
|
33
42
|
PlanGroup,
|
|
34
43
|
PlanPlanProductsItem,
|
|
35
44
|
PlanPlanProductsItemPlanProductAttributeItem,
|
|
45
|
+
PlanWithFeatures,
|
|
46
|
+
PlanWithFeaturesFeaturesItem,
|
|
36
47
|
PricePoint,
|
|
37
48
|
Pricing,
|
|
38
49
|
PricingModelType,
|
|
@@ -40,6 +51,9 @@ from .types import (
|
|
|
40
51
|
ProductType,
|
|
41
52
|
ProductUpdate,
|
|
42
53
|
ProductUpdateType,
|
|
54
|
+
ProrationAttributeUpdate,
|
|
55
|
+
ProrationDetail,
|
|
56
|
+
ProrationUpgradeResponse,
|
|
43
57
|
Salutation,
|
|
44
58
|
Signal,
|
|
45
59
|
SignalV2,
|
|
@@ -56,6 +70,7 @@ from .types import (
|
|
|
56
70
|
from .errors import BadRequestError, ForbiddenError, InternalServerError, NotFoundError
|
|
57
71
|
from . import agents, contacts, customers, orders, plans, products, traces, usage
|
|
58
72
|
from .client import AsyncPaid, Paid
|
|
73
|
+
from .customers import CustomersCheckEntitlementRequestView, CustomersCheckEntitlementResponse
|
|
59
74
|
from .environment import PaidEnvironment
|
|
60
75
|
from .products import ProductCreateType
|
|
61
76
|
from .usage import UsageCheckUsageResponse
|
|
@@ -72,8 +87,10 @@ __all__ = [
|
|
|
72
87
|
"AsyncPaid",
|
|
73
88
|
"BadRequestError",
|
|
74
89
|
"BillingFrequency",
|
|
90
|
+
"CancelRenewalResponse",
|
|
75
91
|
"ChargeType",
|
|
76
92
|
"Contact",
|
|
93
|
+
"ContactCreateForCustomer",
|
|
77
94
|
"CostAmount",
|
|
78
95
|
"CostTrace",
|
|
79
96
|
"CostTracesResponse",
|
|
@@ -81,10 +98,14 @@ __all__ = [
|
|
|
81
98
|
"CreationState",
|
|
82
99
|
"Customer",
|
|
83
100
|
"CustomerUpdate",
|
|
101
|
+
"CustomersCheckEntitlementRequestView",
|
|
102
|
+
"CustomersCheckEntitlementResponse",
|
|
84
103
|
"EntitlementUsage",
|
|
85
104
|
"Error",
|
|
86
105
|
"ForbiddenError",
|
|
87
106
|
"InternalServerError",
|
|
107
|
+
"Invoice",
|
|
108
|
+
"InvoiceStatus",
|
|
88
109
|
"NotFoundError",
|
|
89
110
|
"Order",
|
|
90
111
|
"OrderLine",
|
|
@@ -95,10 +116,17 @@ __all__ = [
|
|
|
95
116
|
"PaginationMeta",
|
|
96
117
|
"Paid",
|
|
97
118
|
"PaidEnvironment",
|
|
119
|
+
"PaymentMethod",
|
|
120
|
+
"PaymentMethodCard",
|
|
121
|
+
"PaymentMethodType",
|
|
122
|
+
"PaymentMethodUsBankAccount",
|
|
123
|
+
"PaymentMethodUsBankAccountAccountType",
|
|
98
124
|
"Plan",
|
|
99
125
|
"PlanGroup",
|
|
100
126
|
"PlanPlanProductsItem",
|
|
101
127
|
"PlanPlanProductsItemPlanProductAttributeItem",
|
|
128
|
+
"PlanWithFeatures",
|
|
129
|
+
"PlanWithFeaturesFeaturesItem",
|
|
102
130
|
"PricePoint",
|
|
103
131
|
"Pricing",
|
|
104
132
|
"PricingModelType",
|
|
@@ -107,6 +135,9 @@ __all__ = [
|
|
|
107
135
|
"ProductType",
|
|
108
136
|
"ProductUpdate",
|
|
109
137
|
"ProductUpdateType",
|
|
138
|
+
"ProrationAttributeUpdate",
|
|
139
|
+
"ProrationDetail",
|
|
140
|
+
"ProrationUpgradeResponse",
|
|
110
141
|
"Salutation",
|
|
111
142
|
"Signal",
|
|
112
143
|
"SignalV2",
|
paid/client.py
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import typing
|
|
4
|
-
import warnings
|
|
5
4
|
|
|
6
5
|
import httpx
|
|
7
|
-
from dotenv import load_dotenv
|
|
8
|
-
|
|
9
|
-
# Load environment variables from .env file
|
|
10
|
-
load_dotenv()
|
|
11
6
|
from .agents.client import AgentsClient, AsyncAgentsClient
|
|
12
7
|
from .contacts.client import AsyncContactsClient, ContactsClient
|
|
13
8
|
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
@@ -17,22 +12,8 @@ from .orders.client import AsyncOrdersClient, OrdersClient
|
|
|
17
12
|
from .plans.client import AsyncPlansClient, PlansClient
|
|
18
13
|
from .products.client import AsyncProductsClient, ProductsClient
|
|
19
14
|
from .traces.client import AsyncTracesClient, TracesClient
|
|
20
|
-
from .tracing.distributed_tracing import (
|
|
21
|
-
generate_tracing_token,
|
|
22
|
-
set_tracing_token,
|
|
23
|
-
unset_tracing_token,
|
|
24
|
-
)
|
|
25
|
-
from .tracing.signal import signal
|
|
26
|
-
from .tracing.tracing import (
|
|
27
|
-
DEFAULT_COLLECTOR_ENDPOINT,
|
|
28
|
-
initialize_tracing,
|
|
29
|
-
trace_async_,
|
|
30
|
-
trace_sync_,
|
|
31
|
-
)
|
|
32
15
|
from .usage.client import AsyncUsageClient, UsageClient
|
|
33
16
|
|
|
34
|
-
T = typing.TypeVar("T")
|
|
35
|
-
|
|
36
17
|
|
|
37
18
|
class Paid:
|
|
38
19
|
"""
|
|
@@ -81,14 +62,6 @@ class Paid:
|
|
|
81
62
|
follow_redirects: typing.Optional[bool] = True,
|
|
82
63
|
httpx_client: typing.Optional[httpx.Client] = None,
|
|
83
64
|
):
|
|
84
|
-
# If token is not provided, try to get it from environment variable
|
|
85
|
-
if token is None:
|
|
86
|
-
token = os.environ.get("PAID_API_KEY")
|
|
87
|
-
if token is None:
|
|
88
|
-
raise ValueError(
|
|
89
|
-
"API token must be provided either via the 'token' parameter or the 'PAID_API_KEY' environment variable"
|
|
90
|
-
)
|
|
91
|
-
|
|
92
65
|
_defaulted_timeout = (
|
|
93
66
|
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
94
67
|
)
|
|
@@ -111,223 +84,6 @@ class Paid:
|
|
|
111
84
|
self.usage = UsageClient(client_wrapper=self._client_wrapper)
|
|
112
85
|
self.traces = TracesClient(client_wrapper=self._client_wrapper)
|
|
113
86
|
|
|
114
|
-
def initialize_tracing(self, collector_endpoint: str = DEFAULT_COLLECTOR_ENDPOINT) -> None:
|
|
115
|
-
"""
|
|
116
|
-
Deprecated: Use the @paid_tracing decorator or context manager instead.
|
|
117
|
-
|
|
118
|
-
This method is deprecated and will be removed in a future version.
|
|
119
|
-
The @paid_tracing decorator automatically initializes tracing as needed.
|
|
120
|
-
|
|
121
|
-
Instead of:
|
|
122
|
-
client.initialize_tracing()
|
|
123
|
-
client.trace(external_customer_id="...", fn=lambda: ...)
|
|
124
|
-
|
|
125
|
-
Use:
|
|
126
|
-
from paid.tracing import paid_tracing
|
|
127
|
-
|
|
128
|
-
@paid_tracing(external_customer_id="...", external_agent_id="...")
|
|
129
|
-
def my_function():
|
|
130
|
-
...
|
|
131
|
-
|
|
132
|
-
Or as a context manager:
|
|
133
|
-
with paid_tracing(external_customer_id="..."):
|
|
134
|
-
result = agent_workflow()
|
|
135
|
-
"""
|
|
136
|
-
warnings.warn(
|
|
137
|
-
"Paid.initialize_tracing() is deprecated and will be removed in a future version. "
|
|
138
|
-
"Use @paid_tracing decorator/context manager directly, which auto-initializes tracing. "
|
|
139
|
-
"See documentation: https://docs.paid.ai/documentation/getting-started/integrate-signals-and-cost-tracking-to-your-codebase",
|
|
140
|
-
DeprecationWarning,
|
|
141
|
-
stacklevel=2,
|
|
142
|
-
)
|
|
143
|
-
token = self._client_wrapper._get_token()
|
|
144
|
-
initialize_tracing(token, collector_endpoint=collector_endpoint)
|
|
145
|
-
|
|
146
|
-
def generate_tracing_token(self) -> int:
|
|
147
|
-
"""
|
|
148
|
-
Deprecated: Import and use generate_tracing_token() directly from paid.tracing.
|
|
149
|
-
|
|
150
|
-
This method is deprecated and will be removed in a future version.
|
|
151
|
-
Use the standalone function instead.
|
|
152
|
-
|
|
153
|
-
Instead of:
|
|
154
|
-
from paid import Paid
|
|
155
|
-
client = Paid(token="...")
|
|
156
|
-
token = client.generate_tracing_token()
|
|
157
|
-
|
|
158
|
-
Use:
|
|
159
|
-
from paid.tracing import generate_tracing_token
|
|
160
|
-
token = generate_tracing_token()
|
|
161
|
-
"""
|
|
162
|
-
warnings.warn(
|
|
163
|
-
"Paid.generate_tracing_token() is deprecated and will be removed in a future version. "
|
|
164
|
-
"Import and use generate_tracing_token() directly from paid.tracing instead.",
|
|
165
|
-
DeprecationWarning,
|
|
166
|
-
stacklevel=2,
|
|
167
|
-
)
|
|
168
|
-
return generate_tracing_token()
|
|
169
|
-
|
|
170
|
-
def set_tracing_token(self, token: int):
|
|
171
|
-
"""
|
|
172
|
-
Deprecated: Pass tracing_token directly to @paid_tracing() decorator instead.
|
|
173
|
-
|
|
174
|
-
This method is deprecated and will be removed in a future version.
|
|
175
|
-
Use the tracing_token parameter in @paid_tracing() to link traces across processes.
|
|
176
|
-
|
|
177
|
-
Instead of:
|
|
178
|
-
from paid import Paid
|
|
179
|
-
client = Paid(token="...")
|
|
180
|
-
token = load_from_storage("workflow_123")
|
|
181
|
-
client.set_tracing_token(token)
|
|
182
|
-
@paid_tracing(external_customer_id="cust_123", external_agent_id="agent_456")
|
|
183
|
-
def process_workflow():
|
|
184
|
-
...
|
|
185
|
-
client.unset_tracing_token()
|
|
186
|
-
|
|
187
|
-
Use:
|
|
188
|
-
from paid.tracing import paid_tracing
|
|
189
|
-
token = load_from_storage("workflow_123")
|
|
190
|
-
|
|
191
|
-
@paid_tracing(
|
|
192
|
-
external_customer_id="cust_123",
|
|
193
|
-
external_agent_id="agent_456",
|
|
194
|
-
tracing_token=token
|
|
195
|
-
)
|
|
196
|
-
def process_workflow():
|
|
197
|
-
...
|
|
198
|
-
|
|
199
|
-
Parameters
|
|
200
|
-
----------
|
|
201
|
-
token : int
|
|
202
|
-
A tracing token to use for the next traces.
|
|
203
|
-
"""
|
|
204
|
-
warnings.warn(
|
|
205
|
-
"Paid.set_tracing_token() is deprecated and will be removed in a future version. "
|
|
206
|
-
"Pass tracing_token directly to @paid_tracing(tracing_token=...) decorator instead.",
|
|
207
|
-
DeprecationWarning,
|
|
208
|
-
stacklevel=2,
|
|
209
|
-
)
|
|
210
|
-
set_tracing_token(token)
|
|
211
|
-
|
|
212
|
-
def unset_tracing_token(self):
|
|
213
|
-
"""
|
|
214
|
-
Deprecated: No longer needed. Use tracing_token parameter in @paid_tracing() instead.
|
|
215
|
-
|
|
216
|
-
This method is deprecated and will be removed in a future version.
|
|
217
|
-
Since tracing_token is now passed directly to @paid_tracing(), there's no need
|
|
218
|
-
to manually set/unset tokens in the context.
|
|
219
|
-
|
|
220
|
-
Old pattern (no longer recommended):
|
|
221
|
-
from paid import Paid
|
|
222
|
-
client = Paid(token="...")
|
|
223
|
-
client.set_tracing_token(token)
|
|
224
|
-
@paid_tracing(external_customer_id="cust_123", external_agent_id="agent_456")
|
|
225
|
-
def my_function():
|
|
226
|
-
...
|
|
227
|
-
client.unset_tracing_token()
|
|
228
|
-
|
|
229
|
-
New pattern (recommended):
|
|
230
|
-
from paid.tracing import paid_tracing
|
|
231
|
-
@paid_tracing(
|
|
232
|
-
external_customer_id="cust_123",
|
|
233
|
-
external_agent_id="agent_456",
|
|
234
|
-
tracing_token=token
|
|
235
|
-
)
|
|
236
|
-
def my_function():
|
|
237
|
-
...
|
|
238
|
-
"""
|
|
239
|
-
warnings.warn(
|
|
240
|
-
"Paid.unset_tracing_token() is deprecated and will be removed in a future version. "
|
|
241
|
-
"Use tracing_token parameter in @paid_tracing(tracing_token=...) decorator instead.",
|
|
242
|
-
DeprecationWarning,
|
|
243
|
-
stacklevel=2,
|
|
244
|
-
)
|
|
245
|
-
unset_tracing_token()
|
|
246
|
-
|
|
247
|
-
def trace(
|
|
248
|
-
self,
|
|
249
|
-
external_customer_id: str,
|
|
250
|
-
fn: typing.Callable[[], T],
|
|
251
|
-
external_agent_id: typing.Optional[str] = None,
|
|
252
|
-
tracing_token: typing.Optional[int] = None,
|
|
253
|
-
metadata: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
254
|
-
args: typing.Optional[typing.Tuple] = None,
|
|
255
|
-
kwargs: typing.Optional[typing.Dict] = None,
|
|
256
|
-
) -> T:
|
|
257
|
-
"""
|
|
258
|
-
Deprecated: Use the @paid_tracing decorator or context manager instead.
|
|
259
|
-
|
|
260
|
-
This method is deprecated and will be removed in a future version.
|
|
261
|
-
The callback-based tracing via Paid.trace() is being replaced with the more
|
|
262
|
-
Pythonic @paid_tracing decorator and context manager.
|
|
263
|
-
|
|
264
|
-
Instead of:
|
|
265
|
-
result = client.trace(
|
|
266
|
-
external_customer_id="cust_123",
|
|
267
|
-
fn=lambda: agent_workflow(),
|
|
268
|
-
external_agent_id="agent_456"
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
Use the decorator:
|
|
272
|
-
from paid.tracing import paid_tracing
|
|
273
|
-
|
|
274
|
-
@paid_tracing(external_customer_id="cust_123", external_agent_id="agent_456")
|
|
275
|
-
def agent_workflow():
|
|
276
|
-
...
|
|
277
|
-
|
|
278
|
-
result = agent_workflow()
|
|
279
|
-
|
|
280
|
-
Or use the context manager:
|
|
281
|
-
with paid_tracing(external_customer_id="cust_123", external_agent_id="agent_456"):
|
|
282
|
-
result = agent_workflow()
|
|
283
|
-
"""
|
|
284
|
-
warnings.warn(
|
|
285
|
-
"Paid.trace() is deprecated and will be removed in a future version. "
|
|
286
|
-
"Use the @paid_tracing decorator or context manager instead. "
|
|
287
|
-
"See documentation: https://docs.paid.ai/documentation/getting-started/integrate-signals-and-cost-tracking-to-your-codebase",
|
|
288
|
-
DeprecationWarning,
|
|
289
|
-
stacklevel=2,
|
|
290
|
-
)
|
|
291
|
-
return trace_sync_(
|
|
292
|
-
external_customer_id=external_customer_id,
|
|
293
|
-
fn=fn,
|
|
294
|
-
external_agent_id=external_agent_id,
|
|
295
|
-
tracing_token=tracing_token,
|
|
296
|
-
metadata=metadata,
|
|
297
|
-
args=args,
|
|
298
|
-
kwargs=kwargs,
|
|
299
|
-
)
|
|
300
|
-
|
|
301
|
-
def signal(
|
|
302
|
-
self,
|
|
303
|
-
event_name: str,
|
|
304
|
-
*,
|
|
305
|
-
data: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
306
|
-
enable_cost_tracing: bool = False,
|
|
307
|
-
) -> None:
|
|
308
|
-
"""
|
|
309
|
-
Deprecated: Import and use signal() directly from paid.tracing.
|
|
310
|
-
|
|
311
|
-
This method is deprecated and will be removed in a future version.
|
|
312
|
-
Use the standalone function instead.
|
|
313
|
-
|
|
314
|
-
Instead of:
|
|
315
|
-
from paid import Paid
|
|
316
|
-
client = Paid(token="...")
|
|
317
|
-
client.signal("event_name", data={...})
|
|
318
|
-
|
|
319
|
-
Use:
|
|
320
|
-
from paid.tracing import signal
|
|
321
|
-
signal("event_name", data={...})
|
|
322
|
-
"""
|
|
323
|
-
warnings.warn(
|
|
324
|
-
"Paid.signal() is deprecated and will be removed in a future version. "
|
|
325
|
-
"Import and use signal() directly from paid.tracing instead.",
|
|
326
|
-
DeprecationWarning,
|
|
327
|
-
stacklevel=2,
|
|
328
|
-
)
|
|
329
|
-
signal(event_name=event_name, enable_cost_tracing=enable_cost_tracing, data=data)
|
|
330
|
-
|
|
331
87
|
|
|
332
88
|
class AsyncPaid:
|
|
333
89
|
"""
|
|
@@ -376,14 +132,6 @@ class AsyncPaid:
|
|
|
376
132
|
follow_redirects: typing.Optional[bool] = True,
|
|
377
133
|
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
|
378
134
|
):
|
|
379
|
-
# If token is not provided, try to get it from environment variable
|
|
380
|
-
if token is None:
|
|
381
|
-
token = os.environ.get("PAID_API_KEY")
|
|
382
|
-
if token is None:
|
|
383
|
-
raise ValueError(
|
|
384
|
-
"API token must be provided either via the 'token' parameter or the 'PAID_API_KEY' environment variable"
|
|
385
|
-
)
|
|
386
|
-
|
|
387
135
|
_defaulted_timeout = (
|
|
388
136
|
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
389
137
|
)
|
|
@@ -406,225 +154,6 @@ class AsyncPaid:
|
|
|
406
154
|
self.usage = AsyncUsageClient(client_wrapper=self._client_wrapper)
|
|
407
155
|
self.traces = AsyncTracesClient(client_wrapper=self._client_wrapper)
|
|
408
156
|
|
|
409
|
-
def initialize_tracing(self, collector_endpoint: str = DEFAULT_COLLECTOR_ENDPOINT) -> None:
|
|
410
|
-
"""
|
|
411
|
-
Deprecated: Use the @paid_tracing decorator or context manager instead.
|
|
412
|
-
|
|
413
|
-
This method is deprecated and will be removed in a future version.
|
|
414
|
-
The @paid_tracing decorator automatically initializes tracing as needed.
|
|
415
|
-
|
|
416
|
-
Instead of:
|
|
417
|
-
client.initialize_tracing()
|
|
418
|
-
await client.trace(external_customer_id="...", fn=async_func)
|
|
419
|
-
|
|
420
|
-
Use:
|
|
421
|
-
from paid.tracing import paid_tracing
|
|
422
|
-
|
|
423
|
-
@paid_tracing(external_customer_id="...", external_agent_id="...")
|
|
424
|
-
async def my_async_function():
|
|
425
|
-
...
|
|
426
|
-
|
|
427
|
-
await my_async_function()
|
|
428
|
-
|
|
429
|
-
Or as an async context manager:
|
|
430
|
-
async with paid_tracing(external_customer_id="..."):
|
|
431
|
-
result = await async_operation()
|
|
432
|
-
"""
|
|
433
|
-
warnings.warn(
|
|
434
|
-
"AsyncPaid.initialize_tracing() is deprecated and will be removed in a future version. "
|
|
435
|
-
"Use @paid_tracing decorator/context manager directly, which auto-initializes tracing. "
|
|
436
|
-
"See documentation: https://docs.paid.ai/documentation/getting-started/integrate-signals-and-cost-tracking-to-your-codebase",
|
|
437
|
-
DeprecationWarning,
|
|
438
|
-
stacklevel=2,
|
|
439
|
-
)
|
|
440
|
-
token = self._client_wrapper._get_token()
|
|
441
|
-
initialize_tracing(token, collector_endpoint=collector_endpoint)
|
|
442
|
-
|
|
443
|
-
def generate_tracing_token(self) -> int:
|
|
444
|
-
"""
|
|
445
|
-
Deprecated: Import and use generate_tracing_token() directly from paid.tracing.
|
|
446
|
-
|
|
447
|
-
This method is deprecated and will be removed in a future version.
|
|
448
|
-
Use the standalone function instead.
|
|
449
|
-
|
|
450
|
-
Instead of:
|
|
451
|
-
from paid import AsyncPaid
|
|
452
|
-
client = AsyncPaid(token="...")
|
|
453
|
-
token = client.generate_tracing_token()
|
|
454
|
-
|
|
455
|
-
Use:
|
|
456
|
-
from paid.tracing import generate_tracing_token
|
|
457
|
-
token = generate_tracing_token()
|
|
458
|
-
"""
|
|
459
|
-
warnings.warn(
|
|
460
|
-
"AsyncPaid.generate_tracing_token() is deprecated and will be removed in a future version. "
|
|
461
|
-
"Import and use generate_tracing_token() directly from paid.tracing instead.",
|
|
462
|
-
DeprecationWarning,
|
|
463
|
-
stacklevel=2,
|
|
464
|
-
)
|
|
465
|
-
return generate_tracing_token()
|
|
466
|
-
|
|
467
|
-
def set_tracing_token(self, token: int):
|
|
468
|
-
"""
|
|
469
|
-
Deprecated: Pass tracing_token directly to @paid_tracing() decorator instead.
|
|
470
|
-
|
|
471
|
-
This method is deprecated and will be removed in a future version.
|
|
472
|
-
Use the tracing_token parameter in @paid_tracing() to link traces across processes.
|
|
473
|
-
|
|
474
|
-
Instead of:
|
|
475
|
-
from paid import AsyncPaid
|
|
476
|
-
client = AsyncPaid(token="...")
|
|
477
|
-
token = load_from_storage("workflow_123")
|
|
478
|
-
client.set_tracing_token(token)
|
|
479
|
-
@paid_tracing(external_customer_id="cust_123", external_agent_id="agent_456")
|
|
480
|
-
async def process_workflow():
|
|
481
|
-
...
|
|
482
|
-
client.unset_tracing_token()
|
|
483
|
-
|
|
484
|
-
Use:
|
|
485
|
-
from paid.tracing import paid_tracing
|
|
486
|
-
token = load_from_storage("workflow_123")
|
|
487
|
-
|
|
488
|
-
@paid_tracing(
|
|
489
|
-
external_customer_id="cust_123",
|
|
490
|
-
external_agent_id="agent_456",
|
|
491
|
-
tracing_token=token
|
|
492
|
-
)
|
|
493
|
-
async def process_workflow():
|
|
494
|
-
...
|
|
495
|
-
|
|
496
|
-
Parameters
|
|
497
|
-
----------
|
|
498
|
-
token : int
|
|
499
|
-
A tracing token to use for the next traces.
|
|
500
|
-
"""
|
|
501
|
-
warnings.warn(
|
|
502
|
-
"AsyncPaid.set_tracing_token() is deprecated and will be removed in a future version. "
|
|
503
|
-
"Pass tracing_token directly to @paid_tracing(tracing_token=...) decorator instead.",
|
|
504
|
-
DeprecationWarning,
|
|
505
|
-
stacklevel=2,
|
|
506
|
-
)
|
|
507
|
-
set_tracing_token(token)
|
|
508
|
-
|
|
509
|
-
def unset_tracing_token(self):
|
|
510
|
-
"""
|
|
511
|
-
Deprecated: No longer needed. Use tracing_token parameter in @paid_tracing() instead.
|
|
512
|
-
|
|
513
|
-
This method is deprecated and will be removed in a future version.
|
|
514
|
-
Since tracing_token is now passed directly to @paid_tracing(), there's no need
|
|
515
|
-
to manually set/unset tokens in the context.
|
|
516
|
-
|
|
517
|
-
Old pattern (no longer recommended):
|
|
518
|
-
from paid import AsyncPaid
|
|
519
|
-
client = AsyncPaid(token="...")
|
|
520
|
-
client.set_tracing_token(token)
|
|
521
|
-
@paid_tracing(external_customer_id="cust_123", external_agent_id="agent_456")
|
|
522
|
-
async def my_function():
|
|
523
|
-
...
|
|
524
|
-
client.unset_tracing_token()
|
|
525
|
-
|
|
526
|
-
New pattern (recommended):
|
|
527
|
-
from paid.tracing import paid_tracing
|
|
528
|
-
@paid_tracing(
|
|
529
|
-
external_customer_id="cust_123",
|
|
530
|
-
external_agent_id="agent_456",
|
|
531
|
-
tracing_token=token
|
|
532
|
-
)
|
|
533
|
-
async def my_function():
|
|
534
|
-
...
|
|
535
|
-
"""
|
|
536
|
-
warnings.warn(
|
|
537
|
-
"AsyncPaid.unset_tracing_token() is deprecated and will be removed in a future version. "
|
|
538
|
-
"Use tracing_token parameter in @paid_tracing(tracing_token=...) decorator instead.",
|
|
539
|
-
DeprecationWarning,
|
|
540
|
-
stacklevel=2,
|
|
541
|
-
)
|
|
542
|
-
unset_tracing_token()
|
|
543
|
-
|
|
544
|
-
async def trace(
|
|
545
|
-
self,
|
|
546
|
-
external_customer_id: str,
|
|
547
|
-
fn: typing.Callable[[], typing.Awaitable[T]],
|
|
548
|
-
external_agent_id: typing.Optional[str] = None,
|
|
549
|
-
tracing_token: typing.Optional[int] = None,
|
|
550
|
-
metadata: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
551
|
-
args: typing.Optional[typing.Tuple] = None,
|
|
552
|
-
kwargs: typing.Optional[typing.Dict] = None,
|
|
553
|
-
) -> typing.Union[T, typing.Awaitable[T]]:
|
|
554
|
-
"""
|
|
555
|
-
Deprecated: Use the @paid_tracing decorator or context manager instead.
|
|
556
|
-
|
|
557
|
-
This method is deprecated and will be removed in a future version.
|
|
558
|
-
The callback-based tracing via AsyncPaid.trace() is being replaced with the more
|
|
559
|
-
Pythonic @paid_tracing decorator and context manager.
|
|
560
|
-
|
|
561
|
-
Instead of:
|
|
562
|
-
result = await client.trace(
|
|
563
|
-
external_customer_id="cust_123",
|
|
564
|
-
fn=agent_workflow,
|
|
565
|
-
external_agent_id="agent_456"
|
|
566
|
-
)
|
|
567
|
-
|
|
568
|
-
Use the decorator:
|
|
569
|
-
from paid.tracing import paid_tracing
|
|
570
|
-
|
|
571
|
-
@paid_tracing(external_customer_id="cust_123", external_agent_id="agent_456")
|
|
572
|
-
async def agent_workflow():
|
|
573
|
-
...
|
|
574
|
-
|
|
575
|
-
result = await agent_workflow()
|
|
576
|
-
|
|
577
|
-
Or use the async context manager:
|
|
578
|
-
async with paid_tracing(external_customer_id="cust_123", external_agent_id="agent_456"):
|
|
579
|
-
result = await agent_workflow()
|
|
580
|
-
"""
|
|
581
|
-
warnings.warn(
|
|
582
|
-
"AsyncPaid.trace() is deprecated and will be removed in a future version. "
|
|
583
|
-
"Use the @paid_tracing decorator or context manager instead. "
|
|
584
|
-
"See documentation: https://docs.paid.ai/documentation/getting-started/integrate-signals-and-cost-tracking-to-your-codebase",
|
|
585
|
-
DeprecationWarning,
|
|
586
|
-
stacklevel=2,
|
|
587
|
-
)
|
|
588
|
-
return await trace_async_(
|
|
589
|
-
external_customer_id=external_customer_id,
|
|
590
|
-
fn=fn,
|
|
591
|
-
external_agent_id=external_agent_id,
|
|
592
|
-
tracing_token=tracing_token,
|
|
593
|
-
metadata=metadata,
|
|
594
|
-
args=args,
|
|
595
|
-
kwargs=kwargs,
|
|
596
|
-
)
|
|
597
|
-
|
|
598
|
-
def signal(
|
|
599
|
-
self,
|
|
600
|
-
event_name: str,
|
|
601
|
-
*,
|
|
602
|
-
data: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
603
|
-
enable_cost_tracing: bool = False,
|
|
604
|
-
) -> None:
|
|
605
|
-
"""
|
|
606
|
-
Deprecated: Import and use signal() directly from paid.tracing.
|
|
607
|
-
|
|
608
|
-
This method is deprecated and will be removed in a future version.
|
|
609
|
-
Use the standalone function instead.
|
|
610
|
-
|
|
611
|
-
Instead of:
|
|
612
|
-
from paid import AsyncPaid
|
|
613
|
-
client = AsyncPaid(token="...")
|
|
614
|
-
client.signal("event_name", data={...})
|
|
615
|
-
|
|
616
|
-
Use:
|
|
617
|
-
from paid.tracing import signal
|
|
618
|
-
signal("event_name", data={...})
|
|
619
|
-
"""
|
|
620
|
-
warnings.warn(
|
|
621
|
-
"AsyncPaid.signal() is deprecated and will be removed in a future version. "
|
|
622
|
-
"Import and use signal() directly from paid.tracing instead.",
|
|
623
|
-
DeprecationWarning,
|
|
624
|
-
stacklevel=2,
|
|
625
|
-
)
|
|
626
|
-
signal(event_name=event_name, enable_cost_tracing=enable_cost_tracing, data=data)
|
|
627
|
-
|
|
628
157
|
|
|
629
158
|
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: PaidEnvironment) -> str:
|
|
630
159
|
if base_url is not None:
|
paid/core/client_wrapper.py
CHANGED
|
@@ -20,9 +20,10 @@ class BaseClientWrapper:
|
|
|
20
20
|
|
|
21
21
|
def get_headers(self) -> typing.Dict[str, str]:
|
|
22
22
|
headers: typing.Dict[str, str] = {
|
|
23
|
+
"User-Agent": "paid-python/1.0.0-alpha0",
|
|
23
24
|
"X-Fern-Language": "Python",
|
|
24
|
-
"X-Fern-SDK-Name": "paid",
|
|
25
|
-
"X-Fern-SDK-Version": "0.
|
|
25
|
+
"X-Fern-SDK-Name": "paid-python",
|
|
26
|
+
"X-Fern-SDK-Version": "1.0.0-alpha0",
|
|
26
27
|
}
|
|
27
28
|
token = self._get_token()
|
|
28
29
|
if token is not None:
|