|
6 | 6 | import sentry_sdk |
7 | 7 | from sentry_sdk.consts import OP, SPANDATA |
8 | 8 | from sentry_sdk.integrations import DidNotEnable, Integration |
9 | | -from sentry_sdk.scope import should_send_default_pii |
10 | | -from sentry_sdk.utils import has_data_collection_enabled |
11 | 9 |
|
12 | 10 | if TYPE_CHECKING: |
13 | 11 | from typing import ( |
@@ -263,26 +261,20 @@ def wrap_system_one(self: "TypeSafeClient", *args: "Any", **kwargs: "Any") -> "A |
263 | 261 | SPANDATA.GEN_AI_USAGE_OUTPUT_TOKENS, response.usage.output_tokens |
264 | 262 | ) |
265 | 263 |
|
266 | | - if ( |
267 | | - has_data_collection_enabled(client.options) |
268 | | - and client.options["data_collection"]["gen_ai"]["outputs"] |
269 | | - ) or ( |
270 | | - not has_data_collection_enabled(client.options) |
271 | | - and should_send_default_pii() |
272 | | - ): |
273 | | - span.set_attribute( |
274 | | - SPANDATA.GEN_AI_OUTPUT_MESSAGES, |
275 | | - json.dumps( |
276 | | - [ |
277 | | - { |
278 | | - "type": "evaluation", |
279 | | - "answers": _transform_evaluation_answers( |
280 | | - response.answers |
281 | | - ), |
282 | | - } |
283 | | - ] |
284 | | - ), |
285 | | - ) |
| 264 | + if not client.options["data_collection"]["gen_ai"]["outputs"]: |
| 265 | + return response |
| 266 | + |
| 267 | + span.set_attribute( |
| 268 | + SPANDATA.GEN_AI_OUTPUT_MESSAGES, |
| 269 | + json.dumps( |
| 270 | + [ |
| 271 | + { |
| 272 | + "type": "evaluation", |
| 273 | + "answers": _transform_evaluation_answers(response.answers), |
| 274 | + } |
| 275 | + ] |
| 276 | + ), |
| 277 | + ) |
286 | 278 |
|
287 | 279 | return response |
288 | 280 |
|
@@ -353,26 +345,20 @@ async def wrap_system_one_async( |
353 | 345 | SPANDATA.GEN_AI_USAGE_OUTPUT_TOKENS, response.usage.output_tokens |
354 | 346 | ) |
355 | 347 |
|
356 | | - if ( |
357 | | - has_data_collection_enabled(client.options) |
358 | | - and client.options["data_collection"]["gen_ai"]["outputs"] |
359 | | - ) or ( |
360 | | - not has_data_collection_enabled(client.options) |
361 | | - and should_send_default_pii() |
362 | | - ): |
363 | | - span.set_attribute( |
364 | | - SPANDATA.GEN_AI_OUTPUT_MESSAGES, |
365 | | - json.dumps( |
366 | | - [ |
367 | | - { |
368 | | - "type": "evaluation", |
369 | | - "answers": _transform_evaluation_answers( |
370 | | - response.answers |
371 | | - ), |
372 | | - } |
373 | | - ] |
374 | | - ), |
375 | | - ) |
| 348 | + if not client.options["data_collection"]["gen_ai"]["outputs"]: |
| 349 | + return response |
| 350 | + |
| 351 | + span.set_attribute( |
| 352 | + SPANDATA.GEN_AI_OUTPUT_MESSAGES, |
| 353 | + json.dumps( |
| 354 | + [ |
| 355 | + { |
| 356 | + "type": "evaluation", |
| 357 | + "answers": _transform_evaluation_answers(response.answers), |
| 358 | + } |
| 359 | + ] |
| 360 | + ), |
| 361 | + ) |
376 | 362 |
|
377 | 363 | return response |
378 | 364 |
|
|
0 commit comments