@xuda.io/ai_module 1.1.4595 → 1.1.4597

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
@@ -4486,7 +4486,7 @@ const chat_email = async function (req, job_id, headers) {
4486
4486
  if (perform_ai_execution) {
4487
4487
  await attachment_handler(uid, sender_app_id, conversation_id, attachments, account_profile_info);
4488
4488
  }
4489
- const item = await client.conversations.items.create(conversation_id, {
4489
+ const item = await client.conversations.items.create(conversation_doc.reference_conversation_id, {
4490
4490
  items: [
4491
4491
  {
4492
4492
  type: 'message',
@@ -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: 'out',
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.4595",
3
+ "version": "1.1.4597",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",