tmp #21
|
@ -5,7 +5,7 @@ const Game = require('../../models/gameModel'); // Ensure this path matches your
|
||||||
|
|
||||||
const aiEvaluateImageToStar = async (req, res) => {
|
const aiEvaluateImageToStar = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { userId, gameName, gameID, gameTime, gameStar, screenShot } = req.body;
|
const { childId, gameName, gameID, gameTime, gameStar, screenShot } = req.body;
|
||||||
if (!screenShot) {
|
if (!screenShot) {
|
||||||
return res.status(400).json({ error: 'Screenshot is required' });
|
return res.status(400).json({ error: 'Screenshot is required' });
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ const aiEvaluateImageToStar = async (req, res) => {
|
||||||
// .catch(error => {
|
// .catch(error => {
|
||||||
// console.error('Error:', error);
|
// console.error('Error:', error);
|
||||||
// });
|
// });
|
||||||
console.log(screenshotUrl.data.filePath)
|
// console.log(screenshotUrl.data.filePath)
|
||||||
const openAiPayload = {
|
const openAiPayload = {
|
||||||
model: 'gpt-4o-mini',
|
model: 'gpt-4o-mini',
|
||||||
messages: [
|
messages: [
|
||||||
|
@ -65,11 +65,11 @@ const aiEvaluateImageToStar = async (req, res) => {
|
||||||
console.log(openAiResponse)
|
console.log(openAiResponse)
|
||||||
const gameData = new Game({
|
const gameData = new Game({
|
||||||
gameName,
|
gameName,
|
||||||
userId,
|
childId,
|
||||||
gameID,
|
gameID,
|
||||||
gameTime,
|
gameTime,
|
||||||
score: parsedScore.score || 'N/A', // Adjust key to match OpenAI response
|
score: parsedScore.score || 'N/A', // Adjust key to match OpenAI response
|
||||||
gameStar,
|
gameStar: parsedScore.score || 'N/A',
|
||||||
screenshotUrl,
|
screenshotUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ const saveGalleryImage = async (req, res) => {
|
||||||
throw new Error('Image upload failed: ' + uploadResponse.statusText);
|
throw new Error('Image upload failed: ' + uploadResponse.statusText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Extract and store the uploaded image URL from the response
|
// Extract and store the uploaded image URL from the response
|
||||||
const screenshotUrl = uploadResponse.data.urls[0];
|
const screenshotUrl = uploadResponse.data.urls[0];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue