Skip to content

Commit

Permalink
Merge pull request wise-agents#402 from maeste/utilty_log
Browse files Browse the repository at this point in the history
following up on the utility method to log messages exchanged in a con…
  • Loading branch information
fjuma authored Oct 9, 2024
2 parents ca61206 + 5da2ef8 commit a9251fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/wiseagents/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def log_messages_exchanged(messages: List[ChatCompletionMessageParam], agent_nam
"""
if not os.path.exists(dir_path):
os.makedirs(dir_path)
with open(f'{dir_path}/messages-{agent_name}-{context_name}.md', 'w') as file:
message : ChatCompletionMessageParam
for message in messages:
file.write(f"## {message.get('role')}\n {message.get('content')}\n\n\n")
#file.write(f"{message}\n\n\n")
with open(f'{dir_path}/messages-{agent_name}-{context_name}.log', 'w') as file:
json.dump(messages, file, indent=2)
print(f"[{agent_name}] Logged messages to {dir_path}/messages-{agent_name}-{context_name}.log for the current request")

0 comments on commit a9251fd

Please sign in to comment.