aiFeedbackOnReport
parent
f490aac87e
commit
58805dac6f
|
@ -1,3 +1,6 @@
|
|||
node_modules
|
||||
.git
|
||||
.gitignore
|
||||
**/docker-compose*
|
||||
**/compose.y*ml
|
||||
**/Dockerfile*
|
14
Dockerfile
14
Dockerfile
|
@ -1,8 +1,12 @@
|
|||
FROM node:alpine
|
||||
ARG NODE_VERSION=18
|
||||
|
||||
RUN mkdir -p /usr/src/node-app && chown -R node:node /usr/src/node-app
|
||||
FROM node:${NODE_VERSION}-alpine
|
||||
|
||||
WORKDIR /usr/src/node-app
|
||||
ENV NODE_ENV production
|
||||
|
||||
RUN mkdir -p /usr/src/iimtt_api && chown -R node:node /usr/src/iimtt_api
|
||||
|
||||
WORKDIR /usr/src/iimtt_api
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
|
||||
|
@ -12,4 +16,6 @@ RUN yarn install --pure-lockfile
|
|||
|
||||
COPY --chown=node:node . .
|
||||
|
||||
EXPOSE 3000
|
||||
EXPOSE 5174
|
||||
|
||||
CMD yarn start
|
|
@ -1,32 +1,31 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
node-app:
|
||||
iimtt_api:
|
||||
build: .
|
||||
image: node-app
|
||||
environment:
|
||||
- MONGODB_URL=mongodb://mongodb:27017/node-boilerplate
|
||||
image: iimtt_api
|
||||
# environment:
|
||||
# - MONGODB_URL=mongodb://mongodb:27017/node-boilerplate
|
||||
ports:
|
||||
- '3000:3000'
|
||||
depends_on:
|
||||
- mongodb
|
||||
- '5174:5174'
|
||||
# depends_on:
|
||||
# - mongodb
|
||||
volumes:
|
||||
- .:/usr/src/node-app
|
||||
networks:
|
||||
- node-network
|
||||
- .:/usr/src/iimtt_api
|
||||
# networks:
|
||||
# - host
|
||||
# - node-network
|
||||
|
||||
mongodb:
|
||||
image: mongo:4.2.1-bionic
|
||||
ports:
|
||||
- '27017:27017'
|
||||
volumes:
|
||||
- dbdata:/data/db
|
||||
networks:
|
||||
- node-network
|
||||
# mongodb:
|
||||
# image: mongo:4.2.1-bionic
|
||||
# ports:
|
||||
# - '27017:27017'
|
||||
# volumes:
|
||||
# - dbdata:/data/db
|
||||
# networks:
|
||||
# - node-network
|
||||
|
||||
volumes:
|
||||
dbdata:
|
||||
# volumes:
|
||||
# dbdata:
|
||||
|
||||
networks:
|
||||
node-network:
|
||||
driver: bridge
|
||||
# networks:
|
||||
# node-network:
|
||||
# driver: bridge
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"node": ">=12.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "pm2 start ecosystem.config.json --no-daemon",
|
||||
"start": "NODE_ENV=production node src/index.js",
|
||||
"start:pm2": "pm2 start ecosystem.config.json --no-daemon",
|
||||
"dev": "cross-env NODE_ENV=development nodemon src/index.js",
|
||||
"test": "jest -i --colors --verbose --detectOpenHandles",
|
||||
"test:watch": "jest -i --watchAll",
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
const aiFeedbackOnReport = async (req, res) => {
|
||||
const url = process.env.AI_API_ENDOINT;
|
||||
const api_key = process.env.AI_API_KEY;
|
||||
const payload = {
|
||||
"model": "gpt-4o-mini",
|
||||
"messages": [{ "role": "user",
|
||||
"content": JSON.stringify(req.body.grades) + " - first dataset(grades) " + JSON.stringify(req.body.suggested) + " - second dataset(suggested actions) " + req.body.instruction }]
|
||||
}
|
||||
try {
|
||||
const apiResponse = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${api_key}`,
|
||||
// 'Authorization': api_key,
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
if (!apiResponse.ok) {
|
||||
return res.status(apiResponse.status).send({ error: 'API response was not ok'+res });
|
||||
}
|
||||
|
||||
const data = await apiResponse.json();
|
||||
|
||||
res.send(data);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching data:', error);
|
||||
res.status(500).send({ error: 'Something went wrong with the fetch operation' });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = aiFeedbackOnReport;
|
|
@ -4,7 +4,7 @@ const aiFeedbackOnReport = async (req, res) => {
|
|||
const payload = {
|
||||
"model": "gpt-4o-mini",
|
||||
"messages": [{ "role": "user",
|
||||
"content": JSON.stringify(req.body.score) + " - is a sample of a students report card " + req.body.instruction }]
|
||||
"content": JSON.stringify(req.body.score) + " - is the students report card. " + req.body.instruction }]
|
||||
}
|
||||
try {
|
||||
const apiResponse = await fetch(url, {
|
||||
|
|
|
@ -24,6 +24,7 @@ const resultAfterQuizSubmit = require("../api/resultAfterQuizSubmit");
|
|||
const generateQuestions = require("../api/generateQuestions");
|
||||
const saveGameScore = require("../api/saveGameScore");
|
||||
const aiFeedbackOnReport = require("../api/aiFeedbackOnReport");
|
||||
const aiFeedbackActionParent = require("../api/aiFeedbackActionParent");
|
||||
|
||||
|
||||
const router = express.Router();
|
||||
|
@ -149,6 +150,10 @@ router.get("/ping", (req, res) => {
|
|||
aiFeedbackOnReport(req, res);
|
||||
});
|
||||
|
||||
// AI top ten action items for a parent of this child.
|
||||
router.post("/aiFeedbackActionParent", (req, res) => {
|
||||
aiFeedbackActionParent(req, res);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
|
|
Loading…
Reference in New Issue