-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fix: langchain async and sync batch calls #518
Fix: langchain async and sync batch calls #518
Conversation
* test: Add test cases for langchain syn and async methods * fix: move the assertion on streaming outside exception block * test: add ainvoke test on llm model * test: removed streaming=true from non-streaming cases * test: adding the streaming parameter in cases where it makes sense
…:noble-varghese/langfuse-python into noble-varghese/langchain-streaming-tests
…:langfuse/langfuse-python into noble-varghese/langchain-streaming-tests
…:noble-varghese/langfuse-python into noble-varghese/langchain-streaming-tests
Once the runs are generated in the current scenario when the callback is declared as a single declaration and re-used, then the runs basically starts collecting the run traces indefinitely untill it goes OOM. To avoid this situtaion we remove the run details after the end of the chain and at the end of the run invocation itself. This ensures the details are persistent till the end of the loop and is removed once the traces are pushed to langfuse.
@@ -743,6 +743,9 @@ def _update_trace(self, run_id: str, parent_run_id: Optional[str], output: any): | |||
): | |||
self.trace = self.trace.update(output=output) | |||
|
|||
# Remove the run details after updating the trace. |
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.
Can we quickly rename the function? E.g. _update_trace_and_remove_state(...) to make this more readable?
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.
If the tests complete, i think we are good to go here. Can you add assertions to e.g. https://github.com/noble-varghese/langfuse-python/blob/c1aee1422c48c7cabb4fc4febf7407fca11ccfa4/tests/test_langchain.py#L886 to check that the runs map is empty?
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.
Fixed on Issue #527 and added assertions as well.
Description
Test Langchain's synchronous, asynchronous streaming, batch, and invoke methods, and resolve the asynchronous issue encountered with Langchain batch calls.
Key Modifications: