paid-python 0.5.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 +33 -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 +445 -0
- paid/orders/raw_client.py +705 -0
- paid/plans/client.py +142 -0
- paid/plans/raw_client.py +238 -0
- paid/types/__init__.py +30 -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_group.py +60 -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.5.0.dist-info → paid_python-1.0.0a0.dist-info}/METADATA +6 -4
- {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/RECORD +36 -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.5.0.dist-info → paid_python-1.0.0a0.dist-info}/LICENSE +0 -0
- {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/WHEEL +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
paid/__init__.py,sha256=
|
|
1
|
+
paid/__init__.py,sha256=JUYR1KiH4jdOR1Z_GRfLW0lN0AAPIt-qYbBN-1BuUHw,3737
|
|
2
2
|
paid/agents/__init__.py,sha256=_VhToAyIt_5axN6CLJwtxg3-CO7THa_23pbUzqhXJa4,85
|
|
3
3
|
paid/agents/client.py,sha256=kfErQ51mMppV0YS-n0G2w_kISShdC4S8JoL02TZae1U,24369
|
|
4
4
|
paid/agents/raw_client.py,sha256=4ehmy21TnS_FhL_NmPwYrUVNWkYaVTobTO22YWu7PGc,27897
|
|
5
|
-
paid/client.py,sha256=
|
|
5
|
+
paid/client.py,sha256=6dnhzYcU8-qv003uRUUv1GkmnuJeRtubUXVxfvNQXxw,6983
|
|
6
6
|
paid/contacts/__init__.py,sha256=_VhToAyIt_5axN6CLJwtxg3-CO7THa_23pbUzqhXJa4,85
|
|
7
7
|
paid/contacts/client.py,sha256=sNm-yAg4dR9AyYWL7-RC_CuCCvOXX7YlDAUqn47yZhE,14058
|
|
8
8
|
paid/contacts/raw_client.py,sha256=ZYNWuekHiL2sqK_gHR0IzcrLAopUKRXIqMUi-fuLGe4,19211
|
|
9
9
|
paid/core/__init__.py,sha256=lTcqUPXcx4112yLDd70RAPeqq6tu3eFMe1pKOqkW9JQ,1562
|
|
10
10
|
paid/core/api_error.py,sha256=44vPoTyWN59gonCIZMdzw7M1uspygiLnr3GNFOoVL2Q,614
|
|
11
|
-
paid/core/client_wrapper.py,sha256=
|
|
11
|
+
paid/core/client_wrapper.py,sha256=c25VM9AUGlNCa-2qzhHzPJs1e1Zft3ZV1WLewdmMHgw,2418
|
|
12
12
|
paid/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
|
13
13
|
paid/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
|
|
14
14
|
paid/core/force_multipart.py,sha256=awxh5MtcRYe74ehY8U76jzv6fYM_w_D3Rur7KQQzSDk,429
|
|
@@ -20,9 +20,12 @@ paid/core/query_encoder.py,sha256=ekulqNd0j8TgD7ox-Qbz7liqX8-KP9blvT9DsRCenYM,21
|
|
|
20
20
|
paid/core/remove_none_from_dict.py,sha256=EU9SGgYidWq7SexuJbNs4-PZ-5Bl3Vppd864mS6vQZw,342
|
|
21
21
|
paid/core/request_options.py,sha256=h0QUNCFVdCW_7GclVySCAY2w4NhtXVBUCmHgmzaxpcg,1681
|
|
22
22
|
paid/core/serialization.py,sha256=ECL3bvv_0i7U4uvPidZCNel--MUbA0iq0aGcNKi3kws,9818
|
|
23
|
-
paid/customers/__init__.py,sha256=
|
|
24
|
-
paid/customers/client.py,sha256=
|
|
25
|
-
paid/customers/raw_client.py,sha256=
|
|
23
|
+
paid/customers/__init__.py,sha256=jKuBDR0U8JloJKyzmcQSUSoNpJqjZ7BowRNiHr1SLKE,265
|
|
24
|
+
paid/customers/client.py,sha256=sOsEmiqqzfInDoSVNflSbClnNgdFm5mTWm_9VUwDroQ,47097
|
|
25
|
+
paid/customers/raw_client.py,sha256=thhqTpyKBBahb-tj0I1wxaFk_l4ciLDwz8cPGIbnj5I,74849
|
|
26
|
+
paid/customers/types/__init__.py,sha256=vd_PTvslroA4P6FGiqqOhZm5qbiR_17hssZbL53kpCA,349
|
|
27
|
+
paid/customers/types/customers_check_entitlement_request_view.py,sha256=Z6mijxu6J2rfJhK0qQvlOuNGCmewss2e3iqktHqOi5o,182
|
|
28
|
+
paid/customers/types/customers_check_entitlement_response.py,sha256=kQ2pPVsgwpQsLiDigBCscZYX_AfQ7PvG-84OoPgSsWQ,641
|
|
26
29
|
paid/environment.py,sha256=8sOi15Agshd4TrgHoqlUFXegvQESdSi7zE3n7uJktMs,164
|
|
27
30
|
paid/errors/__init__.py,sha256=i1Cxfwfm2tL1DRuYRbTEXZ5MIhobgDE8zm38gqGSNKY,363
|
|
28
31
|
paid/errors/bad_request_error.py,sha256=_nkSDHMpzm0RadIc19BDq-yM9uJMQGWNrdsT2_6B6Iw,348
|
|
@@ -31,14 +34,14 @@ paid/errors/internal_server_error.py,sha256=WPvk3xayCQqRAir4nfMhVVextjsR9hMi8zCq
|
|
|
31
34
|
paid/errors/not_found_error.py,sha256=nsBHj9gxzRkoJMdFyChYv9ePaPYYf8h4s2nuoUo4CuI,346
|
|
32
35
|
paid/logger.py,sha256=CIo_i2n2Azp4g57GkU9twb_GzJ7x9lZmURqPsq4379M,514
|
|
33
36
|
paid/orders/__init__.py,sha256=CrbHKbmp63NAum57EE9NnGmJqLKiWDMLyPRemOs_U9w,126
|
|
34
|
-
paid/orders/client.py,sha256=
|
|
37
|
+
paid/orders/client.py,sha256=CAGEvE9oi4hgrI0az2Tid6IYvITNhkGhb_Q2RXe9_BA,24929
|
|
35
38
|
paid/orders/lines/__init__.py,sha256=_VhToAyIt_5axN6CLJwtxg3-CO7THa_23pbUzqhXJa4,85
|
|
36
39
|
paid/orders/lines/client.py,sha256=7RCqD78g4VARoCLiwjFm59imsSlbd1E3HPrGKhYG6xI,4062
|
|
37
40
|
paid/orders/lines/raw_client.py,sha256=KZN_yBokCOkf1lUb4ZJtX_NZbqmTqCdJNoaIOdWar8I,4590
|
|
38
|
-
paid/orders/raw_client.py,sha256=
|
|
41
|
+
paid/orders/raw_client.py,sha256=apng0iGUwVlI09YL7to2Rf9aT6fu-CxkiUth76GrU0Q,43167
|
|
39
42
|
paid/plans/__init__.py,sha256=_VhToAyIt_5axN6CLJwtxg3-CO7THa_23pbUzqhXJa4,85
|
|
40
|
-
paid/plans/client.py,sha256=
|
|
41
|
-
paid/plans/raw_client.py,sha256=
|
|
43
|
+
paid/plans/client.py,sha256=hWtGmpbuFpPjGpUWZazK3mwddGM0QHNKn-tY7vaEPgM,10967
|
|
44
|
+
paid/plans/raw_client.py,sha256=pJRK5tja274vj3Uc3m1DBvtRxN2X7wgMJ7pOcqo6rOQ,22374
|
|
42
45
|
paid/products/__init__.py,sha256=oCZ9LvM5pb1zsdux1hBIxN1DVphi5gyPgQmR2p7XNZw,155
|
|
43
46
|
paid/products/client.py,sha256=doYlu9mI1j_rzMX3wWvetptxVrJmYeOuXJ0Pm3z02uE,21010
|
|
44
47
|
paid/products/raw_client.py,sha256=LwYSuv6wj1N7oU1GDUINkGbgF_Q5x6y_0g6gy8PaJ0A,29546
|
|
@@ -73,7 +76,7 @@ paid/tracing/wrappers/openai/openAiWrapper.py,sha256=DIMOGdQTjpFaiKV-JeJvNH_cxHs
|
|
|
73
76
|
paid/tracing/wrappers/openai_agents/__init__.py,sha256=-xX5HPhYYX6hDWbn5FpFw-P6M2h0k1X9Qjrg0Bkv7cc,94
|
|
74
77
|
paid/tracing/wrappers/openai_agents/openaiAgentsHook.py,sha256=-uXUNL0S85cFVT7ObrL9hzEQAIYh5Lo1JgEE57hxk2Y,6650
|
|
75
78
|
paid/tracing/wrappers/utils.py,sha256=_0FCF3BC2wK5cU8suEvo_mXm6Jn8ULkyeEhnYPUlO2Y,2347
|
|
76
|
-
paid/types/__init__.py,sha256=
|
|
79
|
+
paid/types/__init__.py,sha256=DsDo78pLA5erfWPqsP8uhggE7HQc6BEOGdk23Qivtbg,4423
|
|
77
80
|
paid/types/address.py,sha256=fJa_oYXxsIxJXFZy5UQqflVkr8BQkwQ7fKhp2wO05fo,871
|
|
78
81
|
paid/types/agent.py,sha256=dHqSO_hO0fgM5TsnEYrx3zL-rZsWc2GkjkCD2_aOch4,1168
|
|
79
82
|
paid/types/agent_attribute.py,sha256=rmIQnmPFOAvCYUtc9oiBD5aqMrL3vdJ1krdxNhLRTEc,588
|
|
@@ -82,8 +85,10 @@ paid/types/agent_price_point_tiers.py,sha256=Pml1UFDjLYrsETpiJbnSgusN3c4HSgVi2lE
|
|
|
82
85
|
paid/types/agent_update.py,sha256=5Xc4L4Y37YLHmKphX2RuSsAKltjTIJCRy8tOTsU6CSg,1117
|
|
83
86
|
paid/types/api_error.py,sha256=j91xSZV1-5Hpx375E087XfP_WwWzGbnplf_FfEyDJgM,792
|
|
84
87
|
paid/types/billing_frequency.py,sha256=67owqyQimW-M9VOpJ1AdE09vw9NzFYIotsjR6eR5-0Q,174
|
|
88
|
+
paid/types/cancel_renewal_response.py,sha256=fgis8kI9qXFnK-KHRt3ClqH0Qq-jba6QL1euxxhc6PY,1424
|
|
85
89
|
paid/types/charge_type.py,sha256=43hS72QcU4IM53R9PRXKTbPgu9CZqWX76GnU8hGrmWA,180
|
|
86
90
|
paid/types/contact.py,sha256=HwkyRLpw8gg8bnWNtOkEdx5hagsODZh08J1Icvfm0bg,2086
|
|
91
|
+
paid/types/contact_create_for_customer.py,sha256=KO3jhqFHMpGbtwnLsumRA-3RFwTOZVCd9R2gBRbtQ3k,1716
|
|
87
92
|
paid/types/cost_amount.py,sha256=ZA8iITYudldVbpj6MREsfqpk0lgzUN07GYBEl7mRVw8,713
|
|
88
93
|
paid/types/cost_trace.py,sha256=DKmVwKOGV2UaJm5ZUYaJ_TCzqJESss5ThWPfxQit29I,1630
|
|
89
94
|
paid/types/cost_traces_response.py,sha256=RJBrK7MSnsM94Y8q8Fi_1oHO-_l8wEsoVIKHNiAInTw,726
|
|
@@ -93,6 +98,8 @@ paid/types/customer.py,sha256=WwJDXqM38VmBeBUoLLQAwtWSqRIIoWg44EKwMjv75qw,2020
|
|
|
93
98
|
paid/types/customer_update.py,sha256=0fsB2YP7IgvWsVhi3_ybVrAz6cu9XP04sv-CH8dKgjs,1764
|
|
94
99
|
paid/types/entitlement_usage.py,sha256=-zuXAOzbNTr_ugpiOjZEcQpu2i8-xVTtKJsfkhBsT6I,1715
|
|
95
100
|
paid/types/error.py,sha256=lWDAazLU1lnuLYGufPYO7YH1EInG2jevvR8ylR6OBiU,607
|
|
101
|
+
paid/types/invoice.py,sha256=Tu125_YkGEcRjLpwHbu_jJFynIWMdiiOvOFDJy8ytSI,2806
|
|
102
|
+
paid/types/invoice_status.py,sha256=Aj7o01H9duyeD4_UsFRfxadUblXN-yxePi25QuVVFek,187
|
|
96
103
|
paid/types/order.py,sha256=hkBRN6OauZYfnzpWLY2COYMqToWdJRLzDokPVyV__rc,2324
|
|
97
104
|
paid/types/order_line.py,sha256=oM-fxr5sQ1ttAERR_FsdCAPW2cctaQUvppIKzqjinYk,2092
|
|
98
105
|
paid/types/order_line_attribute.py,sha256=cYHpX0p5rEE0eYn4BPq-aB9snn9V5p3yZ5nYDo2W6z8,938
|
|
@@ -100,9 +107,17 @@ paid/types/order_line_attribute_create_one.py,sha256=H9_zXFQRrutoP_WKlhTBAksEde0
|
|
|
100
107
|
paid/types/order_line_attribute_pricing.py,sha256=UDE8OYP93wwmXcPVwgchMknCd64O0g4BNIgLUlK-a5s,1386
|
|
101
108
|
paid/types/order_line_create.py,sha256=T8M2nDfyTmc2ph226mePT9SI_MJSciOOsBS-uoIF-K8,2696
|
|
102
109
|
paid/types/pagination_meta.py,sha256=RJFmwweexzkYdfsb9ohascJCvQep2scF51kk4377Huo,2398
|
|
110
|
+
paid/types/payment_method.py,sha256=kGBRYKLO9XO8RRLL6t-jdbCNAzGkje-IddBS2OS-Q68,1812
|
|
111
|
+
paid/types/payment_method_card.py,sha256=mu6qmZunkJtWxAEWenLFvaZhsjh6GM3zE5p-Dhr-p60,1328
|
|
112
|
+
paid/types/payment_method_type.py,sha256=Zr04tOTmJhZ1P5ge7XA6eBx3k832eFCcmyQ3bcaqH4c,182
|
|
113
|
+
paid/types/payment_method_us_bank_account.py,sha256=qTY93Ylq725TJ7RaVXVbc2yP4vAk1rnnAmxDWNcuadY,1230
|
|
114
|
+
paid/types/payment_method_us_bank_account_account_type.py,sha256=T5u-G3NJ2ZCGG84XlX3XNa_IepQ_g9N_5mCwx2eDZeI,184
|
|
103
115
|
paid/types/plan.py,sha256=WE7BXhFrBDsbRWXrcJlND90-UQYPwGomEPCOsNfP81E,2314
|
|
104
|
-
paid/types/
|
|
116
|
+
paid/types/plan_group.py,sha256=OlLrDIBmrE6TsnWJXxLBVSirXUvGK4iKxezyEnznSUI,1621
|
|
117
|
+
paid/types/plan_plan_products_item.py,sha256=JTjJGzl7v1S0k_vdbORUH89Uba4O7cKtKVVf4Ssyfi0,1774
|
|
105
118
|
paid/types/plan_plan_products_item_plan_product_attribute_item.py,sha256=w9Zc7y6zcxrKCK_RAWZRYx5iwDKm-XepjeBgWYiou8A,1443
|
|
119
|
+
paid/types/plan_with_features.py,sha256=hFOlqSFH6jHuUsJtUdZ6Wy2bybNh7pNih2kY1wi3CRk,1938
|
|
120
|
+
paid/types/plan_with_features_features_item.py,sha256=ep-RjlPSmhYXWa1bMf9U6HkoR_9m5VMtU7Sm3M4c9ss,1050
|
|
106
121
|
paid/types/price_point.py,sha256=lyeI38kJCBMOWdq97hG2kyYiixHgMCKjoCNmzOLG9Fk,915
|
|
107
122
|
paid/types/pricing.py,sha256=qrTQHe2CZhUoS7e4sVMDO10aCzeaxZGkSwEKXf7qJkU,1409
|
|
108
123
|
paid/types/pricing_model_type.py,sha256=DxTx1zO1gR22gDnnQ55LBvRRIh5EyV5pfE4LF8FFDTI,212
|
|
@@ -110,9 +125,12 @@ paid/types/product.py,sha256=hSnHIsXR_jImAzhBJLXlBXgahimgp6vYT3oyWrbw6lU,1981
|
|
|
110
125
|
paid/types/product_type.py,sha256=ZP3_66LJly6ebJ4JNxt0VNOqUnsbY43p38LwIPq-aRo,178
|
|
111
126
|
paid/types/product_update.py,sha256=35cu1IwPalh-1wEjFQLqivEk6Q0c6yVZbThoWDhBLNY,1393
|
|
112
127
|
paid/types/product_update_type.py,sha256=y1EP0aNHyAOPj9zaoMVOgkkE8PlPn1n8iWfyuAXM_PI,184
|
|
128
|
+
paid/types/proration_attribute_update.py,sha256=nvI0zbKuUketz-Q_NXmY5VcQvSCxzxHUpVilqqt81aI,1286
|
|
129
|
+
paid/types/proration_detail.py,sha256=dQW1nGcp8TEFtkuR0AR3Dw_kDL2_xTdqhDaTlupTnP4,1902
|
|
130
|
+
paid/types/proration_upgrade_response.py,sha256=Qk0ssIwl8doLi7zVRqtMMz7NYaezVp4NYEVSS3JzArM,2142
|
|
113
131
|
paid/types/salutation.py,sha256=nxqSuMkcohP_xut2wf9j-gHQri5caKP65N13Qxqr9UM,180
|
|
114
132
|
paid/types/signal.py,sha256=UZvHU6MsTXjBds1lw1tszmVax6hyronLDuD5al0GksA,1636
|
|
115
|
-
paid/types/signal_v_2.py,sha256=
|
|
133
|
+
paid/types/signal_v_2.py,sha256=a9nRjgOiw9XETmxT0B1pO0suOmPs_zSeWm4ROAhyX_s,2018
|
|
116
134
|
paid/types/tax_exempt_status.py,sha256=H8jr087Vvp51pfK8mZ5ZDRdRPbagsSzYDXroz5lRPP4,168
|
|
117
135
|
paid/types/tier.py,sha256=damnNp6Eb3T5Gqq15Z3UL1JSauvqXI1k65Aivs4QjMg,832
|
|
118
136
|
paid/types/trace.py,sha256=fmDLfG-HxGZ_QllPKvUuixKQptBnJDxAlQos2UpwU3Y,2073
|
|
@@ -123,30 +141,12 @@ paid/types/usage_summary.py,sha256=js1EOBlOTPq9QHz7dvpk0QL0kyyp4s83bjoxHnyrW4o,3
|
|
|
123
141
|
paid/types/usage_summary_order.py,sha256=eXNb27FT1zeZ_pviqJhMXgTp1dfdHjL59CcgWcQPjrU,775
|
|
124
142
|
paid/types/usage_summary_order_line.py,sha256=jRhgT-zuXBQI7s_5CCC2Rhyn_kWYAI8QFSdeOHbZOjU,784
|
|
125
143
|
paid/usage/__init__.py,sha256=m0ujD0N7E9e37mHfN6Ww2LDnVi5SggwiIxpN-c7ZFTM,167
|
|
126
|
-
paid/usage/client.py,sha256
|
|
144
|
+
paid/usage/client.py,sha256=I6Trkf_HLXOWEVL1lCPU0jGwLOWx638Rn6XtWYkGNf4,8982
|
|
127
145
|
paid/usage/raw_client.py,sha256=0LQU409K1ZwgluN3PoD3yk4Br9uwaiDNh__S-KxKx1M,14261
|
|
128
146
|
paid/usage/types/__init__.py,sha256=ywkMUGnwdZzyCfSJaVaL1mSNTROVXOp40VvwRCyzvbk,188
|
|
129
147
|
paid/usage/types/usage_check_usage_response.py,sha256=kJY4Y7-tbCQVUyA-FMFWPVYJvm8UYQYbWuRUDXfFT_I,1599
|
|
130
148
|
paid/version.py,sha256=QIpDFnOrxMxrs86eL0iNH0mSZ1DO078wWHYY9TYAoew,78
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
opentelemetry/instrumentation/openai/shared/completion_wrappers.py,sha256=OAy-tp-jHFvZKb-n_AyZPuXPI3F2lpEmGmnAgIhH6a0,9353
|
|
136
|
-
opentelemetry/instrumentation/openai/shared/config.py,sha256=xMSz47vDPboU3Vciulf6lZkyWXTFA6eaLJHk-tYfkus,479
|
|
137
|
-
opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py,sha256=eb4HU7cklpR0vi_H9OlpkLZmKH0touWYIipuacJipA0,9364
|
|
138
|
-
opentelemetry/instrumentation/openai/shared/event_emitter.py,sha256=zQ4ZCz7VnWWDGHIdlYm8T3MGFpldpOOy8M15iB_HuK8,3237
|
|
139
|
-
opentelemetry/instrumentation/openai/shared/event_models.py,sha256=PCfCGxrrArwZqR-4wFcXrhwQq0sBMAxmSrpC4PUMtaM,876
|
|
140
|
-
opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py,sha256=y_jN9oqjiOCoht3z-L1vuxaYehZRcpqUB4x3FyoqdrI,2120
|
|
141
|
-
opentelemetry/instrumentation/openai/shared/span_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
142
|
-
opentelemetry/instrumentation/openai/utils.py,sha256=LN5CcmbNoOto9HXJRkx578e47bhSo5JgDZ_ztvMCsvk,5680
|
|
143
|
-
opentelemetry/instrumentation/openai/v0/__init__.py,sha256=g4wONoGVqyFjyoYmT1kL3qrB808sawxd9fOY_BoLCgg,6315
|
|
144
|
-
opentelemetry/instrumentation/openai/v1/__init__.py,sha256=TK9qP6VCoLoQ4SoUu0RQJUtB4bVmkDSmgHPEiuQl_OI,14629
|
|
145
|
-
opentelemetry/instrumentation/openai/v1/assistant_wrappers.py,sha256=gXpQUY0KAi0HMcRLztq_3a5Olbg2IqvTUwgdSkXrjr4,11460
|
|
146
|
-
opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py,sha256=IjmMDnX7EFOuaOi34YIOfHG07pGWDhEssMQhu9AS9XY,4410
|
|
147
|
-
opentelemetry/instrumentation/openai/v1/responses_wrappers.py,sha256=bfovvrFPI-2v7xxgTBBO3X_D4fzwJffBaYHAGXLq90o,44463
|
|
148
|
-
opentelemetry/instrumentation/openai/version.py,sha256=lqGEr9tvmZ_6Qa2559q1rV0OQ1kC9xcQ9JVV0A-9nt4,23
|
|
149
|
-
paid_python-0.5.0.dist-info/LICENSE,sha256=Nz4baY1zvv0Qy7lqrQtbaiMhmEeGr2Q7A93aqzpml4c,1071
|
|
150
|
-
paid_python-0.5.0.dist-info/METADATA,sha256=7-Hqxub31YH7Gtr8WIjM8U1kk0QdpdqPwstw-n_sf5c,24088
|
|
151
|
-
paid_python-0.5.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
152
|
-
paid_python-0.5.0.dist-info/RECORD,,
|
|
149
|
+
paid_python-1.0.0a0.dist-info/LICENSE,sha256=Nz4baY1zvv0Qy7lqrQtbaiMhmEeGr2Q7A93aqzpml4c,1071
|
|
150
|
+
paid_python-1.0.0a0.dist-info/METADATA,sha256=I9KlwbPqEcybvZ11UAjyTFFh7S6B5wz2blPzDAJswo4,24210
|
|
151
|
+
paid_python-1.0.0a0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
152
|
+
paid_python-1.0.0a0.dist-info/RECORD,,
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
from typing import Callable, Collection, Optional
|
|
2
|
-
|
|
3
|
-
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
4
|
-
from opentelemetry.instrumentation.openai.shared.config import Config
|
|
5
|
-
from opentelemetry.instrumentation.openai.utils import is_openai_v1
|
|
6
|
-
from typing_extensions import Coroutine
|
|
7
|
-
|
|
8
|
-
_instruments = ("openai >= 0.27.0",)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class OpenAIInstrumentor(BaseInstrumentor):
|
|
12
|
-
"""An instrumentor for OpenAI's client library."""
|
|
13
|
-
|
|
14
|
-
def __init__(
|
|
15
|
-
self,
|
|
16
|
-
enrich_assistant: bool = False,
|
|
17
|
-
exception_logger=None,
|
|
18
|
-
get_common_metrics_attributes: Callable[[], dict] = lambda: {},
|
|
19
|
-
upload_base64_image: Optional[
|
|
20
|
-
Callable[[str, str, str, str], Coroutine[None, None, str]]
|
|
21
|
-
] = lambda *args: "",
|
|
22
|
-
enable_trace_context_propagation: bool = True,
|
|
23
|
-
use_legacy_attributes: bool = True,
|
|
24
|
-
):
|
|
25
|
-
super().__init__()
|
|
26
|
-
Config.enrich_assistant = enrich_assistant
|
|
27
|
-
Config.exception_logger = exception_logger
|
|
28
|
-
Config.get_common_metrics_attributes = get_common_metrics_attributes
|
|
29
|
-
Config.upload_base64_image = upload_base64_image
|
|
30
|
-
Config.enable_trace_context_propagation = enable_trace_context_propagation
|
|
31
|
-
Config.use_legacy_attributes = use_legacy_attributes
|
|
32
|
-
|
|
33
|
-
def instrumentation_dependencies(self) -> Collection[str]:
|
|
34
|
-
return _instruments
|
|
35
|
-
|
|
36
|
-
def _instrument(self, **kwargs):
|
|
37
|
-
if is_openai_v1():
|
|
38
|
-
from opentelemetry.instrumentation.openai.v1 import OpenAIV1Instrumentor
|
|
39
|
-
|
|
40
|
-
OpenAIV1Instrumentor().instrument(**kwargs)
|
|
41
|
-
else:
|
|
42
|
-
from opentelemetry.instrumentation.openai.v0 import OpenAIV0Instrumentor
|
|
43
|
-
|
|
44
|
-
OpenAIV0Instrumentor().instrument(**kwargs)
|
|
45
|
-
|
|
46
|
-
def _uninstrument(self, **kwargs):
|
|
47
|
-
if is_openai_v1():
|
|
48
|
-
from opentelemetry.instrumentation.openai.v1 import OpenAIV1Instrumentor
|
|
49
|
-
|
|
50
|
-
OpenAIV1Instrumentor().uninstrument(**kwargs)
|
|
51
|
-
else:
|
|
52
|
-
from opentelemetry.instrumentation.openai.v0 import OpenAIV0Instrumentor
|
|
53
|
-
|
|
54
|
-
OpenAIV0Instrumentor().uninstrument(**kwargs)
|
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import logging
|
|
3
|
-
import types
|
|
4
|
-
import openai
|
|
5
|
-
import pydantic
|
|
6
|
-
from importlib.metadata import version
|
|
7
|
-
|
|
8
|
-
from opentelemetry.instrumentation.openai.shared.config import Config
|
|
9
|
-
from opentelemetry.instrumentation.openai.utils import (
|
|
10
|
-
dont_throw,
|
|
11
|
-
is_openai_v1,
|
|
12
|
-
)
|
|
13
|
-
from opentelemetry.semconv._incubating.attributes import (
|
|
14
|
-
gen_ai_attributes as GenAIAttributes,
|
|
15
|
-
openai_attributes as OpenAIAttributes,
|
|
16
|
-
)
|
|
17
|
-
from opentelemetry.semconv_ai import SpanAttributes
|
|
18
|
-
from opentelemetry.trace.propagation import set_span_in_context
|
|
19
|
-
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
|
|
20
|
-
|
|
21
|
-
OPENAI_LLM_USAGE_TOKEN_TYPES = ["prompt_tokens", "completion_tokens"]
|
|
22
|
-
PROMPT_FILTER_KEY = "prompt_filter_results"
|
|
23
|
-
PROMPT_ERROR = "prompt_error"
|
|
24
|
-
|
|
25
|
-
_PYDANTIC_VERSION = version("pydantic")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
logger = logging.getLogger(__name__)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def _set_span_attribute(span, name, value):
|
|
32
|
-
if value is None or value == "":
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
if hasattr(openai, "NOT_GIVEN") and value == openai.NOT_GIVEN:
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
span.set_attribute(name, value)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def _set_client_attributes(span, instance):
|
|
42
|
-
if not span.is_recording():
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
if not is_openai_v1():
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
client = instance._client # pylint: disable=protected-access
|
|
49
|
-
if isinstance(client, (openai.AsyncOpenAI, openai.OpenAI)):
|
|
50
|
-
_set_span_attribute(
|
|
51
|
-
span, SpanAttributes.LLM_OPENAI_API_BASE, str(client.base_url)
|
|
52
|
-
)
|
|
53
|
-
if isinstance(client, (openai.AsyncAzureOpenAI, openai.AzureOpenAI)):
|
|
54
|
-
_set_span_attribute(
|
|
55
|
-
span, SpanAttributes.LLM_OPENAI_API_VERSION, client._api_version
|
|
56
|
-
) # pylint: disable=protected-access
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def _set_api_attributes(span):
|
|
60
|
-
if not span.is_recording():
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
if is_openai_v1():
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
base_url = openai.base_url if hasattr(openai, "base_url") else openai.api_base
|
|
67
|
-
|
|
68
|
-
_set_span_attribute(span, SpanAttributes.LLM_OPENAI_API_BASE, base_url)
|
|
69
|
-
_set_span_attribute(span, SpanAttributes.LLM_OPENAI_API_TYPE, openai.api_type)
|
|
70
|
-
_set_span_attribute(span, SpanAttributes.LLM_OPENAI_API_VERSION, openai.api_version)
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def _set_functions_attributes(span, functions):
|
|
76
|
-
if not functions:
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
for i, function in enumerate(functions):
|
|
80
|
-
prefix = f"{SpanAttributes.LLM_REQUEST_FUNCTIONS}.{i}"
|
|
81
|
-
_set_span_attribute(span, f"{prefix}.name", function.get("name"))
|
|
82
|
-
_set_span_attribute(span, f"{prefix}.description", function.get("description"))
|
|
83
|
-
_set_span_attribute(
|
|
84
|
-
span, f"{prefix}.parameters", json.dumps(function.get("parameters"))
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def set_tools_attributes(span, tools):
|
|
89
|
-
if not tools:
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
for i, tool in enumerate(tools):
|
|
93
|
-
function = tool.get("function")
|
|
94
|
-
if not function:
|
|
95
|
-
continue
|
|
96
|
-
|
|
97
|
-
prefix = f"{SpanAttributes.LLM_REQUEST_FUNCTIONS}.{i}"
|
|
98
|
-
_set_span_attribute(span, f"{prefix}.name", function.get("name"))
|
|
99
|
-
_set_span_attribute(span, f"{prefix}.description", function.get("description"))
|
|
100
|
-
_set_span_attribute(
|
|
101
|
-
span, f"{prefix}.parameters", json.dumps(function.get("parameters"))
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def _set_request_attributes(span, kwargs, instance=None):
|
|
106
|
-
if not span.is_recording():
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
_set_api_attributes(span)
|
|
110
|
-
|
|
111
|
-
base_url = _get_openai_base_url(instance) if instance else ""
|
|
112
|
-
vendor = _get_vendor_from_url(base_url)
|
|
113
|
-
_set_span_attribute(span, GenAIAttributes.GEN_AI_SYSTEM, vendor)
|
|
114
|
-
|
|
115
|
-
model = kwargs.get("model")
|
|
116
|
-
if vendor == "AWS" and model and "." in model:
|
|
117
|
-
model = _cross_region_check(model)
|
|
118
|
-
elif vendor == "OpenRouter":
|
|
119
|
-
model = _extract_model_name_from_provider_format(model)
|
|
120
|
-
|
|
121
|
-
_set_span_attribute(span, GenAIAttributes.GEN_AI_REQUEST_MODEL, model)
|
|
122
|
-
_set_span_attribute(
|
|
123
|
-
span, GenAIAttributes.GEN_AI_REQUEST_MAX_TOKENS, kwargs.get("max_tokens")
|
|
124
|
-
)
|
|
125
|
-
_set_span_attribute(
|
|
126
|
-
span, GenAIAttributes.GEN_AI_REQUEST_TEMPERATURE, kwargs.get("temperature")
|
|
127
|
-
)
|
|
128
|
-
_set_span_attribute(span, GenAIAttributes.GEN_AI_REQUEST_TOP_P, kwargs.get("top_p"))
|
|
129
|
-
_set_span_attribute(
|
|
130
|
-
span, SpanAttributes.LLM_FREQUENCY_PENALTY, kwargs.get("frequency_penalty")
|
|
131
|
-
)
|
|
132
|
-
_set_span_attribute(
|
|
133
|
-
span, SpanAttributes.LLM_PRESENCE_PENALTY, kwargs.get("presence_penalty")
|
|
134
|
-
)
|
|
135
|
-
_set_span_attribute(span, SpanAttributes.LLM_USER, kwargs.get("user"))
|
|
136
|
-
_set_span_attribute(span, SpanAttributes.LLM_HEADERS, str(kwargs.get("headers")))
|
|
137
|
-
# The new OpenAI SDK removed the `headers` and create new field called `extra_headers`
|
|
138
|
-
if kwargs.get("extra_headers") is not None:
|
|
139
|
-
_set_span_attribute(
|
|
140
|
-
span, SpanAttributes.LLM_HEADERS, str(kwargs.get("extra_headers"))
|
|
141
|
-
)
|
|
142
|
-
_set_span_attribute(
|
|
143
|
-
span, SpanAttributes.LLM_IS_STREAMING, kwargs.get("stream") or False
|
|
144
|
-
)
|
|
145
|
-
_set_span_attribute(
|
|
146
|
-
span, OpenAIAttributes.OPENAI_REQUEST_SERVICE_TIER, kwargs.get("service_tier")
|
|
147
|
-
)
|
|
148
|
-
if response_format := kwargs.get("response_format"):
|
|
149
|
-
# backward-compatible check for
|
|
150
|
-
# openai.types.shared_params.response_format_json_schema.ResponseFormatJSONSchema
|
|
151
|
-
if (
|
|
152
|
-
isinstance(response_format, dict)
|
|
153
|
-
and response_format.get("type") == "json_schema"
|
|
154
|
-
and response_format.get("json_schema")
|
|
155
|
-
):
|
|
156
|
-
schema = dict(response_format.get("json_schema")).get("schema")
|
|
157
|
-
if schema:
|
|
158
|
-
_set_span_attribute(
|
|
159
|
-
span,
|
|
160
|
-
SpanAttributes.LLM_REQUEST_STRUCTURED_OUTPUT_SCHEMA,
|
|
161
|
-
json.dumps(schema),
|
|
162
|
-
)
|
|
163
|
-
elif (
|
|
164
|
-
isinstance(response_format, pydantic.BaseModel)
|
|
165
|
-
or (
|
|
166
|
-
hasattr(response_format, "model_json_schema")
|
|
167
|
-
and callable(response_format.model_json_schema)
|
|
168
|
-
)
|
|
169
|
-
):
|
|
170
|
-
_set_span_attribute(
|
|
171
|
-
span,
|
|
172
|
-
SpanAttributes.LLM_REQUEST_STRUCTURED_OUTPUT_SCHEMA,
|
|
173
|
-
json.dumps(response_format.model_json_schema()),
|
|
174
|
-
)
|
|
175
|
-
else:
|
|
176
|
-
schema = None
|
|
177
|
-
try:
|
|
178
|
-
schema = json.dumps(pydantic.TypeAdapter(response_format).json_schema())
|
|
179
|
-
except Exception:
|
|
180
|
-
try:
|
|
181
|
-
schema = json.dumps(response_format)
|
|
182
|
-
except Exception:
|
|
183
|
-
pass
|
|
184
|
-
|
|
185
|
-
if schema:
|
|
186
|
-
_set_span_attribute(
|
|
187
|
-
span,
|
|
188
|
-
SpanAttributes.LLM_REQUEST_STRUCTURED_OUTPUT_SCHEMA,
|
|
189
|
-
schema,
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
@dont_throw
|
|
194
|
-
def _set_response_attributes(span, response):
|
|
195
|
-
if not span.is_recording():
|
|
196
|
-
return
|
|
197
|
-
|
|
198
|
-
if "error" in response:
|
|
199
|
-
_set_span_attribute(
|
|
200
|
-
span,
|
|
201
|
-
f"{GenAIAttributes.GEN_AI_PROMPT}.{PROMPT_ERROR}",
|
|
202
|
-
json.dumps(response.get("error")),
|
|
203
|
-
)
|
|
204
|
-
return
|
|
205
|
-
|
|
206
|
-
response_model = response.get("model")
|
|
207
|
-
if response_model:
|
|
208
|
-
response_model = _extract_model_name_from_provider_format(response_model)
|
|
209
|
-
_set_span_attribute(span, GenAIAttributes.GEN_AI_RESPONSE_MODEL, response_model)
|
|
210
|
-
_set_span_attribute(span, GenAIAttributes.GEN_AI_RESPONSE_ID, response.get("id"))
|
|
211
|
-
|
|
212
|
-
_set_span_attribute(
|
|
213
|
-
span,
|
|
214
|
-
SpanAttributes.LLM_OPENAI_RESPONSE_SYSTEM_FINGERPRINT,
|
|
215
|
-
response.get("system_fingerprint"),
|
|
216
|
-
)
|
|
217
|
-
_set_span_attribute(
|
|
218
|
-
span,
|
|
219
|
-
OpenAIAttributes.OPENAI_RESPONSE_SERVICE_TIER,
|
|
220
|
-
response.get("service_tier"),
|
|
221
|
-
)
|
|
222
|
-
_log_prompt_filter(span, response)
|
|
223
|
-
usage = response.get("usage")
|
|
224
|
-
if not usage:
|
|
225
|
-
return
|
|
226
|
-
|
|
227
|
-
if is_openai_v1() and not isinstance(usage, dict):
|
|
228
|
-
usage = usage.__dict__
|
|
229
|
-
|
|
230
|
-
_set_span_attribute(
|
|
231
|
-
span, SpanAttributes.LLM_USAGE_TOTAL_TOKENS, usage.get("total_tokens")
|
|
232
|
-
)
|
|
233
|
-
_set_span_attribute(
|
|
234
|
-
span,
|
|
235
|
-
GenAIAttributes.GEN_AI_USAGE_OUTPUT_TOKENS,
|
|
236
|
-
usage.get("completion_tokens"),
|
|
237
|
-
)
|
|
238
|
-
_set_span_attribute(
|
|
239
|
-
span, GenAIAttributes.GEN_AI_USAGE_INPUT_TOKENS, usage.get("prompt_tokens")
|
|
240
|
-
)
|
|
241
|
-
prompt_tokens_details = dict(usage.get("prompt_tokens_details", {}))
|
|
242
|
-
_set_span_attribute(
|
|
243
|
-
span,
|
|
244
|
-
SpanAttributes.LLM_USAGE_CACHE_READ_INPUT_TOKENS,
|
|
245
|
-
prompt_tokens_details.get("cached_tokens", 0),
|
|
246
|
-
)
|
|
247
|
-
return
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
def _log_prompt_filter(span, response_dict):
|
|
251
|
-
if response_dict.get("prompt_filter_results"):
|
|
252
|
-
_set_span_attribute(
|
|
253
|
-
span,
|
|
254
|
-
f"{GenAIAttributes.GEN_AI_PROMPT}.{PROMPT_FILTER_KEY}",
|
|
255
|
-
json.dumps(response_dict.get("prompt_filter_results")),
|
|
256
|
-
)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
@dont_throw
|
|
260
|
-
def _set_span_stream_usage(span, prompt_tokens, completion_tokens):
|
|
261
|
-
if not span.is_recording():
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
if isinstance(completion_tokens, int) and completion_tokens >= 0:
|
|
265
|
-
_set_span_attribute(
|
|
266
|
-
span, GenAIAttributes.GEN_AI_USAGE_OUTPUT_TOKENS, completion_tokens
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
if isinstance(prompt_tokens, int) and prompt_tokens >= 0:
|
|
270
|
-
_set_span_attribute(span, GenAIAttributes.GEN_AI_USAGE_INPUT_TOKENS, prompt_tokens)
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
isinstance(prompt_tokens, int)
|
|
274
|
-
and isinstance(completion_tokens, int)
|
|
275
|
-
and completion_tokens + prompt_tokens >= 0
|
|
276
|
-
):
|
|
277
|
-
_set_span_attribute(
|
|
278
|
-
span,
|
|
279
|
-
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
|
|
280
|
-
completion_tokens + prompt_tokens,
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
def _get_openai_base_url(instance):
|
|
285
|
-
if hasattr(instance, "_client"):
|
|
286
|
-
client = instance._client # pylint: disable=protected-access
|
|
287
|
-
if isinstance(client, (openai.AsyncOpenAI, openai.OpenAI)):
|
|
288
|
-
return str(client.base_url)
|
|
289
|
-
|
|
290
|
-
return ""
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
def _get_vendor_from_url(base_url):
|
|
294
|
-
if not base_url:
|
|
295
|
-
return "openai"
|
|
296
|
-
|
|
297
|
-
if "openai.azure.com" in base_url:
|
|
298
|
-
return "Azure"
|
|
299
|
-
elif "amazonaws.com" in base_url or "bedrock" in base_url:
|
|
300
|
-
return "AWS"
|
|
301
|
-
elif "googleapis.com" in base_url or "vertex" in base_url:
|
|
302
|
-
return "Google"
|
|
303
|
-
elif "openrouter.ai" in base_url:
|
|
304
|
-
return "OpenRouter"
|
|
305
|
-
|
|
306
|
-
return "openai"
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
def _cross_region_check(value):
|
|
310
|
-
if not value or "." not in value:
|
|
311
|
-
return value
|
|
312
|
-
|
|
313
|
-
prefixes = ["us", "us-gov", "eu", "apac"]
|
|
314
|
-
if any(value.startswith(prefix + ".") for prefix in prefixes):
|
|
315
|
-
parts = value.split(".")
|
|
316
|
-
if len(parts) > 2:
|
|
317
|
-
return parts[2]
|
|
318
|
-
else:
|
|
319
|
-
return value
|
|
320
|
-
else:
|
|
321
|
-
vendor, model = value.split(".", 1)
|
|
322
|
-
return model
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
def _extract_model_name_from_provider_format(model_name):
|
|
326
|
-
"""
|
|
327
|
-
Extract model name from provider/model format.
|
|
328
|
-
E.g., 'openai/gpt-4o' -> 'gpt-4o', 'anthropic/claude-3-sonnet' -> 'claude-3-sonnet'
|
|
329
|
-
"""
|
|
330
|
-
if not model_name:
|
|
331
|
-
return model_name
|
|
332
|
-
|
|
333
|
-
if "/" in model_name:
|
|
334
|
-
parts = model_name.split("/")
|
|
335
|
-
return parts[-1] # Return the last part (actual model name)
|
|
336
|
-
|
|
337
|
-
return model_name
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
def is_streaming_response(response):
|
|
341
|
-
if is_openai_v1():
|
|
342
|
-
return isinstance(response, openai.Stream) or isinstance(
|
|
343
|
-
response, openai.AsyncStream
|
|
344
|
-
)
|
|
345
|
-
|
|
346
|
-
return isinstance(response, types.GeneratorType) or isinstance(
|
|
347
|
-
response, types.AsyncGeneratorType
|
|
348
|
-
)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
def model_as_dict(model):
|
|
352
|
-
if isinstance(model, dict):
|
|
353
|
-
return model
|
|
354
|
-
if _PYDANTIC_VERSION < "2.0.0":
|
|
355
|
-
return model.dict()
|
|
356
|
-
if hasattr(model, "model_dump"):
|
|
357
|
-
return model.model_dump()
|
|
358
|
-
elif hasattr(model, "parse"): # Raw API response
|
|
359
|
-
return model_as_dict(model.parse())
|
|
360
|
-
else:
|
|
361
|
-
return model
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
def _token_type(token_type: str):
|
|
365
|
-
if token_type == "prompt_tokens":
|
|
366
|
-
return "input"
|
|
367
|
-
elif token_type == "completion_tokens":
|
|
368
|
-
return "output"
|
|
369
|
-
|
|
370
|
-
return None
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
def metric_shared_attributes(
|
|
374
|
-
response_model: str, operation: str, server_address: str, is_streaming: bool = False
|
|
375
|
-
):
|
|
376
|
-
attributes = Config.get_common_metrics_attributes()
|
|
377
|
-
vendor = _get_vendor_from_url(server_address)
|
|
378
|
-
|
|
379
|
-
return {
|
|
380
|
-
**attributes,
|
|
381
|
-
GenAIAttributes.GEN_AI_SYSTEM: vendor,
|
|
382
|
-
GenAIAttributes.GEN_AI_RESPONSE_MODEL: response_model,
|
|
383
|
-
"gen_ai.operation.name": operation,
|
|
384
|
-
"server.address": server_address,
|
|
385
|
-
"stream": is_streaming,
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
def propagate_trace_context(span, kwargs):
|
|
390
|
-
if is_openai_v1():
|
|
391
|
-
extra_headers = kwargs.get("extra_headers", {})
|
|
392
|
-
ctx = set_span_in_context(span)
|
|
393
|
-
TraceContextTextMapPropagator().inject(extra_headers, context=ctx)
|
|
394
|
-
kwargs["extra_headers"] = extra_headers
|
|
395
|
-
else:
|
|
396
|
-
headers = kwargs.get("headers", {})
|
|
397
|
-
ctx = set_span_in_context(span)
|
|
398
|
-
TraceContextTextMapPropagator().inject(headers, context=ctx)
|
|
399
|
-
kwargs["headers"] = headers
|