@xuda.io/ai_module 1.1.5579 → 1.1.5581
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 +51 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2005,7 +2005,6 @@ export const get_ai_agent_info = async function (uid, job_id, headers, doc, from
|
|
|
2005
2005
|
};
|
|
2006
2006
|
|
|
2007
2007
|
const get_user_ai_agents = async function (uid) {
|
|
2008
|
-
debugger;
|
|
2009
2008
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2010
2009
|
|
|
2011
2010
|
let opt = {
|
|
@@ -2041,7 +2040,7 @@ export const get_ai_agents = async function (req, job_id, headers) {
|
|
|
2041
2040
|
skip: skip || 0,
|
|
2042
2041
|
sort: [{ ts: 'desc' }],
|
|
2043
2042
|
};
|
|
2044
|
-
|
|
2043
|
+
debugger;
|
|
2045
2044
|
if (!account_profile_info.is_main) {
|
|
2046
2045
|
opt.selector['studio_meta.account_profiles'] = { $in: [account_profile_info.account_profile_id] };
|
|
2047
2046
|
} else {
|
|
@@ -2282,8 +2281,55 @@ export const unarchive_ai_agent = async function (req) {
|
|
|
2282
2281
|
return { code: -9, data: err.message };
|
|
2283
2282
|
}
|
|
2284
2283
|
};
|
|
2284
|
+
|
|
2285
|
+
const update_agent_conversation_items_stat = async function (app_id, agent_id, stat, conversation_id) {
|
|
2286
|
+
const conversation_ids = [];
|
|
2287
|
+
|
|
2288
|
+
if (conversation_id) {
|
|
2289
|
+
conversation_ids.push(conversation_id);
|
|
2290
|
+
} else {
|
|
2291
|
+
const conversations_ret = await db_module.find_app_couch_query(app_id, {
|
|
2292
|
+
selector: {
|
|
2293
|
+
docType: 'chat_conversation',
|
|
2294
|
+
reference_id: agent_id,
|
|
2295
|
+
},
|
|
2296
|
+
fields: ['_id'],
|
|
2297
|
+
limit: 9999,
|
|
2298
|
+
});
|
|
2299
|
+
|
|
2300
|
+
conversation_ids.push(...(conversations_ret.docs || []).map((doc) => doc._id).filter(Boolean));
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
let updated = 0;
|
|
2304
|
+
const ts = Date.now();
|
|
2305
|
+
|
|
2306
|
+
for (const conversation_id of conversation_ids) {
|
|
2307
|
+
const items_ret = await db_module.find_app_couch_query(app_id, {
|
|
2308
|
+
selector: {
|
|
2309
|
+
docType: 'chat_conversation_item',
|
|
2310
|
+
conversation_id,
|
|
2311
|
+
stat: { $lt: 4 },
|
|
2312
|
+
},
|
|
2313
|
+
limit: 9999,
|
|
2314
|
+
});
|
|
2315
|
+
|
|
2316
|
+
const docs = (items_ret.docs || []).map((doc) => ({
|
|
2317
|
+
...doc,
|
|
2318
|
+
stat,
|
|
2319
|
+
ts,
|
|
2320
|
+
}));
|
|
2321
|
+
|
|
2322
|
+
if (docs.length) {
|
|
2323
|
+
await db_module.sava_app_couch_bulk_docs(app_id, docs);
|
|
2324
|
+
updated += docs.length;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
return updated;
|
|
2329
|
+
};
|
|
2330
|
+
|
|
2285
2331
|
export const archive_ai_agent = async function (req) {
|
|
2286
|
-
let { agent_id, uid } = req;
|
|
2332
|
+
let { agent_id, uid, conversation_id } = req;
|
|
2287
2333
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2288
2334
|
|
|
2289
2335
|
try {
|
|
@@ -2298,8 +2344,9 @@ export const archive_ai_agent = async function (req) {
|
|
|
2298
2344
|
agent_doc.stat = 5;
|
|
2299
2345
|
agent_doc.ts = Date.now();
|
|
2300
2346
|
const save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, agent_doc);
|
|
2347
|
+
const updated_conversation_items = await update_agent_conversation_items_stat(account_profile_info.app_id, agent_id, 5, conversation_id);
|
|
2301
2348
|
|
|
2302
|
-
return save_ret;
|
|
2349
|
+
return { code: 1, data: { save_ret, updated_conversation_items } };
|
|
2303
2350
|
} catch (err) {
|
|
2304
2351
|
return { code: -9, data: err.message };
|
|
2305
2352
|
}
|