Building a new website everyday to kickstart any new project I am recruited for.
ai gets time right
1 file changed, +14 -0
+14-0008_hygofitweb/app/api/generate/route.ts
| @@ -125,6 +125,20 @@ export async function POST(request: Request) { | ||
| 125 | 125 | messages: messages, |
| 126 | 126 | }); |
| 127 | 127 | 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 | + | |
| 128 | 142 | return new Response(content, { |
| 129 | 143 | headers: { |
| 130 | 144 | "content-type": "application/json", |