@xuda.io/ai_module 1.1.3849 → 1.1.3851

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 +4 -4
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2018,7 +2018,7 @@ export const unarchive_ai_chat = async function (req) {
2018
2018
  // }
2019
2019
  // };
2020
2020
 
2021
- const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', size = '1024x1024', n = 1, width = 256, height = 256) {
2021
+ const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', size = '1024x1024', n = 1, width = 256, height = 256, metadata = {}) {
2022
2022
  try {
2023
2023
  const response = await client.images.generate({
2024
2024
  model,
@@ -2062,7 +2062,7 @@ const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', si
2062
2062
 
2063
2063
  const thumbnailBase64 = resized.toString('base64');
2064
2064
 
2065
- record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model);
2065
+ record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model, metadata);
2066
2066
 
2067
2067
  return thumbnailBase64;
2068
2068
  } catch (err) {
@@ -5462,7 +5462,7 @@ const get_plugin_tool = async function (app_id, uid, plugin_name, method, prop_d
5462
5462
  const create_and_upload_image_to_drive = async function (drive_type, file_path, file_name, prompt, numGenerations, uid, app_id, job_id, headers, is_system, tags = [], width, height) {
5463
5463
  try {
5464
5464
  // 1. Generate the images
5465
- let result = await create_image(uid, prompt, undefined, undefined, numGenerations);
5465
+ let result = await create_image(uid, prompt, undefined, undefined, numGenerations, undefined, undefined, { drive_type, file_path, file_name });
5466
5466
 
5467
5467
  // Normalize to array
5468
5468
  const images = Array.isArray(result) ? result : [result];
@@ -5782,7 +5782,7 @@ export const convert_profile_image_to_avatar = async function (req, job_id, head
5782
5782
  const prompt = `analyze the the person info : ${JSON.stringify({ first_name, last_name, bio, country, mainCategory, subCategory })}
5783
5783
  and create realistic fictional profile picture transparent background ,person in the center of the picture return only a centered head-and-shoulders portrait facing the camera. include no labels or text add top margin the person should cover the whole picture`;
5784
5784
 
5785
- imageBase64 = await create_image(uid, prompt, undefined, undefined, 1);
5785
+ imageBase64 = await create_image(uid, prompt, undefined, undefined, 1, undefined, undefined, { url });
5786
5786
  avatar_source = 'fictional';
5787
5787
  };
5788
5788
  // personal account
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.3849",
3
+ "version": "1.1.3851",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",