Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #39

Merged
merged 11 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
node-version: 22
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix questionservice ci
- run: npm --prefix llmservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ services:
networks:
- mynetwork

questionservice:
container_name: questionservice-wichat_es1b
image: ghcr.io/arquisoft/wichat_es1b/questionservice:latest
profiles: ["dev", "prod"]
build: ./questionservice
depends_on:
- mongodb
ports:
- "8004:8004"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

gatewayservice:
container_name: gatewayservice-wichat_es1b
image: ghcr.io/arquisoft/wichat_es1b/gatewayservice:latest
Expand All @@ -58,6 +72,7 @@ services:
- userservice
- authservice
- llmservice
- questionservice
ports:
- "8000:8000"
networks:
Expand All @@ -66,6 +81,7 @@ services:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
LLM_SERVICE_URL: http://llmservice:8003
QUESTION_SERVICE_URL: http://questionservice:8004

webapp:
container_name: webapp-wichat_es1b
Expand Down
Binary file added docs/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
// configure EN settings for asciidoc
include::src/config.adoc[]

= image:arc42-logo.png[arc42] wichat_es1b
= image:logo.png[logo] image:arc42-logo.png[arc42] Wichat en español - Equipo 1-B
:revnumber: 8.2 EN
:revdate: January 2023
:revdate: February 2025
:revremark: (based upon AsciiDoc version)
// toc-title definition MUST follow document title without blank line!
:toc-title: Table of Contents
:toc-title: Tabla de contenidos

//additional style for arc42 help callouts
ifdef::backend-html5[]
Expand Down
39 changes: 39 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ const YAML = require('yaml')
const app = express();
const port = 8000;

//const originEndpoint = REACT_APP_API_ORIGIN_ENDPOINT || 'http://localhost:3000';
const llmServiceUrl = process.env.LLM_SERVICE_URL || 'http://localhost:8003';
const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';
const questionsServiceUrl = process.env.QUESTION_SERVICE_URL || 'http://localhost:8004';

// const corsOptions = {
// origin: `${originEndpoint}`,
// methods: ['GET', 'POST'],
// allowedHeaders: ['Content-Type', 'Authorization']
// };

app.use(cors());
app.use(express.json());
Expand Down Expand Up @@ -56,6 +64,37 @@ app.post('/askllm', async (req, res) => {
}
});


app.get('/generateQuestion', async (req, res) => {
try {
//Mandar al endpoint del servicio de preguntas para que gestione la petición, con los parámetros añadidos
//const URL = questionsServiceUrl + 'generateQuestion?user=' + req.query.user + '&category=' + req.query.category; //codigo completo
const URL = questionsServiceUrl + '/generateQuestion'; // + '?category=' + req.query.category; //codigo de prueba
//console.log("Category" + req.query.category);
const response = await axios.get(URL);
console.log("URL: "+ URL);
res.json(response.data);
console.log("Pregunta generada: "+ response.data.responseQuestion);
}
catch(error) {
res.status(error.response.status).json({error: error.response.data.error});
}
});


app.post('/configureGame', async (req, res) => {
try {
const response = await axios.post(questionsServiceUrl + '/configureGame', req.body);
res.json(response.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
});





// Read the OpenAPI YAML file synchronously
openapiPath='./openapi.yaml'
if (fs.existsSync(openapiPath)) {
Expand Down
50 changes: 50 additions & 0 deletions gatewayservice/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,56 @@ paths:
type: string
description: Shows the error info..
example: Invalid credentials
'500':
description: Internal server error.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error information.
example: Internal Server Error
/generateQuestion:
get:
summary: Generate a question.
operationId: generateQuestion
responses:
'200':
description: Generation successful. Returns the question, the options, the correct option, the image (if neccessary) and the question id
content:
application/json:
schema:
type: object
properties:
responseQuestion:
type: string
description: Question.
example: ¿Cual es la capital de España?
responseOptions:
type: array
description: Options of the question.
example: [Barcelona, Madrid, Oviedo, Valladolid]
responseCorrectOption:
type: string
description: Correct option.
example: Madrid
responseImage:
type: URL
description: URL of the image of the question if neccessary.
example: https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Joe_Biden_presidential_portrait.jpg/220px-Joe_Biden_presidential_portrait.jpg
'400':
description: Error during the question generator.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Shows the error info.
example: currentNumberOfQuestions is not defined
'500':
description: Internal server error.
content:
Expand Down
4 changes: 2 additions & 2 deletions llmservice/llm-service.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const request = require('supertest');
const axios = require('axios');
const app = require('./llm-service');
require('dotenv').config();
//require('dotenv').config();

afterAll(async () => {
app.close();
Expand All @@ -27,7 +27,7 @@ describe('LLM Service', () => {
it('the llm should reply', async () => {
const response = await request(app)
.post('/ask')
.send({ question: 'a question', apiKey: process.env['api-key-password']});
.send({ question: 'a question', apiKey: 'apiKey'});

expect(response.statusCode).toBe(200);
expect(response.body.answer).toBe('llmanswer');
Expand Down
Loading
Loading