@xuda.io/ai_module 1.1.4605 → 1.1.4607

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 +26 -6
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4351,11 +4351,10 @@ const contact_chat_conversation = async function (req, job_id, headers) {
4351
4351
  let receiver_conversation_doc = await db_module.get_app_couch_doc_native(receiver_app_id, conversation_id);
4352
4352
 
4353
4353
  const sender_contact_doc = await account_module.get_contact_info(uid, null, conversation_doc.reference_id);
4354
- // const sender_app_id = await account_module.get_account_default_project_id(uid);
4355
4354
  const sender_app_id = account_profile_info.app_id;
4356
4355
  let sender_conversation_doc = await db_module.get_app_couch_doc_native(sender_app_id, conversation_id);
4357
4356
 
4358
- const item = await client.conversations.items.create(conversation_id, {
4357
+ const item = await client.conversations.items.create(conversation_doc.reference_conversation_id, {
4359
4358
  items: [
4360
4359
  {
4361
4360
  type: 'message',
@@ -4365,12 +4364,33 @@ const contact_chat_conversation = async function (req, job_id, headers) {
4365
4364
  ],
4366
4365
  });
4367
4366
 
4368
- const obj = { id: item.data[0].id, ts: Date.now(), uid, read: true, conversation_type: 'chat' };
4369
- receiver_conversation_doc.messages.push(obj);
4367
+ // const obj = { id: item.data[0].id, ts: Date.now(), uid, read: true, conversation_type: 'chat' };
4368
+ // receiver_conversation_doc.messages.push(obj);
4369
+
4370
4370
  await db_module.save_app_couch_doc_native(receiver_app_id, receiver_conversation_doc);
4371
- sender_conversation_doc.messages.push({ ...obj, ...{ read: false } });
4371
+ // sender_conversation_doc.messages.push({ ...obj, ...{ read: false } });
4372
+
4372
4373
  await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
4373
4374
 
4375
+ let out_conversation_item_obj = {
4376
+ _id: await _common.xuda_get_uuid('chat_conversation_item'),
4377
+ stat: 3,
4378
+ docType: 'chat_conversation_item',
4379
+ uid,
4380
+ conversation_type: 'note',
4381
+ type: 'note',
4382
+ date_created_ts: Date.now(),
4383
+ ts: Date.now(),
4384
+ conversation_id,
4385
+ text: body,
4386
+ reference_id: conversation_doc.reference_id,
4387
+ conversation_item_reference_id: item.data[0].id,
4388
+ direction: 'out',
4389
+ role: 'user',
4390
+ };
4391
+
4392
+ const save_ret = await db_module.save_app_couch_doc(sender_app_id, out_conversation_item_obj);
4393
+
4374
4394
  update_conversation_mood_level(uid, conversation_id, prompt, uid, receiver_contact_doc.contact_uid, conversation_doc.reference_type === 'contacts', account_profile_info);
4375
4395
 
4376
4396
  return { code: 15, data: item };
@@ -4424,7 +4444,7 @@ const chat_note = async function (req, job_id, headers) {
4424
4444
 
4425
4445
  // await db_module.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 });
4426
4446
 
4427
- return { code: 15, data: item };
4447
+ return save_ret; //{ code: 15, data: item };
4428
4448
  } catch (err) {
4429
4449
  return { code: -15, data: err.message };
4430
4450
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4605",
3
+ "version": "1.1.4607",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",