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