Zet
Zet2w ago

LangchainCallbackHandler custom input/output?

Is there a way to set/override input/output when using the LangchainCallbackHandler similar to how the @observe() decorator allows updating observation context with custom inputs/outputs?
Solution:
Overriding single observation/span/generation outputs is tricky. You could fetch the trace via the fetch_* methods to then update it. If you want to change the trace output you could wrap this with the decorator and handle the trace yourself. Details: https://langfuse.com/docs/integrations/langchain/tracing#interoperability What do you try to achieve here? Maybe I can help in a better way with more context...
Open Source Observability for LangChain - Langfuse
Open source tracing and monitoring for your LangChain application. Python and JS/TS. Automatically capture rich traces and metrics and evaluate outputs.
Jump to solution
3 Replies
Solution
Marc
Marc7d ago
Overriding single observation/span/generation outputs is tricky. You could fetch the trace via the fetch_* methods to then update it. If you want to change the trace output you could wrap this with the decorator and handle the trace yourself. Details: https://langfuse.com/docs/integrations/langchain/tracing#interoperability What do you try to achieve here? Maybe I can help in a better way with more context
Open Source Observability for LangChain - Langfuse
Open source tracing and monitoring for your LangChain application. Python and JS/TS. Automatically capture rich traces and metrics and evaluate outputs.
Zet
Zet7d ago
I wanted to explore truncating the input/output to a certain length on certain conditions so we don't persist too much into the DB.
Marc
Marc3d ago
makes sense, not supported yet, please open a thread here: langfuse.com/ideas