data-primals-engine 1.2.6-rc3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/client/package-lock.json +247 -4354
- package/client/package.json +16 -15
- package/client/src/App.jsx +13 -20
- package/client/src/App.scss +1 -0
- package/client/src/AssistantChat.jsx +5 -4
- package/client/src/DataEditor.jsx +2 -2
- package/client/src/DataTable.jsx +47 -3
- package/client/src/ExportDialog.jsx +2 -2
- package/client/src/Field.jsx +6 -18
- package/client/src/KanbanCard.jsx +4 -2
- package/client/src/KanbanConfigModal.jsx +5 -7
- package/client/src/ModelCreatorField.jsx +9 -9
- package/client/src/PackGallery.jsx +89 -9
- package/client/src/PackGallery.scss +58 -4
- package/client/src/RTETrans.jsx +11 -0
- package/client/src/RelationValue.jsx +3 -4
- package/client/src/constants.js +1 -1
- package/client/src/core/data.js +2 -1
- package/client/src/translations.js +80 -0
- package/package.json +8 -1
- package/server.js +4 -4
- package/src/constants.js +6 -0
- package/src/defaultModels.js +23 -10
- package/src/filter.js +35 -5
- package/src/i18n.js +1 -1
- package/src/modules/{assistant.js → assistant/assistant.js} +42 -27
- package/src/modules/assistant/constants.js +16 -0
- package/src/modules/data/data.core.js +1 -3
- package/src/modules/data/data.js +4601 -4525
- package/src/modules/data/data.routes.js +29 -3
- package/src/modules/mongodb.js +3 -1
- package/src/modules/user.js +12 -1
- package/src/modules/workflow.js +198 -117
- package/src/packs.js +1015 -9
- package/src/services/index.js +11 -0
- package/src/services/stripe.js +141 -0
- package/test/data.integration.test.js +66 -3
- package/test/workflow.actions.integration.test.js +474 -0
- package/test/workflow.integration.test.js +1 -1
|
@@ -1,17 +1,45 @@
|
|
|
1
|
-
import { getCollectionForUser, modelsCollection } from "
|
|
2
|
-
import { Logger } from "
|
|
1
|
+
import { getCollectionForUser, modelsCollection } from "../mongodb.js";
|
|
2
|
+
import { Logger } from "../../gameObject.js";
|
|
3
3
|
import { ChatOpenAI } from "@langchain/openai";
|
|
4
4
|
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
|
|
5
5
|
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
|
|
6
|
-
import {searchData, patchData, deleteData, insertData} from "
|
|
7
|
-
import { getDataAsString } from "
|
|
8
|
-
import i18n from "../../
|
|
9
|
-
import {generateLimiter} from "
|
|
6
|
+
import {searchData, patchData, deleteData, insertData} from "../data/index.js";
|
|
7
|
+
import { getDataAsString } from "../../data.js";
|
|
8
|
+
import i18n from "../../i18n.js";
|
|
9
|
+
import {generateLimiter} from "../user.js";
|
|
10
10
|
import rateLimit from "express-rate-limit";
|
|
11
|
-
import {maxAIReflectiveSteps} from "
|
|
11
|
+
import {maxAIReflectiveSteps} from "../../constants.js";
|
|
12
|
+
import {providers} from "./constants.js";
|
|
13
|
+
import {ChatDeepSeek} from "@langchain/deepseek";
|
|
14
|
+
import {ChatAnthropic} from "@langchain/anthropic";
|
|
12
15
|
|
|
13
16
|
let logger = null;
|
|
14
17
|
|
|
18
|
+
export const getAIProvider= (aiProvider, aiModel, apiKey)=>{
|
|
19
|
+
let llm;
|
|
20
|
+
try {
|
|
21
|
+
switch (aiProvider) {
|
|
22
|
+
case 'OpenAI':
|
|
23
|
+
llm = new ChatOpenAI({apiKey, model: aiModel, temperature: 0.7});
|
|
24
|
+
break;
|
|
25
|
+
case 'Google':
|
|
26
|
+
llm = new ChatGoogleGenerativeAI({apiKey, model: aiModel, temperature: 0.7});
|
|
27
|
+
break;
|
|
28
|
+
case 'DeepSeek':
|
|
29
|
+
llm = new ChatDeepSeek({apiKey, model: aiModel, temperature: 0.7});
|
|
30
|
+
break;
|
|
31
|
+
case 'Anthropic':
|
|
32
|
+
llm = new ChatAnthropic({apiKey, model: aiModel, temperature: 0.7});
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
throw new Error(`Unsupported AI provider: ${aiProvider}`);
|
|
36
|
+
}
|
|
37
|
+
return llm;
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
15
43
|
export const assistantGlobalLimiter = rateLimit({
|
|
16
44
|
windowMs: 15 * 60 * 1000, // Fenêtre de 15 minutes
|
|
17
45
|
max: 100, // Limite à 100 requêtes globales pour l'assistant pendant la fenêtre (vous pouvez ajuster cette valeur)
|
|
@@ -207,7 +235,7 @@ async function executeTool(action, params, user, allModels) {
|
|
|
207
235
|
* soit en lançant la boucle de raisonnement de l'IA.
|
|
208
236
|
* @param {string} message - Le message de l'utilisateur.
|
|
209
237
|
* @param {Array} history - L'historique de la conversation.
|
|
210
|
-
* @param {string} provider - Le fournisseur d'IA ('
|
|
238
|
+
* @param {string} provider - Le fournisseur d'IA ('OpenAI' ou 'google').
|
|
211
239
|
* @param {object} context - Contexte additionnel.
|
|
212
240
|
* @param {object} user - L'objet utilisateur.
|
|
213
241
|
* @param {object} confirmedAction - Une action pré-approuvée par l'utilisateur.
|
|
@@ -239,30 +267,17 @@ async function handleChatRequest(message, history, provider, context, user, conf
|
|
|
239
267
|
// --- INITIALISATION DE L'IA ---
|
|
240
268
|
let llm;
|
|
241
269
|
try {
|
|
242
|
-
const p = provider || '
|
|
243
|
-
const
|
|
244
|
-
const envKeyName = providers[p];
|
|
270
|
+
const p = provider || 'OpenAI';
|
|
271
|
+
const envKeyName = providers[p].key;
|
|
245
272
|
if (!envKeyName) return {success: false, message: `Fournisseur IA non supporté : ${p}`};
|
|
246
273
|
|
|
247
274
|
const envCollection = await getCollectionForUser(user);
|
|
248
275
|
const userEnvVar = await envCollection.findOne({_model: 'env', name: envKeyName, _user: user.username});
|
|
249
276
|
const apiKey = userEnvVar?.value || process.env[envKeyName];
|
|
250
277
|
|
|
251
|
-
if (!apiKey) return {success: false, message: `Clé API pour ${
|
|
252
|
-
|
|
253
|
-
llm = p
|
|
254
|
-
? new ChatOpenAI({
|
|
255
|
-
apiKey,
|
|
256
|
-
modelName: "gpt-4o-mini",
|
|
257
|
-
temperature: 0.2,
|
|
258
|
-
response_format: {"type": "json_object"}
|
|
259
|
-
})
|
|
260
|
-
: new ChatGoogleGenerativeAI({
|
|
261
|
-
apiKey,
|
|
262
|
-
modelName: "gemini-1.5-pro-latest",
|
|
263
|
-
temperature: 0.2,
|
|
264
|
-
response_format: {"type": "json_object"}
|
|
265
|
-
});
|
|
278
|
+
if (!apiKey) return {success: false, message: `Clé API pour ${p} (${envKeyName}) non trouvée.`};
|
|
279
|
+
|
|
280
|
+
llm = getAIProvider(p, providers[p]?.defaultModel, apiKey);
|
|
266
281
|
} catch (initError) {
|
|
267
282
|
logger.error(`[Assistant] Erreur d'initialisation du client IA: ${initError.message}`);
|
|
268
283
|
return {success: false, message: `Erreur d'initialisation du client IA: ${initError.message}`};
|
|
@@ -371,7 +386,7 @@ async function executeConfirmedAction(action, params, user) {
|
|
|
371
386
|
export async function onInit(engine) {
|
|
372
387
|
logger = engine.getComponent(Logger);
|
|
373
388
|
|
|
374
|
-
const {middlewareAuthenticator, userInitiator} = await import('
|
|
389
|
+
const {middlewareAuthenticator, userInitiator} = await import('../user.js');
|
|
375
390
|
|
|
376
391
|
engine.post('/api/assistant/chat', [middlewareAuthenticator, userInitiator, assistantGlobalLimiter, generateLimiter], async (req, res) => {
|
|
377
392
|
// On récupère TOUTES les propriétés du body, y compris l'action confirmée
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
export const providers = {
|
|
3
|
+
"OpenAI" : {
|
|
4
|
+
key:"OPENAI_API_KEY",
|
|
5
|
+
defaultModel: 'gpt-3.5-turbo'
|
|
6
|
+
},
|
|
7
|
+
"Google": {
|
|
8
|
+
key:"GOOGLE_API_KEY"
|
|
9
|
+
},
|
|
10
|
+
"DeepSeek": {
|
|
11
|
+
key: "DEEPSEEK_API_KEY"
|
|
12
|
+
},
|
|
13
|
+
"Anthropic": {
|
|
14
|
+
key:"ANTHROPIC_API_KEY"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import NodeCache from "node-cache";
|
|
2
|
-
import i18n from "../../i18n.js";
|
|
3
|
-
import {allowedFields, maxStringLength} from "../../constants.js";
|
|
4
2
|
import path from "node:path";
|
|
5
|
-
|
|
3
|
+
import {Worker} from 'worker_threads';
|
|
6
4
|
export const modelsCache = new NodeCache( { stdTTL: 100, checkperiod: 120 } );
|
|
7
5
|
|
|
8
6
|
export const mongoDBWhitelist = [
|