I'm using langchain for my RAG app. Right now, I have 4 "sub" chains that I conditionally execute based on various things. So this means every user interaction/message, generates anywhere from 2-4 top level traces. I think these should be "grouped" under a top-level chain right? Is there anyway I can do that directly in my code? (not in langchain)?
you can take a look at this new_group function here https://github.com/explodinggradients/ragas/blob/5cdab0ae21d7d64ceaa6429e73a5d838e704b756/src/ragas/evaluation.py#L189
Hey Trantor D., it's also possible to manually create a top-level span and invoke your chains within that span. There is an example here, e.g., on this line. You would probably want to create a CHAIN span. For this sort of thing, we will eventually support sessions, which will allow you to provide a session ID to group multiple traces together.
Hm - not exactly sure how to create a chain span - that code you linked uses several functions to set span attributes - is there a simple:
with tracer.start_as_current_span("my top level chain") as span:
span.set_type(openinference.type.chain) Sessions seem really useful! Following that task thanks!
use this
with tracer.start_as_current_span("my top level chain") as span:
span.set_attribute("openinference.span.kind", "CHAIN") 