Replies: 1 comment 2 replies
-
Hi @kongzii - thanks a lot for opening this discussion! Let me first understand the problem we are trying to solve here: reducing the required instrumentation code for each Langchain. Before discussing monkey patching the Langchain module, one could abstract away the callback handler init into a function that is called at Also, one could try to push for a global callback handler in the Langchain repos similar as in LlamaIndex. In the past, we have mixed experiences with monkey patching modules such as How would you trade off the cost / benefits here? What could I be missing here? |
Beta Was this translation helpful? Give feedback.
-
Describe the feature or potential improvement
I have been integrating Langfuse into our agents lately, and it's quite cumbersome to always initialize and include Langfuse's callback before calling Langchain's invoke method:
It's even more cumbersome if someone needs to have both observed and non-observed versions of the function:
As an inspiration, we can take MLFlow, which is quite popular, they provide an
auto_log
feature that will "magically" include mlflow logging in supported libraries: https://mlflow.org/docs/latest/tracking/autolog.htmlI think something similar shouldn't be too hard to achieve, I can see two approaches:
@observed
function are monkey-patched with auto-tracking, ifautolog
is enabledautolog
is enabledI think (1) is way better, but I'm not sure it would be possible, but still (2) would be great too.
If this sounds reasonable to you as well, I'm open to kicking off the first implementation.
We could start with Langchain (as that's the library I'm working most atm), and then add support for others if all goes well.
Additional information
No response
Beta Was this translation helpful? Give feedback.
All reactions