Skip to content

Commit

Permalink
Cleaner DEBUG=1 Output
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Aug 30, 2024
1 parent ef1217b commit 7ec1cde
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

See this http://keepachangelog.com link for information on how we want this document formatted.

## v1.5.9

### Changed

- Enhanced `debugEvent` function in `src/helpers.js` to remove function descriptions from debug output, further reducing verbosity in logs.

## v1.5.8

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "experts",
"version": "1.5.8",
"version": "1.5.9",
"description": "An opinionated panel of experts implementation using OpenAI's Assistants API",
"type": "module",
"scripts": {
Expand Down
18 changes: 17 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const DEBUG = process.env.DEBUG === "1";
const DEBUG_DELTAS = process.env.DEBUG_DELTAS === "1";
const DEBUG_PRETTY_JSON = process.env.DEBUG_PRETTY_JSON === "1";

const debug = (message) => {
if (DEBUG) {
Expand All @@ -14,7 +15,22 @@ const debugEvent = (event) => {
if (eventCopy.data && eventCopy.data.instructions) {
eventCopy.data.instructions = "[INSTRUCTIONS REMOVED]";
}
debug(`📡 Event: ${JSON.stringify(eventCopy)}`);
if (eventCopy.data && eventCopy.data.tools) {
eventCopy.data.tools = eventCopy.data.tools.map((tool) => {
if (
tool.type === "function" &&
tool.function &&
tool.function.description
) {
tool.function.description = "[DESCRIPTION REMOVED]";
}
return tool;
});
}
const jsonOutput = DEBUG_PRETTY_JSON
? JSON.stringify(eventCopy, null, 2)
: JSON.stringify(eventCopy);
debug(`📡 Event: ${jsonOutput}`);
};

const messagesContent = (messages) => {
Expand Down

0 comments on commit 7ec1cde

Please sign in to comment.