@xuda.io/ai_module 1.1.3618 → 1.1.3620
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 +10 -13
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5758,10 +5758,11 @@ export const create_ai_agent_image = async function (req, job_id, headers) {
|
|
|
5758
5758
|
return { is_transparent, image_blob: new Blob([buffer], { type: 'image/png' }) };
|
|
5759
5759
|
}
|
|
5760
5760
|
|
|
5761
|
-
const {
|
|
5761
|
+
const { app_id, uid, account_obj, ai_agent_id, prompt } = req;
|
|
5762
5762
|
|
|
5763
5763
|
const ai_agent_doc = await db_module.get_app_couch_doc_native(app_id, ai_agent_id);
|
|
5764
5764
|
const account_doc = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
5765
|
+
let url = account_doc.account_info.profile_avatar;
|
|
5765
5766
|
|
|
5766
5767
|
try {
|
|
5767
5768
|
if (!url) {
|
|
@@ -5811,21 +5812,17 @@ export const create_ai_agent_image = async function (req, job_id, headers) {
|
|
|
5811
5812
|
//////////////////
|
|
5812
5813
|
imageBase64 = Buffer.from(await images[0].image_blob.arrayBuffer()).toString('base64');
|
|
5813
5814
|
|
|
5814
|
-
const
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
image: images[0].image_blob,
|
|
5815
|
+
const { first_name, last_name, bio, country, mainCategory, subCategory } = account_obj.account_info;
|
|
5816
|
+
const ai_avatar_response = await client.images.edit({
|
|
5817
|
+
model: 'chatgpt-image-latest',
|
|
5818
|
+
image: images[0].image_blob,
|
|
5819
5819
|
|
|
5820
|
-
|
|
5820
|
+
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.
|
|
5821
5821
|
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.
|
|
5822
5822
|
Context: ${JSON.stringify({ first_name, last_name, bio, country, mainCategory, subCategory })}`,
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
};
|
|
5827
|
-
|
|
5828
|
-
await create_avatar_from_pic();
|
|
5823
|
+
background: 'transparent',
|
|
5824
|
+
});
|
|
5825
|
+
imageBase64 = ai_avatar_response.data[0].b64_json;
|
|
5829
5826
|
|
|
5830
5827
|
console.log('Normalizing final avatar to 1024 with transparent padding...');
|
|
5831
5828
|
imageBase64 = await normalizeBase64To1024(imageBase64);
|