telemetry-dev-openai 0.2.1__tar.gz → 0.2.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telemetry-dev-openai
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: OpenAI integration for telemetry.dev Python SDK
5
5
  Keywords: telemetry,opentelemetry,openai,llm,genai,tracing
6
6
  Author: telemetry.dev
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "telemetry-dev-openai"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "OpenAI integration for telemetry.dev Python SDK"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "telemetry-dev-openai"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "OpenAI integration for telemetry.dev Python SDK"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -20,7 +20,7 @@ from openai.resources.embeddings import AsyncEmbeddings, Embeddings
20
20
  from openai.resources.images import AsyncImages, Images
21
21
  from openai.resources.responses.responses import AsyncResponses, Responses
22
22
 
23
- __version__ = "0.2.1"
23
+ __version__ = "0.2.2"
24
24
 
25
25
  ProviderResolver = Callable[[object | None], str]
26
26
  RequestMapper = Callable[[Mapping[str, Any]], tuple[str, dict[str, Any]]]
@@ -349,9 +349,18 @@ def _capture_text(value: str, budget: telemetry_dev.CaptureBudget) -> str:
349
349
  return value
350
350
 
351
351
 
352
+ def _prompt_attributes(messages: object) -> dict[str, Any]:
353
+ # Older cores have no prompt_attributes_for and record a prompt only inside with_prompt.
354
+ read = getattr(telemetry_dev, "prompt_attributes_for", None)
355
+ return cast("dict[str, Any]", read(messages)) if callable(read) else {}
356
+
357
+
352
358
  def _chat_request(params: Mapping[str, Any]) -> tuple[str, dict[str, Any]]:
353
359
  model = _string(params.get("model"))
360
+ attributes = _prompt_attributes(params.get("messages"))
354
361
  captured, truncated = _bounded_responses_capture(params.get("messages"), "input")
362
+ if truncated:
363
+ attributes["telemetry.dev.capture.truncated"] = True
355
364
  return (
356
365
  f"chat {model or 'unknown'}",
357
366
  {
@@ -366,7 +375,7 @@ def _chat_request(params: Mapping[str, Any]) -> tuple[str, dict[str, Any]]:
366
375
  "seed": _number(params.get("seed")),
367
376
  "frequency_penalty": _number(params.get("frequency_penalty")),
368
377
  "presence_penalty": _number(params.get("presence_penalty")),
369
- "attributes": {"telemetry.dev.capture.truncated": True} if truncated else None,
378
+ "attributes": attributes or None,
370
379
  },
371
380
  )
372
381
 
@@ -432,7 +441,10 @@ def _chat_response(response: Any) -> dict[str, Any]:
432
441
 
433
442
  def _responses_request(params: Mapping[str, Any]) -> tuple[str, dict[str, Any]]:
434
443
  model = _string(params.get("model"))
444
+ attributes = _prompt_attributes(params.get("input"))
435
445
  captured, truncated = _bounded_responses_capture(params.get("input"), "input")
446
+ if truncated:
447
+ attributes["telemetry.dev.capture.truncated"] = True
436
448
  return (
437
449
  f"chat {model or 'unknown'}",
438
450
  {
@@ -443,7 +455,7 @@ def _responses_request(params: Mapping[str, Any]) -> tuple[str, dict[str, Any]]:
443
455
  "temperature": _number(params.get("temperature")),
444
456
  "top_p": _number(params.get("top_p")),
445
457
  "max_tokens": _number(params.get("max_output_tokens")),
446
- "attributes": {"telemetry.dev.capture.truncated": True} if truncated else None,
458
+ "attributes": attributes or None,
447
459
  },
448
460
  )
449
461