openinference-instrumentation-beeai 0.1.7__py3-none-any.whl → 0.1.8__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.
@@ -19,9 +19,11 @@ def _datetime_to_span_time(dt: datetime.datetime) -> int:
19
19
 
20
20
  def _unpack_object(obj: dict[str, Any] | list[Any] | BaseModel, prefix: str = "") -> dict[str, Any]:
21
21
  if not isinstance(obj, dict) and not isinstance(obj, list):
22
+ obj_ref = obj
22
23
  obj = json.loads(stringify(obj))
23
24
  if not isinstance(obj, dict) and not isinstance(obj, list):
24
- raise ValueError(f"Cannot unpack object of type {type(obj)}")
25
+ logger.warning(f"Cannot unpack object of type {type(obj_ref)} (prefix={prefix})")
26
+ return {"value": str(obj)}
25
27
 
26
28
  if prefix and prefix.startswith("."):
27
29
  prefix = prefix[1:]
@@ -1,4 +1,3 @@
1
- import json
2
1
  from datetime import datetime
3
2
  from typing import Any, ClassVar
4
3
 
@@ -81,7 +80,7 @@ class ChatModelProcessor(Processor):
81
80
  )
82
81
  self.span.set_attributes(
83
82
  {
84
- SpanAttributes.LLM_TOOLS: json.loads(stringify(event.input.tools or [])),
83
+ SpanAttributes.LLM_TOOLS: [t.name for t in (event.input.tools or [])],
85
84
  SpanAttributes.LLM_INVOCATION_PARAMETERS: stringify(
86
85
  meta.creator.parameters.model_dump(
87
86
  exclude_none=True, exclude_unset=True
@@ -103,18 +102,27 @@ class ChatModelProcessor(Processor):
103
102
  self._add_new_messages(event.value.messages)
104
103
 
105
104
  usage = event.value.usage
105
+ if usage:
106
+ self.span.set_attributes(
107
+ {
108
+ SpanAttributes.LLM_TOKEN_COUNT_TOTAL: usage.total_tokens,
109
+ SpanAttributes.LLM_TOKEN_COUNT_PROMPT: usage.prompt_tokens,
110
+ SpanAttributes.LLM_TOKEN_COUNT_COMPLETION: usage.completion_tokens,
111
+ }
112
+ )
113
+
114
+ cost = event.value.cost
115
+ if cost:
116
+ self.span.set_attributes(
117
+ {
118
+ SpanAttributes.LLM_COST_COMPLETION: cost.completion_tokens_cost_usd,
119
+ SpanAttributes.LLM_COST_PROMPT: cost.prompt_tokens_usd,
120
+ SpanAttributes.LLM_COST_TOTAL: cost.total_cost_usd,
121
+ }
122
+ )
106
123
 
107
124
  self.span.set_attributes(
108
125
  {
109
- **(
110
- {
111
- SpanAttributes.LLM_TOKEN_COUNT_TOTAL: usage.total_tokens,
112
- SpanAttributes.LLM_TOKEN_COUNT_PROMPT: usage.prompt_tokens,
113
- SpanAttributes.LLM_TOKEN_COUNT_COMPLETION: usage.completion_tokens,
114
- }
115
- if usage
116
- else {}
117
- ),
118
126
  SpanAttributes.OPENINFERENCE_SPAN_KIND: type(self).kind,
119
127
  SpanAttributes.OUTPUT_VALUE: event.value.get_text_content(),
120
128
  SpanAttributes.OUTPUT_MIME_TYPE: OpenInferenceMimeTypeValues.TEXT.value,
@@ -149,8 +157,6 @@ def _process_tools(tools: list[AnyTool]) -> list[dict[str, str | Any]]:
149
157
  {
150
158
  SpanAttributes.TOOL_NAME: t.name,
151
159
  SpanAttributes.TOOL_DESCRIPTION: t.description,
152
- # TODO: difference between TOOL_PARAMETERS and TOOL_JSON_SCHEMA is not obvious
153
- SpanAttributes.TOOL_PARAMETERS: safe_dump_model_schema(t.input_schema),
154
160
  ToolAttributes.TOOL_JSON_SCHEMA: safe_dump_model_schema(t.input_schema),
155
161
  }
156
162
  for t in tools
@@ -31,10 +31,6 @@ class ToolProcessor(Processor):
31
31
  {
32
32
  SpanAttributes.TOOL_NAME: tool.name,
33
33
  SpanAttributes.TOOL_DESCRIPTION: tool.description,
34
- # TODO: what's the difference?
35
- SpanAttributes.TOOL_PARAMETERS: stringify(
36
- safe_dump_model_schema(tool.input_schema)
37
- ),
38
34
  ToolAttributes.TOOL_JSON_SCHEMA: stringify(
39
35
  safe_dump_model_schema(tool.input_schema)
40
36
  ),
@@ -1 +1 @@
1
- __version__ = "0.1.7"
1
+ __version__ = "0.1.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openinference-instrumentation-beeai
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: OpenInference BeeAI Instrumentation
5
5
  Project-URL: Homepage, https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-beeai
6
6
  Author: IBM Corp.
@@ -15,17 +15,17 @@ Classifier: Programming Language :: Python :: 3.11
15
15
  Classifier: Programming Language :: Python :: 3.12
16
16
  Classifier: Programming Language :: Python :: 3.13
17
17
  Requires-Python: <3.14,>=3.11
18
- Requires-Dist: beeai-framework<0.2.0,>=0.1.32
19
- Requires-Dist: openinference-instrumentation>=0.1.36
18
+ Requires-Dist: beeai-framework<0.2.0,>=0.1.36
19
+ Requires-Dist: openinference-instrumentation>=0.1.37
20
20
  Requires-Dist: openinference-semantic-conventions>=0.1.21
21
21
  Requires-Dist: opentelemetry-api>=1.36.0
22
22
  Requires-Dist: opentelemetry-instrumentation>=0.57b0
23
23
  Requires-Dist: opentelemetry-semantic-conventions>=0.57b0
24
24
  Requires-Dist: wrapt>=1.17.2
25
25
  Provides-Extra: instruments
26
- Requires-Dist: beeai-framework>=0.1.32; extra == 'instruments'
26
+ Requires-Dist: beeai-framework>=0.1.36; extra == 'instruments'
27
27
  Provides-Extra: test
28
- Requires-Dist: beeai-framework>=0.1.32; extra == 'test'
28
+ Requires-Dist: beeai-framework>=0.1.36; extra == 'test'
29
29
  Requires-Dist: opentelemetry-exporter-otlp; extra == 'test'
30
30
  Requires-Dist: opentelemetry-sdk; extra == 'test'
31
31
  Description-Content-Type: text/markdown
@@ -1,21 +1,21 @@
1
1
  openinference/instrumentation/beeai/__init__.py,sha256=5_bUn-XMonUXUgbbqU_PrGyW2ojiWQD7LUvjB7B-g0A,4467
2
2
  openinference/instrumentation/beeai/_span.py,sha256=VZfoQHDUlAeyHxI7MnQ6QGq2LwhHiI1AQ2Uw_4Dn5Zw,2750
3
- openinference/instrumentation/beeai/_utils.py,sha256=nZQkVv1QTNVYu23EqEaRkYtncmpE4LLqEH_xCoHzM3c,2247
4
- openinference/instrumentation/beeai/version.py,sha256=YpKDcdV7CqL8n45u267wKtyloM13FSVbOdrqgNZnSLM,22
3
+ openinference/instrumentation/beeai/_utils.py,sha256=m4ZXoGLm-iJGAJBjrfSh06OU2EaDMNgStVTLbljmPSA,2328
4
+ openinference/instrumentation/beeai/version.py,sha256=C69ADlbQREQlR15trneyA2sk8x0-oH4rDAX5fsv19_U,22
5
5
  openinference/instrumentation/beeai/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  openinference/instrumentation/beeai/processors/base.py,sha256=akaQCsZmbapEC5tctD_VXWiBOu2pYHFRJRZ_pynpApc,2176
7
- openinference/instrumentation/beeai/processors/chat.py,sha256=yyNjoG3AY2XPNHr6t2JJEwmx5NCibc3ThsWBL8lIuTU,9082
7
+ openinference/instrumentation/beeai/processors/chat.py,sha256=a4Ps6opRb2POrQ8Nla1JHUhkdVFZF5rmht8Xca3F_xA,9285
8
8
  openinference/instrumentation/beeai/processors/embedding.py,sha256=T9fZs2M7qEs4SnLYbSXRbhe3P7rCNch-snRQBDSC9Es,2598
9
9
  openinference/instrumentation/beeai/processors/locator.py,sha256=G9TFW_HgXM1TrOVdvtRU2Eq3D-atHLAET4fSo4F02X8,3635
10
10
  openinference/instrumentation/beeai/processors/requirement.py,sha256=Q9DgHDd-5rmP88Fe00d7cNKQg5zQ7ILuRzVAej5xfmk,2666
11
- openinference/instrumentation/beeai/processors/tool.py,sha256=LmYD9Oj9l_jRZEXoTyfMSykZQum0EHdBZOW6AtiPoHE,2720
11
+ openinference/instrumentation/beeai/processors/tool.py,sha256=03pNF04ELsxRl8EK3JhHktoQl_aXAY1rrXHV4QuXcJk,2533
12
12
  openinference/instrumentation/beeai/processors/workflow.py,sha256=OMwFFHv3mp4M4hFvH7utYd_fiSkTnBcl2oUVaMEdy-A,3815
13
13
  openinference/instrumentation/beeai/processors/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  openinference/instrumentation/beeai/processors/agents/base.py,sha256=3fidrUoU9pVixq9YN_y1jkNMozNMX-YG2CMuh855cLk,1244
15
15
  openinference/instrumentation/beeai/processors/agents/react.py,sha256=rS3xlvgyZ5G6MyDMeSh4xFLT_66h7GVAYEYlwZCpIdY,3022
16
16
  openinference/instrumentation/beeai/processors/agents/requirement_agent.py,sha256=HpleY8pNWojuUqcae2PZgat7Xq2edU9C-uz0YjZQUyc,2774
17
17
  openinference/instrumentation/beeai/processors/agents/tool_calling.py,sha256=yaWP5JmGuvZIha9iUSKgv0MJgI0QSbuiJLLQFnbqUZw,1223
18
- openinference_instrumentation_beeai-0.1.7.dist-info/METADATA,sha256=j0D1RjhUiFGl8lZ8vzgQzt_yGWaZO1-2eQVDe6maZdI,5491
19
- openinference_instrumentation_beeai-0.1.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
20
- openinference_instrumentation_beeai-0.1.7.dist-info/entry_points.txt,sha256=ee7EUhbWv-XK1dxhPXuFVy9qstzj-lc-265Phe2Ml9s,183
21
- openinference_instrumentation_beeai-0.1.7.dist-info/RECORD,,
18
+ openinference_instrumentation_beeai-0.1.8.dist-info/METADATA,sha256=Jp_y16JgscRpObUhhtwhgRW-nG3MwTDKQIgQA_oYFxM,5491
19
+ openinference_instrumentation_beeai-0.1.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
20
+ openinference_instrumentation_beeai-0.1.8.dist-info/entry_points.txt,sha256=ee7EUhbWv-XK1dxhPXuFVy9qstzj-lc-265Phe2Ml9s,183
21
+ openinference_instrumentation_beeai-0.1.8.dist-info/RECORD,,