@xuda.io/ai_module 1.1.4675 → 1.1.4677
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 +38 -36
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4309,6 +4309,43 @@ export const create_conversation = async function (req, job_id, headers) {
|
|
|
4309
4309
|
// }
|
|
4310
4310
|
// }
|
|
4311
4311
|
// }
|
|
4312
|
+
|
|
4313
|
+
if (conversation_doc.reference_type === 'contacts') {
|
|
4314
|
+
if (recipient_uid) {
|
|
4315
|
+
// valid for chat conversation
|
|
4316
|
+
// write conversation to host after thumbnail update
|
|
4317
|
+
// get sender conversation
|
|
4318
|
+
|
|
4319
|
+
const conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
4320
|
+
|
|
4321
|
+
const recipient_account_profile_info = await account_module.get_active_account_profile_info(recipient_uid);
|
|
4322
|
+
let recipient_conversation_doc = await db_module.get_app_couch_doc_native(recipient_account_profile_info.app_id, conversation_doc._id);
|
|
4323
|
+
recipient_conversation_doc.title = conversation_doc.title;
|
|
4324
|
+
|
|
4325
|
+
recipient_conversation_doc.thumbnail_request_ts = conversation_doc.thumbnail_request_ts;
|
|
4326
|
+
recipient_conversation_doc.chat_image = conversation_doc.chat_image;
|
|
4327
|
+
await db_module.save_app_couch_doc_native(recipient_account_profile_info.app_id, recipient_conversation_doc);
|
|
4328
|
+
|
|
4329
|
+
await update_conversation_mood_level(
|
|
4330
|
+
uid,
|
|
4331
|
+
[
|
|
4332
|
+
{ uid: account_profile_info.uid, contact_id: reference_id },
|
|
4333
|
+
{ uid: recipient_uid, contact_id: recipient_contact_id },
|
|
4334
|
+
],
|
|
4335
|
+
conversation_doc._id,
|
|
4336
|
+
prompt,
|
|
4337
|
+
uid,
|
|
4338
|
+
recipient_uid,
|
|
4339
|
+
true,
|
|
4340
|
+
account_profile_info,
|
|
4341
|
+
);
|
|
4342
|
+
} else {
|
|
4343
|
+
// other cases rather then chat
|
|
4344
|
+
if (perform_ai_execution) {
|
|
4345
|
+
await update_conversation_mood_level(uid, [{ uid: account_profile_info.uid, contact_id: reference_id }], conversation_doc._id, prompt, null, reference_id, conversation_doc.reference_type === 'contacts', account_profile_info);
|
|
4346
|
+
}
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4312
4349
|
}, 1000);
|
|
4313
4350
|
|
|
4314
4351
|
return save_ret;
|
|
@@ -4371,42 +4408,6 @@ const process_conversation = async function (uid, conversation_id, account_profi
|
|
|
4371
4408
|
if (category_info.category) {
|
|
4372
4409
|
await update_thumbnail('conversation_category', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
4373
4410
|
}
|
|
4374
|
-
if (conversation_doc.reference_type === 'contacts') {
|
|
4375
|
-
if (recipient_uid) {
|
|
4376
|
-
// valid for chat conversation
|
|
4377
|
-
// write conversation to host after thumbnail update
|
|
4378
|
-
// get sender conversation
|
|
4379
|
-
|
|
4380
|
-
const conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
4381
|
-
|
|
4382
|
-
const recipient_account_profile_info = await account_module.get_active_account_profile_info(recipient_uid);
|
|
4383
|
-
let recipient_conversation_doc = await db_module.get_app_couch_doc_native(recipient_account_profile_info.app_id, conversation_doc._id);
|
|
4384
|
-
recipient_conversation_doc.title = conversation_doc.title;
|
|
4385
|
-
|
|
4386
|
-
recipient_conversation_doc.thumbnail_request_ts = conversation_doc.thumbnail_request_ts;
|
|
4387
|
-
recipient_conversation_doc.chat_image = conversation_doc.chat_image;
|
|
4388
|
-
await db_module.save_app_couch_doc_native(recipient_account_profile_info.app_id, recipient_conversation_doc);
|
|
4389
|
-
|
|
4390
|
-
await update_conversation_mood_level(
|
|
4391
|
-
uid,
|
|
4392
|
-
[
|
|
4393
|
-
{ uid: account_profile_info.uid, contact_id: reference_id },
|
|
4394
|
-
{ uid: recipient_uid, contact_id: recipient_contact_id },
|
|
4395
|
-
],
|
|
4396
|
-
conversation_doc._id,
|
|
4397
|
-
prompt,
|
|
4398
|
-
uid,
|
|
4399
|
-
recipient_uid,
|
|
4400
|
-
true,
|
|
4401
|
-
account_profile_info,
|
|
4402
|
-
);
|
|
4403
|
-
} else {
|
|
4404
|
-
// other cases rather then chat
|
|
4405
|
-
if (perform_ai_execution) {
|
|
4406
|
-
await update_conversation_mood_level(uid, [{ uid: account_profile_info.uid, contact_id: reference_id }], conversation_doc._id, prompt, null, reference_id, conversation_doc.reference_type === 'contacts', account_profile_info);
|
|
4407
|
-
}
|
|
4408
|
-
}
|
|
4409
|
-
}
|
|
4410
4411
|
};
|
|
4411
4412
|
|
|
4412
4413
|
const contactGuardrailAgent = new Agent({
|
|
@@ -6729,6 +6730,7 @@ const attachment_handler = async function (uid, app_id, conversation_id, attachm
|
|
|
6729
6730
|
direction: 'out',
|
|
6730
6731
|
role: 'user',
|
|
6731
6732
|
conversation_item_reference_id: items.last_id,
|
|
6733
|
+
file,
|
|
6732
6734
|
};
|
|
6733
6735
|
await db_module.save_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_obj);
|
|
6734
6736
|
system_message_items.push(out_conversation_item_obj);
|