Skip to content
Merged
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
6 changes: 5 additions & 1 deletion langfuse/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ def _get_langfuse_data_from_kwargs(resource: OpenAiDefinition, kwargs):
raise ValueError("parent_observation_id requires trace_id to be set")

metadata = kwargs.get("metadata", {})
if metadata is not None and not isinstance(metadata, dict):
if (
metadata is not None
and not isinstance(metadata, NotGiven)
Copy link
Contributor

Choose a reason for hiding this comment

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

The new check for NotGiven is good; consider adding an inline comment explaining why NotGiven is skipped in type validation.

Suggested change
and not isinstance(metadata, NotGiven)
and not isinstance(metadata, NotGiven) # NotGiven is a sentinel for missing values, not a dict

and not isinstance(metadata, dict)
):
raise TypeError("metadata must be a dictionary")

model = kwargs.get("model", None) or None
Expand Down