by-framework-langgraph 0.0.3.dev1__py3-none-any.whl → 0.0.3.dev2__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.
- by_framework_langgraph/adapter.py +35 -57
- {by_framework_langgraph-0.0.3.dev1.dist-info → by_framework_langgraph-0.0.3.dev2.dist-info}/METADATA +1 -1
- {by_framework_langgraph-0.0.3.dev1.dist-info → by_framework_langgraph-0.0.3.dev2.dist-info}/RECORD +4 -4
- {by_framework_langgraph-0.0.3.dev1.dist-info → by_framework_langgraph-0.0.3.dev2.dist-info}/WHEEL +0 -0
|
@@ -590,69 +590,47 @@ class LangGraphAdapter:
|
|
|
590
590
|
# Always inject token accumulator — works regardless of Langfuse config.
|
|
591
591
|
callbacks.append(_TokenAccumulatingCallbackHandler(self._context))
|
|
592
592
|
|
|
593
|
-
# Prefer AgentContext's callback factory so trace and parent ids align.
|
|
594
|
-
# Filter out auto-generated MagicMock attributes when tests use a mock
|
|
595
|
-
# context — real callback objects always come from a non-test module.
|
|
596
|
-
langfuse_callback_value = getattr(self._context, "langfuse_callback", None)
|
|
597
|
-
is_real_callback = langfuse_callback_value is not None and type(
|
|
598
|
-
langfuse_callback_value
|
|
599
|
-
).__module__ not in ("unittest.mock",)
|
|
600
|
-
|
|
601
|
-
if is_real_callback:
|
|
602
|
-
handler = (
|
|
603
|
-
langfuse_callback_value()
|
|
604
|
-
if callable(langfuse_callback_value)
|
|
605
|
-
else langfuse_callback_value
|
|
606
|
-
)
|
|
607
|
-
if handler is not None:
|
|
608
|
-
callbacks.append(handler)
|
|
609
|
-
yield
|
|
610
|
-
return
|
|
611
|
-
|
|
612
|
-
# Fallback to local import if context method is missing
|
|
613
|
-
# pylint: disable=import-outside-toplevel
|
|
614
593
|
try:
|
|
615
|
-
|
|
616
|
-
"by_framework_trace_langfuse"
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
raise ImportError("Langfuse not configured")
|
|
620
|
-
|
|
621
|
-
callback_handler = import_module("langfuse.langchain").CallbackHandler
|
|
622
|
-
get_client = import_module("langfuse").get_client
|
|
594
|
+
build_langchain_callback = getattr(
|
|
595
|
+
import_module("by_framework_trace_langfuse"),
|
|
596
|
+
"build_langchain_callback",
|
|
597
|
+
)
|
|
623
598
|
except (ImportError, AttributeError):
|
|
624
599
|
yield
|
|
625
600
|
return
|
|
626
601
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
602
|
+
get_parent_observation_id = getattr(
|
|
603
|
+
self._context,
|
|
604
|
+
"get_trace_parent_observation_id",
|
|
605
|
+
None,
|
|
606
|
+
)
|
|
607
|
+
parent_observation_id = (
|
|
608
|
+
str(get_parent_observation_id() or "")
|
|
609
|
+
if callable(get_parent_observation_id)
|
|
610
|
+
else ""
|
|
611
|
+
)
|
|
612
|
+
if not parent_observation_id:
|
|
613
|
+
framework_observation = getattr(
|
|
614
|
+
self._context, LANGFUSE_OBSERVATION_ATTR, None
|
|
615
|
+
)
|
|
616
|
+
parent_observation_id = getattr(framework_observation, "id", "") or ""
|
|
617
|
+
if not parent_observation_id:
|
|
618
|
+
execution_id = getattr(self._context, "execution_id", "")
|
|
619
|
+
message_id = getattr(self._context, "message_id", "")
|
|
620
|
+
raw_parent_id = (
|
|
621
|
+
f"{execution_id}:worker.execute"
|
|
622
|
+
if execution_id
|
|
623
|
+
else f"{message_id}:worker.execute"
|
|
624
|
+
)
|
|
625
|
+
parent_observation_id = f"{str_to_uint64(raw_parent_id):016x}"
|
|
633
626
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
},
|
|
642
|
-
metadata=self._default_metadata(),
|
|
643
|
-
):
|
|
644
|
-
# Prevent the generated OTel span from being promoted to a trace root.
|
|
645
|
-
# The native LangfusePlugin sets the same attribute on its own path
|
|
646
|
-
# (via _SdkLangfuseTracer); this covers the LangGraph fallback path.
|
|
647
|
-
try:
|
|
648
|
-
from opentelemetry import trace
|
|
649
|
-
|
|
650
|
-
current_span = trace.get_current_span()
|
|
651
|
-
if current_span and hasattr(current_span, "set_attribute"):
|
|
652
|
-
current_span.set_attribute("langfuse.internal.as_root", False)
|
|
653
|
-
except Exception: # pylint: disable=broad-exception-caught
|
|
654
|
-
pass
|
|
655
|
-
yield
|
|
627
|
+
handler = build_langchain_callback(
|
|
628
|
+
trace_id=getattr(self._context, "trace_id", ""),
|
|
629
|
+
parent_observation_id=parent_observation_id,
|
|
630
|
+
)
|
|
631
|
+
if handler is not None:
|
|
632
|
+
callbacks.append(handler)
|
|
633
|
+
yield
|
|
656
634
|
|
|
657
635
|
@staticmethod
|
|
658
636
|
def _default_input_mapper(content: str) -> dict:
|
{by_framework_langgraph-0.0.3.dev1.dist-info → by_framework_langgraph-0.0.3.dev2.dist-info}/RECORD
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
by_framework_langgraph/__init__.py,sha256=x08wIaK4VRnUnUD_mbBxVgI2Zf7CvwAVbr3syP2NQps,1046
|
|
2
2
|
by_framework_langgraph/_utils.py,sha256=A8eQ19YqyBiMKcPIlzmwggN_mK5iQvNJPTaTmsywWsw,1605
|
|
3
|
-
by_framework_langgraph/adapter.py,sha256=
|
|
3
|
+
by_framework_langgraph/adapter.py,sha256=b4WcK6R3B0Y7a52lIY6kMLtpp9mjXOkp4p6HcALAzbA,26689
|
|
4
4
|
by_framework_langgraph/tools.py,sha256=l7LurtKKXA1Z4fyj15ffFWyWpt8drNCJ-mkGmlS7EVo,5561
|
|
5
5
|
by_framework_langgraph/worker.py,sha256=wFalpBQLqFm-YzJugzAzkA3ciI9lUzxRTv4GmqVCv78,6156
|
|
6
|
-
by_framework_langgraph-0.0.3.
|
|
7
|
-
by_framework_langgraph-0.0.3.
|
|
8
|
-
by_framework_langgraph-0.0.3.
|
|
6
|
+
by_framework_langgraph-0.0.3.dev2.dist-info/METADATA,sha256=lzuVDa2l8CUp_af7-VnadrCq-wJgXCWJ2ldcuEwHKRw,2334
|
|
7
|
+
by_framework_langgraph-0.0.3.dev2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
8
|
+
by_framework_langgraph-0.0.3.dev2.dist-info/RECORD,,
|
{by_framework_langgraph-0.0.3.dev1.dist-info → by_framework_langgraph-0.0.3.dev2.dist-info}/WHEEL
RENAMED
|
File without changes
|