@xuda.io/ai_module 1.1.4353 → 1.1.4355
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 +20 -21
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5291,16 +5291,16 @@ setTimeout(async () => {
|
|
|
5291
5291
|
// });
|
|
5292
5292
|
|
|
5293
5293
|
// ret = await get_profile_image(uid, 'business', 'ioshka media', {}, account_profile_info);
|
|
5294
|
-
ret = await get_profile_image(
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
);
|
|
5294
|
+
// ret = await get_profile_image(
|
|
5295
|
+
// uid,
|
|
5296
|
+
// 'personal',
|
|
5297
|
+
// 'Glenn Willett',
|
|
5298
|
+
// {
|
|
5299
|
+
// email: 'glennwillett@schoolsponsoringregionzft.com',
|
|
5300
|
+
// body: 'We have a couple middle and elementary schools a few minutes from you in Boca Raton that have available sponsorship slots. The parents would see your sponsorship in the student progress reports each week.Is it okay if I send over the available spots?',
|
|
5301
|
+
// },
|
|
5302
|
+
// account_profile_info,
|
|
5303
|
+
// );
|
|
5304
5304
|
|
|
5305
5305
|
console.log(ret);
|
|
5306
5306
|
}, 1000);
|
|
@@ -5675,6 +5675,10 @@ export const create_account_profile_avatar = async function (req, job_id, header
|
|
|
5675
5675
|
};
|
|
5676
5676
|
|
|
5677
5677
|
export const create_profile_avatar = async function (req, job_id, headers) {
|
|
5678
|
+
const tempDir = os.tmpdir();
|
|
5679
|
+
const uniqueId = Date.now() + '_' + Math.random().toString(36).substring(7);
|
|
5680
|
+
const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`);
|
|
5681
|
+
|
|
5678
5682
|
async function normalizeBase64To1024(base64Image) {
|
|
5679
5683
|
const inputBuffer = Buffer.from(base64Image, 'base64');
|
|
5680
5684
|
|
|
@@ -6734,7 +6738,7 @@ export const is_business_contact = async function (uid, email, name, subject, bo
|
|
|
6734
6738
|
} catch (error) {}
|
|
6735
6739
|
};
|
|
6736
6740
|
|
|
6737
|
-
const get_profile_image = async function (uid, account_type = 'business', name, facts = {}, account_profile_info) {
|
|
6741
|
+
const get_profile_image = async function (uid, account_type = 'business', name, facts = {}, account_profile_info, job_id, headers) {
|
|
6738
6742
|
const tempDir = os.tmpdir();
|
|
6739
6743
|
const uniqueId = Date.now() + '_' + Math.random().toString(36).substring(7);
|
|
6740
6744
|
const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`);
|
|
@@ -6781,12 +6785,12 @@ const get_profile_image = async function (uid, account_type = 'business', name,
|
|
|
6781
6785
|
account_profile_info,
|
|
6782
6786
|
tools: [{ type: 'web_search_preview' }],
|
|
6783
6787
|
});
|
|
6784
|
-
console.log('=============', ret);
|
|
6788
|
+
// console.log('=============', ret);
|
|
6785
6789
|
|
|
6786
6790
|
return ret.data;
|
|
6787
6791
|
};
|
|
6788
6792
|
|
|
6789
|
-
debugger;
|
|
6793
|
+
// debugger;
|
|
6790
6794
|
try {
|
|
6791
6795
|
// first attempt
|
|
6792
6796
|
let url = await get_url();
|
|
@@ -6842,12 +6846,12 @@ const get_profile_image = async function (uid, account_type = 'business', name,
|
|
|
6842
6846
|
|
|
6843
6847
|
const drive_ret = await drive_module.upload_drive_file_user({ uid, path: '/Profile Images' }, job_id, headers, file_obj);
|
|
6844
6848
|
|
|
6845
|
-
record_chat_usage(uid, image_response.usage.input_tokens, image_response.usage.output_tokens, '
|
|
6849
|
+
record_chat_usage(uid, image_response.usage.input_tokens, image_response.usage.output_tokens, 'profile image', prompt, model, { url }, account_profile_info);
|
|
6846
6850
|
|
|
6847
6851
|
return drive_ret;
|
|
6848
6852
|
} catch (err) {
|
|
6849
6853
|
console.error(err);
|
|
6850
|
-
return
|
|
6854
|
+
return;
|
|
6851
6855
|
}
|
|
6852
6856
|
};
|
|
6853
6857
|
|
|
@@ -6937,7 +6941,7 @@ const get_image_blob_from_downloaded_image = async function (url) {
|
|
|
6937
6941
|
|
|
6938
6942
|
const inputExt = path.extname(url) || '.jpg';
|
|
6939
6943
|
const tempInputPath = path.join(tempDir, `input_${uniqueId}${inputExt}`);
|
|
6940
|
-
const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`); // Output is always PNG (transparent)
|
|
6944
|
+
// const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`); // Output is always PNG (transparent)
|
|
6941
6945
|
|
|
6942
6946
|
// 5. Write the downloaded image to disk
|
|
6943
6947
|
fs.writeFileSync(tempInputPath, imageBuffer);
|
|
@@ -6961,9 +6965,4 @@ const get_image_blob_from_downloaded_image = async function (url) {
|
|
|
6961
6965
|
);
|
|
6962
6966
|
|
|
6963
6967
|
return images[0].image_blob;
|
|
6964
|
-
// return { image_blob: images[0].image_blob, is_transparent: images[0].is_transparent, tempOutputPath };
|
|
6965
|
-
|
|
6966
|
-
// } catch (err) {
|
|
6967
|
-
// console.error(err);
|
|
6968
|
-
// }
|
|
6969
6968
|
};
|