@xuda.io/ai_module 1.1.4763 → 1.1.4765
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 +16 -10
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6189,15 +6189,19 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
|
|
|
6189
6189
|
/// PERSONAL
|
|
6190
6190
|
const create_avatar_from_pic = async function () {
|
|
6191
6191
|
const { bio, country, mainCategory, subCategory } = metadata;
|
|
6192
|
+
|
|
6193
|
+
const prompt = `Completely remove the background, enhance and color-correct the subject, and return only a centered head-and-shoulders portrait facing the camera. Add extra top margin, include no labels or text, and export the result as a clean transparent PNG.
|
|
6194
|
+
Ensure the subject is large enough to fill most of the frame. Use the supplied name, country, and context to guide the character’s appearance.
|
|
6195
|
+
Context: ${JSON.stringify({ name, bio, country, mainCategory, subCategory })}`;
|
|
6196
|
+
|
|
6192
6197
|
// const { first_name, last_name, bio, country, mainCategory, subCategory } = account_obj.account_info;
|
|
6193
|
-
const model = 'gpt-image-1-mini';
|
|
6198
|
+
// const model = 'gpt-image-1-mini';
|
|
6199
|
+
const model = 'chatgpt-image-latest';
|
|
6194
6200
|
const ai_avatar_response = await client.images.edit({
|
|
6195
6201
|
model,
|
|
6196
6202
|
image: image_blob_ret.image_blob,
|
|
6197
6203
|
|
|
6198
|
-
prompt
|
|
6199
|
-
Ensure the subject is large enough to fill most of the frame. Use the supplied name, country, and context to guide the character’s appearance.
|
|
6200
|
-
Context: ${JSON.stringify({ name, bio, country, mainCategory, subCategory })}`,
|
|
6204
|
+
prompt,
|
|
6201
6205
|
background: 'transparent',
|
|
6202
6206
|
});
|
|
6203
6207
|
account_module.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);
|
|
@@ -6510,8 +6514,8 @@ const create_ai_agent_image = async function (req, job_id, headers) {
|
|
|
6510
6514
|
const image_blob_ret = await get_image_blob_from_downloaded_image(url);
|
|
6511
6515
|
//////////////////
|
|
6512
6516
|
imageBase64 = Buffer.from(await image_blob_ret.image_blob.arrayBuffer()).toString('base64');
|
|
6513
|
-
|
|
6514
|
-
const model = 'gpt-image-1-mini';
|
|
6517
|
+
const model = 'chatgpt-image-latest';
|
|
6518
|
+
// const model = 'gpt-image-1-mini';
|
|
6515
6519
|
const prompt = `
|
|
6516
6520
|
Create a futuristic, profile portrait with a transparent background.
|
|
6517
6521
|
make the character look like the person from the provided image with complete metal face hairless ,
|
|
@@ -6544,10 +6548,12 @@ const create_ai_agent_image = async function (req, job_id, headers) {
|
|
|
6544
6548
|
imageBase64 = ai_avatar_response.data[0].b64_json;
|
|
6545
6549
|
account_module.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);
|
|
6546
6550
|
console.log('Normalizing final avatar to 1024 with transparent padding...');
|
|
6547
|
-
imageBase64 = await normalizeBase64To1024(imageBase64
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
+
imageBase64 = await normalizeBase64To1024(imageBase64);
|
|
6552
|
+
|
|
6553
|
+
// imageBase64 = await normalizeBase64To1024(imageBase64, {
|
|
6554
|
+
// fit: 'contain', // Preserve aspect ratio, fit within 211x211
|
|
6555
|
+
// background: { r: 0, g: 0, b: 0, alpha: 0 }, // Transparent background for padding
|
|
6556
|
+
// });
|
|
6551
6557
|
|
|
6552
6558
|
const outputBuffer = Buffer.from(imageBase64, 'base64');
|
|
6553
6559
|
const outputPath = tempOutputPath;
|