@xuda.io/ai_module 1.1.4314 → 1.1.4316
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 +10 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6735,11 +6735,14 @@ const get_business_logo = async function (uid, name, account_profile_info) {
|
|
|
6735
6735
|
tools: [{ type: 'web_search_preview' }],
|
|
6736
6736
|
});
|
|
6737
6737
|
console.log('=============', ret);
|
|
6738
|
-
|
|
6738
|
+
|
|
6739
6739
|
return ret.data;
|
|
6740
6740
|
};
|
|
6741
6741
|
try {
|
|
6742
6742
|
let url = await get_url();
|
|
6743
|
+
if (!url.includes('https://')) {
|
|
6744
|
+
url = await get_url();
|
|
6745
|
+
} // throw new Error('not valid url');
|
|
6743
6746
|
let file;
|
|
6744
6747
|
try {
|
|
6745
6748
|
file = await return_image_blob_from_downloaded_image(url);
|
|
@@ -6765,8 +6768,8 @@ const get_business_logo = async function (uid, name, account_profile_info) {
|
|
|
6765
6768
|
prompt,
|
|
6766
6769
|
background: 'transparent',
|
|
6767
6770
|
});
|
|
6768
|
-
|
|
6769
|
-
imageBase64 = await normalizeBase64To1024(logo_response.data[0].b64_json);
|
|
6771
|
+
debugger;
|
|
6772
|
+
let imageBase64 = await normalizeBase64To1024(logo_response.data[0].b64_json);
|
|
6770
6773
|
|
|
6771
6774
|
const outputBuffer = Buffer.from(imageBase64, 'base64');
|
|
6772
6775
|
const outputPath = file.tempOutputPath;
|
|
@@ -6775,6 +6778,7 @@ const get_business_logo = async function (uid, name, account_profile_info) {
|
|
|
6775
6778
|
console.log('Success! Saved →', outputPath);
|
|
6776
6779
|
|
|
6777
6780
|
console.log(file);
|
|
6781
|
+
record_chat_usage(uid, logo_response.usage.input_tokens, logo_response.usage.output_tokens, 'business logo', prompt, model, { url }, account_profile_info);
|
|
6778
6782
|
// prompt: `find "${name}" logo base on the following facts "${facts}", Return only png,jpg img tag , nothing else`,
|
|
6779
6783
|
// try {
|
|
6780
6784
|
// if (ret.code > -1) {
|
|
@@ -6782,7 +6786,9 @@ const get_business_logo = async function (uid, name, account_profile_info) {
|
|
|
6782
6786
|
// return data.is_business;
|
|
6783
6787
|
// }
|
|
6784
6788
|
// } catch (error) {}
|
|
6785
|
-
} catch (err) {
|
|
6789
|
+
} catch (err) {
|
|
6790
|
+
return console.error(err);
|
|
6791
|
+
}
|
|
6786
6792
|
};
|
|
6787
6793
|
|
|
6788
6794
|
async function normalizeBase64To1024(base64Image) {
|