openinference-instrumentation-beeai 0.1.14__py3-none-any.whl → 0.1.15__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.
@@ -1,5 +1,5 @@
1
1
  from datetime import datetime
2
- from typing import Any, ClassVar
2
+ from typing import Any, ClassVar, Dict, Generator, Tuple
3
3
 
4
4
  from beeai_framework.backend import (
5
5
  AnyMessage,
@@ -19,6 +19,7 @@ from beeai_framework.tools import AnyTool
19
19
  from beeai_framework.utils.lists import remove_falsy
20
20
  from typing_extensions import override
21
21
 
22
+ from openinference.instrumentation import safe_json_dumps
22
23
  from openinference.instrumentation.beeai._utils import (
23
24
  _unpack_object,
24
25
  safe_dump_model_schema,
@@ -36,6 +37,24 @@ from openinference.semconv.trace import (
36
37
  )
37
38
 
38
39
 
40
+ def get_tool_parameters(tool: AnyTool) -> Dict[str, Any]:
41
+ tool_dict = tool.to_json_safe()
42
+ if "input_schema" in tool_dict:
43
+ input_schema = tool_dict.pop("input_schema")
44
+ tool_dict["parameters"] = input_schema or {}
45
+ tool_dict["parameters"]["type"] = "object"
46
+ return tool_dict
47
+
48
+
49
+ def get_tools(tools: list[AnyTool]) -> Generator[Tuple[str, str], None, None]:
50
+ for index, tool in enumerate(tools):
51
+ function = {"type": "function", "function": get_tool_parameters(tool)}
52
+ yield (
53
+ f"{SpanAttributes.LLM_TOOLS}.{index}.{ToolAttributes.TOOL_JSON_SCHEMA}",
54
+ safe_json_dumps(function),
55
+ )
56
+
57
+
39
58
  class ChatModelProcessor(Processor):
40
59
  kind: ClassVar[OpenInferenceSpanKindValues] = OpenInferenceSpanKindValues.LLM
41
60
 
@@ -80,7 +99,7 @@ class ChatModelProcessor(Processor):
80
99
  )
81
100
  self.span.set_attributes(
82
101
  {
83
- SpanAttributes.LLM_TOOLS: [t.name for t in (event.input.tools or [])],
102
+ **dict(get_tools(event.input.tools or [])),
84
103
  SpanAttributes.LLM_INVOCATION_PARAMETERS: stringify(
85
104
  meta.creator.parameters.model_dump(
86
105
  exclude_none=True, exclude_unset=True
@@ -1 +1 @@
1
- __version__ = "0.1.14"
1
+ __version__ = "0.1.15"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openinference-instrumentation-beeai
3
- Version: 0.1.14
3
+ Version: 0.1.15
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.
@@ -27,8 +27,13 @@ Provides-Extra: instruments
27
27
  Requires-Dist: beeai-framework>=0.1.51; extra == 'instruments'
28
28
  Provides-Extra: test
29
29
  Requires-Dist: beeai-framework>=0.1.51; extra == 'test'
30
+ Requires-Dist: beeai-framework[duckduckgo]; extra == 'test'
30
31
  Requires-Dist: opentelemetry-exporter-otlp; extra == 'test'
31
32
  Requires-Dist: opentelemetry-sdk; extra == 'test'
33
+ Requires-Dist: pytest; extra == 'test'
34
+ Requires-Dist: pytest-asyncio; extra == 'test'
35
+ Requires-Dist: pytest-recording; extra == 'test'
36
+ Requires-Dist: vcrpy<8.0.0,>=5.0.0; extra == 'test'
32
37
  Description-Content-Type: text/markdown
33
38
 
34
39
  # OpenInference Instrumentation for BeeAI
@@ -1,10 +1,10 @@
1
1
  openinference/instrumentation/beeai/__init__.py,sha256=OVys0Yf0LCB76P_YvnJp9Ph7J746ZPC8r8qYe3REeYE,5229
2
2
  openinference/instrumentation/beeai/_span.py,sha256=iVlYou4vnNKtDxpypMdZuD2AKeaDiG1Cu5PXVzgQ8w4,3259
3
3
  openinference/instrumentation/beeai/_utils.py,sha256=tfQsQEcevyLJno8WmLTOe936GVTIS2etnAFVbAPyztc,2521
4
- openinference/instrumentation/beeai/version.py,sha256=PIBqEOI-nqKFL9oJAWQQwlHuujG9Cd7EmdxDrThNQto,23
4
+ openinference/instrumentation/beeai/version.py,sha256=qb0TalpSt1CbprnFyeLUKqgrqNtmnk9IoQQ7umAoXVY,23
5
5
  openinference/instrumentation/beeai/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  openinference/instrumentation/beeai/processors/base.py,sha256=KyS524sQ5NMXH7HxHGdGiqEofLPHulMG6EURz3ab134,2305
7
- openinference/instrumentation/beeai/processors/chat.py,sha256=Nl0JWThA7f7Oeet6136fARdpNmakMH0SYym3T9kCGFg,9281
7
+ openinference/instrumentation/beeai/processors/chat.py,sha256=KPJjMDUVVINPZEEwKyPJgwkTIejBnULkOCf2Tq26aj0,9997
8
8
  openinference/instrumentation/beeai/processors/embedding.py,sha256=Vzk-XhQ7cwVwkhjfa92iQ8_qs54rtlkVgFNwgQzPs_M,3350
9
9
  openinference/instrumentation/beeai/processors/locator.py,sha256=oleg8Jxg8sJBIzK4cZ7BbfkHuLH9Hu4XRYqDaOGnNBU,3627
10
10
  openinference/instrumentation/beeai/processors/requirement.py,sha256=S5OPN6F5V39puumxEo3fKQRoAOZ_8OC5ml0dr_Z9v0U,2662
@@ -15,7 +15,7 @@ openinference/instrumentation/beeai/processors/agents/base.py,sha256=3fidrUoU9pV
15
15
  openinference/instrumentation/beeai/processors/agents/react.py,sha256=rS3xlvgyZ5G6MyDMeSh4xFLT_66h7GVAYEYlwZCpIdY,3022
16
16
  openinference/instrumentation/beeai/processors/agents/requirement_agent.py,sha256=eEiEls6vUET-gEMor1FDyzOpgXCAZVQ3gugSaK3hOHA,2772
17
17
  openinference/instrumentation/beeai/processors/agents/tool_calling.py,sha256=yaWP5JmGuvZIha9iUSKgv0MJgI0QSbuiJLLQFnbqUZw,1223
18
- openinference_instrumentation_beeai-0.1.14.dist-info/METADATA,sha256=YrO30Bkk1Wh_PLCDruC_Al1MSQ0yosi6bb1mMHFvvU0,5543
19
- openinference_instrumentation_beeai-0.1.14.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
20
- openinference_instrumentation_beeai-0.1.14.dist-info/entry_points.txt,sha256=ee7EUhbWv-XK1dxhPXuFVy9qstzj-lc-265Phe2Ml9s,183
21
- openinference_instrumentation_beeai-0.1.14.dist-info/RECORD,,
18
+ openinference_instrumentation_beeai-0.1.15.dist-info/METADATA,sha256=kEPDUsLBjOqbjbXwXP0hTTQogarK09hy5hjpteFOdXo,5790
19
+ openinference_instrumentation_beeai-0.1.15.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
20
+ openinference_instrumentation_beeai-0.1.15.dist-info/entry_points.txt,sha256=ee7EUhbWv-XK1dxhPXuFVy9qstzj-lc-265Phe2Ml9s,183
21
+ openinference_instrumentation_beeai-0.1.15.dist-info/RECORD,,