@xuda.io/ai_module 1.1.4596 → 1.1.4598

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.
Files changed (2) hide show
  1. package/index.mjs +31 -10
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4412,7 +4412,7 @@ const chat_note = async function (req, job_id, headers) {
4412
4412
  };
4413
4413
 
4414
4414
  const chat_email = async function (req, job_id, headers) {
4415
- const { profile_id, uid, email_id, perform_ai_execution = true, from_mailbox, _thread_reentry } = req;
4415
+ const { profile_id, uid, email_id, perform_ai_execution = true, from_mailbox, _thread_reentry, email_direction } = req;
4416
4416
  const account_profile_info = await account_module.get_active_account_profile_info(uid, profile_id);
4417
4417
  let { prompt: body, conversation_doc, attachments = [], ai_agents } = req;
4418
4418
  try {
@@ -4501,22 +4501,43 @@ const chat_email = async function (req, job_id, headers) {
4501
4501
  sender_conversation_doc.messages.push(obj);
4502
4502
  await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
4503
4503
 
4504
- const save_ret = await db_module.save_app_couch_doc_native(sender_app_id, {
4505
- _id: obj.id,
4504
+ let out_conversation_item_obj = {
4505
+ _id: await _common.xuda_get_uuid('chat_conversation_item'),
4506
4506
  stat: 3,
4507
4507
  docType: 'chat_conversation_item',
4508
- sent_email_result,
4509
- ts: obj.ts,
4510
4508
  uid,
4511
- conversation_type: obj.conversation_type,
4512
- date_created_ts: obj.ts,
4509
+ conversation_type: 'email',
4510
+ type: 'email',
4511
+ date_created_ts: Date.now(),
4512
+ ts: Date.now(),
4513
4513
  conversation_id,
4514
- body,
4514
+ text: body,
4515
+ reference_id: conversation_doc.reference_id,
4516
+ conversation_item_reference_id: item.data[0].id,
4517
+ direction: email_direction,
4518
+ role: 'user',
4515
4519
  email_id,
4516
4520
  subject,
4517
4521
  last_email_item_id: last_email_item?._id,
4518
- reference_id: conversation_doc.reference_id,
4519
- });
4522
+ };
4523
+
4524
+ const save_ret = await db_module.save_app_couch_doc_native(sender_app_id, out_conversation_item_obj);
4525
+ // const save_ret = await db_module.save_app_couch_doc_native(sender_app_id, {
4526
+ // _id: obj.id,
4527
+ // stat: 3,
4528
+ // docType: 'chat_conversation_item',
4529
+ // sent_email_result,
4530
+ // ts: obj.ts,
4531
+ // uid,
4532
+ // conversation_type: obj.conversation_type,
4533
+ // date_created_ts: obj.ts,
4534
+ // conversation_id,
4535
+ // body,
4536
+ // email_id,
4537
+ // subject,
4538
+ // last_email_item_id: last_email_item?._id,
4539
+ // reference_id: conversation_doc.reference_id,
4540
+ // });
4520
4541
 
4521
4542
  return save_ret;
4522
4543
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4596",
3
+ "version": "1.1.4598",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",