Skip to content

Commit

Permalink
fix llm output logging (microsoft#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Q authored Jan 18, 2024
2 parents 5dddffd + 2cbd741 commit dfcfe67
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions taskweaver/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion taskweaver/role/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dfcfe67

Please sign in to comment.