-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
feat: Add W&B Weave Tracing Integration #14262
base: main
Are you sure you want to change the base?
Conversation
if field_name == "inputs": | ||
data = { | ||
"messages": v, | ||
} | ||
elif field_name == "outputs": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When inputs
is a list of dictionaries, the usage_metadata
and file_list
are not added to each message in the list, potentially losing token usage tracking.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if field_name == "inputs": | |
data = { | |
"messages": v, | |
} | |
elif field_name == "outputs": | |
if field_name == "inputs": | |
data = { | |
"messages": [dict(msg, **{"usage_metadata": usage_metadata, "file_list": file_list}) for msg in v] if isinstance(v, list) else v, | |
} | |
elif field_name == "outputs": |
attributes["start_time"] = (trace_info.start_time or trace_info.message_data.created_at,) | ||
attributes["end_time"] = (trace_info.end_time or trace_info.message_data.updated_at,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect tuple creation in start_time
and end_time
attributes due to trailing comma, causing them to be tuples instead of datetime values
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
attributes["start_time"] = (trace_info.start_time or trace_info.message_data.created_at,) | |
attributes["end_time"] = (trace_info.end_time or trace_info.message_data.updated_at,) | |
attributes["start_time"] = trace_info.start_time or trace_info.message_data.created_at | |
attributes["end_time"] = trace_info.end_time or trace_info.message_data.updated_at |
Summary
This PR adds W&B Weave as a new tracing provider in Dify, resolving the feature request in #14463. The integration follows similar patterns to the existing tracers, allowing users to track LLM calls, workflows, and tool usage in W&B Weave.
Motivation and Context
Many Dify users leverage Weights & Biases for their ML workflow tracking and would benefit from native W&B Weave integration. This addition gives users more flexibility in choosing tracing providers that align with their existing MLOps stack.
Weave offers specialized capabilities for LLM applications:
Implementation Details
The implementation:
Weave
as a new tracing provider optionWeaveConfig
model for storing API key, entity, project, and endpoint configurationBaseTraceInstance
interfaceDependencies
weave
package for Python SDK integrationThe implementation follows Dify's existing patterns to ensure consistency while providing the new functionality needed for W&B Weave integration.
Checklist
This change requires a documentation update, included: Dify Document :Docs PR
I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
I've updated the documentation accordingly.
I ran
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods