@xuda.io/ai_module 1.1.4557 → 1.1.4559

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 +6 -4
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4097,10 +4097,10 @@ 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', from_mailbox } = req;
4100
+ const { profile_id, 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
- const account_profile_info = await account_module.get_active_account_profile_info(uid);
4103
+ const account_profile_info = await account_module.get_active_account_profile_info(uid, profile_id);
4104
4104
  const { account_profile_obj } = account_profile_info;
4105
4105
  try {
4106
4106
  if (conversation_type === 'email') {
@@ -4402,7 +4402,7 @@ const chat_note = async function (req, job_id, headers) {
4402
4402
  sender_conversation_doc.messages.push(obj);
4403
4403
  await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
4404
4404
 
4405
- 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 });
4405
+ 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 });
4406
4406
 
4407
4407
  return { code: 15, data: item };
4408
4408
  } catch (err) {
@@ -4514,6 +4514,7 @@ const chat_email = async function (req, job_id, headers) {
4514
4514
  email_id,
4515
4515
  subject,
4516
4516
  last_email_item_id: last_email_item?._id,
4517
+ reference_id: conversation_doc.reference_id,
4517
4518
  });
4518
4519
 
4519
4520
  return save_ret;
@@ -5153,6 +5154,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
5153
5154
  output: output.output,
5154
5155
  prompt,
5155
5156
  response: output.state._currentStep.output,
5157
+ reference_id: conversation_doc.reference_id,
5156
5158
  });
5157
5159
 
5158
5160
  account_module.record_ai_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: obj.ai_agent_id, item_id: obj.id }, account_profile_info);
@@ -6407,7 +6409,7 @@ const attachment_handler = async function (uid, app_id, conversation_id, attachm
6407
6409
  const obj = { id: items.last_id, ts: Date.now(), conversation_type: 'attachment', file };
6408
6410
  system_message_items.push(obj);
6409
6411
 
6410
- await db_module.save_app_couch_doc_native(account_profile_info.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, file, transcript });
6412
+ await db_module.save_app_couch_doc_native(account_profile_info.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, file, transcript, reference_id: conversation_doc.reference_id });
6411
6413
  }
6412
6414
 
6413
6415
  // const items = await client.conversations.items.create(conversation_id, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4557",
3
+ "version": "1.1.4559",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",