@xuda.io/ai_module 1.1.4662 → 1.1.4664

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 +83 -80
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4205,89 +4205,92 @@ export const create_conversation = async function (req, job_id, headers) {
4205
4205
  const save_ret = await db_module.save_app_couch_doc(app_id, { ...conversation_doc, ...{ uid: recipient_uid, reference_id: recipient_contact_id } });
4206
4206
  }
4207
4207
 
4208
- // setTimeout(async () => {
4209
- // // Ask GPT for title
4210
- // if (conversation_type !== 'email') {
4211
- // if (prompt.split(' ').length > 10) {
4212
- // const title = await submit_chat_gpt_prompt({ uid, prompt: `create title for the prompt return 5 words result maximum text only without options : ${prompt}`, model: 'gpt-5-nano', metadata: { conversation_id: conversation_doc._id, func: 'create_conversation' }, account_profile_info });
4213
-
4214
- // conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
4215
- // conversation_doc.title = title.data;
4216
-
4217
- // await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
4218
- // }
4219
- // }
4220
- // /// categorize prompt
4221
- // let category_info = {};
4222
- // switch (conversation_type) {
4223
- // case 'ai': {
4224
- // category_info = await categorize_ai_prompt(uid, prompt, account_profile_info);
4225
- // break;
4226
- // }
4227
-
4228
- // case 'email': {
4229
- // category_info = await categorize_email_subject(uid, prompt, account_profile_info);
4230
- // break;
4231
- // }
4232
-
4233
- // case 'chat': {
4234
- // category_info = await categorize_text_message(uid, prompt, account_profile_info);
4235
- // break;
4236
- // }
4208
+ setTimeout(async () => {
4209
+ if (perform_ai_execution) {
4210
+ process_conversation(uid, conversation_doc._id, account_profile_info, job_id, headers);
4211
+ }
4212
+ // // Ask GPT for title
4213
+ // if (conversation_type !== 'email') {
4214
+ // if (prompt.split(' ').length > 10) {
4215
+ // const title = await submit_chat_gpt_prompt({ uid, prompt: `create title for the prompt return 5 words result maximum text only without options : ${prompt}`, model: 'gpt-5-nano', metadata: { conversation_id: conversation_doc._id, func: 'create_conversation' }, account_profile_info });
4237
4216
 
4238
- // case 'note': {
4239
- // category_info = await categorize_contact_note(uid, prompt, account_profile_info);
4240
- // break;
4241
- // }
4217
+ // conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
4218
+ // conversation_doc.title = title.data;
4242
4219
 
4243
- // default:
4244
- // break;
4245
- // }
4220
+ // await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
4221
+ // }
4222
+ // }
4223
+ // /// categorize prompt
4224
+ // let category_info = {};
4225
+ // switch (conversation_type) {
4226
+ // case 'ai': {
4227
+ // category_info = await categorize_ai_prompt(uid, prompt, account_profile_info);
4228
+ // break;
4229
+ // }
4230
+
4231
+ // case 'email': {
4232
+ // category_info = await categorize_email_subject(uid, prompt, account_profile_info);
4233
+ // break;
4234
+ // }
4235
+
4236
+ // case 'chat': {
4237
+ // category_info = await categorize_text_message(uid, prompt, account_profile_info);
4238
+ // break;
4239
+ // }
4240
+
4241
+ // case 'note': {
4242
+ // category_info = await categorize_contact_note(uid, prompt, account_profile_info);
4243
+ // break;
4244
+ // }
4245
+
4246
+ // default:
4247
+ // break;
4248
+ // }
4246
4249
 
4247
- // conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
4248
- // contact_doc.category_info = category_info;
4249
- // await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
4250
+ // conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
4251
+ // contact_doc.category_info = category_info;
4252
+ // await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
4250
4253
 
4251
- // if (perform_ai_execution) {
4252
- // // await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
4253
- // }
4254
- // if (conversation_doc.reference_type === 'contacts') {
4255
- // if (recipient_uid) {
4256
- // // valid for chat conversation
4257
- // // write conversation to host after thumbnail update
4258
- // // get sender conversation
4259
-
4260
- // const conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
4261
-
4262
- // const recipient_account_profile_info = await ac3180count_module.get_active_account_profile_info(recipient_uid);
4263
- // let recipient_conversation_doc = await db_module.get_app_couch_doc_native(recipient_account_profile_info.app_id, conversation_doc._id);
4264
- // recipient_conversation_doc.title = conversation_doc.title;
4265
-
4266
- // recipient_conversation_doc.thumbnail_request_ts = conversation_doc.thumbnail_request_ts;
4267
- // recipient_conversation_doc.chat_image = conversation_doc.chat_image;
4268
- // await db_module.save_app_couch_doc_native(recipient_account_profile_info.app_id, recipient_conversation_doc);
4269
-
4270
- // await update_conversation_mood_level(
4271
- // uid,
4272
- // [
4273
- // { uid: account_profile_info.uid, contact_id: reference_id },
4274
- // { uid: recipient_uid, contact_id: recipient_contact_id },
4275
- // ],
4276
- // conversation_doc._id,
4277
- // prompt,
4278
- // uid,
4279
- // recipient_uid,
4280
- // true,
4281
- // account_profile_info,
4282
- // );
4283
- // } else {
4284
- // // other cases rather then chat
4285
- // if (perform_ai_execution) {
4286
- // await update_conversation_mood_level(uid, [{ uid: account_profile_info.uid, contact_id: reference_id }], conversation_doc._id, prompt, null, contact_id, conversation_doc.reference_type === 'contacts', account_profile_info);
4287
- // }
4288
- // }
4289
- // }
4290
- // }, 1000);
4254
+ // if (perform_ai_execution) {
4255
+ // // await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
4256
+ // }
4257
+ // if (conversation_doc.reference_type === 'contacts') {
4258
+ // if (recipient_uid) {
4259
+ // // valid for chat conversation
4260
+ // // write conversation to host after thumbnail update
4261
+ // // get sender conversation
4262
+
4263
+ // const conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
4264
+
4265
+ // const recipient_account_profile_info = await ac3180count_module.get_active_account_profile_info(recipient_uid);
4266
+ // let recipient_conversation_doc = await db_module.get_app_couch_doc_native(recipient_account_profile_info.app_id, conversation_doc._id);
4267
+ // recipient_conversation_doc.title = conversation_doc.title;
4268
+
4269
+ // recipient_conversation_doc.thumbnail_request_ts = conversation_doc.thumbnail_request_ts;
4270
+ // recipient_conversation_doc.chat_image = conversation_doc.chat_image;
4271
+ // await db_module.save_app_couch_doc_native(recipient_account_profile_info.app_id, recipient_conversation_doc);
4272
+
4273
+ // await update_conversation_mood_level(
4274
+ // uid,
4275
+ // [
4276
+ // { uid: account_profile_info.uid, contact_id: reference_id },
4277
+ // { uid: recipient_uid, contact_id: recipient_contact_id },
4278
+ // ],
4279
+ // conversation_doc._id,
4280
+ // prompt,
4281
+ // uid,
4282
+ // recipient_uid,
4283
+ // true,
4284
+ // account_profile_info,
4285
+ // );
4286
+ // } else {
4287
+ // // other cases rather then chat
4288
+ // if (perform_ai_execution) {
4289
+ // await update_conversation_mood_level(uid, [{ uid: account_profile_info.uid, contact_id: reference_id }], conversation_doc._id, prompt, null, contact_id, conversation_doc.reference_type === 'contacts', account_profile_info);
4290
+ // }
4291
+ // }
4292
+ // }
4293
+ }, 1000);
4291
4294
 
4292
4295
  return save_ret;
4293
4296
  } catch (err) {
@@ -4346,7 +4349,7 @@ const process_conversation = async function (uid, conversation_id, account_profi
4346
4349
  await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
4347
4350
 
4348
4351
  // if (perform_ai_execution) {
4349
- await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
4352
+ // await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
4350
4353
  // }
4351
4354
  if (conversation_doc.reference_type === 'contacts') {
4352
4355
  if (recipient_uid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4662",
3
+ "version": "1.1.4664",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",