@xuda.io/ai_module 1.1.4661 → 1.1.4663
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.
- package/index.mjs +83 -81
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4205,89 +4205,90 @@ 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
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
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
|
-
// }
|
|
4208
|
+
setTimeout(async () => {
|
|
4209
|
+
process_conversation(uid, conversation_doc._id, account_profile_info, job_id, headers);
|
|
4210
|
+
// // Ask GPT for title
|
|
4211
|
+
// if (conversation_type !== 'email') {
|
|
4212
|
+
// if (prompt.split(' ').length > 10) {
|
|
4213
|
+
// 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 });
|
|
4227
4214
|
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
// break;
|
|
4231
|
-
// }
|
|
4215
|
+
// conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
4216
|
+
// conversation_doc.title = title.data;
|
|
4232
4217
|
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4218
|
+
// await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
4219
|
+
// }
|
|
4220
|
+
// }
|
|
4221
|
+
// /// categorize prompt
|
|
4222
|
+
// let category_info = {};
|
|
4223
|
+
// switch (conversation_type) {
|
|
4224
|
+
// case 'ai': {
|
|
4225
|
+
// category_info = await categorize_ai_prompt(uid, prompt, account_profile_info);
|
|
4226
|
+
// break;
|
|
4227
|
+
// }
|
|
4228
|
+
|
|
4229
|
+
// case 'email': {
|
|
4230
|
+
// category_info = await categorize_email_subject(uid, prompt, account_profile_info);
|
|
4231
|
+
// break;
|
|
4232
|
+
// }
|
|
4233
|
+
|
|
4234
|
+
// case 'chat': {
|
|
4235
|
+
// category_info = await categorize_text_message(uid, prompt, account_profile_info);
|
|
4236
|
+
// break;
|
|
4237
|
+
// }
|
|
4238
|
+
|
|
4239
|
+
// case 'note': {
|
|
4240
|
+
// category_info = await categorize_contact_note(uid, prompt, account_profile_info);
|
|
4241
|
+
// break;
|
|
4242
|
+
// }
|
|
4243
|
+
|
|
4244
|
+
// default:
|
|
4245
|
+
// break;
|
|
4246
|
+
// }
|
|
4246
4247
|
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4248
|
+
// conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
4249
|
+
// contact_doc.category_info = category_info;
|
|
4250
|
+
// await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
4250
4251
|
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4252
|
+
// if (perform_ai_execution) {
|
|
4253
|
+
// // await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
4254
|
+
// }
|
|
4255
|
+
// if (conversation_doc.reference_type === 'contacts') {
|
|
4256
|
+
// if (recipient_uid) {
|
|
4257
|
+
// // valid for chat conversation
|
|
4258
|
+
// // write conversation to host after thumbnail update
|
|
4259
|
+
// // get sender conversation
|
|
4260
|
+
|
|
4261
|
+
// const conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
4262
|
+
|
|
4263
|
+
// const recipient_account_profile_info = await ac3180count_module.get_active_account_profile_info(recipient_uid);
|
|
4264
|
+
// let recipient_conversation_doc = await db_module.get_app_couch_doc_native(recipient_account_profile_info.app_id, conversation_doc._id);
|
|
4265
|
+
// recipient_conversation_doc.title = conversation_doc.title;
|
|
4266
|
+
|
|
4267
|
+
// recipient_conversation_doc.thumbnail_request_ts = conversation_doc.thumbnail_request_ts;
|
|
4268
|
+
// recipient_conversation_doc.chat_image = conversation_doc.chat_image;
|
|
4269
|
+
// await db_module.save_app_couch_doc_native(recipient_account_profile_info.app_id, recipient_conversation_doc);
|
|
4270
|
+
|
|
4271
|
+
// await update_conversation_mood_level(
|
|
4272
|
+
// uid,
|
|
4273
|
+
// [
|
|
4274
|
+
// { uid: account_profile_info.uid, contact_id: reference_id },
|
|
4275
|
+
// { uid: recipient_uid, contact_id: recipient_contact_id },
|
|
4276
|
+
// ],
|
|
4277
|
+
// conversation_doc._id,
|
|
4278
|
+
// prompt,
|
|
4279
|
+
// uid,
|
|
4280
|
+
// recipient_uid,
|
|
4281
|
+
// true,
|
|
4282
|
+
// account_profile_info,
|
|
4283
|
+
// );
|
|
4284
|
+
// } else {
|
|
4285
|
+
// // other cases rather then chat
|
|
4286
|
+
// if (perform_ai_execution) {
|
|
4287
|
+
// 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);
|
|
4288
|
+
// }
|
|
4289
|
+
// }
|
|
4290
|
+
// }
|
|
4291
|
+
}, 1000);
|
|
4291
4292
|
|
|
4292
4293
|
return save_ret;
|
|
4293
4294
|
} catch (err) {
|
|
@@ -4313,7 +4314,7 @@ const process_conversation = async function (uid, conversation_id, account_profi
|
|
|
4313
4314
|
}
|
|
4314
4315
|
}
|
|
4315
4316
|
/// categorize prompt
|
|
4316
|
-
let category_info = {
|
|
4317
|
+
let category_info = {};
|
|
4317
4318
|
if (prompt?.length > 5) {
|
|
4318
4319
|
switch (conversation_type) {
|
|
4319
4320
|
case 'ai': {
|
|
@@ -4337,6 +4338,7 @@ const process_conversation = async function (uid, conversation_id, account_profi
|
|
|
4337
4338
|
}
|
|
4338
4339
|
|
|
4339
4340
|
default:
|
|
4341
|
+
category_info = { category: 'unknown' };
|
|
4340
4342
|
break;
|
|
4341
4343
|
}
|
|
4342
4344
|
}
|
|
@@ -4345,7 +4347,7 @@ const process_conversation = async function (uid, conversation_id, account_profi
|
|
|
4345
4347
|
await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
4346
4348
|
|
|
4347
4349
|
// if (perform_ai_execution) {
|
|
4348
|
-
await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
4350
|
+
// await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
4349
4351
|
// }
|
|
4350
4352
|
if (conversation_doc.reference_type === 'contacts') {
|
|
4351
4353
|
if (recipient_uid) {
|