Decorator-based integration with Langfuse #1009
Replies: 3 comments 5 replies
-
Attached in the gist is a paradigm that I've found helpful for logging tool info to a root span. https://gist.github.com/lshalon/a87e099c893c8e786ade439acb890508 Something like this functionality is great, but if integrated into the library, I believe advantages could include:
|
Beta Was this translation helpful? Give feedback.
-
Just wanted to contribute a quick implementation I put together for my own use. Key change for discussion would be explicitly passing through trace parameters in the decorator explicitly and as attributes. https://gist.github.com/AshisGhosh/5d1ab84aa54e965005b2dbb959e612ad |
Beta Was this translation helpful? Give feedback.
-
👑🐍 Decorator-based Python SDK now in alpha-release, please test & leave your feedback here 😊 Hi all - we're happy to share with you an alpha-release of the decorators-based Python SDK. This will significantly reduce code overhead and complexity in adopting Langfuse in Python projects and abstract away the tedious managing of the nesting hierarchy of Langfuse traces and observations. Feel free to see for yourself and check it out - your feedback is incredibly valuable for us to get a stable and complete version out of the door as soon as possible. You can leave your feedback right here! 🙌🏾 Here's the gist: from langfuse.decorators import langfuse_context, observe
@observe()
def span_inside_trace():
print("Hello, from a span inside a trace!")
@observe()
def function_to_trace():
print("Hello, from the parent trace!")
span_inside_trace()
function_to_trace()
langfuse_context.flush() Voilà! ✨ Langfuse will generate a trace with a nested span for you. Links: 👀 @AshisGhosh @phenomagentx @lshalon - as you showed interest here in the past 😊 |
Beta Was this translation helpful? Give feedback.
-
I've heard from many Langfuse users who'd like to see a decorator-based integration with Langfuse in addition to the current integrations and SDKs.
Inspiration from the OTel docs:
Advantages:
This is not a work in progress at the moment, but something that @maxdeichmann and I really want to prioritize soon. Please share your ideas and feedback here.
We believe this will be highly effective for the Python SDK, but may not be as applicable for the JS/TS SDK.
Beta Was this translation helpful? Give feedback.
All reactions