@xuda.io/ai_module 1.1.4305 → 1.1.4307
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 +19 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6726,7 +6726,7 @@ export const is_business_contact = async function (uid, email, name, subject, bo
|
|
|
6726
6726
|
const get_business_logo = async function (uid, name, account_profile_info) {
|
|
6727
6727
|
const ret = await submit_chat_gpt_prompt({
|
|
6728
6728
|
uid,
|
|
6729
|
-
prompt: `find "${name}" icon/logo, Return only png,jpg image url single result, nothing else`,
|
|
6729
|
+
prompt: `find "${name}" icon/logo, Return only png,jpg image url single result e.g: "https://example.com/logo_image.png", nothing else`,
|
|
6730
6730
|
model: 'gpt-5-nano',
|
|
6731
6731
|
// response_format: z.object({
|
|
6732
6732
|
// is_business: z.boolean().describe('true if this is a business account/contact, false otherwise'),
|
|
@@ -6751,6 +6751,24 @@ const get_business_logo = async function (uid, name, account_profile_info) {
|
|
|
6751
6751
|
};
|
|
6752
6752
|
|
|
6753
6753
|
const return_image_blob_from_downloaded_image = async function (url) {
|
|
6754
|
+
async function imageToPngBlob(filePath) {
|
|
6755
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
6756
|
+
|
|
6757
|
+
let buffer;
|
|
6758
|
+
|
|
6759
|
+
let is_transparent = false;
|
|
6760
|
+
if (ext === '.png') {
|
|
6761
|
+
buffer = await fs.promises.readFile(filePath);
|
|
6762
|
+
is_transparent = await hasTransparentBackground(filePath);
|
|
6763
|
+
} else {
|
|
6764
|
+
console.log(`Converting ${path.basename(filePath)} to PNG...`);
|
|
6765
|
+
buffer = await sharp(filePath).png({ quality: 100, compressionLevel: 9, force: true }).toBuffer();
|
|
6766
|
+
}
|
|
6767
|
+
|
|
6768
|
+
// Create a Blob with correct MIME type
|
|
6769
|
+
|
|
6770
|
+
return { is_transparent, image_blob: new Blob([buffer], { type: 'image/png' }) };
|
|
6771
|
+
}
|
|
6754
6772
|
try {
|
|
6755
6773
|
if (!url) {
|
|
6756
6774
|
throw new Error('No URL provided in request');
|