@xuda.io/ai_module 1.1.5010 → 1.1.5012
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 +10 -77
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1125,7 +1125,7 @@ export const get_chat_conversation = async function (req) {
|
|
|
1125
1125
|
};
|
|
1126
1126
|
|
|
1127
1127
|
export const get_ai_chats = async function (req, job_id, headers) {
|
|
1128
|
-
let { uid, reference_id, _id, search, filter_type = 'all', conversation_type, limit, skip, conversation_id, profile_id } = req;
|
|
1128
|
+
let { uid, reference_id = '', _id, search, filter_type = 'all', conversation_type, limit, skip, conversation_id, profile_id } = req;
|
|
1129
1129
|
|
|
1130
1130
|
const account_profile_info = await get_active_account_profile_info(uid, profile_id);
|
|
1131
1131
|
|
|
@@ -1286,41 +1286,9 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1286
1286
|
const get_data_view = async function () {
|
|
1287
1287
|
let stat = 3;
|
|
1288
1288
|
|
|
1289
|
-
const ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'ai_chat_list', {
|
|
1290
|
-
startkey: [stat, reference_id, 0],
|
|
1291
|
-
endkey: [stat, reference_id, 9999999999999],
|
|
1292
|
-
limit: limit || 9999,
|
|
1293
|
-
skip: skip || 0,
|
|
1294
|
-
include_docs: true,
|
|
1295
|
-
descending: reference_id ? false : true,
|
|
1296
|
-
});
|
|
1297
|
-
|
|
1298
|
-
debugger;
|
|
1299
|
-
return;
|
|
1300
|
-
let opt = {
|
|
1301
|
-
selector: {
|
|
1302
|
-
docType: 'chat_conversation',
|
|
1303
|
-
stat: 3,
|
|
1304
|
-
reference_id: '',
|
|
1305
|
-
},
|
|
1306
|
-
limit: limit || 9999,
|
|
1307
|
-
skip: skip || 0,
|
|
1308
|
-
// sort: [{ ts: reference_id ? 'asc' : 'desc' }],
|
|
1309
|
-
};
|
|
1310
|
-
|
|
1311
|
-
if (reference_id) {
|
|
1312
|
-
opt.sort = [{ date_created_ts: 'asc' }];
|
|
1313
|
-
} else {
|
|
1314
|
-
opt.sort = [{ ts: 'desc' }];
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
if (!account_profile_info.is_main) {
|
|
1318
|
-
opt.selector.account_profiles = { $in: [account_profile_info.account_profile_id] };
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
1289
|
switch (filter_type) {
|
|
1322
1290
|
case 'archived': {
|
|
1323
|
-
|
|
1291
|
+
stat = 5;
|
|
1324
1292
|
break;
|
|
1325
1293
|
}
|
|
1326
1294
|
case 'shared': {
|
|
@@ -1340,49 +1308,14 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1340
1308
|
break;
|
|
1341
1309
|
}
|
|
1342
1310
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
if (conversation_id) {
|
|
1352
|
-
opt.selector._id = conversation_id;
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
if (search) {
|
|
1356
|
-
opt.selector = {
|
|
1357
|
-
...opt.selector,
|
|
1358
|
-
$or: [
|
|
1359
|
-
{
|
|
1360
|
-
title: {
|
|
1361
|
-
$regex: `(?i)${search}`,
|
|
1362
|
-
},
|
|
1363
|
-
},
|
|
1364
|
-
{
|
|
1365
|
-
_id: {
|
|
1366
|
-
$regex: `(?i)${search}`,
|
|
1367
|
-
},
|
|
1368
|
-
},
|
|
1369
|
-
],
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
let ai_chats = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1374
|
-
if (!limit || conversation_id) {
|
|
1375
|
-
ai_chats.total_docs = ai_chats.docs.length;
|
|
1376
|
-
} else {
|
|
1377
|
-
delete opt.sort;
|
|
1378
|
-
delete opt.skip;
|
|
1379
|
-
opt.limit = 9999;
|
|
1380
|
-
opt.fields = ['_id'];
|
|
1381
|
-
|
|
1382
|
-
const counter = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1383
|
-
ai_chats.total_docs = counter.docs.length;
|
|
1384
|
-
}
|
|
1385
|
-
return ai_chats;
|
|
1311
|
+
const ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'ai_chat_list', {
|
|
1312
|
+
startkey: [stat, reference_id, 0],
|
|
1313
|
+
endkey: [stat, reference_id, 9999999999999],
|
|
1314
|
+
limit: limit || 9999,
|
|
1315
|
+
skip: skip || 0,
|
|
1316
|
+
include_docs: true,
|
|
1317
|
+
descending: reference_id ? false : true,
|
|
1318
|
+
});
|
|
1386
1319
|
};
|
|
1387
1320
|
|
|
1388
1321
|
////// FROM - IN
|