From af6d333147db0af7d558a4a66d6c2752b6027204 Mon Sep 17 00:00:00 2001 From: AI-Chef Date: Fri, 14 Jul 2023 10:39:21 +0800 Subject: [PATCH] Fix same issue #7524 in FileCallbackHandler (#7687) Fix for Serializable class to include name, used in FileCallbackHandler as same issue #7524 Description: Fixes the Serializable class to include 'name' attribute (class_name) in the dict created, This is used in Callbacks, specifically the StdOutCallbackHandler, FileCallbackHandler. Issue: As described in issue #7524 Dependencies: None Tag maintainer: SInce this is related to the callback module, tagging @agola11 @idoru Comments: Glad to see issue #7524 fixed in pull #6124, but you forget to change the same place in FileCallbackHandler --- langchain/callbacks/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain/callbacks/file.py b/langchain/callbacks/file.py index 7c13295364..1c359e7a1d 100644 --- a/langchain/callbacks/file.py +++ b/langchain/callbacks/file.py @@ -24,7 +24,7 @@ class FileCallbackHandler(BaseCallbackHandler): self, serialized: Dict[str, Any], inputs: Dict[str, Any], **kwargs: Any ) -> None: """Print out that we are entering a chain.""" - class_name = serialized["name"] + class_name = serialized.get("name", serialized.get("id", [""])[-1]) print_text( f"\n\n\033[1m> Entering new {class_name} chain...\033[0m", end="\n",