@xuda.io/ai_module 1.1.4998 → 1.1.5000
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/index.mjs +77 -74
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -70,6 +70,7 @@ const email_ms = await import(`${module_path}/email_module/index_ms.mjs`);
|
|
|
70
70
|
|
|
71
71
|
const ws_dashboard_msa = await import(`${module_path}/ws_dashboard_module/index_msa.mjs`);
|
|
72
72
|
const account_msa = await import(`${module_path}/account_module/index_msa.mjs`);
|
|
73
|
+
const drive_msa = await import(`${module_path}/drive_module/index_msa.mjs`);
|
|
73
74
|
|
|
74
75
|
var open_ai_status = {};
|
|
75
76
|
const report_ai_status = function (model, err) {
|
|
@@ -1167,79 +1168,6 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1167
1168
|
return data;
|
|
1168
1169
|
}
|
|
1169
1170
|
|
|
1170
|
-
let opt = {
|
|
1171
|
-
selector: {
|
|
1172
|
-
docType: 'chat_conversation',
|
|
1173
|
-
stat: 3,
|
|
1174
|
-
reference_id: '',
|
|
1175
|
-
},
|
|
1176
|
-
limit: limit || 9999,
|
|
1177
|
-
skip: skip || 0,
|
|
1178
|
-
// sort: [{ ts: reference_id ? 'asc' : 'desc' }],
|
|
1179
|
-
};
|
|
1180
|
-
|
|
1181
|
-
if (reference_id) {
|
|
1182
|
-
opt.sort = [{ date_created_ts: 'asc' }];
|
|
1183
|
-
} else {
|
|
1184
|
-
opt.sort = [{ ts: 'desc' }];
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
if (!account_profile_info.is_main) {
|
|
1188
|
-
opt.selector.account_profiles = { $in: [account_profile_info.account_profile_id] };
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
switch (filter_type) {
|
|
1192
|
-
case 'archived': {
|
|
1193
|
-
opt.selector.stat = 5;
|
|
1194
|
-
break;
|
|
1195
|
-
}
|
|
1196
|
-
case 'shared': {
|
|
1197
|
-
opt.selector.shared_from_uid = { $gt: null };
|
|
1198
|
-
// opt.selector.team_req_stat = { $eq: 3 };
|
|
1199
|
-
break;
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
case 'mine': {
|
|
1203
|
-
opt.selector.uid = uid;
|
|
1204
|
-
|
|
1205
|
-
break;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
default:
|
|
1209
|
-
// opt.selector.team_req_stat = { $eq: 3 };
|
|
1210
|
-
break;
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
if (conversation_type) {
|
|
1214
|
-
opt.selector.conversation_type = conversation_type;
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
if (reference_id) {
|
|
1218
|
-
opt.selector.reference_id = reference_id;
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
if (conversation_id) {
|
|
1222
|
-
opt.selector._id = conversation_id;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
if (search) {
|
|
1226
|
-
opt.selector = {
|
|
1227
|
-
...opt.selector,
|
|
1228
|
-
$or: [
|
|
1229
|
-
{
|
|
1230
|
-
title: {
|
|
1231
|
-
$regex: `(?i)${search}`,
|
|
1232
|
-
},
|
|
1233
|
-
},
|
|
1234
|
-
{
|
|
1235
|
-
_id: {
|
|
1236
|
-
$regex: `(?i)${search}`,
|
|
1237
|
-
},
|
|
1238
|
-
},
|
|
1239
|
-
],
|
|
1240
|
-
};
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
1171
|
const chat_conversation_count = async function (contact_id, conversation_id) {
|
|
1244
1172
|
const counts_ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_counts', {
|
|
1245
1173
|
reduce: true,
|
|
@@ -1266,6 +1194,81 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1266
1194
|
return counts_ret?.rows?.[0]?.value || 0;
|
|
1267
1195
|
};
|
|
1268
1196
|
|
|
1197
|
+
const get_data_find = async function () {
|
|
1198
|
+
let opt = {
|
|
1199
|
+
selector: {
|
|
1200
|
+
docType: 'chat_conversation',
|
|
1201
|
+
stat: 3,
|
|
1202
|
+
reference_id: '',
|
|
1203
|
+
},
|
|
1204
|
+
limit: limit || 9999,
|
|
1205
|
+
skip: skip || 0,
|
|
1206
|
+
// sort: [{ ts: reference_id ? 'asc' : 'desc' }],
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
if (reference_id) {
|
|
1210
|
+
opt.sort = [{ date_created_ts: 'asc' }];
|
|
1211
|
+
} else {
|
|
1212
|
+
opt.sort = [{ ts: 'desc' }];
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
if (!account_profile_info.is_main) {
|
|
1216
|
+
opt.selector.account_profiles = { $in: [account_profile_info.account_profile_id] };
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
switch (filter_type) {
|
|
1220
|
+
case 'archived': {
|
|
1221
|
+
opt.selector.stat = 5;
|
|
1222
|
+
break;
|
|
1223
|
+
}
|
|
1224
|
+
case 'shared': {
|
|
1225
|
+
opt.selector.shared_from_uid = { $gt: null };
|
|
1226
|
+
// opt.selector.team_req_stat = { $eq: 3 };
|
|
1227
|
+
break;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
case 'mine': {
|
|
1231
|
+
opt.selector.uid = uid;
|
|
1232
|
+
|
|
1233
|
+
break;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
default:
|
|
1237
|
+
// opt.selector.team_req_stat = { $eq: 3 };
|
|
1238
|
+
break;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
if (conversation_type) {
|
|
1242
|
+
opt.selector.conversation_type = conversation_type;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
if (reference_id) {
|
|
1246
|
+
opt.selector.reference_id = reference_id;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
if (conversation_id) {
|
|
1250
|
+
opt.selector._id = conversation_id;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
if (search) {
|
|
1254
|
+
opt.selector = {
|
|
1255
|
+
...opt.selector,
|
|
1256
|
+
$or: [
|
|
1257
|
+
{
|
|
1258
|
+
title: {
|
|
1259
|
+
$regex: `(?i)${search}`,
|
|
1260
|
+
},
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
_id: {
|
|
1264
|
+
$regex: `(?i)${search}`,
|
|
1265
|
+
},
|
|
1266
|
+
},
|
|
1267
|
+
],
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1269
1272
|
////// FROM - IN
|
|
1270
1273
|
let requests_from = { docs: [], total_docs: 0 };
|
|
1271
1274
|
|
|
@@ -1404,7 +1407,7 @@ export const delete_ai_chat = async function (req) {
|
|
|
1404
1407
|
}
|
|
1405
1408
|
|
|
1406
1409
|
if (conversation_doc?.chat_image?.[0]) {
|
|
1407
|
-
|
|
1410
|
+
drive_msa.delete_drive_files({ uid, drive_type: 'user', files_arr: [{ type: 'file', file_path: path.join(conversation_doc.chat_image[0].file_path, conversation_doc.chat_image[0].filename) }] });
|
|
1408
1411
|
}
|
|
1409
1412
|
}
|
|
1410
1413
|
|