@xuda.io/ai_module 1.1.4997 → 1.1.4998

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 +14 -14
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1525,7 +1525,7 @@ const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', si
1525
1525
 
1526
1526
  const thumbnailBase64 = resized.toString('base64');
1527
1527
 
1528
- account_ms.record_ai_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model, metadata, account_profile_info);
1528
+ account_msa.record_ai_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model, metadata, account_profile_info);
1529
1529
 
1530
1530
  return thumbnailBase64;
1531
1531
  } catch (err) {
@@ -2887,7 +2887,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
2887
2887
  images_arr = [cache];
2888
2888
  if (!cache) {
2889
2889
  images_arr = await create_and_upload_image_to_drive('user', 'Chat Thumbnails', doc._id, prompt, 1, uid, app_id, job_id, headers, true, tags, account_profile_info);
2890
- account_ms.save_xuda_cache(uid, 'chat_thumbnail', doc.title, images_arr[0], { tags });
2890
+ account_msa.save_xuda_cache(uid, 'chat_thumbnail', doc.title, images_arr[0], { tags });
2891
2891
  }
2892
2892
  db_doc = await get_db_doc();
2893
2893
  db_doc.thumbnail_request_ts = Date.now();
@@ -2906,7 +2906,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
2906
2906
  images_arr = [cache];
2907
2907
  if (!cache) {
2908
2908
  images_arr = await create_and_upload_image_to_drive('user', 'Chat Thumbnails', doc._id, prompt, 1, uid, app_id, job_id, headers, true, tags, account_profile_info);
2909
- account_ms.save_xuda_cache(uid, 'chat_thumbnail', doc.category_info.category, images_arr[0], { tags });
2909
+ account_msa.save_xuda_cache(uid, 'chat_thumbnail', doc.category_info.category, images_arr[0], { tags });
2910
2910
  }
2911
2911
  db_doc = await get_db_doc();
2912
2912
  db_doc.thumbnail_request_ts = Date.now();
@@ -3044,7 +3044,7 @@ const transcribe = async function (uid, stream, metadata, account_profile_info)
3044
3044
  // temperature: 0 // lower = more literal
3045
3045
  });
3046
3046
  report_ai_status(model);
3047
- account_ms.record_ai_usage(uid, 0, resp.length || 0, 'transcribe', '', model, metadata, account_profile_info);
3047
+ account_msa.record_ai_usage(uid, 0, resp.length || 0, 'transcribe', '', model, metadata, account_profile_info);
3048
3048
  // console.log(resp); // or resp for JSON formats
3049
3049
  return resp;
3050
3050
  } catch (err) {
@@ -3364,7 +3364,7 @@ export const submit_chat_gpt_prompt = async function (req) {
3364
3364
  report_ai_status(model, err);
3365
3365
  throw err;
3366
3366
  }
3367
- account_ms.record_ai_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'submit chat', prompt, model, metadata, account_profile_info, tools);
3367
+ account_msa.record_ai_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'submit chat', prompt, model, metadata, account_profile_info, tools);
3368
3368
  return { code: 5, data: response.output_text };
3369
3369
  } catch (err) {
3370
3370
  return { code: -5, data: err.message };
@@ -3605,7 +3605,7 @@ export const submit_chat_conversation = async function (req, job_id, headers) {
3605
3605
  if (conversation_doc.reference_type === 'contacts') {
3606
3606
  req._thread_reentry = Date.now() - conversation_doc.date_created_ts > 60000;
3607
3607
 
3608
- account_ms.ts_contact(uid, conversation_doc.reference_id);
3608
+ account_msa.ts_contact(uid, conversation_doc.reference_id);
3609
3609
 
3610
3610
  switch (conversation_doc.conversation_type) {
3611
3611
  case 'note': {
@@ -4636,7 +4636,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4636
4636
  out_conversation_item_doc.conversation_item_reference_id = conversation_items?.data?.[0]?.id;
4637
4637
  await db_module.save_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_doc);
4638
4638
 
4639
- account_ms.record_ai_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: in_conversation_item_obj.ai_agent_id, item_id: in_conversation_item_obj._id }, account_profile_info);
4639
+ account_msa.record_ai_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: in_conversation_item_obj.ai_agent_id, item_id: in_conversation_item_obj._id }, account_profile_info);
4640
4640
  // if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
4641
4641
  // update_thumbnail('conversation', conversation_doc, app_id, uid, job_id, headers);
4642
4642
  // }
@@ -5213,7 +5213,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5213
5213
  throw err;
5214
5214
  }
5215
5215
  imageBase64 = ai_avatar_response.data[0].b64_json;
5216
- account_ms.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5216
+ account_msa.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5217
5217
  } else {
5218
5218
  imageBase64 = Buffer.from(await image_blob_ret.image_blob.arrayBuffer()).toString('base64');
5219
5219
  if (account_type === 'business') {
@@ -5305,7 +5305,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5305
5305
  // The background should be fully removed, remove trees,clouds,sky or any landscape objects`,
5306
5306
  // background: 'transparent',
5307
5307
  // });
5308
- // account_ms.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5308
+ // account_msa.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5309
5309
  // imageBase64 = ai_avatar_response.data[0].b64_json;
5310
5310
  if (is_user) {
5311
5311
  if (business_has_person) {
@@ -5332,7 +5332,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5332
5332
  report_ai_status(model, err);
5333
5333
  throw err;
5334
5334
  }
5335
- account_ms.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5335
+ account_msa.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5336
5336
  imageBase64 = ai_avatar_response.data[0].b64_json;
5337
5337
  }
5338
5338
  } else {
@@ -5404,7 +5404,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5404
5404
  report_ai_status(model, err);
5405
5405
  throw err;
5406
5406
  }
5407
- account_ms.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5407
+ account_msa.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5408
5408
  imageBase64 = ai_avatar_response.data[0].b64_json;
5409
5409
  avatar_source = 'ai profile';
5410
5410
  };
@@ -5627,7 +5627,7 @@ export const get_profile_picture = async function (uid, account_type = 'business
5627
5627
  }
5628
5628
 
5629
5629
  imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json, resize);
5630
- account_ms.record_ai_usage(uid, image_response.usage.input_tokens, image_response.usage.output_tokens, 'profile image', prompt, model, { url }, account_profile_info);
5630
+ account_msa.record_ai_usage(uid, image_response.usage.input_tokens, image_response.usage.output_tokens, 'profile image', prompt, model, { url }, account_profile_info);
5631
5631
  }
5632
5632
 
5633
5633
  const outputBuffer = Buffer.from(imageBase64, 'base64');
@@ -5943,7 +5943,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
5943
5943
  throw err;
5944
5944
  }
5945
5945
  imageBase64 = ai_avatar_response.data[0].b64_json;
5946
- account_ms.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'agent avatar', prompt, model, { ai_agent_id }, account_profile_info);
5946
+ account_msa.record_ai_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'agent avatar', prompt, model, { ai_agent_id }, account_profile_info);
5947
5947
  console.log('Normalizing final avatar to 1024 with transparent padding...');
5948
5948
  imageBase64 = await normalizeBase64To1024(imageBase64);
5949
5949
 
@@ -6615,7 +6615,7 @@ const get_chat_picture_cache = async function (uid, docType, key) {
6615
6615
  const ret = await db_module.find_couch_query('xuda_cache', query);
6616
6616
 
6617
6617
  if (ret.docs.length > 0) {
6618
- account_ms.save_cache_hit(ret.docs[0]._id);
6618
+ account_msa.save_cache_hit(ret.docs[0]._id);
6619
6619
  return ret.docs[0].file;
6620
6620
  }
6621
6621
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4997",
3
+ "version": "1.1.4998",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",