@xuda.io/ai_module 1.1.5495 → 1.1.5497
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 +3 -37
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5112,15 +5112,11 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
5112
5112
|
}
|
|
5113
5113
|
};
|
|
5114
5114
|
|
|
5115
|
-
const add_conversation_item = async function (uid, profile_id, text, conversation_type, contact_id, metadata = {}) {
|
|
5116
|
-
const { uid, profile_id } = req;
|
|
5115
|
+
const add_conversation_item = async function (uid, profile_id, conversation_id, text, conversation_type, contact_id, metadata = {}) {
|
|
5117
5116
|
const account_profile_info = await get_active_account_profile_info(uid, profile_id);
|
|
5118
|
-
let { prompt: body, conversation_doc, attachments = [], ai_agents } = req;
|
|
5119
|
-
try {
|
|
5120
|
-
const conversation_id = conversation_doc._id;
|
|
5121
5117
|
|
|
5122
|
-
|
|
5123
|
-
let sender_conversation_doc = await db_module.get_app_couch_doc_native(
|
|
5118
|
+
try {
|
|
5119
|
+
let sender_conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
5124
5120
|
|
|
5125
5121
|
await attachment_handler(uid, sender_app_id, conversation_id, attachments, account_profile_info);
|
|
5126
5122
|
let item;
|
|
@@ -5139,36 +5135,6 @@ const add_conversation_item = async function (uid, profile_id, text, conversatio
|
|
|
5139
5135
|
report_ai_status('conversations', err);
|
|
5140
5136
|
throw err;
|
|
5141
5137
|
}
|
|
5142
|
-
|
|
5143
|
-
// let obj = { id: item.data[0].id, ts: Date.now(), uid, read: true, conversation_type: 'note' };
|
|
5144
|
-
|
|
5145
|
-
// sender_conversation_doc.messages.push(obj);
|
|
5146
|
-
// await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
|
|
5147
|
-
|
|
5148
|
-
let out_conversation_item_obj = {
|
|
5149
|
-
_id: await _common.xuda_get_uuid('chat_conversation_item'),
|
|
5150
|
-
stat: 3,
|
|
5151
|
-
docType: 'chat_conversation_item',
|
|
5152
|
-
uid,
|
|
5153
|
-
conversation_type: 'note',
|
|
5154
|
-
type: 'note',
|
|
5155
|
-
date_created_ts: Date.now(),
|
|
5156
|
-
ts: Date.now(),
|
|
5157
|
-
conversation_id,
|
|
5158
|
-
text: body,
|
|
5159
|
-
reference_id: conversation_doc.reference_id,
|
|
5160
|
-
conversation_item_reference_id: item.data[0].id,
|
|
5161
|
-
direction: 'out',
|
|
5162
|
-
role: 'user',
|
|
5163
|
-
read: { [uid]: Date.now() },
|
|
5164
|
-
rtl: _common.detectRTL(body),
|
|
5165
|
-
};
|
|
5166
|
-
|
|
5167
|
-
const save_ret = await db_module.save_app_couch_doc(sender_app_id, out_conversation_item_obj);
|
|
5168
|
-
|
|
5169
|
-
// await db_module.save_app_couch_doc_native(sender_app_id, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', ts: obj.ts, uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, body, reference_id: conversation_doc.reference_id });
|
|
5170
|
-
|
|
5171
|
-
return save_ret; //{ code: 15, data: item };
|
|
5172
5138
|
} catch (err) {
|
|
5173
5139
|
return { code: -15, data: err.message };
|
|
5174
5140
|
}
|