Skip to content

Commit

Permalink
fix: Better logging and update assistant id cookie name
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Oct 16, 2024
1 parent f044567 commit 3ac7997
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/app/api/[..._path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ async function handleRequest(req: NextRequest, method: string) {
options
);

if (res.status >= 400) {
console.error("ERROR IN PROXY", res.status, res.statusText);
return new Response(res.body, {
status: res.status,
statusText: res.statusText,
});
}

const headers = new Headers({
...getCorsHeaders(),
});
Expand All @@ -54,6 +62,9 @@ async function handleRequest(req: NextRequest, method: string) {
headers,
});
} catch (e: any) {
console.error("Error in proxy");
console.error(e);
console.error("\n\n\nEND ERROR\n\n");
return NextResponse.json({ error: e.message }, { status: e.status ?? 500 });
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function useGraph() {
};

const getOrCreateThread = async () => {
const assistantIdCookie = getCookie("oc_assistant_id");
const assistantIdCookie = getCookie("oc_assistant_id_v2");
if (assistantIdCookie) {
setAssistantId(assistantIdCookie);
return;
Expand All @@ -97,7 +97,7 @@ export function useGraph() {
graphId: "agent",
});
setAssistantId(assistant.assistant_id);
setCookie("oc_assistant_id", assistant.assistant_id);
setCookie("oc_assistant_id_v2", assistant.assistant_id);
};

const streamMessage = async (params: GraphInput) => {
Expand Down

0 comments on commit 3ac7997

Please sign in to comment.