From a9a0cd5ca3feab2d43e623a83bbc33b204e4e0ed Mon Sep 17 00:00:00 2001 From: Kar Date: Fri, 20 Sep 2024 14:59:58 +0530 Subject: [PATCH] aiFeedbackOnReport working --- src/routes/api/aiFeedbackOnReport.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/routes/api/aiFeedbackOnReport.js b/src/routes/api/aiFeedbackOnReport.js index b420316..d420004 100644 --- a/src/routes/api/aiFeedbackOnReport.js +++ b/src/routes/api/aiFeedbackOnReport.js @@ -5,11 +5,10 @@ const aiFeedbackOnReport = async (req, res) => { const payload = { "model": "gpt-4o-mini", "messages": [{ "role": "user", - "content": JSON.stringify(data.score) + "\n above is a sample of a students report card\n" + data.instruction }] + "content": JSON.stringify(req.score) + "\n above is a sample of a students report card\n" + req.instruction }] } try { - // Make the API call using fetch const apiResponse = await fetch(url, { method: 'POST', headers: { @@ -20,20 +19,16 @@ const aiFeedbackOnReport = async (req, res) => { body: JSON.stringify(payload) }); - // Check if the response is OK if (!apiResponse.ok) { return res.status(apiResponse.status).send({ error: 'API response was not ok' }); } - // Parse the response as JSON const data = await apiResponse.json(); - // Send the API response back to the client res.send(data); } catch (error) { console.error('Error fetching data:', error); - // Send an error response if something goes wrong res.status(500).send({ error: 'Something went wrong with the fetch operation' }); } }