@xuda.io/ai_module 1.1.4438 → 1.1.4439

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 +10 -10
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2063,7 +2063,7 @@ const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', si
2063
2063
 
2064
2064
  const thumbnailBase64 = resized.toString('base64');
2065
2065
 
2066
- record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model, metadata, account_profile_info);
2066
+ record_ai_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model, metadata, account_profile_info);
2067
2067
 
2068
2068
  return thumbnailBase64;
2069
2069
  } catch (err) {
@@ -3501,7 +3501,7 @@ const transcribe = async function (uid, stream, metadata, account_profile_info)
3501
3501
  language: 'en', // hint language (ISO 639-1), e.g. "he" for Hebrew
3502
3502
  // temperature: 0 // lower = more literal
3503
3503
  });
3504
- record_chat_usage(uid, 0, resp.length || 0, 'transcribe', '', model, metadata, account_profile_info);
3504
+ record_ai_usage(uid, 0, resp.length || 0, 'transcribe', '', model, metadata, account_profile_info);
3505
3505
  console.log(resp); // or resp for JSON formats
3506
3506
  return resp;
3507
3507
  } catch (error) {
@@ -4043,7 +4043,7 @@ export const submit_chat_gpt_prompt = async function (req) {
4043
4043
  format: formattedParams,
4044
4044
  },
4045
4045
  });
4046
- record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'submit chat', prompt, model, metadata, account_profile_info);
4046
+ record_ai_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'submit chat', prompt, model, metadata, account_profile_info);
4047
4047
  return { code: 5, data: response.output_text };
4048
4048
  } catch (err) {
4049
4049
  return { code: -5, data: err.message };
@@ -5014,7 +5014,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
5014
5014
  response: output.state._currentStep.output,
5015
5015
  });
5016
5016
 
5017
- record_chat_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: obj.ai_agent_id, item_id: obj.id }, account_profile_info);
5017
+ 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);
5018
5018
  // if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
5019
5019
  // update_thumbnail('conversation', conversation_doc, app_id, uid, job_id, headers);
5020
5020
  // }
@@ -5565,7 +5565,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5565
5565
  background: 'transparent',
5566
5566
  });
5567
5567
  imageBase64 = ai_avatar_response.data[0].b64_json;
5568
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5568
+ 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);
5569
5569
  } else {
5570
5570
  imageBase64 = Buffer.from(await image_blob_ret.image_blob.arrayBuffer()).toString('base64');
5571
5571
  if (account_type === 'business') {
@@ -5647,7 +5647,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5647
5647
  The background should be fully removed, remove trees,clouds,sky or any landscape objects`,
5648
5648
  background: 'transparent',
5649
5649
  });
5650
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5650
+ 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);
5651
5651
  imageBase64 = ai_avatar_response.data[0].b64_json;
5652
5652
  avatar_source = 'fictional';
5653
5653
  } else {
@@ -5664,7 +5664,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5664
5664
  Context: ${JSON.stringify({ name, bio, country, mainCategory, subCategory })}`,
5665
5665
  background: 'transparent',
5666
5666
  });
5667
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5667
+ 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);
5668
5668
  imageBase64 = ai_avatar_response.data[0].b64_json;
5669
5669
  avatar_source = 'ai profile';
5670
5670
  };
@@ -6103,7 +6103,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6103
6103
  background: 'transparent',
6104
6104
  });
6105
6105
  imageBase64 = ai_avatar_response.data[0].b64_json;
6106
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'agent avatar', prompt, model, { ai_agent_id }, account_profile_info);
6106
+ 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);
6107
6107
  console.log('Normalizing final avatar to 1024 with transparent padding...');
6108
6108
  imageBase64 = await normalizeBase64To1024(imageBase64);
6109
6109
 
@@ -6145,7 +6145,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6145
6145
  }
6146
6146
  };
6147
6147
 
6148
- const record_chat_usage = async function (uid, input_tokens, output_tokens, source, prompt, model, metadata = {}, account_profile_info) {
6148
+ const record_ai_usage = async function (uid, input_tokens, output_tokens, source, prompt, model, metadata = {}, account_profile_info) {
6149
6149
  try {
6150
6150
  if (!account_profile_info) throw new Error('missing account_profile_info');
6151
6151
  const app_id = await account_module.get_account_default_project_id(uid);
@@ -6553,7 +6553,7 @@ export const get_profile_picture = async function (uid, account_type = 'business
6553
6553
  });
6554
6554
 
6555
6555
  imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json);
6556
- record_chat_usage(uid, image_response.usage.input_tokens, image_response.usage.output_tokens, 'profile image', prompt, model, { url }, account_profile_info);
6556
+ record_ai_usage(uid, image_response.usage.input_tokens, image_response.usage.output_tokens, 'profile image', prompt, model, { url }, account_profile_info);
6557
6557
  }
6558
6558
  const outputBuffer = Buffer.from(imageBase64, 'base64');
6559
6559
  const outputPath = tempOutputPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4438",
3
+ "version": "1.1.4439",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",