-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GEN AI] Improving Langfuse's traces #1793
base: master
Are you sure you want to change the base?
[GEN AI] Improving Langfuse's traces #1793
Conversation
a4222d9
to
1878fe2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR, ok for me juste added some suggestions and reflexions about our callback integration approach, if you agree I will create an other ticket for that I thing our current observability integration needs to be updated.
history: list[ChatMessage] = Field( | ||
description="Conversation history, used to reformulate the user's question." | ||
) | ||
dialog: DialogDetails = Field(description='The user dialog details.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it optional for non "conversational" use cases of the orchestrator, I agree it a bit hypothetical
dialog_id: Optional[str] = Field(description="The dialog ID.", default=None, examples=["uuid-0123"]) | ||
user_id: Optional[str] = Field(description="The user ID.", default=None, examples=["[email protected]"]) | ||
history: list[ChatMessage] = Field(description="Conversation history, used to reformulate the user's question.") | ||
tags: list[str] = Field(description='List of tags', examples=[["my-Tag"]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tags: list[str] = Field(description='List of tags', examples=[["my-Tag"]]) | |
tags: list[str] = Field(description='List of tags, attached to the observability trace, if the observability provider support it .', examples=[["my-Tag"]]) |
class DialogDetails(BaseModel): | ||
"""The dialog details model""" | ||
|
||
dialog_id: Optional[str] = Field(description="The dialog ID.", default=None, examples=["uuid-0123"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dialog_id: Optional[str] = Field(description="The dialog ID.", default=None, examples=["uuid-0123"]) | |
dialog_id: Optional[str] = Field(description="The dialog/session ID, attached to the observability traces if the observability provider support it.", default=None, examples=["uuid-0123"]) |
"""The dialog details model""" | ||
|
||
dialog_id: Optional[str] = Field(description="The dialog ID.", default=None, examples=["uuid-0123"]) | ||
user_id: Optional[str] = Field(description="The user ID.", default=None, examples=["[email protected]"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user_id: Optional[str] = Field(description="The user ID.", default=None, examples=["[email protected]"]) | |
user_id: Optional[str] = Field(description="The user ID, attached to the observability traces if the observability provider support it.", default=None, examples=["[email protected]"]) |
setting=observability_setting | ||
).get_callback_handler(trace_name=trace_name.value) | ||
setting=observability_setting, | ||
).get_callback_handler(**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are directly mapped to the langfuse attributes ... I'm thinking that this is ok untill we just have langfuse but what about langsmith or Arize Phoenix so I made some research in case we would someday implement them :
- Arize Phoenix uses auto-instrumentation (compatible with OpenTelemetry standard and OpenInference), meaning it's not done though an explicit langchain callback
- Langsmith SDK is now called LangChainTracer, it seems that they aren't using callbacks any more : context managers are use in the document, tags are passed by wrapping the LCEL chain ...
It seems that langfuse also recommends using decorators : https://langfuse.com/docs/sdk/python/decorators#decorator-context
I think that it would be great to investigate a bit more and maybe instead of using a callback, wrap chains calls inside python's context managers ... where the manager is build by a factory.
Also we should test LCEL chain tags with_configs (to pass tags) in a more generic way, maybe we would have to pass them to the observability provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's a good thing, we need to move towards this new way of tracing. As seen together on a separate ticket.
5042a54
to
3a19167
Compare
c49bc63
to
6072ada
Compare
Add dialogs details to Langfuse trace & Return Langfuse trace (id, name, url) in RAG Response