Skip to content

Commit

Permalink
fallback to snippet for 0 data size
Browse files Browse the repository at this point in the history
  • Loading branch information
RankJay committed Apr 24, 2024
1 parent 0e0b64e commit eb3e914
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/api/email/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export async function GET(request: NextApiRequest) {
}
);
const messageDetails = await detailResponse.json();
const snippet = atob(messageDetails.payload.body.data);
const snippet =
Number(messageDetails.payload.body.size ?? 0) > 0
? atob(messageDetails.payload.body.data)
: messageDetails.snippet;

// Send the snippet to OpenAI for summarization
const openaiResponse = await fetch(OPENAI_CHAT_API_URL, {
Expand Down

0 comments on commit eb3e914

Please sign in to comment.