aiFeedbackOnReport working

galleryApi
Kar 2024-09-20 14:59:58 +05:30
parent 1244f5f06b
commit a9a0cd5ca3
1 changed files with 1 additions and 6 deletions

View File

@ -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' });
}
}