@xuda.io/ai_module 1.1.4144 → 1.1.4146

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 -59
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -3309,60 +3309,13 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
3309
3309
  if (xuda_db) {
3310
3310
  return await db_module.get_couch_doc_native(xuda_db, doc._id);
3311
3311
  } else {
3312
- return await db_module.get_app_couch_doc_native(app_id, doc._id);
3312
+ return await db_module.get_app_couch_doc_native(account_profile_info.app_id, doc._id);
3313
3313
  }
3314
3314
  };
3315
3315
 
3316
3316
  let db_doc;
3317
3317
 
3318
3318
  switch (type) {
3319
- // case 'ai_agent': {
3320
- // db_doc = await get_db_doc();
3321
-
3322
- // prompt = `
3323
- // Create a futuristic, faceless humanoid profile portrait with a transparent background.
3324
-
3325
- // Center the character facing forward, with subtle top spacing, showing only the head and shoulders.
3326
- // The humanoid must remain completely faceless.
3327
-
3328
- // Style the humanoid with functional, minimal attire integrated into its form
3329
- // (such as collars, layered panels, shoulder structures, or fabric-like surfaces),
3330
- // avoiding human fashion tropes.
3331
-
3332
- // Select exactly ONE accessory category per generation (do not combine):
3333
- // - Head-mounted element (visor, band, halo ring)
3334
- // - Chest or collar element (badge, glyph, embedded tag)
3335
- // - Floating or projected element (holographic symbol, light node)
3336
- // - Structural or partially visible object that reinforces the role
3337
-
3338
- // Accessories must directly reinforce the identity of
3339
- // "${db_doc.properties.menuName} - ${db_doc.studio_meta.agent_assistant_name}".
3340
-
3341
- // Use a consistent, fixed color palette across all generations.
3342
- // Do not introduce new colors.
3343
- // All variation must come from geometry, materials, texture, and lighting.
3344
-
3345
- // Vary at least two of the following:
3346
- // - Head geometry
3347
- // - Surface structure
3348
- // - Material finish
3349
- // - Light interaction
3350
-
3351
- // Use advanced or reflective materials to convey intelligence and sophistication.
3352
- // The overall composition should symbolize the fusion of human creativity and machine intelligence.
3353
-
3354
- // `;
3355
- // //and a hat
3356
- // const images_arr = await create_and_upload_image_to_drive('studio', 'Progs Thumbnails', doc._id, prompt, 1, uid, app_id, job_id, headers, false, tags);
3357
-
3358
- // db_doc = await get_db_doc();
3359
- // db_doc.studio_meta.thumbnail_request_ts = Date.now();
3360
- // db_doc.studio_meta.agent_image = images_arr;
3361
- // // db_doc.studio_meta.agent_assistant_name = agent_assistant_name.data;
3362
-
3363
- // break;
3364
- // }
3365
-
3366
3319
  case 'ai_agent': {
3367
3320
  const images_arr = await create_ai_agent_image({ app_id, uid, ai_agent_id: doc._id, tags }, job_id, headers);
3368
3321
  db_doc = await get_db_doc();
@@ -3375,7 +3328,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
3375
3328
  case 'conversation': {
3376
3329
  prompt = `create image: ${doc.title}`;
3377
3330
 
3378
- const images_arr = await create_and_upload_image_to_drive('user', 'Chat Thumbnails', doc._id, prompt, 1, uid, app_id, job_id, headers, true, tags);
3331
+ const 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);
3379
3332
  db_doc = await get_db_doc();
3380
3333
  db_doc.thumbnail_request_ts = Date.now();
3381
3334
  db_doc.chat_image = images_arr;
@@ -3386,7 +3339,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
3386
3339
  if (doc.studio_meta.agent_image) return;
3387
3340
  prompt = `create image: ${doc.properties.menuName}`;
3388
3341
 
3389
- const images_arr = await create_and_upload_image_to_drive('studio', 'Progs Thumbnails', doc._id, prompt, 1, uid, app_id, job_id, headers, false, tags);
3342
+ const images_arr = await create_and_upload_image_to_drive('studio', 'Progs Thumbnails', doc._id, prompt, 1, uid, app_id, job_id, headers, false, tags, account_profile_info);
3390
3343
  db_doc = await get_db_doc();
3391
3344
  db_doc.studio_meta.thumbnail_request_ts = Date.now();
3392
3345
  db_doc.studio_meta.agent_image = images_arr;
@@ -3399,7 +3352,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
3399
3352
  doc?.context || ''
3400
3353
  }"} and create realistic fictional profile picture transparent background ,person in the center of the picture add top margin the person should cover the whole picture`;
3401
3354
 
3402
- const images_arr = await create_and_upload_image_to_drive('user', 'Profile Images', doc._id, prompt, 1, uid, app_id, job_id, headers, true, tags, 1024, 1024);
3355
+ const images_arr = await create_and_upload_image_to_drive('user', 'Profile Images', doc._id, prompt, 1, uid, app_id, job_id, headers, true, tags, account_profile_info, 1024, 1024);
3403
3356
  await update_profile_avatar_status(doc._id, 3);
3404
3357
  db_doc = await get_db_doc();
3405
3358
  db_doc.image_request_ts = Date.now();
@@ -3415,7 +3368,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
3415
3368
  doc?.context || ''
3416
3369
  }"} and create realistic fictional profile picture transparent background person in the center of the picture add top margin the person should cover the whole picture`;
3417
3370
 
3418
- const images_arr = await create_and_upload_image_to_drive('user', 'Profile Images', doc._id, prompt, 1, uid, app_id, job_id, headers, true, tags, 1024, 1024);
3371
+ const images_arr = await create_and_upload_image_to_drive('user', 'Profile Images', doc._id, prompt, 1, uid, app_id, job_id, headers, true, tags, account_profile_info, 1024, 1024);
3419
3372
  db_doc = await get_db_doc();
3420
3373
  db_doc.image_request_ts = Date.now();
3421
3374
  db_doc.account_info.profile_avatar = images_arr[0].file_url;
@@ -3435,7 +3388,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
3435
3388
  if (xuda_db) {
3436
3389
  save_ret = await db_module.save_couch_doc_native(xuda_db, db_doc);
3437
3390
  } else {
3438
- save_ret = await db_module.save_app_couch_doc_native(app_id, db_doc);
3391
+ save_ret = await db_module.save_app_couch_doc_native(account_profile_info.app_id, db_doc);
3439
3392
  }
3440
3393
  return save_ret;
3441
3394
  } catch (error) {
@@ -4850,7 +4803,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4850
4803
  const { prompt, numGenerations } = e;
4851
4804
  try {
4852
4805
  let imgTags = '';
4853
- const images_arr = await create_and_upload_image_to_drive('workspace', 'Chat Images', agent_id, prompt, numGenerations, uid, app_id, job_id, headers);
4806
+ 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);
4854
4807
  for (const img_obj of images_arr) {
4855
4808
  imgTags += `<img src="${img_obj.file_url}" alt="${prompt}" style="max-width: 100%; border-radius: 8px;" />`;
4856
4809
  }
@@ -5489,10 +5442,10 @@ const get_plugin_tool = async function (app_id, uid, plugin_name, method, prop_d
5489
5442
  }
5490
5443
  };
5491
5444
 
5492
- 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) {
5445
+ 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 = [], account_profile_info) {
5493
5446
  try {
5494
5447
  // 1. Generate the images
5495
- let result = await create_image(uid, prompt, undefined, undefined, numGenerations, undefined, undefined, { drive_type, file_path, file_name });
5448
+ let result = await create_image(uid, prompt, undefined, undefined, numGenerations, undefined, undefined, { drive_type, file_path, file_name }, account_profile_info);
5496
5449
 
5497
5450
  // Normalize to array
5498
5451
  const images = Array.isArray(result) ? result : [result];
@@ -5829,7 +5782,7 @@ export const create_profile_avatar = async function (req, job_id, headers) {
5829
5782
  const prompt = `analyze the the person info : ${JSON.stringify({ first_name, last_name, bio, country, mainCategory, subCategory })}
5830
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`;
5831
5784
 
5832
- imageBase64 = await create_image(uid, prompt, undefined, undefined, 1, undefined, undefined, { url });
5785
+ imageBase64 = await create_image(uid, prompt, undefined, undefined, 1, undefined, undefined, { url }, account_profile_info);
5833
5786
  avatar_source = 'fictional';
5834
5787
  };
5835
5788
  // personal account
@@ -6150,7 +6103,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6150
6103
  return { is_transparent, image_blob: new Blob([buffer], { type: 'image/png' }) };
6151
6104
  }
6152
6105
 
6153
- const { app_id, uid, ai_agent_id, tags } = req;
6106
+ const { app_id, uid, ai_agent_id, tags, account_profile_info } = req;
6154
6107
 
6155
6108
  const ai_agent_doc = await db_module.get_app_couch_doc_native(app_id, ai_agent_id);
6156
6109
  const account_doc = await db_module.get_couch_doc_native('xuda_accounts', uid);
@@ -6190,7 +6143,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6190
6143
 
6191
6144
  `;
6192
6145
 
6193
- const images_arr = await create_and_upload_image_to_drive('studio', 'Progs Thumbnails', ai_agent_id, prompt, 1, uid, app_id, job_id, headers, false, tags);
6146
+ const images_arr = await create_and_upload_image_to_drive('studio', 'Progs Thumbnails', ai_agent_id, prompt, 1, uid, app_id, job_id, headers, false, tags, account_profile_info);
6194
6147
  return { code: 1, data: images_arr[0] };
6195
6148
  }
6196
6149
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4144",
3
+ "version": "1.1.4146",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",