irongit

Building a new website everyday to kickstart any new project I am recruited for.

ai gets time right

huncholanehuncholaneauthored
parent 0be150bcommit 5062bc5ad1fb61fe688c85053259ec177055847dBrowse files

1 file changed, +14 -0

+14-0008_hygofitweb/app/api/generate/route.ts
@@ -125,6 +125,20 @@ export async function POST(request: Request) {
125125 messages: messages,
126126 });
127127 const content = openaiResponse.choices[0].message.content;
128+
129+ // Log the duration vs the sum of the exercise durations
130+ if (content) {
131+ try {
132+ const data = JSON.parse(content);
133+ const actualDuration = data.data.reduce((acc: number, group) => {
134+ return acc + group.durationMinutes;
135+ }, 0);
136+ console.log(
137+ `Actual duration: ${actualDuration}, Expected duration: ${duration}`
138+ );
139+ } catch {}
140+ }
141+
128142 return new Response(content, {
129143 headers: {
130144 "content-type": "application/json",