@xuda.io/ai_module 1.1.4143 → 1.1.4145
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.
- package/index.mjs +13 -13
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2021,7 +2021,7 @@ export const unarchive_ai_chat = async function (req) {
|
|
|
2021
2021
|
// }
|
|
2022
2022
|
// };
|
|
2023
2023
|
|
|
2024
|
-
const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', size = '1024x1024', n = 1, width = 256, height = 256, metadata = {}) {
|
|
2024
|
+
const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', size = '1024x1024', n = 1, width = 256, height = 256, metadata = {}, account_profile_info) {
|
|
2025
2025
|
try {
|
|
2026
2026
|
const response = await client.images.generate({
|
|
2027
2027
|
model,
|
|
@@ -2065,7 +2065,7 @@ const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', si
|
|
|
2065
2065
|
|
|
2066
2066
|
const thumbnailBase64 = resized.toString('base64');
|
|
2067
2067
|
|
|
2068
|
-
record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model, metadata);
|
|
2068
|
+
record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model, metadata, account_profile_info);
|
|
2069
2069
|
|
|
2070
2070
|
return thumbnailBase64;
|
|
2071
2071
|
} catch (err) {
|
|
@@ -3309,7 +3309,7 @@ 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
|
|
|
@@ -3375,7 +3375,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
|
|
|
3375
3375
|
case 'conversation': {
|
|
3376
3376
|
prompt = `create image: ${doc.title}`;
|
|
3377
3377
|
|
|
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);
|
|
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, account_profile_info);
|
|
3379
3379
|
db_doc = await get_db_doc();
|
|
3380
3380
|
db_doc.thumbnail_request_ts = Date.now();
|
|
3381
3381
|
db_doc.chat_image = images_arr;
|
|
@@ -3386,7 +3386,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
|
|
|
3386
3386
|
if (doc.studio_meta.agent_image) return;
|
|
3387
3387
|
prompt = `create image: ${doc.properties.menuName}`;
|
|
3388
3388
|
|
|
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);
|
|
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, account_profile_info);
|
|
3390
3390
|
db_doc = await get_db_doc();
|
|
3391
3391
|
db_doc.studio_meta.thumbnail_request_ts = Date.now();
|
|
3392
3392
|
db_doc.studio_meta.agent_image = images_arr;
|
|
@@ -3399,7 +3399,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
|
|
|
3399
3399
|
doc?.context || ''
|
|
3400
3400
|
}"} 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
3401
|
|
|
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);
|
|
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, account_profile_info, 1024, 1024);
|
|
3403
3403
|
await update_profile_avatar_status(doc._id, 3);
|
|
3404
3404
|
db_doc = await get_db_doc();
|
|
3405
3405
|
db_doc.image_request_ts = Date.now();
|
|
@@ -3415,7 +3415,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
|
|
|
3415
3415
|
doc?.context || ''
|
|
3416
3416
|
}"} 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
3417
|
|
|
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);
|
|
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, account_profile_info, 1024, 1024);
|
|
3419
3419
|
db_doc = await get_db_doc();
|
|
3420
3420
|
db_doc.image_request_ts = Date.now();
|
|
3421
3421
|
db_doc.account_info.profile_avatar = images_arr[0].file_url;
|
|
@@ -3435,7 +3435,7 @@ export const update_thumbnail = async function (type, doc, app_id, uid, job_id,
|
|
|
3435
3435
|
if (xuda_db) {
|
|
3436
3436
|
save_ret = await db_module.save_couch_doc_native(xuda_db, db_doc);
|
|
3437
3437
|
} else {
|
|
3438
|
-
save_ret = await db_module.save_app_couch_doc_native(app_id, db_doc);
|
|
3438
|
+
save_ret = await db_module.save_app_couch_doc_native(account_profile_info.app_id, db_doc);
|
|
3439
3439
|
}
|
|
3440
3440
|
return save_ret;
|
|
3441
3441
|
} catch (error) {
|
|
@@ -5489,10 +5489,10 @@ const get_plugin_tool = async function (app_id, uid, plugin_name, method, prop_d
|
|
|
5489
5489
|
}
|
|
5490
5490
|
};
|
|
5491
5491
|
|
|
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 = [],
|
|
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 = [], account_profile_info) {
|
|
5493
5493
|
try {
|
|
5494
5494
|
// 1. Generate the images
|
|
5495
|
-
let result = await create_image(uid, prompt, undefined, undefined, numGenerations, undefined, undefined, { drive_type, file_path, file_name });
|
|
5495
|
+
let result = await create_image(uid, prompt, undefined, undefined, numGenerations, undefined, undefined, { drive_type, file_path, file_name }, account_profile_info);
|
|
5496
5496
|
|
|
5497
5497
|
// Normalize to array
|
|
5498
5498
|
const images = Array.isArray(result) ? result : [result];
|
|
@@ -5829,7 +5829,7 @@ export const create_profile_avatar = async function (req, job_id, headers) {
|
|
|
5829
5829
|
const prompt = `analyze the the person info : ${JSON.stringify({ first_name, last_name, bio, country, mainCategory, subCategory })}
|
|
5830
5830
|
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
5831
|
|
|
5832
|
-
imageBase64 = await create_image(uid, prompt, undefined, undefined, 1, undefined, undefined, { url });
|
|
5832
|
+
imageBase64 = await create_image(uid, prompt, undefined, undefined, 1, undefined, undefined, { url }, account_profile_info);
|
|
5833
5833
|
avatar_source = 'fictional';
|
|
5834
5834
|
};
|
|
5835
5835
|
// personal account
|
|
@@ -6150,7 +6150,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
|
|
|
6150
6150
|
return { is_transparent, image_blob: new Blob([buffer], { type: 'image/png' }) };
|
|
6151
6151
|
}
|
|
6152
6152
|
|
|
6153
|
-
const { app_id, uid, ai_agent_id, tags } = req;
|
|
6153
|
+
const { app_id, uid, ai_agent_id, tags, account_profile_info } = req;
|
|
6154
6154
|
|
|
6155
6155
|
const ai_agent_doc = await db_module.get_app_couch_doc_native(app_id, ai_agent_id);
|
|
6156
6156
|
const account_doc = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
@@ -6190,7 +6190,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
|
|
|
6190
6190
|
|
|
6191
6191
|
`;
|
|
6192
6192
|
|
|
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);
|
|
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, account_profile_info);
|
|
6194
6194
|
return { code: 1, data: images_arr[0] };
|
|
6195
6195
|
}
|
|
6196
6196
|
|