@xuda.io/ai_module 1.1.4317 → 1.1.4318
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 +23 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5289,7 +5289,8 @@ setTimeout(async () => {
|
|
|
5289
5289
|
// Location: 'https://xuda-bucket-dev.nyc3.digitaloceanspaces.com/dev.xuda.io/user/d39126e0e2c51ffbd1aad10709fc8335/cb7353fc-4788-49b7-8e73-f7f1be108b69_drv_d39126e0e2c51ffbd1aad10709fc8335_b92337f79e090a2f287bc3dc35d0033e.png',
|
|
5290
5290
|
// },
|
|
5291
5291
|
// });
|
|
5292
|
-
|
|
5292
|
+
|
|
5293
|
+
// ret = await get_business_logo(uid, 'bank of america', account_profile_info);
|
|
5293
5294
|
|
|
5294
5295
|
console.log(ret);
|
|
5295
5296
|
}, 1000);
|
|
@@ -6724,6 +6725,15 @@ export const is_business_contact = async function (uid, email, name, subject, bo
|
|
|
6724
6725
|
};
|
|
6725
6726
|
|
|
6726
6727
|
const get_business_logo = async function (uid, name, account_profile_info) {
|
|
6728
|
+
function normalizeFilename(name) {
|
|
6729
|
+
return name
|
|
6730
|
+
.toLowerCase() // lowercase
|
|
6731
|
+
.replace(/\s+/g, '_') // replace all spaces with single underscore
|
|
6732
|
+
.replace(/[^a-z0-9._-]/g, '') // remove anything that's not letter, number, dot, underscore, or hyphen
|
|
6733
|
+
.replace(/_+/g, '_') // collapse multiple underscores
|
|
6734
|
+
.replace(/^_+|_+$/g, ''); // trim leading/trailing underscores
|
|
6735
|
+
}
|
|
6736
|
+
|
|
6727
6737
|
const get_url = async function () {
|
|
6728
6738
|
const ret = await submit_chat_gpt_prompt({
|
|
6729
6739
|
uid,
|
|
@@ -6768,7 +6778,7 @@ const get_business_logo = async function (uid, name, account_profile_info) {
|
|
|
6768
6778
|
prompt,
|
|
6769
6779
|
background: 'transparent',
|
|
6770
6780
|
});
|
|
6771
|
-
|
|
6781
|
+
|
|
6772
6782
|
let imageBase64 = await normalizeBase64To1024(logo_response.data[0].b64_json);
|
|
6773
6783
|
|
|
6774
6784
|
const outputBuffer = Buffer.from(imageBase64, 'base64');
|
|
@@ -6778,6 +6788,15 @@ const get_business_logo = async function (uid, name, account_profile_info) {
|
|
|
6778
6788
|
console.log('Success! Saved →', outputPath);
|
|
6779
6789
|
|
|
6780
6790
|
console.log(file);
|
|
6791
|
+
|
|
6792
|
+
const file_obj = {
|
|
6793
|
+
originalname: normalizeFilename(name) + '_xu_logo.png',
|
|
6794
|
+
path: outputPath,
|
|
6795
|
+
mimetype: `application/png`,
|
|
6796
|
+
};
|
|
6797
|
+
|
|
6798
|
+
const drive_ret = await drive_module.upload_drive_file_user({ uid, path: '/Profile Images' }, job_id, headers, file_obj);
|
|
6799
|
+
|
|
6781
6800
|
record_chat_usage(uid, logo_response.usage.input_tokens, logo_response.usage.output_tokens, 'business logo', prompt, model, { url }, account_profile_info);
|
|
6782
6801
|
// prompt: `find "${name}" logo base on the following facts "${facts}", Return only png,jpg img tag , nothing else`,
|
|
6783
6802
|
// try {
|
|
@@ -6786,6 +6805,8 @@ const get_business_logo = async function (uid, name, account_profile_info) {
|
|
|
6786
6805
|
// return data.is_business;
|
|
6787
6806
|
// }
|
|
6788
6807
|
// } catch (error) {}
|
|
6808
|
+
|
|
6809
|
+
return drive_ret;
|
|
6789
6810
|
} catch (err) {
|
|
6790
6811
|
return console.error(err);
|
|
6791
6812
|
}
|