@xuda.io/ai_module 1.1.4240 → 1.1.4241
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 +35 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4482,6 +4482,41 @@ const chat_note = async function (req, job_id, headers) {
|
|
|
4482
4482
|
}
|
|
4483
4483
|
};
|
|
4484
4484
|
|
|
4485
|
+
const chat_email = async function (req, job_id, headers) {
|
|
4486
|
+
const { uid } = req;
|
|
4487
|
+
const account_profile_info = await account_module.get_active_account_profile_info(uid);
|
|
4488
|
+
let { prompt, conversation_doc, attachments = [], ai_agents } = req;
|
|
4489
|
+
try {
|
|
4490
|
+
const conversation_id = conversation_doc._id;
|
|
4491
|
+
|
|
4492
|
+
const sender_app_id = account_profile_info.app_id;
|
|
4493
|
+
let sender_conversation_doc = await db_module.get_app_couch_doc_native(sender_app_id, conversation_id);
|
|
4494
|
+
|
|
4495
|
+
await attachment_handler(uid, sender_app_id, conversation_id, attachments, account_profile_info);
|
|
4496
|
+
|
|
4497
|
+
const item = await client.conversations.items.create(conversation_id, {
|
|
4498
|
+
items: [
|
|
4499
|
+
{
|
|
4500
|
+
type: 'message',
|
|
4501
|
+
role: 'user',
|
|
4502
|
+
content: [{ type: 'input_text', text: prompt }],
|
|
4503
|
+
},
|
|
4504
|
+
],
|
|
4505
|
+
});
|
|
4506
|
+
|
|
4507
|
+
let obj = { id: item.data[0].id, ts: Date.now(), uid, read: true, conversation_type: 'note' };
|
|
4508
|
+
|
|
4509
|
+
sender_conversation_doc.messages.push(obj);
|
|
4510
|
+
await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
|
|
4511
|
+
|
|
4512
|
+
await db_module.save_app_couch_doc_native(sender_app_id, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, prompt });
|
|
4513
|
+
|
|
4514
|
+
return { code: 15, data: item };
|
|
4515
|
+
} catch (err) {
|
|
4516
|
+
return { code: -15, data: err.message };
|
|
4517
|
+
}
|
|
4518
|
+
};
|
|
4519
|
+
|
|
4485
4520
|
const ai_chat_conversation = async function (req, job_id, headers) {
|
|
4486
4521
|
const { uid, gtp_token } = req;
|
|
4487
4522
|
const account_profile_info = await account_module.get_active_account_profile_info(uid);
|