Langchain handler with multiple spans as parent elements
I end up with a trace like this
How do i get this instead
I am sorry for the abstract functions, but I am not able to share the exact code. Thanks a lot in advance.
3 Replies
HI @untilhamza, happy to help with this. I'd recommend to use the following approach:
- create trace: trace=langfuse.trace(...)
- create the parent spans for each async loop: span=trace.span(...)
- get callback handlers scoped to each of the spans to use langchain to make your LLM calls: scoped_handler = span.get_langchain_handler()
Let me know if this helps solve it for you
Thanks a lot! I will try it tomorrow and let you know.
Perfect