@xuda.io/ai_module 1.1.4516 → 1.1.4518

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 +19 -15
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4097,7 +4097,7 @@ function getFirstNWords(text, n = 10) {
4097
4097
  }
4098
4098
 
4099
4099
  export const create_conversation = async function (req, job_id, headers) {
4100
- const { uid, prompt, perform_ai_execution = true, email_id, email_direction = 'out' } = req;
4100
+ const { uid, prompt, perform_ai_execution = true, email_id, email_direction = 'out', from_mailbox } = req;
4101
4101
  let { reference_type, reference_id = '', conversation_type } = req;
4102
4102
 
4103
4103
  const account_profile_info = await account_module.get_active_account_profile_info(uid);
@@ -4164,12 +4164,14 @@ export const create_conversation = async function (req, job_id, headers) {
4164
4164
  setTimeout(async () => {
4165
4165
  // Ask GPT for title
4166
4166
  if (conversation_type !== 'email') {
4167
- 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 });
4167
+ if (prompt.split(' ').length > 10) {
4168
+ 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 });
4168
4169
 
4169
- conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_obj.id);
4170
- conversation_doc.title = title.data;
4170
+ conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_obj.id);
4171
+ conversation_doc.title = title.data;
4171
4172
 
4172
- await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
4173
+ await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
4174
+ }
4173
4175
  }
4174
4176
  if (perform_ai_execution) {
4175
4177
  await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
@@ -4435,18 +4437,20 @@ const chat_email = async function (req, job_id, headers) {
4435
4437
 
4436
4438
  // send an email by user invocation
4437
4439
  if (!from_mailbox) {
4438
- const subject_ret = await submit_chat_gpt_prompt({ uid, prompt: `create title for the prompt return 5 words result maximum text only without options : ${body}`, model: 'gpt-5-nano', metadata: { conversation_id: conversation_doc._id, func: 'chat_email' }, account_profile_info });
4439
- if (subject_ret.code < 0) {
4440
- throw new Error('something wrong creating email subject');
4441
- }
4440
+ if (body.split(' ').length > 10) {
4441
+ const subject_ret = await submit_chat_gpt_prompt({ uid, prompt: `create title for the prompt return 5 words result maximum text only without options : ${body}`, model: 'gpt-5-nano', metadata: { conversation_id: conversation_doc._id, func: 'chat_email' }, account_profile_info });
4442
+ if (subject_ret.code < 0) {
4443
+ throw new Error('something wrong creating email subject');
4444
+ }
4442
4445
 
4443
- const subject = subject_ret.data;
4444
- const email_module = await import(`${module_path}/email_module/index.mjs`);
4445
- const email_ret = email_module.sendEmailFromAccount(email_account_doc, contact_info.email, subject, body, null, attachments);
4446
- if (!email_ret.result) {
4447
- throw new Error('error sending email');
4446
+ const subject = subject_ret.data;
4447
+ const email_module = await import(`${module_path}/email_module/index.mjs`);
4448
+ const email_ret = email_module.sendEmailFromAccount(email_account_doc, contact_info.email, subject, body, null, attachments);
4449
+ if (!email_ret.result) {
4450
+ throw new Error('error sending email');
4451
+ }
4452
+ sent_email_result = email_ret.result;
4448
4453
  }
4449
- sent_email_result = email_ret.result;
4450
4454
  }
4451
4455
 
4452
4456
  if (perform_ai_execution) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4516",
3
+ "version": "1.1.4518",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",