@xuda.io/ai_module 1.1.4335 → 1.1.4337
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 +9 -5
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6734,17 +6734,21 @@ const get_profile_image = async function (uid, account_type = 'business', name,
|
|
|
6734
6734
|
.replace(/^_+|_+$/g, ''); // trim leading/trailing underscores
|
|
6735
6735
|
}
|
|
6736
6736
|
|
|
6737
|
-
|
|
6737
|
+
const get_factual_image = function () {};
|
|
6738
|
+
|
|
6739
|
+
let prompt, factual_prompt, originalname;
|
|
6738
6740
|
|
|
6739
6741
|
switch (account_type) {
|
|
6740
6742
|
case 'personal': {
|
|
6741
6743
|
prompt = `find "${name}" person profile image base on the following facts: "${JSON.stringify(facts)}", Return only png,jpg image url single result e.g: "https://fb.com/person_image.png", nothing else`;
|
|
6744
|
+
factual_prompt = ``;
|
|
6742
6745
|
originalname = normalizeFilename(name) + '_xu_profile.png';
|
|
6743
6746
|
break;
|
|
6744
6747
|
}
|
|
6745
6748
|
|
|
6746
6749
|
case 'business': {
|
|
6747
6750
|
prompt = `find "${name}" icon/logo, Return only png,jpg image url single result e.g: "https://example.com/logo_image.png", nothing else`;
|
|
6751
|
+
factual_prompt = `create logo for the company named: "${name}" the logo should only be initials of the name or geometric shape`;
|
|
6748
6752
|
originalname = normalizeFilename(name) + '_xu_logo.png';
|
|
6749
6753
|
break;
|
|
6750
6754
|
}
|
|
@@ -6775,20 +6779,20 @@ const get_profile_image = async function (uid, account_type = 'business', name,
|
|
|
6775
6779
|
} // throw new Error('not valid url');
|
|
6776
6780
|
let file;
|
|
6777
6781
|
try {
|
|
6778
|
-
file = await
|
|
6782
|
+
file = await get_image_blob_from_downloaded_image(url);
|
|
6779
6783
|
} catch (err) {
|
|
6780
6784
|
if (!err.message.includes('Failed to fetch image URL')) return console.error(err);
|
|
6781
6785
|
|
|
6782
6786
|
try {
|
|
6783
6787
|
url = await get_url();
|
|
6784
|
-
file = await
|
|
6788
|
+
file = await get_image_blob_from_downloaded_image(url);
|
|
6785
6789
|
} catch (err) {
|
|
6786
6790
|
// create factual image
|
|
6787
6791
|
|
|
6788
6792
|
return console.error(err);
|
|
6789
6793
|
}
|
|
6790
6794
|
}
|
|
6791
|
-
// const file = await
|
|
6795
|
+
// const file = await get_image_blob_from_downloaded_image(url);
|
|
6792
6796
|
// const imageBase64 = Buffer.from(await file.image_blob.arrayBuffer()).toString('base64');
|
|
6793
6797
|
const model = 'chatgpt-image-latest';
|
|
6794
6798
|
const prompt = `
|
|
@@ -6846,7 +6850,7 @@ async function normalizeBase64To1024(base64Image) {
|
|
|
6846
6850
|
return normalizedBuffer.toString('base64'); // Return normalized base64 string
|
|
6847
6851
|
}
|
|
6848
6852
|
|
|
6849
|
-
const
|
|
6853
|
+
const get_image_blob_from_downloaded_image = async function (url) {
|
|
6850
6854
|
async function hasTransparentBackground(filePath) {
|
|
6851
6855
|
const image = sharp(filePath);
|
|
6852
6856
|
const metadata = await image.metadata();
|