openinference-instrumentation-beeai 0.1.8__py3-none-any.whl → 0.1.9__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.
- openinference/instrumentation/beeai/__init__.py +3 -1
- openinference/instrumentation/beeai/_span.py +15 -0
- openinference/instrumentation/beeai/_utils.py +9 -2
- openinference/instrumentation/beeai/processors/base.py +3 -4
- openinference/instrumentation/beeai/processors/tool.py +2 -0
- openinference/instrumentation/beeai/version.py +1 -1
- {openinference_instrumentation_beeai-0.1.8.dist-info → openinference_instrumentation_beeai-0.1.9.dist-info}/METADATA +1 -1
- {openinference_instrumentation_beeai-0.1.8.dist-info → openinference_instrumentation_beeai-0.1.9.dist-info}/RECORD +10 -10
- {openinference_instrumentation_beeai-0.1.8.dist-info → openinference_instrumentation_beeai-0.1.9.dist-info}/WHEEL +0 -0
- {openinference_instrumentation_beeai-0.1.8.dist-info → openinference_instrumentation_beeai-0.1.9.dist-info}/entry_points.txt +0 -0
|
@@ -2,6 +2,8 @@ import logging
|
|
|
2
2
|
from importlib.metadata import PackageNotFoundError, version
|
|
3
3
|
from typing import TYPE_CHECKING, Any, Callable, Collection
|
|
4
4
|
|
|
5
|
+
from opentelemetry.trace import StatusCode
|
|
6
|
+
|
|
5
7
|
if TYPE_CHECKING:
|
|
6
8
|
from beeai_framework.emitter import EventMeta
|
|
7
9
|
|
|
@@ -82,7 +84,7 @@ class BeeAIInstrumentor(BaseInstrumentor): # type: ignore
|
|
|
82
84
|
self._build_tree(children)
|
|
83
85
|
|
|
84
86
|
current_span.set_status(node.status)
|
|
85
|
-
if node.error is not None:
|
|
87
|
+
if node.error is not None and node.status == StatusCode.ERROR:
|
|
86
88
|
current_span.record_exception(node.error)
|
|
87
89
|
|
|
88
90
|
current_span.end(_datetime_to_span_time(node.ended_at) if node.ended_at else None)
|
|
@@ -77,5 +77,20 @@ class SpanWrapper:
|
|
|
77
77
|
def set_status(self, status: StatusCode) -> None:
|
|
78
78
|
self.status = status
|
|
79
79
|
|
|
80
|
+
def reset_exception(self) -> None:
|
|
81
|
+
self.error = None
|
|
82
|
+
self.set_status(StatusCode.OK)
|
|
83
|
+
|
|
80
84
|
def record_exception(self, error: Exception) -> None:
|
|
85
|
+
from beeai_framework.errors import FrameworkError
|
|
86
|
+
|
|
81
87
|
self.error = error
|
|
88
|
+
self.set_status(StatusCode.ERROR)
|
|
89
|
+
self.set_attributes(
|
|
90
|
+
{
|
|
91
|
+
SpanAttributes.OUTPUT_VALUE: error.explain()
|
|
92
|
+
if isinstance(error, FrameworkError)
|
|
93
|
+
else str(error),
|
|
94
|
+
SpanAttributes.OUTPUT_MIME_TYPE: OpenInferenceMimeTypeValues.TEXT.value,
|
|
95
|
+
}
|
|
96
|
+
)
|
|
@@ -22,7 +22,7 @@ def _unpack_object(obj: dict[str, Any] | list[Any] | BaseModel, prefix: str = ""
|
|
|
22
22
|
obj_ref = obj
|
|
23
23
|
obj = json.loads(stringify(obj))
|
|
24
24
|
if not isinstance(obj, dict) and not isinstance(obj, list):
|
|
25
|
-
logger.
|
|
25
|
+
logger.debug(f"Cannot unpack object of type {type(obj_ref)} (prefix={prefix})")
|
|
26
26
|
return {"value": str(obj)}
|
|
27
27
|
|
|
28
28
|
if prefix and prefix.startswith("."):
|
|
@@ -34,7 +34,7 @@ def _unpack_object(obj: dict[str, Any] | list[Any] | BaseModel, prefix: str = ""
|
|
|
34
34
|
for key, value in obj.items() if isinstance(obj, dict) else enumerate(obj):
|
|
35
35
|
if value is None:
|
|
36
36
|
continue
|
|
37
|
-
if is_primitive(value):
|
|
37
|
+
if is_primitive(value) or has_custom_str(value):
|
|
38
38
|
output[f"{prefix}{key}"] = str(value)
|
|
39
39
|
else:
|
|
40
40
|
output.update(_unpack_object(value, prefix=f"{prefix}{key}"))
|
|
@@ -45,6 +45,13 @@ def is_primitive(value: Any) -> bool:
|
|
|
45
45
|
return isinstance(value, str | bool | int | float | type(None))
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
def has_custom_str(value: Any) -> bool:
|
|
49
|
+
if value.__class__.__module__ == "builtins":
|
|
50
|
+
return False
|
|
51
|
+
|
|
52
|
+
return value.__class__.__str__ is not object.__str__
|
|
53
|
+
|
|
54
|
+
|
|
48
55
|
def stringify(value: Any, pretty: bool = False) -> str:
|
|
49
56
|
if is_primitive(value):
|
|
50
57
|
return str(value)
|
|
@@ -43,6 +43,9 @@ class Processor:
|
|
|
43
43
|
pass
|
|
44
44
|
|
|
45
45
|
async def end(self, event: "RunContextFinishEvent", meta: "EventMeta") -> None:
|
|
46
|
+
if event.error is not None:
|
|
47
|
+
self.span.record_exception(event.error)
|
|
48
|
+
|
|
46
49
|
if event.output is not None:
|
|
47
50
|
if SpanAttributes.OUTPUT_VALUE not in self.span.attributes:
|
|
48
51
|
self.span.attributes.update(
|
|
@@ -53,8 +56,4 @@ class Processor:
|
|
|
53
56
|
)
|
|
54
57
|
self.span.set_status(StatusCode.OK)
|
|
55
58
|
|
|
56
|
-
if event.error is not None:
|
|
57
|
-
self.span.set_status(StatusCode.ERROR)
|
|
58
|
-
self.span.record_exception(event.error)
|
|
59
|
-
|
|
60
59
|
self.span.ended_at = meta.created_at
|
|
@@ -51,6 +51,7 @@ class ToolProcessor(Processor):
|
|
|
51
51
|
case ToolSuccessEvent():
|
|
52
52
|
output_cls = type(event.output)
|
|
53
53
|
|
|
54
|
+
self.span.reset_exception()
|
|
54
55
|
self.span.set_attributes(
|
|
55
56
|
{
|
|
56
57
|
SpanAttributes.OUTPUT_VALUE: event.output.get_text_content(),
|
|
@@ -62,6 +63,7 @@ class ToolProcessor(Processor):
|
|
|
62
63
|
case ToolErrorEvent():
|
|
63
64
|
span = self.span.child(meta.name, event=(event, meta))
|
|
64
65
|
span.record_exception(event.error)
|
|
66
|
+
self.span.record_exception(event.error)
|
|
65
67
|
case ToolRetryEvent():
|
|
66
68
|
self.span.child(meta.name, event=(event, meta))
|
|
67
69
|
case _:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openinference-instrumentation-beeai
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
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.
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
openinference/instrumentation/beeai/__init__.py,sha256=
|
|
2
|
-
openinference/instrumentation/beeai/_span.py,sha256=
|
|
3
|
-
openinference/instrumentation/beeai/_utils.py,sha256=
|
|
4
|
-
openinference/instrumentation/beeai/version.py,sha256=
|
|
1
|
+
openinference/instrumentation/beeai/__init__.py,sha256=tEM7-1EhCKIFsoLeMEa7GcRYPFfjuGeXi2w4CEKA1R4,4547
|
|
2
|
+
openinference/instrumentation/beeai/_span.py,sha256=iVlYou4vnNKtDxpypMdZuD2AKeaDiG1Cu5PXVzgQ8w4,3259
|
|
3
|
+
openinference/instrumentation/beeai/_utils.py,sha256=tfQsQEcevyLJno8WmLTOe936GVTIS2etnAFVbAPyztc,2521
|
|
4
|
+
openinference/instrumentation/beeai/version.py,sha256=XIaxbMbyiP-L3kguR1GhxirFblTXiHR1lMfDVITvHUI,22
|
|
5
5
|
openinference/instrumentation/beeai/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
openinference/instrumentation/beeai/processors/base.py,sha256=
|
|
6
|
+
openinference/instrumentation/beeai/processors/base.py,sha256=eAcKq6ip23sp1pjCa6efjDEcfoPJ_Jc3GwaWk5oZU7k,2125
|
|
7
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=
|
|
11
|
+
openinference/instrumentation/beeai/processors/tool.py,sha256=ddkJP0Y7-pZFQNlKSB-SOOwquAbWL9ram8VS46SU8-Q,2633
|
|
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.
|
|
19
|
-
openinference_instrumentation_beeai-0.1.
|
|
20
|
-
openinference_instrumentation_beeai-0.1.
|
|
21
|
-
openinference_instrumentation_beeai-0.1.
|
|
18
|
+
openinference_instrumentation_beeai-0.1.9.dist-info/METADATA,sha256=q2qwIddIyMKySNHBL6DRFSCCQi5NqoK9xHuSn1fkEm0,5491
|
|
19
|
+
openinference_instrumentation_beeai-0.1.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
20
|
+
openinference_instrumentation_beeai-0.1.9.dist-info/entry_points.txt,sha256=ee7EUhbWv-XK1dxhPXuFVy9qstzj-lc-265Phe2Ml9s,183
|
|
21
|
+
openinference_instrumentation_beeai-0.1.9.dist-info/RECORD,,
|
|
File without changes
|