Skip to content
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

Conversation

noble-varghese
Copy link
Contributor

@noble-varghese noble-varghese commented Mar 31, 2024

Description

Test Langchain's synchronous, asynchronous streaming, batch, and invoke methods, and resolve the asynchronous issue encountered with Langchain batch calls.

Key Modifications:

  • Users encountered issues due to parallel processing in Langchain integrations, resulting in missing "unable to find run-id" error messages in the logs.
  • Integration tests have been implemented for both synchronous and asynchronous streaming methods.

@noble-varghese noble-varghese marked this pull request as ready for review March 31, 2024 14:56
@noble-varghese noble-varghese requested a review from a team as a code owner March 31, 2024 14:56
maxdeichmann and others added 5 commits March 31, 2024 19:36
…: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.
Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants