feat: merge branche IA (beta) - Intégration assistant IA logisticien Gemini
This commit is contained in:
@@ -7,3 +7,4 @@ SMTP_PASS="aL8@Rx8xqFrNij$a"
|
||||
# URL de l'application
|
||||
APP_URL="https://app.em2events.fr"
|
||||
|
||||
GEMINI_API_KEY="AIzaSyBdBdjFLma2pLenmFBlqZHArS4GVF-mclo"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,8 +3,11 @@
|
||||
* Architecture backend sécurisée avec authentification et permissions
|
||||
*/
|
||||
|
||||
// Charger les variables d'environnement depuis .env
|
||||
require('dotenv').config();
|
||||
// Charger les variables d'environnement depuis .env.local (développement)
|
||||
// ou .env (production Firebase)
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.join(__dirname, '.env.local') });
|
||||
require('dotenv').config({ path: path.join(__dirname, '.env') });
|
||||
|
||||
const { onRequest, onCall } = require("firebase-functions/v2/https");
|
||||
const { onSchedule } = require("firebase-functions/v2/scheduler");
|
||||
@@ -17,6 +20,7 @@ const { Storage } = require('@google-cloud/storage');
|
||||
const auth = require('./utils/auth');
|
||||
const helpers = require('./utils/helpers');
|
||||
const { generateTTS } = require('./generateTTS');
|
||||
const { handleAiEquipmentProposal } = require('./aiEquipmentProposal');
|
||||
|
||||
// Initialisation sécurisée
|
||||
if (!admin.apps.length) {
|
||||
@@ -33,6 +37,13 @@ const httpOptions = {
|
||||
// Version: 2.0 - Ajout de l'invoker public pour résoudre les problèmes CORS
|
||||
};
|
||||
|
||||
// Options dédiées pour les traitements IA potentiellement longs.
|
||||
const aiHttpOptions = {
|
||||
...httpOptions,
|
||||
timeoutSeconds: 300,
|
||||
memory: '1GiB',
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// CORS Middleware
|
||||
// ============================================================================
|
||||
@@ -4544,3 +4555,20 @@ exports.generateTTSV2 = onRequest(ttsHttpOptions, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================================================
|
||||
// AI - Assistant Logisticien (Gemini avec function calling côté serveur)
|
||||
// ============================================================================
|
||||
|
||||
exports.aiEquipmentProposal = onRequest(aiHttpOptions, withCors(async (req, res) => {
|
||||
try {
|
||||
// Authentification Firebase obligatoire (pas de clé API côté client)
|
||||
await auth.authenticateUser(req);
|
||||
await handleAiEquipmentProposal(req, res);
|
||||
} catch (error) {
|
||||
logger.error('[aiEquipmentProposal] Error:', error);
|
||||
if (!res.headersSent) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
Generated
+19
-5
@@ -8,11 +8,12 @@
|
||||
"dependencies": {
|
||||
"@google-cloud/storage": "^7.18.0",
|
||||
"@google-cloud/text-to-speech": "^5.4.0",
|
||||
"@google/generative-ai": "^0.21.0",
|
||||
"axios": "^1.13.2",
|
||||
"dotenv": "^17.2.3",
|
||||
"envdot": "^0.0.3",
|
||||
"firebase-admin": "^12.6.0",
|
||||
"firebase-functions": "^7.0.3",
|
||||
"firebase-functions": "^7.2.5",
|
||||
"handlebars": "^4.7.8",
|
||||
"nodemailer": "^6.10.1"
|
||||
},
|
||||
@@ -785,6 +786,15 @@
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@google/generative-ai": {
|
||||
"version": "0.21.0",
|
||||
"resolved": "https://registry.npmjs.org/@google/generative-ai/-/generative-ai-0.21.0.tgz",
|
||||
"integrity": "sha512-7XhUbtnlkSEZK15kN3t+tzIMxsbKm/dSkKBFalj+20NvPKe1kBY7mR2P7vuijEn+f06z5+A8bVGKO0v39cr6Wg==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@grpc/grpc-js": {
|
||||
"version": "1.13.4",
|
||||
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.13.4.tgz",
|
||||
@@ -3354,9 +3364,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/firebase-functions": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-7.0.3.tgz",
|
||||
"integrity": "sha512-DiIjIUv0OS4KEAA3jqyIc7ymZKdcmMcaXy7FCCkrDQo/1CVMbDDWMdZIslmsgSjldA2nhau1dTE/6JQI8Urjjw==",
|
||||
"version": "7.2.5",
|
||||
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-7.2.5.tgz",
|
||||
"integrity": "sha512-K+pP0AknluAguLRbD96hibyXbnOgwnvd4hkExWdGrxnNCLoj8LBFj08uvJYxyvhsCgYzQumrUaHBW4lsXKSiRg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
@@ -3375,7 +3385,8 @@
|
||||
"peerDependencies": {
|
||||
"@apollo/server": "^5.2.0",
|
||||
"@as-integrations/express4": "^1.1.2",
|
||||
"firebase-admin": "^11.10.0 || ^12.0.0 || ^13.0.0"
|
||||
"firebase-admin": "^11.10.0 || ^12.0.0 || ^13.0.0",
|
||||
"graphql": "^16.12.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@apollo/server": {
|
||||
@@ -3383,6 +3394,9 @@
|
||||
},
|
||||
"@as-integrations/express4": {
|
||||
"optional": true
|
||||
},
|
||||
"graphql": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
"dependencies": {
|
||||
"@google-cloud/storage": "^7.18.0",
|
||||
"@google-cloud/text-to-speech": "^5.4.0",
|
||||
"@google/generative-ai": "^0.21.0",
|
||||
"axios": "^1.13.2",
|
||||
"dotenv": "^17.2.3",
|
||||
"envdot": "^0.0.3",
|
||||
"firebase-admin": "^12.6.0",
|
||||
"firebase-functions": "^7.0.3",
|
||||
"firebase-functions": "^7.2.5",
|
||||
"handlebars": "^4.7.8",
|
||||
"nodemailer": "^6.10.1"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user