@xuda.io/ai_module 1.1.4149 → 1.1.4151

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 +12 -12
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4133,7 +4133,7 @@ export const create_conversation = async function (req, job_id, headers) {
4133
4133
 
4134
4134
  const account_profile_info = await account_module.get_active_account_profile_info(uid);
4135
4135
 
4136
- const app_id = await account_module.get_account_default_project_id(uid);
4136
+ // const app_id = await account_module.get_account_default_project_id(uid);
4137
4137
 
4138
4138
  try {
4139
4139
  const conversation_obj = await client.conversations.create();
@@ -4365,7 +4365,7 @@ const contact_chat_conversation = async function (req, job_id, headers) {
4365
4365
  let { prompt, conversation_doc, attachments = [], ai_agents } = req;
4366
4366
 
4367
4367
  const conversation_id = conversation_doc._id;
4368
-
4368
+ const { account_profile_info } = conversation_doc;
4369
4369
  const receiver_contact_doc = await account_module.get_contact_info(uid, null, conversation_doc.reference_id);
4370
4370
  const receiver_app_id = await account_module.get_account_default_project_id(receiver_contact_doc.contact_uid);
4371
4371
  let receiver_conversation_doc = await db_module.get_app_couch_doc_native(receiver_app_id, conversation_id);
@@ -4485,7 +4485,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4485
4485
 
4486
4486
  try {
4487
4487
  const app_id = await account_module.get_account_default_project_id(uid);
4488
- const app_obj = await get_app_obj(app_id);
4488
+ const app_obj = await get_app_obj(conversation_doc.account_profile_info.app_id);
4489
4489
  const userName = await account_module.get_user_name(uid);
4490
4490
  const account_info = (await account_module.get_account_name({ uid })).data;
4491
4491
  let context = { ...{ app_id, uid, userName, account_info, app_obj, account_id: uid }, ...extractClientInfo(headers) };
@@ -4531,7 +4531,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4531
4531
 
4532
4532
  conversation_doc.stat = 2;
4533
4533
  conversation_doc.ts = Date.now();
4534
- await db_module.save_app_couch_doc_native(app_id, conversation_doc);
4534
+ await db_module.save_app_couch_doc_native(conversation_doc.account_profile_info.app_id, conversation_doc);
4535
4535
 
4536
4536
  await update_job('analyzing request');
4537
4537
 
@@ -4644,16 +4644,16 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4644
4644
  try {
4645
4645
  let ai_agent_doc;
4646
4646
  try {
4647
- ai_agent_doc = await db_module.get_app_couch_doc_native(app_id, agent_id);
4647
+ ai_agent_doc = await db_module.get_app_couch_doc_native(conversation_doc.account_profile_info.app_id, agent_id);
4648
4648
  if (ai_agent_doc.studio_meta.shared_from_uid) {
4649
4649
  const reference_doc = _.cloneDeep(ai_agent_doc);
4650
4650
  const app_id = await account_module.get_account_default_project_id(ai_agent_doc.studio_meta.shared_from_uid);
4651
- ai_agent_doc = await db_module.get_app_couch_doc_native(app_id, ai_agent_doc.studio_meta.share_item_id);
4651
+ ai_agent_doc = await db_module.get_app_couch_doc_native(conversation_doc.account_profile_info.app_id, ai_agent_doc.studio_meta.share_item_id);
4652
4652
  ai_agent_doc.reference_doc = reference_doc;
4653
4653
  } else if (ai_agent_doc.studio_meta.installed_from_uid) {
4654
4654
  const reference_doc = _.cloneDeep(ai_agent_doc);
4655
4655
  const app_id = await account_module.get_account_default_project_id(ai_agent_doc.studio_meta.installed_from_uid);
4656
- ai_agent_doc = await db_module.get_app_couch_doc_native(app_id, ai_agent_doc.studio_meta.share_item_id);
4656
+ ai_agent_doc = await db_module.get_app_couch_doc_native(conversation_doc.account_profile_info.app_id, ai_agent_doc.studio_meta.share_item_id);
4657
4657
  ai_agent_doc.reference_doc = reference_doc;
4658
4658
  }
4659
4659
  } catch (err) {
@@ -4804,7 +4804,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4804
4804
  const { prompt, numGenerations } = e;
4805
4805
  try {
4806
4806
  let imgTags = '';
4807
- const images_arr = await create_and_upload_image_to_drive('workspace', 'Chat Images', agent_id, prompt, numGenerations, uid, app_id, job_id, headers, null, null, account_profile_info);
4807
+ const images_arr = await create_and_upload_image_to_drive('workspace', 'Chat Images', agent_id, prompt, numGenerations, uid, conversation_doc.account_profile_info.app_id, job_id, headers, null, null, account_profile_info);
4808
4808
  for (const img_obj of images_arr) {
4809
4809
  imgTags += `<img src="${img_obj.file_url}" alt="${prompt}" style="max-width: 100%; border-radius: 8px;" />`;
4810
4810
  }
@@ -4991,9 +4991,9 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4991
4991
 
4992
4992
  const set_ts_to_agent = async function () {
4993
4993
  try {
4994
- let agent_doc = await db_module.get_app_couch_doc_native(app_id, reference_id);
4994
+ let agent_doc = await db_module.get_app_couch_doc_native(conversation_doc.account_profile_info.app_id, reference_id);
4995
4995
  agent_doc.ts = Date.now();
4996
- await db_module.save_app_couch_doc_native(app_id, agent_doc);
4996
+ await db_module.save_app_couch_doc_native(conversation_doc.account_profile_info.app_id, agent_doc);
4997
4997
  } catch (err) {}
4998
4998
  };
4999
4999
 
@@ -5039,7 +5039,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
5039
5039
  const done = async function (output) {
5040
5040
  try {
5041
5041
  const obj = { id: output?.output?.[0]?.id, ts: Date.now(), ai_agent_id: output.state._currentAgent.name, attachments };
5042
- conversation_doc = await db_module.get_app_couch_doc_native(app_id, conversation_id);
5042
+ conversation_doc = await db_module.get_app_couch_doc_native(conversation_doc.account_profile_info.app_id, conversation_id);
5043
5043
 
5044
5044
  conversation_doc.ts = Date.now();
5045
5045
  conversation_doc.stat = 3;
@@ -5053,7 +5053,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
5053
5053
  outputTokens += item.usage.outputTokens;
5054
5054
  }
5055
5055
 
5056
- await db_module.save_app_couch_doc_native(app_id, conversation_doc);
5056
+ await db_module.save_app_couch_doc_native(conversation_doc.account_profile_info.app_id, conversation_doc);
5057
5057
  record_chat_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: obj.ai_agent_id, item_id: obj.id });
5058
5058
  // if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
5059
5059
  // update_thumbnail('conversation', conversation_doc, app_id, uid, job_id, headers);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4149",
3
+ "version": "1.1.4151",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",