@xuda.io/ai_module 1.1.5001 → 1.1.5003
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 +109 -11
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1283,6 +1283,102 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1283
1283
|
return ai_chats;
|
|
1284
1284
|
};
|
|
1285
1285
|
|
|
1286
|
+
const get_data_view = async function () {
|
|
1287
|
+
const ret = await db_module.get_app_couch_view_raw(account_profile_info.app_id, 'ai_chat_list', {
|
|
1288
|
+
key: [reference_id],
|
|
1289
|
+
include_docs: true,
|
|
1290
|
+
});
|
|
1291
|
+
|
|
1292
|
+
debugger;
|
|
1293
|
+
|
|
1294
|
+
let opt = {
|
|
1295
|
+
selector: {
|
|
1296
|
+
docType: 'chat_conversation',
|
|
1297
|
+
stat: 3,
|
|
1298
|
+
reference_id: '',
|
|
1299
|
+
},
|
|
1300
|
+
limit: limit || 9999,
|
|
1301
|
+
skip: skip || 0,
|
|
1302
|
+
// sort: [{ ts: reference_id ? 'asc' : 'desc' }],
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
if (reference_id) {
|
|
1306
|
+
opt.sort = [{ date_created_ts: 'asc' }];
|
|
1307
|
+
} else {
|
|
1308
|
+
opt.sort = [{ ts: 'desc' }];
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
if (!account_profile_info.is_main) {
|
|
1312
|
+
opt.selector.account_profiles = { $in: [account_profile_info.account_profile_id] };
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
switch (filter_type) {
|
|
1316
|
+
case 'archived': {
|
|
1317
|
+
opt.selector.stat = 5;
|
|
1318
|
+
break;
|
|
1319
|
+
}
|
|
1320
|
+
case 'shared': {
|
|
1321
|
+
opt.selector.shared_from_uid = { $gt: null };
|
|
1322
|
+
// opt.selector.team_req_stat = { $eq: 3 };
|
|
1323
|
+
break;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
case 'mine': {
|
|
1327
|
+
opt.selector.uid = uid;
|
|
1328
|
+
|
|
1329
|
+
break;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
default:
|
|
1333
|
+
// opt.selector.team_req_stat = { $eq: 3 };
|
|
1334
|
+
break;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
if (conversation_type) {
|
|
1338
|
+
opt.selector.conversation_type = conversation_type;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
if (reference_id) {
|
|
1342
|
+
opt.selector.reference_id = reference_id;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
if (conversation_id) {
|
|
1346
|
+
opt.selector._id = conversation_id;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
if (search) {
|
|
1350
|
+
opt.selector = {
|
|
1351
|
+
...opt.selector,
|
|
1352
|
+
$or: [
|
|
1353
|
+
{
|
|
1354
|
+
title: {
|
|
1355
|
+
$regex: `(?i)${search}`,
|
|
1356
|
+
},
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
_id: {
|
|
1360
|
+
$regex: `(?i)${search}`,
|
|
1361
|
+
},
|
|
1362
|
+
},
|
|
1363
|
+
],
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
let ai_chats = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1368
|
+
if (!limit || conversation_id) {
|
|
1369
|
+
ai_chats.total_docs = ai_chats.docs.length;
|
|
1370
|
+
} else {
|
|
1371
|
+
delete opt.sort;
|
|
1372
|
+
delete opt.skip;
|
|
1373
|
+
opt.limit = 9999;
|
|
1374
|
+
opt.fields = ['_id'];
|
|
1375
|
+
|
|
1376
|
+
const counter = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1377
|
+
ai_chats.total_docs = counter.docs.length;
|
|
1378
|
+
}
|
|
1379
|
+
return ai_chats;
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1286
1382
|
////// FROM - IN
|
|
1287
1383
|
let requests_from = { docs: [], total_docs: 0 };
|
|
1288
1384
|
|
|
@@ -1313,18 +1409,20 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1313
1409
|
let ai_chats = { docs: [], total_docs: 0 };
|
|
1314
1410
|
|
|
1315
1411
|
if (filter_type !== 'pending') {
|
|
1316
|
-
ai_chats = await
|
|
1317
|
-
if (!limit || conversation_id) {
|
|
1318
|
-
ai_chats.total_docs = ai_chats.docs.length;
|
|
1319
|
-
} else {
|
|
1320
|
-
delete opt.sort;
|
|
1321
|
-
delete opt.skip;
|
|
1322
|
-
opt.limit = 9999;
|
|
1323
|
-
opt.fields = ['_id'];
|
|
1412
|
+
ai_chats = await get_data_find();
|
|
1324
1413
|
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1414
|
+
// ai_chats = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1415
|
+
// if (!limit || conversation_id) {
|
|
1416
|
+
// ai_chats.total_docs = ai_chats.docs.length;
|
|
1417
|
+
// } else {
|
|
1418
|
+
// delete opt.sort;
|
|
1419
|
+
// delete opt.skip;
|
|
1420
|
+
// opt.limit = 9999;
|
|
1421
|
+
// opt.fields = ['_id'];
|
|
1422
|
+
|
|
1423
|
+
// const counter = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1424
|
+
// ai_chats.total_docs = counter.docs.length;
|
|
1425
|
+
// }
|
|
1328
1426
|
}
|
|
1329
1427
|
|
|
1330
1428
|
let docs = [];
|