File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
libs/core/langchain_core/tracers Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ def __init__(
95
95
self .client = client or get_client ()
96
96
self .tags = tags or []
97
97
self .latest_run : Optional [Run ] = None
98
+ self .run_has_token_event_map : dict [str , bool ] = {}
98
99
99
100
def _start_trace (self , run : Run ) -> None :
100
101
if self .project_name :
@@ -235,6 +236,11 @@ def _llm_run_with_token_event(
235
236
parent_run_id : Optional [UUID ] = None ,
236
237
) -> Run :
237
238
"""Append token event to LLM run and return the run."""
239
+ run_id_str = str (run_id )
240
+ if run_id_str not in self .run_has_token_event_map :
241
+ self .run_has_token_event_map [run_id_str ] = True
242
+ else :
243
+ return self ._get_run (run_id , run_type = {"llm" , "chat_model" })
238
244
return super ()._llm_run_with_token_event (
239
245
# Drop the chunk; we don't need to save it
240
246
token ,
You can’t perform that action at this time.
0 commit comments