Skip to content

fix(media): allow setting IO media via decorator update - #1005

Merged
hassiebp merged 1 commit into
mainfrom
fix-media-decorator-output
Nov 20, 2024
Merged

hassiebp merged 1 commit into
mainfrom
fix-media-decorator-output

Conversation

@hassiebp

@hassiebp hassiebp commented Nov 20, 2024 •

Copy link
Copy Markdown
Collaborator

Important

Fixes JSON serialization of output in _handle_call_result in langfuse_decorator.py and updates test_media in test_decorators.py to verify media handling.

  • Behavior:
    • In langfuse_decorator.py, _handle_call_result now directly serializes result using json.dumps and json.loads with EventSerializer to ensure proper JSON serialization.
  • Tests:
    • In test_decorators.py, test_media is updated to check that media references in input, output, and metadata are correctly serialized and deserialized.

This description was created by Ellipsis for 1ad58c0. It will automatically update as commits are pushed.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclaimer: Experimental PR review

PR Summary

Improved media object handling in the Python SDK's decorator system by consolidating JSON serialization of outputs for more reliable media object processing.

  • Modified _handle_call_result in /langfuse/decorators/langfuse_decorator.py to use single-step JSON serialization for outputs
  • Added media object support tests in /tests/test_decorators.py to verify nested media handling within input/output/metadata dictionaries
  • Enhanced decorator update functionality to properly handle LangfuseMedia objects in trace updates

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@hassiebp
hassiebp enabled auto-merge (squash) November 20, 2024 12:48
@hassiebp
hassiebp merged commit 91231ea into main Nov 20, 2024
@hassiebp
hassiebp deleted the fix-media-decorator-output branch November 20, 2024 13:06
niklassemmler added a commit that referenced this pull request Oct 8, 2026
The bare `langfuse.observation.metadata` attribute (non-dict metadata) is
now sent as `json.dumps(metadata, cls=EventSerializer)`, strings
included, matching the per-key values and langfuse-js #1005. Previously
strings were passed through raw, so `metadata="foo"` sent `foo` in
Python but `"foo"` in JS. None is still not written. Input/output and
other `_serialize` callers are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant