Skip to content

Commit

Permalink
Merge branch 'machine-learning'
Browse files Browse the repository at this point in the history
  • Loading branch information
mathcoll committed Nov 23, 2024
2 parents 246f9fc + 58e947b commit 8c993b4
Show file tree
Hide file tree
Showing 16 changed files with 1,079 additions and 133 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Types of changes
------------

## 2024
### Milestone 29 - 2024-11
**Added**
- [x] Added AI-Flex feature using OpenAI: enhance automation workflows by directly integrating OpenAI's powerful language model responses into Rule Engine flows.

### Milestone 28 - 2024-05
**Added**
- [x] Machine Learning single flow and multiple flows compilation, including training and prediction
Expand All @@ -40,7 +44,7 @@ Types of changes
- [x] Adding `dead_notification` POST (Admin role required) api endpoint to send a push notification when sensors are not sending datapoints anymore
- [x] Adding `admin` routes to customize config on realtime (with non persistent values): smtp and loglevels
- [x] Adding route to Explain a Trained Model with a graph (svg)

**Fixed**
- [x] Fix OTA bug: mismatch on version number
- [x] Fix `goExternal` push notification type
Expand Down
35 changes: 27 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ global.multer = require("multer");
global.nodeunits = require("node-units");
global.uuid = require("uuid");
global.nodemailer = require("nodemailer");
if (openAISettings.activated === true) {
global.OpenAI = require("openai");
if(process.env.NODE_ENV==="development") {
const { mockOpenAIResponse: mockRes, stopMocking: mockStop } = require("openai-api-mock");
global.mockOpenAIResponse = mockRes;
global.stopMocking = mockStop;
}
}
global.otpGen = require("otp-generator");
global.otpTool = require("otp-without-db");
global.outlier = require("outlier");
Expand Down Expand Up @@ -194,30 +202,39 @@ global.t6events.setMeasurement("events");
global.t6events.setRP(typeof influxSettings.retentionPolicies.events!=="undefined"?influxSettings.retentionPolicies.events:"autogen");
global.t6mailer.setBcc(bcc);
global.t6ConnectedObjects = [];

/* Logging */
var error = fs.createWriteStream(logErrorFile, { flags: "a" });
process.stdout.write = process.stderr.write = error.write.bind(error);
process.on("uncaughtException", function(err) {
t6console.error((err && err.stack) ? err.stack : err);
});

if( db_type.influxdb === true ) {
//var {InfluxDB} = require("@influxdata/influxdb-client"); // Should use "writeApi"
var {InfluxDB} = require("influx");
var dbStringInfluxDB = `${influxSettings.influxdb.protocol}://${influxSettings.influxdb.host}:${influxSettings.influxdb.port}/${influxSettings.database}`;
//dbInfluxDB = new InfluxDB(dbStringInfluxDB);
dbInfluxDB = new InfluxDB({ database: influxSettings.database, host: influxSettings.influxdb.host, port: influxSettings.influxdb.port, username: influxSettings.username, password: influxSettings.password});
try {
dbInfluxDB = new InfluxDB({ database: influxSettings.database, host: influxSettings.influxdb.host, port: influxSettings.influxdb.port, username: influxSettings.username, password: influxSettings.password});
} catch(error) {
t6console.error(`Modules InfluxDB error: ${error}`);
}
}
if( db_type.telegraf === true ) {
var dbStringTelegraf = `${influxSettings.telegraf.protocol}://${influxSettings.telegraf.host}:${influxSettings.telegraf.port}/${influxSettings.database}`;
dbTelegraf = new InfluxDB(dbStringTelegraf);
}
moduleLoadEndTime = new Date();
t6console.log(`Modules load time: ${moduleLoadEndTime-moduleLoadTime}ms`);

/* Logging */
var error = fs.createWriteStream(logErrorFile, { flags: "a" });
process.stdout.write = process.stderr.write = error.write.bind(error);
process.on("uncaughtException", function(err) {
t6console.error((err && err.stack) ? err.stack : err);
});



t6console.log("");
t6console.log("===========================================================");
t6console.log(`============================ ${appName} ===========================`);
t6console.log("===========================================================");
t6console.log(`Modules load time: ${moduleLoadEndTime-moduleLoadTime}ms`);
t6console.log(`Starting ${appName} v${VERSION}`);
t6console.log(`Node: v${process.versions.node}`);
t6console.log(`Build: v${t6BuildVersion}`);
Expand All @@ -240,6 +257,8 @@ if(dbInfluxDB) {
t6console.log("-requests:", `${influxSettings.retentionPolicies.requests}`);
t6console.log("-events:", `${influxSettings.retentionPolicies.events}`);
t6console.log("-data:", `${influxSettings.retentionPolicies.data}`);
}).catch((error) => {
t6console.error(`dbInfluxDB.getDatabaseNames error: ${error}`);
});
}
if(dbTelegraf) {
Expand Down
6 changes: 6 additions & 0 deletions data/settings-hostname.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,9 @@ tts = {
activateInDevelopment: false,
}
process.env.GOOGLE_APPLICATION_CREDENTIALS = tts.admin.serviceAccountFile;

/* openai */
openAISettings = {
activated: true,
apiKey: "",
};
Loading

0 comments on commit 8c993b4

Please sign in to comment.