From 331692ef7b24d1df29ebd10cc6632f66ff41fb80 Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Tue, 8 Aug 2023 17:28:17 -0700 Subject: [PATCH] Add id in error --- .../langchain/callbacks/tracers/base.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/langchain/langchain/callbacks/tracers/base.py b/libs/langchain/langchain/callbacks/tracers/base.py index 292685c56ef5c..3a0ee9d2c528d 100644 --- a/libs/langchain/langchain/callbacks/tracers/base.py +++ b/libs/langchain/langchain/callbacks/tracers/base.py @@ -131,7 +131,7 @@ def on_llm_new_token( run_id_ = str(run_id) llm_run = self.run_map.get(run_id_) if llm_run is None or llm_run.run_type != "llm": - raise TracerException("No LLM Run found to be traced") + raise TracerException(f"No LLM Run found to be traced for {run_id}") llm_run.events.append( { "name": "new_token", @@ -183,7 +183,7 @@ def on_llm_end(self, response: LLMResult, *, run_id: UUID, **kwargs: Any) -> Non run_id_ = str(run_id) llm_run = self.run_map.get(run_id_) if llm_run is None or llm_run.run_type != "llm": - raise TracerException("No LLM Run found to be traced") + raise TracerException(f"No LLM Run found to be traced for {run_id}") llm_run.outputs = response.dict() for i, generations in enumerate(response.generations): for j, generation in enumerate(generations): @@ -211,7 +211,7 @@ def on_llm_error( run_id_ = str(run_id) llm_run = self.run_map.get(run_id_) if llm_run is None or llm_run.run_type != "llm": - raise TracerException("No LLM Run found to be traced") + raise TracerException(f"No LLM Run found to be traced for {run_id}") llm_run.error = repr(error) llm_run.end_time = datetime.utcnow() llm_run.events.append({"name": "error", "time": llm_run.end_time}) @@ -261,7 +261,7 @@ def on_chain_end( raise TracerException("No run_id provided for on_chain_end callback.") chain_run = self.run_map.get(str(run_id)) if chain_run is None: - raise TracerException("No chain Run found to be traced") + raise TracerException(f"No chain Run found to be traced for {run_id}") chain_run.outputs = outputs chain_run.end_time = datetime.utcnow() @@ -281,7 +281,7 @@ def on_chain_error( raise TracerException("No run_id provided for on_chain_error callback.") chain_run = self.run_map.get(str(run_id)) if chain_run is None: - raise TracerException("No chain Run found to be traced") + raise TracerException(f"No chain Run found to be traced for {run_id}") chain_run.error = repr(error) chain_run.end_time = datetime.utcnow() @@ -329,7 +329,7 @@ def on_tool_end(self, output: str, *, run_id: UUID, **kwargs: Any) -> None: raise TracerException("No run_id provided for on_tool_end callback.") tool_run = self.run_map.get(str(run_id)) if tool_run is None or tool_run.run_type != "tool": - raise TracerException("No tool Run found to be traced") + raise TracerException(f"No tool Run found to be traced for {run_id}") tool_run.outputs = {"output": output} tool_run.end_time = datetime.utcnow() @@ -349,7 +349,7 @@ def on_tool_error( raise TracerException("No run_id provided for on_tool_error callback.") tool_run = self.run_map.get(str(run_id)) if tool_run is None or tool_run.run_type != "tool": - raise TracerException("No tool Run found to be traced") + raise TracerException(f"No tool Run found to be traced for {run_id}") tool_run.error = repr(error) tool_run.end_time = datetime.utcnow() @@ -404,7 +404,7 @@ def on_retriever_error( raise TracerException("No run_id provided for on_retriever_error callback.") retrieval_run = self.run_map.get(str(run_id)) if retrieval_run is None or retrieval_run.run_type != "retriever": - raise TracerException("No retriever Run found to be traced") + raise TracerException(f"No retriever Run found to be traced for {run_id}") retrieval_run.error = repr(error) retrieval_run.end_time = datetime.utcnow() @@ -420,7 +420,7 @@ def on_retriever_end( raise TracerException("No run_id provided for on_retriever_end callback.") retrieval_run = self.run_map.get(str(run_id)) if retrieval_run is None or retrieval_run.run_type != "retriever": - raise TracerException("No retriever Run found to be traced") + raise TracerException(f"No retriever Run found to be traced for {run_id}") retrieval_run.outputs = {"documents": documents} retrieval_run.end_time = datetime.utcnow() retrieval_run.events.append({"name": "end", "time": retrieval_run.end_time})