@xuda.io/ai_module 1.1.4260 → 1.1.4262

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 +10 -5
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4181,7 +4181,12 @@ export const create_conversation = async function (req, job_id, headers) {
4181
4181
  // reference_id is the contact id
4182
4182
  receiver_contact_id = reference_id;
4183
4183
  receiver_contact_doc = await account_module.get_contact_info(uid, null, receiver_contact_id);
4184
+
4184
4185
  if (conversation_type === 'chat') {
4186
+ if (!receiver_contact_doc?.contact_uid) {
4187
+ throw new Error('chat conversation to non user recipient is not allowed');
4188
+ }
4189
+
4185
4190
  if (receiver_contact_doc?.connection_stat !== 3) {
4186
4191
  throw new Error('chat conversation to the recipient is not available');
4187
4192
  }
@@ -4237,10 +4242,10 @@ export const create_conversation = async function (req, job_id, headers) {
4237
4242
  receiver_conversation_doc.chat_image = sender_conversation_doc.chat_image;
4238
4243
  await db_module.save_app_couch_doc_native(receiver_app_id, receiver_conversation_doc);
4239
4244
 
4240
- await update_conversation_mood_level(conversation_obj.id, prompt, uid, contact_uid_chat_conversation, true, account_profile_info);
4245
+ await update_conversation_mood_level(uid, conversation_obj.id, prompt, uid, contact_uid_chat_conversation, true, account_profile_info);
4241
4246
  } else {
4242
4247
  // other cases rather then chat
4243
- await update_conversation_mood_level(conversation_obj.id, prompt, null, receiver_contact_doc.contact_uid, conversation_doc.reference_type === 'contacts', account_profile_info);
4248
+ await update_conversation_mood_level(uid, conversation_obj.id, prompt, null, receiver_contact_doc.contact_uid, conversation_doc.reference_type === 'contacts', account_profile_info);
4244
4249
  }
4245
4250
  }
4246
4251
  }, 1000);
@@ -4333,11 +4338,11 @@ export const submit_chat_conversation = async function (req, job_id, headers) {
4333
4338
  }
4334
4339
  };
4335
4340
 
4336
- const update_conversation_mood_level = async function (conversation_id, prompt, sender_uid, receiver_uid, update_contact, account_profile_info) {
4341
+ const update_conversation_mood_level = async function (uid, conversation_id, prompt, sender_uid, receiver_uid, update_contact, account_profile_info) {
4337
4342
  try {
4338
4343
  // analyze the mood of the conversation
4339
4344
  const mood_level = await submit_chat_gpt_prompt({
4340
- uid: sender_uid,
4345
+ uid,
4341
4346
  prompt: `analyze the mood of the following prompt: ${prompt}. return -2: very negative,-1: negative 0:natural 1:positive 2: very positive.`,
4342
4347
  model: 'gpt-5-nano',
4343
4348
  response_format: z.object({
@@ -4449,7 +4454,7 @@ const contact_chat_conversation = async function (req, job_id, headers) {
4449
4454
  sender_conversation_doc.messages.push({ ...obj, ...{ read: false } });
4450
4455
  await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
4451
4456
 
4452
- update_conversation_mood_level(conversation_id, prompt, uid, receiver_contact_doc.contact_uid, conversation_doc.reference_type === 'contacts');
4457
+ update_conversation_mood_level(uid, conversation_id, prompt, uid, receiver_contact_doc.contact_uid, conversation_doc.reference_type === 'contacts');
4453
4458
 
4454
4459
  return { code: 15, data: item };
4455
4460
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4260",
3
+ "version": "1.1.4262",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",