Skip to content

feat: improve input/output detection for traces in the langwatch integration #7067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/backend/base/langflow/services/tracing/langwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ def add_trace(
if "session_id" in inputs and inputs["session_id"] != self.flow_id:
self.trace.update(metadata=(self.trace.metadata or {}) | {"thread_id": inputs["session_id"]})

# If the trace inputs contain an input value, we may want to use this data to
# update the root trace span input/output. We only update the input/output if
# the root span still has an input/output that is None.
if "input_value" in inputs and inputs["input_value"] is not None and "sender" in inputs:
if inputs["sender"] == "User":
root_span = self._client.get_current_trace().root_span
if root_span.input is None:
self.trace.update(input=self._convert_to_langwatch_types(inputs))

if inputs["sender"] == "Machine":
root_span = self._client.get_current_trace().root_span
if root_span.output is None:
self.trace.update(output=self._convert_to_langwatch_types(inputs))

name_without_id = " (".join(trace_name.split(" (")[0:-1])

previous_nodes = (
Expand Down
Loading