@xuda.io/ai_module 1.1.4340 → 1.1.4342
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 +14 -17
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6734,9 +6734,7 @@ const get_profile_image = async function (uid, account_type = 'business', name,
|
|
|
6734
6734
|
.replace(/^_+|_+$/g, ''); // trim leading/trailing underscores
|
|
6735
6735
|
}
|
|
6736
6736
|
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
let prompt, factual_prompt, originalname, factual_image_mode;
|
|
6737
|
+
let prompt, factual_prompt, originalname, factual_image_mode, imageBase64;
|
|
6740
6738
|
|
|
6741
6739
|
switch (account_type) {
|
|
6742
6740
|
case 'personal': {
|
|
@@ -6790,26 +6788,25 @@ const get_profile_image = async function (uid, account_type = 'business', name,
|
|
|
6790
6788
|
file = await get_image_blob_from_downloaded_image(url);
|
|
6791
6789
|
} catch (err) {
|
|
6792
6790
|
// create factual image
|
|
6793
|
-
imageBase64 = await create_image(uid, factual_prompt, undefined, undefined, 1, undefined, undefined, {}, account_profile_info);
|
|
6794
6791
|
factual_image_mode = true;
|
|
6795
|
-
// return console.error(err);
|
|
6796
6792
|
}
|
|
6797
6793
|
}
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6794
|
+
if (factual_image_mode) {
|
|
6795
|
+
imageBase64 = await create_image(uid, factual_prompt, undefined, undefined, 1, undefined, undefined, {}, account_profile_info);
|
|
6796
|
+
} else {
|
|
6797
|
+
const model = 'chatgpt-image-latest';
|
|
6798
|
+
const prompt = `
|
|
6802
6799
|
extract the logo from the image
|
|
6803
6800
|
`;
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
let imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json);
|
|
6801
|
+
const image_response = await client.images.edit({
|
|
6802
|
+
model,
|
|
6803
|
+
image: file.image_blob, //logo
|
|
6804
|
+
prompt,
|
|
6805
|
+
background: 'transparent',
|
|
6806
|
+
});
|
|
6812
6807
|
|
|
6808
|
+
imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json);
|
|
6809
|
+
}
|
|
6813
6810
|
const outputBuffer = Buffer.from(imageBase64, 'base64');
|
|
6814
6811
|
const outputPath = file.tempOutputPath;
|
|
6815
6812
|
await fs.promises.writeFile(outputPath, outputBuffer);
|