From 961bd1da73b4d5932349b561e3108ef82c11c962 Mon Sep 17 00:00:00 2001 From: Jack-Q Date: Tue, 16 Jan 2024 22:30:45 +0800 Subject: [PATCH 1/2] fix llm output logging --- taskweaver/role/translator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taskweaver/role/translator.py b/taskweaver/role/translator.py index 1a2f8ea5..374a3717 100644 --- a/taskweaver/role/translator.py +++ b/taskweaver/role/translator.py @@ -52,7 +52,7 @@ def stream_filter(s: Iterable[ChatMessageType]) -> Iterator[str]: for c in s: full_llm_content += c["content"] yield c["content"] - self.logger.info(f"LLM output: {llm_output}") + self.logger.info(f"LLM output: {full_llm_content}") value_buf: str = "" filtered_stream = stream_filter(llm_output) From 430ae14761f5d45090eb471288619b1896a24e0f Mon Sep 17 00:00:00 2001 From: Jack-Q Date: Tue, 16 Jan 2024 22:45:19 +0800 Subject: [PATCH 2/2] specificy logging file encoding in case logging error --- taskweaver/logging/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/taskweaver/logging/__init__.py b/taskweaver/logging/__init__.py index 5b91c0a7..fc19ab1b 100644 --- a/taskweaver/logging/__init__.py +++ b/taskweaver/logging/__init__.py @@ -58,7 +58,7 @@ def dump_log_file(self, obj: Any, file_path: str): if not self.is_remote: import json - with open(file_path, "w") as log_file: + with open(file_path, "w", encoding="utf-8") as log_file: json.dump(dumped_obj, log_file) else: self.telemetry_logging( @@ -90,7 +90,7 @@ def provide_logger(self, config: LoggingModuleConfig) -> logging.Logger: if not os.path.exists(config.log_full_path): os.makedirs(os.path.dirname(config.log_full_path), exist_ok=True) open(config.log_full_path, "w").close() - file_handler = logging.FileHandler(config.log_full_path) + file_handler = logging.FileHandler(config.log_full_path, encoding="utf-8") file_handler.setLevel(logging.INFO) log_format = "%(asctime)s - %(levelname)s - %(message)s" formatter = logging.Formatter(log_format)