Skip to content

Commit

Permalink
Enhanced debug output for tool call events, including file search.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Sep 9, 2024
1 parent 1597cc3 commit 1063cbb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 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.6.1

### Added

- Enhanced debug output for tool call events, including file search.

## v1.6.0

### Changed
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.6.0",
"version": "1.6.1",
"description": "An opinionated panel of experts implementation using OpenAI's Assistants API",
"type": "module",
"scripts": {
Expand Down
38 changes: 32 additions & 6 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const debug = (message) => {

const debugEvent = (event) => {
if (!DEBUG) return;
if (!DEBUG_EVENTS) return;
if (event.event.includes("delta") && !DEBUG_DELTAS) return;

const eventCopy = JSON.parse(JSON.stringify(event));
if (eventCopy.data && eventCopy.data.instructions) {
eventCopy.data.instructions = "[INSTRUCTIONS REMOVED]";
Expand All @@ -29,10 +28,37 @@ const debugEvent = (event) => {
return tool;
});
}
const jsonOutput = DEBUG_PRETTY_JSON
? JSON.stringify(eventCopy, null, 2)
: JSON.stringify(eventCopy);
debug(`📡 Event: ${jsonOutput}`);

const isToolCallEvent = eventCopy.data?.step_details?.type === "tool_calls";

if (isToolCallEvent) {
const toolCalls = eventCopy.data.step_details.tool_calls;
toolCalls.forEach((toolCall) => {
const emoji = getToolCallEmoji(toolCall.type);
const toolCallData = toolCall[toolCall.type];
const jsonOutput = DEBUG_PRETTY_JSON
? JSON.stringify(toolCallData, null, 2)
: JSON.stringify(toolCallData);
debug(`${emoji} Tool Call (${toolCall.type}): ${jsonOutput}`);
});
} else if (DEBUG_EVENTS) {
if (event.event.includes("delta") && !DEBUG_DELTAS) return;
const jsonOutput = DEBUG_PRETTY_JSON
? JSON.stringify(eventCopy, null, 2)
: JSON.stringify(eventCopy);
debug(`📡 Event: ${jsonOutput}`);
}
};

const getToolCallEmoji = (toolType) => {
switch (toolType) {
case "file_search":
return "🧰 🔍";
case "code_interpreter":
return "🧰 💻";
default:
return "🧰";
}
};

const messagesContent = (messages) => {
Expand Down

0 comments on commit 1063cbb

Please sign in to comment.