Skip to content

Commit

Permalink
Merge branch 'master-COLLAUDO' into features-dic24/auto-reindex-coll4
Browse files Browse the repository at this point in the history
# Conflicts:
#	package-lock.json
#	package.json
#	services/requestService.js
  • Loading branch information
Giovanni Troisi committed Dec 20, 2024
2 parents d2f5ba4 + 3588b1a commit e8b48b7
Show file tree
Hide file tree
Showing 11 changed files with 575 additions and 476 deletions.
4 changes: 4 additions & 0 deletions models/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const TransactionSchema = mongoose.Schema({
type: String,
required: false
},
broadcast: {
type: Boolean,
required: false
},
createdAt: {
type: Date,
default: Date.now
Expand Down
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
"@tiledesk/tiledesk-rasa-connector": "^1.0.10",
"@tiledesk/tiledesk-telegram-connector": "^0.1.14",
"@tiledesk/tiledesk-train-jobworker": "^0.0.11",
"@tiledesk/tiledesk-tybot-connector": "^0.2.134",
"@tiledesk/tiledesk-tybot-connector": "0.2.138",
"@tiledesk/tiledesk-whatsapp-connector": "^0.1.75",
"@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.10",
"@tiledesk/tiledesk-sms-connector": "^0.1.11",
"@tiledesk/tiledesk-vxml-connector": "^0.1.67",
"@tiledesk/tiledesk-vxml-connector": "^0.1.69",
"@tiledesk/tiledesk-voice-twilio-connector": "^0.1.12",
"@tiledesk/tiledesk-multi-worker": "^0.1.5",
"@tiledesk/tiledesk-multi-worker": "^0.1.6",
"amqplib": "^0.5.5",
"app-root-path": "^3.0.0",
"bcrypt-nodejs": "0.0.3",
Expand Down
1 change: 1 addition & 0 deletions pubmodules/voice/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Listener {
voice.startApp({
MONGODB_URI: config.databaseUri,
dbconnection: dbConnection,
//API_URL: apiUrl,
BASE_URL: apiUrl + "/modules/voice",
REDIS_HOST: host,
REDIS_PORT: port,
Expand Down
2 changes: 0 additions & 2 deletions routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ router.post('/signup',
if (!skipVerificationEmail) {

let verify_email_code = uniqid();
console.log("(Auth) verify_email_code: ", verify_email_code);

let redis_client = req.app.get('redis_client');
let key = "emailverify:verify-" + verify_email_code;
let obj = { _id: savedUser._id, email: savedUser.email}
Expand Down
1 change: 0 additions & 1 deletion routes/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ curl -u [email protected]:123456 \
*/

router.post('/users', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken], upload.single('file'), (req, res, next) => {

winston.verbose("files/users")
return res.status(201).json({
message: 'File uploded successfully',
Expand Down
47 changes: 37 additions & 10 deletions services/QuoteManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ const emailEvent = require('../event/emailEvent');


const PLANS_LIST = {
FREE_TRIAL: { requests: 200, messages: 0, tokens: 100000, email: 200, chatbots: 20, namespace: 3, kbs: 50 }, // same as PREMIUM
SANDBOX: { requests: 200, messages: 0, tokens: 100000, email: 200, chatbots: 2, namespace: 1, kbs: 50 },
BASIC: { requests: 800, messages: 0, tokens: 2000000, email: 200, chatbots: 5, namespace: 1, kbs: 150 },
PREMIUM: { requests: 3000, messages: 0, tokens: 5000000, email: 200, chatbots: 20, namespace: 3, kbs: 300 },
TEAM: { requests: 5000, messages: 0, tokens: 10000000, email: 200, chatbots: 50, namespace: 10, kbs: 1000 },
CUSTOM: { requests: 5000, messages: 0, tokens: 10000000, email: 200, chatbots: 50, namespace: 10, kbs: 1000 },
FREE_TRIAL: { requests: 200, messages: 0, tokens: 100000, voice_duration: 0, email: 200, chatbots: 20, namespace: 3, kbs: 50 }, // same as PREMIUM
SANDBOX: { requests: 200, messages: 0, tokens: 100000, voice_duration: 0, email: 200, chatbots: 2, namespace: 1, kbs: 50 },
BASIC: { requests: 800, messages: 0, tokens: 2000000, voice_duration: 0, email: 200, chatbots: 5, namespace: 1, kbs: 150 },
PREMIUM: { requests: 3000, messages: 0, tokens: 5000000, voice_duration: 0, email: 200, chatbots: 20, namespace: 3, kbs: 300 },
TEAM: { requests: 5000, messages: 0, tokens: 10000000, voice_duration: 0, email: 200, chatbots: 50, namespace: 10, kbs: 1000 },
CUSTOM: { requests: 5000, messages: 0, tokens: 10000000, voice_duration: 120000, email: 200, chatbots: 50, namespace: 10, kbs: 1000 },
}

const typesList = ['requests', 'messages', 'email', 'tokens', 'chatbots', 'kbs']
const typesList = ['requests', 'messages', 'email', 'tokens', 'voice_duration', 'chatbots', 'kbs']

let quotes_enabled = true;

Expand Down Expand Up @@ -95,6 +95,25 @@ class QuoteManager {
this.sendEmailIfQuotaExceeded(project, data, 'tokens', key);
return key;
}

async incrementVoiceDurationCount(project, request) {

this.project = project;
let key = await this.generateKey(request, 'voice_duration');
winston.verbose("[QuoteManager] incrementVoiceDurationCount key: " + key);

if (quotes_enabled === false) {
winston.debug("QUOTES DISABLED - incrementVoiceDurationCount")
return key;
}

if (request?.duration) {
let duration = Math.round(request.duration / 1000); // from ms to s
await this.tdCache.incrby(key, duration);

this.sendEmailIfQuotaExceeded(project, request, 'voice_duration', key);
}
}
// INCREMENT KEY SECTION - END


Expand Down Expand Up @@ -228,7 +247,7 @@ class QuoteManager {
winston.verbose("limits for current plan: ", limits)

let quote = await this.getCurrentQuote(project, object, type);
winston.verbose("getCurrentQuote resp: ", quote)
winston.verbose("getCurrentQuote resp: " + quote)

if (quote == null) {
return true;
Expand Down Expand Up @@ -494,13 +513,21 @@ class QuoteManager {
if (quotes_enabled === true) {
winston.verbose("request.create.quote event catched");
let result = await this.incrementRequestsCount(payload.project, payload.request);


return result;
} else {
winston.verbose("QUOTES DISABLED - request.create.quote event")
}
})

requestEvent.on('request.close.quote', async (payload) => {
if (quotes_enabled === true) {
winston.verbose("request.close.quote event catched");
let result = await this.incrementVoiceDurationCount(payload.project, payload.request);
return result;
} else {
winston.verbose("QUOTES DISABLED - request.close.quote event")
}
})
// REQUESTS EVENTS - END


Expand Down
5 changes: 3 additions & 2 deletions services/aiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ class AiService {
}

getContentChunks(namespace_id, content_id, engine) {
winston.info("[OPENAI SERVICE] kb endpoint: " + kb_endpoint_train);
winston.info(kb_endpoint_train + "/id/" + content_id + "/namespace/" + namespace_id)
winston.debug("[OPENAI SERVICE] kb endpoint: " + kb_endpoint_train);
winston.verbose(kb_endpoint_train + "/id/" + content_id + "/namespace/" + namespace_id)
return new Promise((resolve, reject) => {

let payload = { engine: engine };
let token = jwt.sign(payload, secret);
console.log("token: ", token)
axios({
url: kb_endpoint_train + "/id/" + content_id + "/namespace/" + namespace_id + "/" + token,
headers: {
Expand Down
Loading

0 comments on commit e8b48b7

Please sign in to comment.