@xuda.io/ai_module 1.1.4960 → 1.1.4962
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 +143 -144
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -51,7 +51,7 @@ global._ = _;
|
|
|
51
51
|
const _common = await import(path.join(process.env.XUDA_HOME, 'common', 'xuda_node_common.mjs'));
|
|
52
52
|
const _utils = await import(path.join(process.env.XUDA_HOME, 'common', 'xuda-cpi-utils.mjs'));
|
|
53
53
|
|
|
54
|
-
const { get_active_account_profile_info, get_user_card, get_account_name, get_contact_info } = await import(path.join(process.env.XUDA_HOME, 'common', 'cache_cpi.mjs'));
|
|
54
|
+
const { get_active_account_profile_info, get_user_card, get_account_name, get_contact_info, get_account_default_project_id } = await import(path.join(process.env.XUDA_HOME, 'common', 'cache_cpi.mjs'));
|
|
55
55
|
|
|
56
56
|
const { createDoc, valid_menuType } = await import(`${runtime_modules_path}/xuda-studio-doc-utils.mjs`);
|
|
57
57
|
const { xudaPrase } = await import(`${runtime_modules_path}/xuda-cli-plugin-html-parser-module.esm.mjs`);
|
|
@@ -61,8 +61,7 @@ const { init, check, check_structure, get_zod_schema, get_fields_z_schema } = aw
|
|
|
61
61
|
|
|
62
62
|
const { get_xuda_couch } = _common;
|
|
63
63
|
|
|
64
|
-
const
|
|
65
|
-
|
|
64
|
+
const db_ms = await import(`${module_path}/db_module/index_ms.mjs`);
|
|
66
65
|
const account_ms = await import(`${module_path}/account_module/index_ms.mjs`);
|
|
67
66
|
const drive_ms = await import(`${module_path}/drive_module/index_ms.mjs`);
|
|
68
67
|
const jobs_ms = await import(`${module_path}/jobs_module/index_ms.mjs`);
|
|
@@ -149,7 +148,7 @@ const get_studio_table_info_tool = tool({
|
|
|
149
148
|
try {
|
|
150
149
|
const project_db = await get_project_db(app_id);
|
|
151
150
|
// let tables = await project_db.view('xuda', 'studio_docs_by_type', { key: 'table' });
|
|
152
|
-
let tables = await
|
|
151
|
+
let tables = await db_ms.get_app_couch_view(app_id, 'studio_docs_by_type', { key: 'table' });
|
|
153
152
|
let response = '';
|
|
154
153
|
|
|
155
154
|
for (const doc of tables.rows) {
|
|
@@ -1085,19 +1084,19 @@ export const get_chat_conversation = async function (req) {
|
|
|
1085
1084
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
1086
1085
|
|
|
1087
1086
|
if (_id) {
|
|
1088
|
-
let data = await
|
|
1087
|
+
let data = await db_ms.get_app_couch_doc(account_profile_info.app_id, _id);
|
|
1089
1088
|
return data;
|
|
1090
1089
|
}
|
|
1091
1090
|
|
|
1092
1091
|
try {
|
|
1093
|
-
let conversation_doc = await
|
|
1092
|
+
let conversation_doc = await db_ms.get_app_couch_doc(account_profile_info.app_id, conversation_id);
|
|
1094
1093
|
let reference_doc;
|
|
1095
1094
|
if (conversation_doc.shared_from_uid) {
|
|
1096
1095
|
reference_doc = _.cloneDeep(conversation_doc);
|
|
1097
|
-
conversation_doc = await
|
|
1096
|
+
conversation_doc = await db_ms.get_app_couch_doc_native(reference_doc.shared_from_app_id, reference_doc.share_item_id);
|
|
1098
1097
|
conversation_doc.reference_doc = reference_doc;
|
|
1099
1098
|
}
|
|
1100
|
-
let conversation_items = await
|
|
1099
|
+
let conversation_items = await db_ms.find_app_couch_query(account_profile_info.app_id, {
|
|
1101
1100
|
selector: {
|
|
1102
1101
|
docType: 'chat_conversation_item',
|
|
1103
1102
|
conversation_id,
|
|
@@ -1113,7 +1112,7 @@ export const get_chat_conversation = async function (req) {
|
|
|
1113
1112
|
conversation_item_doc.read = {};
|
|
1114
1113
|
}
|
|
1115
1114
|
conversation_item_doc.read[uid] = Date.now();
|
|
1116
|
-
await
|
|
1115
|
+
await db_ms.save_app_couch_doc(account_profile_info.app_id, conversation_item_doc);
|
|
1117
1116
|
}
|
|
1118
1117
|
|
|
1119
1118
|
return { code: 15, data: { conversation: conversation_items, ...conversation_doc } };
|
|
@@ -1162,7 +1161,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1162
1161
|
|
|
1163
1162
|
try {
|
|
1164
1163
|
if (_id) {
|
|
1165
|
-
let data = await
|
|
1164
|
+
let data = await db_ms.get_app_couch_doc(account_profile_info.app_id, _id);
|
|
1166
1165
|
return data;
|
|
1167
1166
|
}
|
|
1168
1167
|
|
|
@@ -1240,7 +1239,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1240
1239
|
}
|
|
1241
1240
|
|
|
1242
1241
|
const chat_conversation_count = async function (contact_id, conversation_id) {
|
|
1243
|
-
const counts_ret = await
|
|
1242
|
+
const counts_ret = await db_ms.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_counts', {
|
|
1244
1243
|
reduce: true,
|
|
1245
1244
|
group_level: 1,
|
|
1246
1245
|
|
|
@@ -1253,7 +1252,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1253
1252
|
return counts_ret?.rows?.[0]?.value || 0;
|
|
1254
1253
|
};
|
|
1255
1254
|
const chat_conversation_read = async function (contact_id, conversation_id) {
|
|
1256
|
-
const counts_ret = await
|
|
1255
|
+
const counts_ret = await db_ms.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_read', {
|
|
1257
1256
|
reduce: true,
|
|
1258
1257
|
group_level: 2,
|
|
1259
1258
|
key: [uid, contact_id, conversation_id],
|
|
@@ -1271,7 +1270,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1271
1270
|
if (!reference_id) {
|
|
1272
1271
|
if (filter_type === 'pending') {
|
|
1273
1272
|
const from_opt = { selector: { docType: 'team_request', access_type: 'chat', team_req_stat: 2, team_req_to_uid: uid }, fields: ['_id', 'team_req_date', 'sender_account_info.email', 'team_req_from_uid', 'share_item_id'] };
|
|
1274
|
-
const requests_from_res = await
|
|
1273
|
+
const requests_from_res = await db_ms.find_couch_query('xuda_team', from_opt);
|
|
1275
1274
|
|
|
1276
1275
|
for await (let e of requests_from_res.docs) {
|
|
1277
1276
|
let doc = { date_created: e.team_req_date, pending: true, uid: e.team_req_from_uid, team_req_id: e._id };
|
|
@@ -1281,8 +1280,8 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1281
1280
|
}
|
|
1282
1281
|
|
|
1283
1282
|
//share_item_id
|
|
1284
|
-
const app_id = await
|
|
1285
|
-
const chat_ret = await
|
|
1283
|
+
const app_id = await get_account_default_project_id(e.team_req_from_uid);
|
|
1284
|
+
const chat_ret = await db_ms.get_app_couch_doc_native(app_id, e.share_item_id);
|
|
1286
1285
|
doc.title = chat_ret.title;
|
|
1287
1286
|
doc.chat_image = chat_ret.chat_image;
|
|
1288
1287
|
|
|
@@ -1295,7 +1294,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1295
1294
|
let ai_chats = { docs: [], total_docs: 0 };
|
|
1296
1295
|
|
|
1297
1296
|
if (filter_type !== 'pending') {
|
|
1298
|
-
ai_chats = await
|
|
1297
|
+
ai_chats = await db_ms.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1299
1298
|
if (!limit || conversation_id) {
|
|
1300
1299
|
ai_chats.total_docs = ai_chats.docs.length;
|
|
1301
1300
|
} else {
|
|
@@ -1304,7 +1303,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1304
1303
|
opt.limit = 9999;
|
|
1305
1304
|
opt.fields = ['_id'];
|
|
1306
1305
|
|
|
1307
|
-
const counter = await
|
|
1306
|
+
const counter = await db_ms.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1308
1307
|
ai_chats.total_docs = counter.docs.length;
|
|
1309
1308
|
}
|
|
1310
1309
|
}
|
|
@@ -1316,7 +1315,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1316
1315
|
|
|
1317
1316
|
if (doc.shared_from_uid) {
|
|
1318
1317
|
reference_doc = _.cloneDeep(doc);
|
|
1319
|
-
doc = await
|
|
1318
|
+
doc = await db_ms.get_app_couch_doc_native(reference_doc.shared_from_app_id, reference_doc.share_item_id);
|
|
1320
1319
|
doc.reference_doc = reference_doc;
|
|
1321
1320
|
}
|
|
1322
1321
|
|
|
@@ -1361,8 +1360,8 @@ export const delete_ai_chat = async function (req) {
|
|
|
1361
1360
|
|
|
1362
1361
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
1363
1362
|
|
|
1364
|
-
const app_id = await
|
|
1365
|
-
let conversation_doc = await
|
|
1363
|
+
const app_id = await get_account_default_project_id(uid);
|
|
1364
|
+
let conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
1366
1365
|
|
|
1367
1366
|
let save_ret;
|
|
1368
1367
|
try {
|
|
@@ -1377,7 +1376,7 @@ export const delete_ai_chat = async function (req) {
|
|
|
1377
1376
|
} else {
|
|
1378
1377
|
conversation_doc.stat = 4;
|
|
1379
1378
|
conversation_doc.ts = Date.now();
|
|
1380
|
-
save_ret = await
|
|
1379
|
+
save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, conversation_doc);
|
|
1381
1380
|
|
|
1382
1381
|
client.conversations.delete(conversation_id);
|
|
1383
1382
|
|
|
@@ -1407,7 +1406,7 @@ export const archive_ai_chat = async function (req) {
|
|
|
1407
1406
|
try {
|
|
1408
1407
|
await team_ms.validate_share_exist(uid, 'chat', conversation_id);
|
|
1409
1408
|
|
|
1410
|
-
let conversation_doc = await
|
|
1409
|
+
let conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
1411
1410
|
|
|
1412
1411
|
if (conversation_doc.uid !== uid && conversation_doc?.account_profile_info?.uid !== uid) {
|
|
1413
1412
|
throw new Error('Operation not allowed');
|
|
@@ -1415,7 +1414,7 @@ export const archive_ai_chat = async function (req) {
|
|
|
1415
1414
|
|
|
1416
1415
|
conversation_doc.stat = 5;
|
|
1417
1416
|
conversation_doc.ts = Date.now();
|
|
1418
|
-
const save_ret = await
|
|
1417
|
+
const save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, conversation_doc);
|
|
1419
1418
|
|
|
1420
1419
|
return save_ret;
|
|
1421
1420
|
} catch (err) {
|
|
@@ -1428,7 +1427,7 @@ export const unarchive_ai_chat = async function (req) {
|
|
|
1428
1427
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
1429
1428
|
|
|
1430
1429
|
try {
|
|
1431
|
-
let conversation_doc = await
|
|
1430
|
+
let conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
1432
1431
|
|
|
1433
1432
|
if (conversation_doc.stat !== 5) {
|
|
1434
1433
|
throw new Error('chat is not archived');
|
|
@@ -1436,7 +1435,7 @@ export const unarchive_ai_chat = async function (req) {
|
|
|
1436
1435
|
|
|
1437
1436
|
conversation_doc.stat = 3;
|
|
1438
1437
|
conversation_doc.ts = Date.now();
|
|
1439
|
-
const save_ret = await
|
|
1438
|
+
const save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, conversation_doc);
|
|
1440
1439
|
|
|
1441
1440
|
return save_ret;
|
|
1442
1441
|
} catch (err) {
|
|
@@ -1524,9 +1523,9 @@ const get_studio_doc = async function (req) {
|
|
|
1524
1523
|
let { uid, _id } = req;
|
|
1525
1524
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
1526
1525
|
|
|
1527
|
-
const app_id = await
|
|
1526
|
+
const app_id = await get_account_default_project_id(uid);
|
|
1528
1527
|
try {
|
|
1529
|
-
let data = await
|
|
1528
|
+
let data = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, _id);
|
|
1530
1529
|
|
|
1531
1530
|
if (data?.studio_meta?.createdByUid !== uid) delete data.agentConfig; //throw new Error('doctype not supported');
|
|
1532
1531
|
return { code: 7, data };
|
|
@@ -1797,7 +1796,7 @@ export const get_ai_agent_info = async function (uid, job_id, headers, doc, from
|
|
|
1797
1796
|
};
|
|
1798
1797
|
|
|
1799
1798
|
const agent_conversation_count = async function (agent_id) {
|
|
1800
|
-
const counts_ret = await
|
|
1799
|
+
const counts_ret = await db_ms.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_counts', {
|
|
1801
1800
|
reduce: true,
|
|
1802
1801
|
group_level: 1,
|
|
1803
1802
|
|
|
@@ -1851,7 +1850,7 @@ const get_user_ai_agents = async function (uid) {
|
|
|
1851
1850
|
'properties.menuType': 'ai_agent',
|
|
1852
1851
|
},
|
|
1853
1852
|
};
|
|
1854
|
-
return await
|
|
1853
|
+
return await db_ms.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1855
1854
|
};
|
|
1856
1855
|
|
|
1857
1856
|
export const get_ai_agents = async function (req, job_id, headers) {
|
|
@@ -1942,7 +1941,7 @@ export const get_ai_agents = async function (req, job_id, headers) {
|
|
|
1942
1941
|
|
|
1943
1942
|
let user_agents = { docs: [], total_docs: 0 };
|
|
1944
1943
|
if (filter_type !== 'pending') {
|
|
1945
|
-
user_agents = await
|
|
1944
|
+
user_agents = await db_ms.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1946
1945
|
if (!limit || agent_id) {
|
|
1947
1946
|
user_agents.total_docs = user_agents.docs.length;
|
|
1948
1947
|
} else {
|
|
@@ -1951,7 +1950,7 @@ export const get_ai_agents = async function (req, job_id, headers) {
|
|
|
1951
1950
|
opt.limit = 9999;
|
|
1952
1951
|
opt.fields = ['_id'];
|
|
1953
1952
|
|
|
1954
|
-
const counter = await
|
|
1953
|
+
const counter = await db_ms.find_app_couch_query(account_profile_info.app_id, opt);
|
|
1955
1954
|
user_agents.total_docs = counter.docs.length;
|
|
1956
1955
|
}
|
|
1957
1956
|
}
|
|
@@ -1960,7 +1959,7 @@ export const get_ai_agents = async function (req, job_id, headers) {
|
|
|
1960
1959
|
let requests_from = { docs: [], total_docs: 0 };
|
|
1961
1960
|
if (filter_type === 'pending') {
|
|
1962
1961
|
const from_opt = { selector: { docType: 'team_request', access_type: 'ai_agent', team_req_stat: 2, team_req_to_uid: uid }, fields: ['_id', 'team_req_date', 'sender_account_info.email', 'team_req_from_uid', 'share_item_id'] };
|
|
1963
|
-
const requests_from_res = await
|
|
1962
|
+
const requests_from_res = await db_ms.find_couch_query('xuda_team', from_opt);
|
|
1964
1963
|
|
|
1965
1964
|
for await (let e of requests_from_res.docs) {
|
|
1966
1965
|
let doc = { ts: e.team_req_date, pending: true, properties: {}, studio_meta: { createdByUid: e.team_req_from_uid }, team_req_id: e._id };
|
|
@@ -1971,8 +1970,8 @@ export const get_ai_agents = async function (req, job_id, headers) {
|
|
|
1971
1970
|
}
|
|
1972
1971
|
|
|
1973
1972
|
//share_item_id
|
|
1974
|
-
const app_id = await
|
|
1975
|
-
const ai_agent_doc = await
|
|
1973
|
+
const app_id = await get_account_default_project_id(e.team_req_from_uid);
|
|
1974
|
+
const ai_agent_doc = await db_ms.get_app_couch_doc_native(app_id, e.share_item_id);
|
|
1976
1975
|
doc.properties.menuName = ai_agent_doc.properties.menuName;
|
|
1977
1976
|
doc.studio_meta.agent_image = ai_agent_doc.studio_meta.agent_image;
|
|
1978
1977
|
|
|
@@ -1990,7 +1989,7 @@ export const get_ai_agents = async function (req, job_id, headers) {
|
|
|
1990
1989
|
if (doc.studio_meta.shared_from_uid && doc.studio_meta.shared_from_app_id) {
|
|
1991
1990
|
reference_doc = _.cloneDeep(doc);
|
|
1992
1991
|
try {
|
|
1993
|
-
doc = await
|
|
1992
|
+
doc = await db_ms.get_app_couch_doc_native(reference_doc.studio_meta.shared_from_app_id, reference_doc.studio_meta.share_item_id);
|
|
1994
1993
|
} catch (error) {
|
|
1995
1994
|
continue;
|
|
1996
1995
|
}
|
|
@@ -2001,7 +2000,7 @@ export const get_ai_agents = async function (req, job_id, headers) {
|
|
|
2001
2000
|
// purchased
|
|
2002
2001
|
if (doc.studio_meta.installed_from_uid && doc.studio_meta.installed_from_app_id) {
|
|
2003
2002
|
reference_doc = _.cloneDeep(doc);
|
|
2004
|
-
doc = await
|
|
2003
|
+
doc = await db_ms.get_app_couch_doc_native(reference_doc.studio_meta.installed_from_app_id, doc._id);
|
|
2005
2004
|
doc.reference_doc = reference_doc;
|
|
2006
2005
|
doc.stat = reference_doc.stat;
|
|
2007
2006
|
}
|
|
@@ -2026,7 +2025,7 @@ export const delete_ai_agent = async function (req) {
|
|
|
2026
2025
|
// const project_db = await get_account_project_db(uid);
|
|
2027
2026
|
|
|
2028
2027
|
try {
|
|
2029
|
-
let prog_doc = await
|
|
2028
|
+
let prog_doc = await db_ms.get_app_couch_doc_native(app_id, agent_id);
|
|
2030
2029
|
|
|
2031
2030
|
if (prog_doc.stat !== 5) {
|
|
2032
2031
|
throw new Error('A document can only be deleted after it has been archived');
|
|
@@ -2038,10 +2037,10 @@ export const delete_ai_agent = async function (req) {
|
|
|
2038
2037
|
|
|
2039
2038
|
save_ret = await team_ms.remove_team_member({ team_req_id: prog_doc.studio_meta.team_req_id });
|
|
2040
2039
|
} else {
|
|
2041
|
-
let agent_doc = await
|
|
2040
|
+
let agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
|
|
2042
2041
|
agent_doc.stat = 4;
|
|
2043
2042
|
agent_doc.ts = Date.now();
|
|
2044
|
-
const save_ret = await
|
|
2043
|
+
const save_ret = await db_ms.save_app_couch_doc_native(account_profile_info.app_id, agent_doc);
|
|
2045
2044
|
|
|
2046
2045
|
for (const [key, val] of Object.entries(agent_doc?.agentConfig?.agent_tools || [])) {
|
|
2047
2046
|
const file_id = val?.youtube?.file_id || val?.file?.file_id;
|
|
@@ -2066,7 +2065,7 @@ export const uninstall_ai_agent = async function (req) {
|
|
|
2066
2065
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2067
2066
|
|
|
2068
2067
|
try {
|
|
2069
|
-
let agent_doc = await
|
|
2068
|
+
let agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
|
|
2070
2069
|
|
|
2071
2070
|
if (!agent_doc.studio_meta.installed_from_app_id) {
|
|
2072
2071
|
throw new Error('agent not installed');
|
|
@@ -2075,7 +2074,7 @@ export const uninstall_ai_agent = async function (req) {
|
|
|
2075
2074
|
agent_doc.stat = 4;
|
|
2076
2075
|
agent_doc.ts = Date.now();
|
|
2077
2076
|
|
|
2078
|
-
const save_ret = await
|
|
2077
|
+
const save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, agent_doc);
|
|
2079
2078
|
|
|
2080
2079
|
return save_ret;
|
|
2081
2080
|
} catch (err) {
|
|
@@ -2088,7 +2087,7 @@ export const unarchive_ai_agent = async function (req) {
|
|
|
2088
2087
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2089
2088
|
|
|
2090
2089
|
try {
|
|
2091
|
-
let agent_doc = await
|
|
2090
|
+
let agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
|
|
2092
2091
|
|
|
2093
2092
|
if (agent_doc.stat !== 5) {
|
|
2094
2093
|
throw new Error('agent is not archived');
|
|
@@ -2097,7 +2096,7 @@ export const unarchive_ai_agent = async function (req) {
|
|
|
2097
2096
|
agent_doc.stat = 3;
|
|
2098
2097
|
agent_doc.ts = Date.now();
|
|
2099
2098
|
|
|
2100
|
-
const save_ret = await
|
|
2099
|
+
const save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, agent_doc);
|
|
2101
2100
|
|
|
2102
2101
|
return save_ret;
|
|
2103
2102
|
} catch (err) {
|
|
@@ -2111,7 +2110,7 @@ export const archive_ai_agent = async function (req) {
|
|
|
2111
2110
|
try {
|
|
2112
2111
|
await team_ms.validate_share_exist(uid, 'ai_agent', agent_id);
|
|
2113
2112
|
|
|
2114
|
-
let agent_doc = await
|
|
2113
|
+
let agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
|
|
2115
2114
|
|
|
2116
2115
|
if (agent_doc.studio_meta.createdByUid !== uid && agent_doc?.studio_meta?.account_profile_info?.uid !== uid) {
|
|
2117
2116
|
throw new Error('Operation not allowed');
|
|
@@ -2119,7 +2118,7 @@ export const archive_ai_agent = async function (req) {
|
|
|
2119
2118
|
|
|
2120
2119
|
agent_doc.stat = 5;
|
|
2121
2120
|
agent_doc.ts = Date.now();
|
|
2122
|
-
const save_ret = await
|
|
2121
|
+
const save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, agent_doc);
|
|
2123
2122
|
|
|
2124
2123
|
return save_ret;
|
|
2125
2124
|
} catch (err) {
|
|
@@ -2135,7 +2134,7 @@ export const archive_mini_app = async function (req) {
|
|
|
2135
2134
|
try {
|
|
2136
2135
|
await team_ms.validate_share_exist(uid, 'miniapp', prog_id);
|
|
2137
2136
|
|
|
2138
|
-
let prog_doc = await
|
|
2137
|
+
let prog_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, prog_id);
|
|
2139
2138
|
|
|
2140
2139
|
if (agent_doc.studio_meta.createdByUid !== uid && agent_doc?.studio_meta?.account_profile_info?.uid !== uid) {
|
|
2141
2140
|
throw new Error('Operation not allowed');
|
|
@@ -2143,7 +2142,7 @@ export const archive_mini_app = async function (req) {
|
|
|
2143
2142
|
|
|
2144
2143
|
prog_doc.stat = 5;
|
|
2145
2144
|
prog_doc.ts = Date.now();
|
|
2146
|
-
const save_ret = await
|
|
2145
|
+
const save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, prog_doc);
|
|
2147
2146
|
|
|
2148
2147
|
return save_ret;
|
|
2149
2148
|
} catch (err) {
|
|
@@ -2157,7 +2156,7 @@ export const unarchive_mini_app = async function (req) {
|
|
|
2157
2156
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2158
2157
|
|
|
2159
2158
|
try {
|
|
2160
|
-
let prog_doc = await
|
|
2159
|
+
let prog_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, prog_id);
|
|
2161
2160
|
|
|
2162
2161
|
if (prog_doc.stat !== 5) {
|
|
2163
2162
|
throw new Error('mini app is not archived');
|
|
@@ -2165,7 +2164,7 @@ export const unarchive_mini_app = async function (req) {
|
|
|
2165
2164
|
|
|
2166
2165
|
prog_doc.stat = 3;
|
|
2167
2166
|
prog_doc.ts = Date.now();
|
|
2168
|
-
const save_ret = await
|
|
2167
|
+
const save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, prog_doc);
|
|
2169
2168
|
|
|
2170
2169
|
return save_ret;
|
|
2171
2170
|
} catch (err) {
|
|
@@ -2179,7 +2178,7 @@ export const delete_mini_app = async function (req) {
|
|
|
2179
2178
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2180
2179
|
|
|
2181
2180
|
try {
|
|
2182
|
-
let prog_doc = await
|
|
2181
|
+
let prog_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, prog_id);
|
|
2183
2182
|
|
|
2184
2183
|
if (prog_doc.stat !== 5) {
|
|
2185
2184
|
throw new Error('A document can only be deleted after it has been archived');
|
|
@@ -2193,7 +2192,7 @@ export const delete_mini_app = async function (req) {
|
|
|
2193
2192
|
} else {
|
|
2194
2193
|
prog_doc.stat = 4;
|
|
2195
2194
|
prog_doc.ts = Date.now();
|
|
2196
|
-
save_ret = await
|
|
2195
|
+
save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, prog_doc);
|
|
2197
2196
|
delete_depended_chats(uid, prog_id);
|
|
2198
2197
|
}
|
|
2199
2198
|
return save_ret;
|
|
@@ -2208,7 +2207,7 @@ export const update_ai_agent = async function (req, job_id, headers) {
|
|
|
2208
2207
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2209
2208
|
|
|
2210
2209
|
try {
|
|
2211
|
-
let agent_doc = await await
|
|
2210
|
+
let agent_doc = await await db_ms.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
|
|
2212
2211
|
|
|
2213
2212
|
agent_doc.ts = Date.now();
|
|
2214
2213
|
agent_doc.agentConfig = agentConfig;
|
|
@@ -2228,7 +2227,7 @@ export const update_ai_agent = async function (req, job_id, headers) {
|
|
|
2228
2227
|
agent_doc.studio_meta.agent_tags = agentConfig.agent_tags;
|
|
2229
2228
|
agent_doc.studio_meta.agent_user_guide = agentConfig.agent_user_guide;
|
|
2230
2229
|
|
|
2231
|
-
const data = await
|
|
2230
|
+
const data = await db_ms.save_app_couch_doc_native(account_profile_info.app_id, agent_doc);
|
|
2232
2231
|
|
|
2233
2232
|
setTimeout(async () => {
|
|
2234
2233
|
await update_ai_agent_properties(agent_doc, account_profile_info.app_id, uid, { name_changed, agent_user_guide_changed, agent_category_changed, agent_subcategory_changed, agent_instructions_changed });
|
|
@@ -2316,7 +2315,7 @@ export const get_apps = async function (req, job_id, headers) {
|
|
|
2316
2315
|
|
|
2317
2316
|
let user_apps = { docs: [], total_docs: 0 };
|
|
2318
2317
|
if (filter_type !== 'pending') {
|
|
2319
|
-
user_apps = await
|
|
2318
|
+
user_apps = await db_ms.find_app_couch_query(account_profile_info.app_id, opt);
|
|
2320
2319
|
if (!limit || mini_app_id) {
|
|
2321
2320
|
user_apps.total_docs = user_apps.docs.length;
|
|
2322
2321
|
} else {
|
|
@@ -2325,7 +2324,7 @@ export const get_apps = async function (req, job_id, headers) {
|
|
|
2325
2324
|
opt.limit = 9999;
|
|
2326
2325
|
opt.fields = ['_id'];
|
|
2327
2326
|
|
|
2328
|
-
const counter = await
|
|
2327
|
+
const counter = await db_ms.find_app_couch_query(account_profile_info.app_id, opt);
|
|
2329
2328
|
user_apps.total_docs = counter.docs.length;
|
|
2330
2329
|
}
|
|
2331
2330
|
}
|
|
@@ -2337,7 +2336,7 @@ export const get_apps = async function (req, job_id, headers) {
|
|
|
2337
2336
|
if (!mini_app_id) {
|
|
2338
2337
|
if (filter_type === 'pending') {
|
|
2339
2338
|
const from_opt = { selector: { docType: 'team_request', access_type: 'miniapp', team_req_stat: 2, team_req_to_uid: uid }, fields: ['_id', 'team_req_date', 'sender_account_info.email', 'team_req_from_uid', 'share_item_id'] };
|
|
2340
|
-
const requests_from_res = await
|
|
2339
|
+
const requests_from_res = await db_ms.find_couch_query('xuda_team', from_opt);
|
|
2341
2340
|
|
|
2342
2341
|
for await (let e of requests_from_res.docs) {
|
|
2343
2342
|
//account_info
|
|
@@ -2348,8 +2347,8 @@ export const get_apps = async function (req, job_id, headers) {
|
|
|
2348
2347
|
}
|
|
2349
2348
|
|
|
2350
2349
|
//share_item_id
|
|
2351
|
-
const app_id = await
|
|
2352
|
-
const miniapp_ret = await
|
|
2350
|
+
const app_id = await get_account_default_project_id(e.team_req_from_uid);
|
|
2351
|
+
const miniapp_ret = await db_ms.get_app_couch_doc_native(app_id, e.share_item_id);
|
|
2353
2352
|
doc.properties.menuName = miniapp_ret.properties.menuName;
|
|
2354
2353
|
doc.studio_meta.agent_image = miniapp_ret.studio_meta.agent_image;
|
|
2355
2354
|
|
|
@@ -2365,7 +2364,7 @@ export const get_apps = async function (req, job_id, headers) {
|
|
|
2365
2364
|
let reference_doc;
|
|
2366
2365
|
if (doc.studio_meta.shared_from_uid) {
|
|
2367
2366
|
reference_doc = _.cloneDeep(doc);
|
|
2368
|
-
doc = await
|
|
2367
|
+
doc = await db_ms.get_app_couch_doc_native(reference_doc.studio_meta.shared_from_app_id, reference_doc.studio_meta.share_item_id);
|
|
2369
2368
|
doc.reference_doc = reference_doc;
|
|
2370
2369
|
}
|
|
2371
2370
|
|
|
@@ -2575,11 +2574,11 @@ const save_agent_status = async function (uid, agent_id, stat, agentConfig) {
|
|
|
2575
2574
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2576
2575
|
|
|
2577
2576
|
try {
|
|
2578
|
-
let agent_doc = await
|
|
2577
|
+
let agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
|
|
2579
2578
|
agent_doc.ts = Date.now();
|
|
2580
2579
|
agent_doc.stat = stat;
|
|
2581
2580
|
agent_doc.agentConfig = agentConfig;
|
|
2582
|
-
const data = await
|
|
2581
|
+
const data = await db_ms.save_app_couch_doc_native(account_profile_info.app_id, agent_doc);
|
|
2583
2582
|
|
|
2584
2583
|
return { code: 12, data };
|
|
2585
2584
|
} catch (err) {
|
|
@@ -2609,7 +2608,7 @@ export const create_ai_agent = async function (req, job_id, headers) {
|
|
|
2609
2608
|
|
|
2610
2609
|
// const data = await db.insert(agent_doc);
|
|
2611
2610
|
|
|
2612
|
-
const data = await
|
|
2611
|
+
const data = await db_ms.save_app_couch_doc_native(account_profile_info.app_id, agent_doc);
|
|
2613
2612
|
setTimeout(async () => {
|
|
2614
2613
|
await update_ai_agent_properties(agent_doc, account_profile_info.app_id, uid);
|
|
2615
2614
|
await update_thumbnail('ai_agent', agent_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
@@ -2624,7 +2623,7 @@ export const create_ai_agent = async function (req, job_id, headers) {
|
|
|
2624
2623
|
|
|
2625
2624
|
export const update_ai_agent_properties = async function (doc, app_id, uid, fields_changed = {}) {
|
|
2626
2625
|
debugger;
|
|
2627
|
-
const db_doc = await
|
|
2626
|
+
const db_doc = await db_ms.get_app_couch_doc_native(app_id, doc._id);
|
|
2628
2627
|
// const { account_profile_info } = doc.studio_meta;
|
|
2629
2628
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2630
2629
|
|
|
@@ -2836,7 +2835,7 @@ export const update_ai_agent_properties = async function (doc, app_id, uid, fiel
|
|
|
2836
2835
|
db_doc.studio_meta.agent_user_guide_steps = db_doc.agentConfig.agent_user_guide_steps;
|
|
2837
2836
|
}
|
|
2838
2837
|
|
|
2839
|
-
const save_ret = await
|
|
2838
|
+
const save_ret = await db_ms.save_app_couch_doc_native(app_id, db_doc);
|
|
2840
2839
|
return save_ret;
|
|
2841
2840
|
};
|
|
2842
2841
|
|
|
@@ -2847,9 +2846,9 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
|
|
|
2847
2846
|
try {
|
|
2848
2847
|
const get_db_doc = async function () {
|
|
2849
2848
|
if (xuda_db) {
|
|
2850
|
-
return await
|
|
2849
|
+
return await db_ms.get_couch_doc_native(xuda_db, doc._id);
|
|
2851
2850
|
} else {
|
|
2852
|
-
return await
|
|
2851
|
+
return await db_ms.get_app_couch_doc_native(account_profile_info.app_id, doc._id);
|
|
2853
2852
|
}
|
|
2854
2853
|
};
|
|
2855
2854
|
|
|
@@ -2952,9 +2951,9 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
|
|
|
2952
2951
|
let save_ret;
|
|
2953
2952
|
|
|
2954
2953
|
if (xuda_db) {
|
|
2955
|
-
save_ret = await
|
|
2954
|
+
save_ret = await db_ms.save_couch_doc_native(xuda_db, db_doc);
|
|
2956
2955
|
} else {
|
|
2957
|
-
save_ret = await
|
|
2956
|
+
save_ret = await db_ms.save_app_couch_doc_native(account_profile_info.app_id, db_doc);
|
|
2958
2957
|
}
|
|
2959
2958
|
return save_ret;
|
|
2960
2959
|
} catch (error) {
|
|
@@ -3417,7 +3416,7 @@ export const create_conversation = async function (req, job_id, headers) {
|
|
|
3417
3416
|
from_mailbox,
|
|
3418
3417
|
email_recipient_type,
|
|
3419
3418
|
};
|
|
3420
|
-
const save_ret = await
|
|
3419
|
+
const save_ret = await db_ms.save_app_couch_doc(account_profile_info.app_id, conversation_doc);
|
|
3421
3420
|
|
|
3422
3421
|
let contact_id, contact_doc, recipient_uid, recipient_contact_id;
|
|
3423
3422
|
|
|
@@ -3437,8 +3436,8 @@ export const create_conversation = async function (req, job_id, headers) {
|
|
|
3437
3436
|
recipient_contact_id = contact_doc.connection_contact_id;
|
|
3438
3437
|
recipient_uid = contact_doc.connection_uid;
|
|
3439
3438
|
|
|
3440
|
-
const app_id = await
|
|
3441
|
-
const save_ret = await
|
|
3439
|
+
const app_id = await get_account_default_project_id(recipient_uid);
|
|
3440
|
+
const save_ret = await db_ms.save_app_couch_doc(app_id, { ...conversation_doc, ...{ uid: recipient_uid, reference_id: recipient_contact_id } });
|
|
3442
3441
|
}
|
|
3443
3442
|
|
|
3444
3443
|
setTimeout(async () => {
|
|
@@ -3452,15 +3451,15 @@ export const create_conversation = async function (req, job_id, headers) {
|
|
|
3452
3451
|
// write conversation to host after thumbnail update
|
|
3453
3452
|
// get sender conversation
|
|
3454
3453
|
|
|
3455
|
-
const conversation_doc = await
|
|
3454
|
+
const conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
3456
3455
|
|
|
3457
3456
|
const recipient_account_profile_info = await get_active_account_profile_info(recipient_uid);
|
|
3458
|
-
let recipient_conversation_doc = await
|
|
3457
|
+
let recipient_conversation_doc = await db_ms.get_app_couch_doc_native(recipient_account_profile_info.app_id, conversation_doc._id);
|
|
3459
3458
|
recipient_conversation_doc.title = conversation_doc.title;
|
|
3460
3459
|
|
|
3461
3460
|
recipient_conversation_doc.thumbnail_request_ts = conversation_doc.thumbnail_request_ts;
|
|
3462
3461
|
recipient_conversation_doc.chat_image = conversation_doc.chat_image;
|
|
3463
|
-
await
|
|
3462
|
+
await db_ms.save_app_couch_doc_native(recipient_account_profile_info.app_id, recipient_conversation_doc);
|
|
3464
3463
|
|
|
3465
3464
|
await update_conversation_mood_level(
|
|
3466
3465
|
uid,
|
|
@@ -3493,7 +3492,7 @@ export const create_conversation = async function (req, job_id, headers) {
|
|
|
3493
3492
|
};
|
|
3494
3493
|
|
|
3495
3494
|
const process_conversation = async function (uid, conversation_id, account_profile_info, job_id, headers) {
|
|
3496
|
-
let conversation_doc = await
|
|
3495
|
+
let conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
3497
3496
|
const { conversation_type, prompt, reference_id } = conversation_doc;
|
|
3498
3497
|
|
|
3499
3498
|
// Ask GPT for title
|
|
@@ -3501,10 +3500,10 @@ const process_conversation = async function (uid, conversation_id, account_profi
|
|
|
3501
3500
|
if (prompt.split(' ').length > 10) {
|
|
3502
3501
|
const title = await submit_chat_gpt_prompt({ uid, prompt: `create title for the prompt return 5 words result maximum text only without options : ${prompt}`, model: 'gpt-5-nano', metadata: { conversation_id: conversation_doc._id, func: 'create_conversation' }, account_profile_info });
|
|
3503
3502
|
|
|
3504
|
-
conversation_doc = await
|
|
3503
|
+
conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
3505
3504
|
conversation_doc.title = title.data;
|
|
3506
3505
|
|
|
3507
|
-
await
|
|
3506
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
3508
3507
|
}
|
|
3509
3508
|
}
|
|
3510
3509
|
/// categorize prompt
|
|
@@ -3537,10 +3536,10 @@ const process_conversation = async function (uid, conversation_id, account_profi
|
|
|
3537
3536
|
}
|
|
3538
3537
|
}
|
|
3539
3538
|
|
|
3540
|
-
conversation_doc = await
|
|
3539
|
+
conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
3541
3540
|
conversation_doc.category_info = category_info;
|
|
3542
3541
|
conversation_doc.process_stat = 'full';
|
|
3543
|
-
await
|
|
3542
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
3544
3543
|
|
|
3545
3544
|
if (category_info.category) {
|
|
3546
3545
|
await update_thumbnail('conversation_category', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
@@ -3581,7 +3580,7 @@ export const submit_chat_conversation = async function (req, job_id, headers) {
|
|
|
3581
3580
|
if (!conversation_id) throw new Error('missing conversation_id');
|
|
3582
3581
|
const account_profile_info = await get_active_account_profile_info(uid, profile_id);
|
|
3583
3582
|
|
|
3584
|
-
let conversation_doc = await
|
|
3583
|
+
let conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
3585
3584
|
req.conversation_doc = conversation_doc;
|
|
3586
3585
|
let ret;
|
|
3587
3586
|
if (conversation_doc.reference_type === 'contacts') {
|
|
@@ -3646,9 +3645,9 @@ const update_conversation_mood_level = async function (uid, target_contacts = []
|
|
|
3646
3645
|
|
|
3647
3646
|
for await (const target of target_contacts) {
|
|
3648
3647
|
const account_profile_info = await get_active_account_profile_info(target.uid);
|
|
3649
|
-
let conversation_doc = await
|
|
3648
|
+
let conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
3650
3649
|
conversation_doc.mood_level = mood_level_obj.mood_level;
|
|
3651
|
-
await
|
|
3650
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
3652
3651
|
|
|
3653
3652
|
if (update_contact) {
|
|
3654
3653
|
const account_profile_info = await get_active_account_profile_info(target.uid);
|
|
@@ -3671,12 +3670,12 @@ const contact_chat_conversation = async function (req, job_id, headers) {
|
|
|
3671
3670
|
const conversation_id = conversation_doc._id;
|
|
3672
3671
|
|
|
3673
3672
|
const receiver_contact_doc = await get_contact_info(uid, null, conversation_doc.reference_id);
|
|
3674
|
-
const receiver_app_id = await
|
|
3675
|
-
let receiver_conversation_doc = await
|
|
3673
|
+
const receiver_app_id = await get_account_default_project_id(receiver_contact_doc.contact_uid);
|
|
3674
|
+
let receiver_conversation_doc = await db_ms.get_app_couch_doc_native(receiver_app_id, conversation_id);
|
|
3676
3675
|
|
|
3677
3676
|
const sender_contact_doc = await get_contact_info(uid, null, conversation_doc.reference_id);
|
|
3678
3677
|
const sender_app_id = account_profile_info.app_id;
|
|
3679
|
-
let sender_conversation_doc = await
|
|
3678
|
+
let sender_conversation_doc = await db_ms.get_app_couch_doc_native(sender_app_id, conversation_id);
|
|
3680
3679
|
|
|
3681
3680
|
let item;
|
|
3682
3681
|
try {
|
|
@@ -3698,10 +3697,10 @@ const contact_chat_conversation = async function (req, job_id, headers) {
|
|
|
3698
3697
|
// const obj = { id: item.data[0].id, ts: Date.now(), uid, read: true, conversation_type: 'chat' };
|
|
3699
3698
|
// receiver_conversation_doc.messages.push(obj);
|
|
3700
3699
|
|
|
3701
|
-
await
|
|
3700
|
+
await db_ms.save_app_couch_doc_native(receiver_app_id, receiver_conversation_doc);
|
|
3702
3701
|
// sender_conversation_doc.messages.push({ ...obj, ...{ read: false } });
|
|
3703
3702
|
|
|
3704
|
-
await
|
|
3703
|
+
await db_ms.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
|
|
3705
3704
|
|
|
3706
3705
|
let out_conversation_item_obj = {
|
|
3707
3706
|
_id: await _common.xuda_get_uuid('chat_conversation_item'),
|
|
@@ -3720,7 +3719,7 @@ const contact_chat_conversation = async function (req, job_id, headers) {
|
|
|
3720
3719
|
role: 'user',
|
|
3721
3720
|
};
|
|
3722
3721
|
|
|
3723
|
-
const save_ret = await
|
|
3722
|
+
const save_ret = await db_ms.save_app_couch_doc(sender_app_id, out_conversation_item_obj);
|
|
3724
3723
|
|
|
3725
3724
|
update_conversation_mood_level(uid, conversation_id, prompt, uid, receiver_contact_doc.contact_uid, conversation_doc.reference_type === 'contacts', account_profile_info);
|
|
3726
3725
|
|
|
@@ -3734,8 +3733,8 @@ const chat_note = async function (req, job_id, headers) {
|
|
|
3734
3733
|
try {
|
|
3735
3734
|
const conversation_id = conversation_doc._id;
|
|
3736
3735
|
|
|
3737
|
-
const sender_app_id = account_profile_info.app_id; //await
|
|
3738
|
-
let sender_conversation_doc = await
|
|
3736
|
+
const sender_app_id = account_profile_info.app_id; //await get_account_default_project_id(uid);
|
|
3737
|
+
let sender_conversation_doc = await db_ms.get_app_couch_doc_native(sender_app_id, conversation_id);
|
|
3739
3738
|
|
|
3740
3739
|
await attachment_handler(uid, sender_app_id, conversation_id, attachments, account_profile_info);
|
|
3741
3740
|
let item;
|
|
@@ -3758,7 +3757,7 @@ const chat_note = async function (req, job_id, headers) {
|
|
|
3758
3757
|
// let obj = { id: item.data[0].id, ts: Date.now(), uid, read: true, conversation_type: 'note' };
|
|
3759
3758
|
|
|
3760
3759
|
// sender_conversation_doc.messages.push(obj);
|
|
3761
|
-
// await
|
|
3760
|
+
// await db_ms.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
|
|
3762
3761
|
|
|
3763
3762
|
let out_conversation_item_obj = {
|
|
3764
3763
|
_id: await _common.xuda_get_uuid('chat_conversation_item'),
|
|
@@ -3779,9 +3778,9 @@ const chat_note = async function (req, job_id, headers) {
|
|
|
3779
3778
|
rtl: _common.detectRTL(body),
|
|
3780
3779
|
};
|
|
3781
3780
|
|
|
3782
|
-
const save_ret = await
|
|
3781
|
+
const save_ret = await db_ms.save_app_couch_doc(sender_app_id, out_conversation_item_obj);
|
|
3783
3782
|
|
|
3784
|
-
// await
|
|
3783
|
+
// await db_ms.save_app_couch_doc_native(sender_app_id, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', ts: obj.ts, uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, body, reference_id: conversation_doc.reference_id });
|
|
3785
3784
|
|
|
3786
3785
|
return save_ret; //{ code: 15, data: item };
|
|
3787
3786
|
} catch (err) {
|
|
@@ -3801,9 +3800,9 @@ const chat_email = async function (req, job_id, headers) {
|
|
|
3801
3800
|
const conversation_id = conversation_doc._id;
|
|
3802
3801
|
const sender_app_id = account_profile_info.app_id;
|
|
3803
3802
|
|
|
3804
|
-
let email_account_doc = await
|
|
3803
|
+
let email_account_doc = await db_ms.get_app_couch_doc_native(sender_app_id, account_profile_info.account_profile_obj?.email_account_id);
|
|
3805
3804
|
|
|
3806
|
-
let sender_conversation_doc = await
|
|
3805
|
+
let sender_conversation_doc = await db_ms.get_app_couch_doc_native(sender_app_id, conversation_id);
|
|
3807
3806
|
|
|
3808
3807
|
if (sender_conversation_doc.reference_type !== 'contacts') {
|
|
3809
3808
|
throw new Error('not an contact conversation');
|
|
@@ -3820,7 +3819,7 @@ const chat_email = async function (req, job_id, headers) {
|
|
|
3820
3819
|
if (!from_mailbox) {
|
|
3821
3820
|
// get last email
|
|
3822
3821
|
|
|
3823
|
-
const chat_conversation_item = await
|
|
3822
|
+
const chat_conversation_item = await db_ms.find_app_couch_query(account_profile_info.app_id, {
|
|
3824
3823
|
selector: {
|
|
3825
3824
|
docType: 'chat_conversation_item',
|
|
3826
3825
|
conversation_type: 'email',
|
|
@@ -3883,7 +3882,7 @@ const chat_email = async function (req, job_id, headers) {
|
|
|
3883
3882
|
// let obj = { id: item.data[0].id, ts: Date.now(), uid, read: true, conversation_type: 'email' };
|
|
3884
3883
|
|
|
3885
3884
|
// sender_conversation_doc.messages.push(obj);
|
|
3886
|
-
await
|
|
3885
|
+
await db_ms.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
|
|
3887
3886
|
|
|
3888
3887
|
let out_conversation_item_obj = {
|
|
3889
3888
|
_id: await _common.xuda_get_uuid('chat_conversation_item'),
|
|
@@ -3907,8 +3906,8 @@ const chat_email = async function (req, job_id, headers) {
|
|
|
3907
3906
|
process_stat: perform_ai_execution ? 'full' : 'partial',
|
|
3908
3907
|
};
|
|
3909
3908
|
|
|
3910
|
-
const save_ret = await
|
|
3911
|
-
// const save_ret = await
|
|
3909
|
+
const save_ret = await db_ms.save_app_couch_doc(sender_app_id, out_conversation_item_obj);
|
|
3910
|
+
// const save_ret = await db_ms.save_app_couch_doc_native(sender_app_id, {
|
|
3912
3911
|
// _id: obj.id,
|
|
3913
3912
|
// stat: 3,
|
|
3914
3913
|
// docType: 'chat_conversation_item',
|
|
@@ -3956,7 +3955,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
3956
3955
|
direction: 'out',
|
|
3957
3956
|
role: 'user',
|
|
3958
3957
|
};
|
|
3959
|
-
await
|
|
3958
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_obj);
|
|
3960
3959
|
|
|
3961
3960
|
// const { account_profile_info } = conversation_doc;
|
|
3962
3961
|
const emitToDashboard = (type, content) => {
|
|
@@ -3993,7 +3992,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
3993
3992
|
};
|
|
3994
3993
|
|
|
3995
3994
|
try {
|
|
3996
|
-
const app_id = await
|
|
3995
|
+
const app_id = await get_account_default_project_id(uid);
|
|
3997
3996
|
const app_obj = await get_app_obj(account_profile_info.app_id);
|
|
3998
3997
|
const userName = await account_ms.get_user_name(uid);
|
|
3999
3998
|
const account_info = (await get_account_name({ uid })).data;
|
|
@@ -4031,13 +4030,13 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4031
4030
|
await _utils.delay(500);
|
|
4032
4031
|
await update_job('initiating conversation');
|
|
4033
4032
|
|
|
4034
|
-
// let conversation_doc = await
|
|
4033
|
+
// let conversation_doc = await db_ms.get_app_couch_doc_native(app_id, conversation_id);
|
|
4035
4034
|
const reference_type = conversation_doc.reference_type;
|
|
4036
4035
|
const reference_id = conversation_doc.reference_id;
|
|
4037
4036
|
|
|
4038
4037
|
conversation_doc.stat = 2;
|
|
4039
4038
|
conversation_doc.ts = Date.now();
|
|
4040
|
-
await
|
|
4039
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
4041
4040
|
|
|
4042
4041
|
await update_job('analyzing request');
|
|
4043
4042
|
|
|
@@ -4150,16 +4149,16 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4150
4149
|
try {
|
|
4151
4150
|
let ai_agent_doc;
|
|
4152
4151
|
try {
|
|
4153
|
-
ai_agent_doc = await
|
|
4152
|
+
ai_agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
|
|
4154
4153
|
if (ai_agent_doc.studio_meta.shared_from_uid) {
|
|
4155
4154
|
const reference_doc = _.cloneDeep(ai_agent_doc);
|
|
4156
|
-
const app_id = await
|
|
4157
|
-
ai_agent_doc = await
|
|
4155
|
+
const app_id = await get_account_default_project_id(ai_agent_doc.studio_meta.shared_from_uid);
|
|
4156
|
+
ai_agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, ai_agent_doc.studio_meta.share_item_id);
|
|
4158
4157
|
ai_agent_doc.reference_doc = reference_doc;
|
|
4159
4158
|
} else if (ai_agent_doc.studio_meta.installed_from_uid) {
|
|
4160
4159
|
const reference_doc = _.cloneDeep(ai_agent_doc);
|
|
4161
|
-
const app_id = await
|
|
4162
|
-
ai_agent_doc = await
|
|
4160
|
+
const app_id = await get_account_default_project_id(ai_agent_doc.studio_meta.installed_from_uid);
|
|
4161
|
+
ai_agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, ai_agent_doc.studio_meta.share_item_id);
|
|
4163
4162
|
ai_agent_doc.reference_doc = reference_doc;
|
|
4164
4163
|
}
|
|
4165
4164
|
} catch (err) {
|
|
@@ -4408,7 +4407,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4408
4407
|
opt.selector._id = val.ai_agent_id;
|
|
4409
4408
|
}
|
|
4410
4409
|
|
|
4411
|
-
const user_agents = await
|
|
4410
|
+
const user_agents = await db_ms.find_app_couch_query(ai_agent_doc?.reference_doc?.studio_meta?.shared_from_app_id || ai_agent_doc?.reference_doc?.studio_meta?.installed_from_app_id || app_id, opt);
|
|
4412
4411
|
for (const agent_doc of user_agents.docs) {
|
|
4413
4412
|
const agent = new Agent({
|
|
4414
4413
|
name: agent_doc.agent_name.substring(0, 60),
|
|
@@ -4497,9 +4496,9 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4497
4496
|
|
|
4498
4497
|
const set_ts_to_agent = async function () {
|
|
4499
4498
|
try {
|
|
4500
|
-
let agent_doc = await
|
|
4499
|
+
let agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, reference_id);
|
|
4501
4500
|
agent_doc.ts = Date.now();
|
|
4502
|
-
await
|
|
4501
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, agent_doc);
|
|
4503
4502
|
} catch (err) {}
|
|
4504
4503
|
};
|
|
4505
4504
|
|
|
@@ -4545,7 +4544,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4545
4544
|
const done = async function (output) {
|
|
4546
4545
|
try {
|
|
4547
4546
|
// const obj = { id: output.state._lastTurnResponse.responseId, ts: Date.now(), ai_agent_id: output.state._currentAgent.name, attachments, conversation_type: 'ai_chat' };
|
|
4548
|
-
conversation_doc = await
|
|
4547
|
+
conversation_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
4549
4548
|
|
|
4550
4549
|
conversation_doc.ts = Date.now();
|
|
4551
4550
|
conversation_doc.stat = 3;
|
|
@@ -4559,7 +4558,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4559
4558
|
outputTokens += item.usage.outputTokens;
|
|
4560
4559
|
}
|
|
4561
4560
|
|
|
4562
|
-
await
|
|
4561
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
4563
4562
|
|
|
4564
4563
|
// let conversation_item_obj = {
|
|
4565
4564
|
// _id: obj.id,
|
|
@@ -4578,7 +4577,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4578
4577
|
// direction: 'out',
|
|
4579
4578
|
// role: 'user',
|
|
4580
4579
|
// };
|
|
4581
|
-
// await
|
|
4580
|
+
// await db_ms.save_app_couch_doc_native(account_profile_info.app_id, conversation_item_obj);
|
|
4582
4581
|
|
|
4583
4582
|
let in_conversation_item_obj = {
|
|
4584
4583
|
_id: await _common.xuda_get_uuid('chat_conversation_item'),
|
|
@@ -4597,16 +4596,16 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4597
4596
|
role: 'assistant',
|
|
4598
4597
|
ai_agent_id: output.state._currentAgent.name,
|
|
4599
4598
|
};
|
|
4600
|
-
await
|
|
4599
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, in_conversation_item_obj);
|
|
4601
4600
|
|
|
4602
4601
|
debugger;
|
|
4603
4602
|
|
|
4604
4603
|
let conversation_items = await client.conversations.items.list(conversation_doc.reference_conversation_id, { order: 'asc', after: last_conversation_item });
|
|
4605
4604
|
|
|
4606
|
-
let out_conversation_item_doc = await
|
|
4605
|
+
let out_conversation_item_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_obj._id);
|
|
4607
4606
|
// out_conversation_item_doc.stat = 3;
|
|
4608
4607
|
out_conversation_item_doc.conversation_item_reference_id = conversation_items?.data?.[0]?.id;
|
|
4609
|
-
await
|
|
4608
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_doc);
|
|
4610
4609
|
|
|
4611
4610
|
account_ms.record_ai_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: in_conversation_item_obj.ai_agent_id, item_id: in_conversation_item_obj._id }, account_profile_info);
|
|
4612
4611
|
// if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
|
|
@@ -4804,7 +4803,7 @@ const run_plugin = async function (app_id, uid, plugin_name, method, prop_data,
|
|
|
4804
4803
|
|
|
4805
4804
|
console.log('Testing plugin with:', { app_id, uid });
|
|
4806
4805
|
|
|
4807
|
-
const couch_ret = await
|
|
4806
|
+
const couch_ret = await db_ms.get_app_couch_nano(app_id);
|
|
4808
4807
|
|
|
4809
4808
|
const couch = couch_ret.data.couch;
|
|
4810
4809
|
try {
|
|
@@ -4812,7 +4811,7 @@ const run_plugin = async function (app_id, uid, plugin_name, method, prop_data,
|
|
|
4812
4811
|
|
|
4813
4812
|
let plugin_doc;
|
|
4814
4813
|
try {
|
|
4815
|
-
plugin_doc = await
|
|
4814
|
+
plugin_doc = await db_ms.get_app_couch_doc_native(app_id, plugin_name);
|
|
4816
4815
|
} catch (error) {
|
|
4817
4816
|
throw new Error(`plugin_doc ${plugin_name} not found`);
|
|
4818
4817
|
}
|
|
@@ -4930,7 +4929,7 @@ const get_plugin_tool = async function (app_id, uid, plugin_name, method, prop_d
|
|
|
4930
4929
|
return data_obj;
|
|
4931
4930
|
};
|
|
4932
4931
|
|
|
4933
|
-
const couch_ret = await
|
|
4932
|
+
const couch_ret = await db_ms.get_app_couch_nano(app_id);
|
|
4934
4933
|
|
|
4935
4934
|
const couch = couch_ret.data.couch;
|
|
4936
4935
|
try {
|
|
@@ -4938,7 +4937,7 @@ const get_plugin_tool = async function (app_id, uid, plugin_name, method, prop_d
|
|
|
4938
4937
|
|
|
4939
4938
|
let plugin_doc;
|
|
4940
4939
|
try {
|
|
4941
|
-
plugin_doc = await
|
|
4940
|
+
plugin_doc = await db_ms.get_app_couch_doc_native(app_id, plugin_name);
|
|
4942
4941
|
} catch (error) {
|
|
4943
4942
|
throw new Error(`plugin_doc ${plugin_name} not found`);
|
|
4944
4943
|
}
|
|
@@ -5110,7 +5109,7 @@ export const create_avatar = async function (req, job_id, headers) {
|
|
|
5110
5109
|
|
|
5111
5110
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
5112
5111
|
|
|
5113
|
-
const account_obj = await
|
|
5112
|
+
const account_obj = await db_ms.get_couch_doc_native('xuda_accounts', uid);
|
|
5114
5113
|
const account_info = account_obj.account_info;
|
|
5115
5114
|
if (!metadata) {
|
|
5116
5115
|
metadata = account_info;
|
|
@@ -5693,9 +5692,9 @@ export const conversation_actions = async function (req, job_id, headers) {
|
|
|
5693
5692
|
|
|
5694
5693
|
// const update_profile_avatar_status = async function (uid, stat) {
|
|
5695
5694
|
// try {
|
|
5696
|
-
// let doc = await
|
|
5695
|
+
// let doc = await db_ms.get_couch_doc_native('xuda_accounts', uid);
|
|
5697
5696
|
// doc.account_info.profile_avatar_stat = stat;
|
|
5698
|
-
// const save_ret = await
|
|
5697
|
+
// const save_ret = await db_ms.save_couch_doc_native('xuda_accounts', doc);
|
|
5699
5698
|
// } catch (err) {
|
|
5700
5699
|
// console.error(err);
|
|
5701
5700
|
// }
|
|
@@ -5743,7 +5742,7 @@ export const modify_profile_avatar = async function (req, job_id, headers) {
|
|
|
5743
5742
|
}
|
|
5744
5743
|
}
|
|
5745
5744
|
|
|
5746
|
-
const account_obj = await
|
|
5745
|
+
const account_obj = await db_ms.get_couch_doc_native('xuda_accounts', uid);
|
|
5747
5746
|
const account_info = account_obj.account_info;
|
|
5748
5747
|
if (!metadata) {
|
|
5749
5748
|
metadata = account_info;
|
|
@@ -5760,7 +5759,7 @@ export const get_ai_workspace_pending_counts = async function (req, job_id, head
|
|
|
5760
5759
|
const { uid } = req;
|
|
5761
5760
|
|
|
5762
5761
|
try {
|
|
5763
|
-
const workspace_pending_counts_ret = await
|
|
5762
|
+
const workspace_pending_counts_ret = await db_ms.get_couch_view('xuda_team', 'pending_workspace_requests_count', {
|
|
5764
5763
|
startkey: [uid, ''],
|
|
5765
5764
|
endkey: [uid, 'zzzz'],
|
|
5766
5765
|
reduce: true,
|
|
@@ -5821,8 +5820,8 @@ const create_ai_agent_image = async function (req, job_id, headers) {
|
|
|
5821
5820
|
|
|
5822
5821
|
const { app_id, uid, ai_agent_id, tags } = req;
|
|
5823
5822
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
5824
|
-
const ai_agent_doc = await
|
|
5825
|
-
const account_doc = await
|
|
5823
|
+
const ai_agent_doc = await db_ms.get_app_couch_doc_native(account_profile_info.app_id, ai_agent_id);
|
|
5824
|
+
const account_doc = await db_ms.get_couch_doc_native('xuda_accounts', uid);
|
|
5826
5825
|
|
|
5827
5826
|
// faceless humanoid for business
|
|
5828
5827
|
if (account_doc.account_info.account_type === 'business') {
|
|
@@ -5964,7 +5963,7 @@ export const create_mini_app = async function (req, job_id, headers) {
|
|
|
5964
5963
|
const name = await submit_chat_gpt_prompt({ uid, prompt: `create title for the prompt return 5 words result maximum text only without options : ${prompt}`, model: 'gpt-5-nano', metadata: { prog_id: component_doc._id, func: 'create_mini_app' } }, account_profile_info);
|
|
5965
5964
|
component_doc.properties.menuName = name.data;
|
|
5966
5965
|
component_doc.properties.menuTitle = name.data;
|
|
5967
|
-
const data = await
|
|
5966
|
+
const data = await db_ms.save_app_couch_doc_native(account_profile_info.app_id, component_doc);
|
|
5968
5967
|
setTimeout(async () => {
|
|
5969
5968
|
await update_thumbnail('mini_app', component_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
5970
5969
|
}, 500);
|
|
@@ -5979,12 +5978,12 @@ export const create_mini_app = async function (req, job_id, headers) {
|
|
|
5979
5978
|
export const pin_ai_agent = async function (req, job_id, headers) {
|
|
5980
5979
|
const { uid, agent_id } = req;
|
|
5981
5980
|
try {
|
|
5982
|
-
const app_id = await
|
|
5983
|
-
const ai_agent_doc = await
|
|
5981
|
+
const app_id = await get_account_default_project_id(uid);
|
|
5982
|
+
const ai_agent_doc = await db_ms.get_app_couch_doc_native(app_id, agent_id);
|
|
5984
5983
|
|
|
5985
5984
|
ai_agent_doc.studio_meta.pinned = true;
|
|
5986
5985
|
|
|
5987
|
-
const save_ret = await
|
|
5986
|
+
const save_ret = await db_ms.save_app_couch_doc(app_id, ai_agent_doc);
|
|
5988
5987
|
|
|
5989
5988
|
ws_dashboard_ms.emit_message_to_dashboard({
|
|
5990
5989
|
service: 'ai_agent_pinned',
|
|
@@ -6003,12 +6002,12 @@ export const pin_ai_agent = async function (req, job_id, headers) {
|
|
|
6003
6002
|
export const unpin_ai_agent = async function (req, job_id, headers) {
|
|
6004
6003
|
const { uid, agent_id } = req;
|
|
6005
6004
|
try {
|
|
6006
|
-
const app_id = await
|
|
6007
|
-
const ai_agent_doc = await
|
|
6005
|
+
const app_id = await get_account_default_project_id(uid);
|
|
6006
|
+
const ai_agent_doc = await db_ms.get_app_couch_doc_native(app_id, agent_id);
|
|
6008
6007
|
|
|
6009
6008
|
ai_agent_doc.studio_meta.pinned = false;
|
|
6010
6009
|
|
|
6011
|
-
const save_ret = await
|
|
6010
|
+
const save_ret = await db_ms.save_app_couch_doc(app_id, ai_agent_doc);
|
|
6012
6011
|
|
|
6013
6012
|
ws_dashboard_ms.emit_message_to_dashboard({
|
|
6014
6013
|
service: 'ai_agent_unpinned',
|
|
@@ -6151,7 +6150,7 @@ export const add_transcript_conversation_item = async function (reference_conver
|
|
|
6151
6150
|
|
|
6152
6151
|
const attachment_handler = async function (uid, app_id, conversation_id, attachments, account_profile_info, date_created_ts) {
|
|
6153
6152
|
if (!attachments?.length) return;
|
|
6154
|
-
let conversation_doc = await
|
|
6153
|
+
let conversation_doc = await db_ms.get_app_couch_doc_native(app_id, conversation_id);
|
|
6155
6154
|
|
|
6156
6155
|
// const get_transcript = async function (filename) {
|
|
6157
6156
|
// async function streamToBuffer(fileStream) {
|
|
@@ -6313,21 +6312,21 @@ const attachment_handler = async function (uid, app_id, conversation_id, attachm
|
|
|
6313
6312
|
read: { [uid]: Date.now() },
|
|
6314
6313
|
process_stat,
|
|
6315
6314
|
};
|
|
6316
|
-
await
|
|
6315
|
+
await db_ms.save_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_obj);
|
|
6317
6316
|
system_message_items.push(out_conversation_item_obj);
|
|
6318
6317
|
}
|
|
6319
6318
|
|
|
6320
|
-
conversation_doc = await
|
|
6319
|
+
conversation_doc = await db_ms.get_app_couch_doc_native(app_id, conversation_id);
|
|
6321
6320
|
|
|
6322
6321
|
conversation_doc.ts = Date.now();
|
|
6323
6322
|
conversation_doc.stat = 2;
|
|
6324
6323
|
|
|
6325
|
-
await
|
|
6324
|
+
await db_ms.save_app_couch_doc_native(app_id, conversation_doc);
|
|
6326
6325
|
return system_message_items;
|
|
6327
6326
|
};
|
|
6328
6327
|
|
|
6329
6328
|
export const is_spam_email = async function (uid, email, subject, account_profile_info) {
|
|
6330
|
-
const spam_whitelists = await
|
|
6329
|
+
const spam_whitelists = await db_ms.find_couch_query('xuda_accounts', {
|
|
6331
6330
|
selector: {
|
|
6332
6331
|
docType: 'spam_whitelist',
|
|
6333
6332
|
email,
|
|
@@ -6549,7 +6548,7 @@ const get_chat_picture_cache = async function (uid, docType, key) {
|
|
|
6549
6548
|
|
|
6550
6549
|
if (words.length < 3) {
|
|
6551
6550
|
// Direct exact match for short names
|
|
6552
|
-
const ret = await
|
|
6551
|
+
const ret = await db_ms.find_couch_query('xuda_cache', {
|
|
6553
6552
|
selector: { docType, key: key.toLowerCase().trim() },
|
|
6554
6553
|
limit: 1,
|
|
6555
6554
|
});
|
|
@@ -6580,7 +6579,7 @@ const get_chat_picture_cache = async function (uid, docType, key) {
|
|
|
6580
6579
|
limit: 1,
|
|
6581
6580
|
};
|
|
6582
6581
|
|
|
6583
|
-
const ret = await
|
|
6582
|
+
const ret = await db_ms.find_couch_query('xuda_cache', query);
|
|
6584
6583
|
|
|
6585
6584
|
if (ret.docs.length > 0) {
|
|
6586
6585
|
account_ms.save_cache_hit(ret.docs[0]._id);
|
|
@@ -10713,11 +10712,11 @@ export const open_ai_alive_check = async function () {};
|
|
|
10713
10712
|
|
|
10714
10713
|
// let account_profile_info;
|
|
10715
10714
|
// try {
|
|
10716
|
-
// account_profile_info = await
|
|
10715
|
+
// account_profile_info = await db_ms.get_memcached_doc(key);
|
|
10717
10716
|
// } catch (error) {
|
|
10718
10717
|
// try {
|
|
10719
10718
|
// account_profile_info = await account_ms.get_active_account_profile_info(uid);
|
|
10720
|
-
//
|
|
10719
|
+
// db_ms.set_memcached_doc(key, account_profile_info);
|
|
10721
10720
|
// } catch (error) {}
|
|
10722
10721
|
// }
|
|
10723
10722
|
|