langfuse-python icon indicating copy to clipboard operation
langfuse-python copied to clipboard

feat(client): LangfuseBaseCallbackHandler allow tags has non-str element (number, None, etc)

Open XenoAmess opened this issue 1 year ago • 1 comments

[!IMPORTANT] LangfuseBaseCallbackHandler now converts tags to strings, allowing non-string elements.

  • Behavior:
    • In LangfuseBaseCallbackHandler.__init__, tags are now converted to strings, allowing non-string elements (e.g., numbers, None).

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

Greptile Summary

Disclaimer: Experimental PR review

Modified the LangfuseBaseCallbackHandler class to ensure all tags are converted to strings, preventing type errors when non-string elements (numbers, None, etc.) are included in the tags list.

  • Changed self.tags = tags to self.tags = [str(tag) for tag in tags] if tags else None in langfuse/utils/base_callback_handler.py
  • Prevents type errors when processing tags with mixed data types in the Langfuse SDK
  • Maintains backward compatibility while improving robustness
  • Handles the case when tags is None by setting self.tags to None
  • Ensures consistent tag formatting for the Langfuse API

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

XenoAmess avatar Mar 03 '25 08:03 XenoAmess

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 03 '25 08:03 CLAassistant

Thanks again for raising this! Closing this PR as stale / no longer relevant with Python SDK v3. If you continue to encounter this issue, please open a Github issue for us to continue the discussion there

hassiebp avatar Jul 15 '25 08:07 hassiebp