@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.
- package/index.mjs +19 -15
- 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
|
-
|
|
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
|
-
|
|
4170
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
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
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
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) {
|