Skip to content

Commit

Permalink
fix(langchain): batch run to update trace outputs (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
hassiebp authored Sep 10, 2024
1 parent e02fb8c commit 8cb88ee
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions langfuse/callback/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,14 @@ def _update_trace_and_remove_state(
else:
self.trace = self.trace.update(output=output, **kwargs)

elif parent_run_id is None and self.langfuse is not None:
"""
For batch runs, self.trace.id == str(run_id) only for the last run
For the rest of the runs, the trace must be manually updated
The check for self.langfuse ensures that no stateful client was provided by the user
"""
self.langfuse.trace(id=str(run_id)).update(output=output, **kwargs)

if not keep_state:
del self.runs[run_id]

Expand Down

0 comments on commit 8cb88ee

Please sign in to comment.