Skip to content

Commit 71226e2

Browse files
committed
Add error logs
1 parent 16c7a03 commit 71226e2

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

CopilotKit/examples/next-openai/src/app/api/copilotkit/openai/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ export async function POST(req: Request): Promise<Response> {
5151

5252
return copilotKit.response(
5353
req,
54-
new OpenAIAssistantAdapter({ assistantId: "asst_oRVCILrsezzrtNoKmcsXLZQj" }),
54+
new OpenAIAssistantAdapter({ assistantId: "asst_NyzWFlvTLdKBKQMOte1BKWym" }),
5555
);
5656
}

CopilotKit/packages/backend/src/lib/openai-assistant-adapter.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class OpenAIAssistantAdapter implements CopilotKitServiceAdapter {
3131
if (status.status === "completed" || status.status === "requires_action") {
3232
return status;
3333
} else if (status.status !== "in_progress" && status.status !== "queued") {
34+
console.error(`Thread run failed with status: ${status.status}`);
3435
throw new Error(`Thread run failed with status: ${status.status}`);
3536
}
3637
await new Promise((resolve) => setTimeout(resolve, RUN_STATUS_POLL_INTERVAL));
@@ -75,9 +76,14 @@ export class OpenAIAssistantAdapter implements CopilotKitServiceAdapter {
7576
});
7677
}
7778

78-
run = await this.openai.beta.threads.runs.submitToolOutputs(threadId, runId, {
79-
tool_outputs: toolOutputs,
80-
});
79+
try {
80+
run = await this.openai.beta.threads.runs.submitToolOutputs(threadId, runId, {
81+
tool_outputs: toolOutputs,
82+
});
83+
} catch (error) {
84+
console.error("Error submitting tool outputs:", error);
85+
throw error;
86+
}
8187

8288
return await this.waitForRun(run);
8389
}
@@ -147,6 +153,7 @@ export class OpenAIAssistantAdapter implements CopilotKitServiceAdapter {
147153
}
148154
// unsupported message
149155
else {
156+
console.error("No actionable message found in the messages");
150157
throw new Error("No actionable message found in the messages");
151158
}
152159

CopilotKit/packages/react-core/src/utils/fetch-chat-completion.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export async function fetchChatCompletion({
5959
...(Object.keys(copilotConfig["body"] ?? {}).length > 0
6060
? {
6161
[EXCLUDE_FROM_FORWARD_PROPS_KEYS]: Object.keys(copilotConfig["backendOnlyProps"] ?? {}),
62+
// was: [EXCLUDE_FROM_FORWARD_PROPS_KEYS]: Object.keys(copilotConfig["body"] ?? {}),
6263
}
6364
: {}),
6465
...(body ? { ...body } : {}),

0 commit comments

Comments
 (0)