@xuda.io/ai_module 1.1.4371 → 1.1.4373

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.
Files changed (2) hide show
  1. package/index.mjs +131 -6
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -5674,7 +5674,7 @@ export const create_account_profile_avatar = async function (req, job_id, header
5674
5674
  }
5675
5675
  };
5676
5676
 
5677
- export const get_profile_avatar = async function (url, uid, prompt, account_profile_info, account_type, docType = 'account', _id, metadata = {}, profile_picture, business_size = 'unknown', name, email, job_id, headers) {
5677
+ export const get_profile_avatar = async function (profile_picture, uid, prompt, account_profile_info, account_type, docType = 'account', _id, metadata = {}, business_size = 'unknown', name, email, job_id, headers) {
5678
5678
  const tempDir = os.tmpdir();
5679
5679
  const uniqueId = Date.now() + '_' + Math.random().toString(36).substring(7);
5680
5680
  const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`);
@@ -5826,7 +5826,7 @@ export const get_profile_avatar = async function (url, uid, prompt, account_prof
5826
5826
  // );
5827
5827
 
5828
5828
  let imageBase64;
5829
- const image_blob_ret = await get_image_blob_from_downloaded_image(url);
5829
+ const image_blob_ret = await get_image_blob_from_downloaded_image(profile_picture);
5830
5830
  let avatar_source = '';
5831
5831
  if (prompt) {
5832
5832
  const model = 'chatgpt-image-latest';
@@ -5837,7 +5837,7 @@ export const get_profile_avatar = async function (url, uid, prompt, account_prof
5837
5837
  background: 'transparent',
5838
5838
  });
5839
5839
  imageBase64 = ai_avatar_response.data[0].b64_json;
5840
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { url }, account_profile_info);
5840
+ record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5841
5841
  } else {
5842
5842
  //////////////////
5843
5843
  imageBase64 = Buffer.from(await image_blob_ret.image_blob.arrayBuffer()).toString('base64');
@@ -5939,7 +5939,7 @@ export const get_profile_avatar = async function (url, uid, prompt, account_prof
5939
5939
  The background should be fully removed, remove trees,clouds,sky or any landscape objects`,
5940
5940
  background: 'transparent',
5941
5941
  });
5942
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { url }, account_profile_info);
5942
+ record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5943
5943
  imageBase64 = ai_avatar_response.data[0].b64_json;
5944
5944
  avatar_source = 'fictional';
5945
5945
  } else {
@@ -5956,7 +5956,7 @@ export const get_profile_avatar = async function (url, uid, prompt, account_prof
5956
5956
  Context: ${JSON.stringify({ name, bio, country, mainCategory, subCategory })}`,
5957
5957
  background: 'transparent',
5958
5958
  });
5959
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { url }, account_profile_info);
5959
+ record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { profile_picture }, account_profile_info);
5960
5960
  imageBase64 = ai_avatar_response.data[0].b64_json;
5961
5961
  avatar_source = 'ai profile';
5962
5962
  };
@@ -5966,7 +5966,7 @@ export const get_profile_avatar = async function (url, uid, prompt, account_prof
5966
5966
  const prompt = `analyze the the person info : ${JSON.stringify({ name, bio, country, mainCategory, subCategory })}
5967
5967
  and create realistic fictional profile picture transparent background ,person in the center of the picture return only a centered head-and-shoulders portrait facing the camera. include no labels or text add top margin the person should cover the whole picture`;
5968
5968
 
5969
- imageBase64 = await create_image(uid, prompt, undefined, undefined, 1, undefined, undefined, { url }, account_profile_info);
5969
+ imageBase64 = await create_image(uid, prompt, undefined, undefined, 1, undefined, undefined, { url: profile_picture }, account_profile_info);
5970
5970
  avatar_source = 'fictional';
5971
5971
  };
5972
5972
  // personal account
@@ -7005,3 +7005,128 @@ const get_image_blob_from_downloaded_image = async function (url) {
7005
7005
 
7006
7006
  return images[0];
7007
7007
  };
7008
+
7009
+ export const get_business_info = async function (uid, name, email, account_profile_info) {
7010
+ // 1. Prepare the valid values from your categories list
7011
+ const categories = [
7012
+ {
7013
+ id: 'ind_technology',
7014
+ name: 'Technology',
7015
+ sub: ['Software Development', 'AI & Machine Learning', 'Cybersecurity', 'Cloud Computing', 'IT Services', 'SaaS & Platforms', 'Hardware & Electronics'],
7016
+ },
7017
+ {
7018
+ id: 'ind_marketing',
7019
+ name: 'Marketing & Advertising',
7020
+ sub: ['Digital Marketing', 'PPC & SEO', 'Content Creation', 'Branding', 'Social Media Management', 'Email Marketing', 'Market Research'],
7021
+ },
7022
+ {
7023
+ id: 'ind_sales',
7024
+ name: 'Sales',
7025
+ sub: ['B2B Sales', 'B2C Sales', 'Real Estate Sales', 'Account Management', 'Lead Generation', 'Inside Sales', 'Field Sales'],
7026
+ },
7027
+ {
7028
+ id: 'ind_finance',
7029
+ name: 'Finance & Accounting',
7030
+ sub: ['Banking', 'Investment', 'Financial Planning', 'Accounting', 'Bookkeeping', 'Insurance', 'FinTech'],
7031
+ },
7032
+ {
7033
+ id: 'ind_healthcare',
7034
+ name: 'Healthcare',
7035
+ sub: ['Medical Clinics', 'Hospitals', 'Pharma', 'Mental Health', 'Healthcare IT', 'Home Care', 'Medical Research'],
7036
+ },
7037
+ {
7038
+ id: 'ind_realestate',
7039
+ name: 'Real Estate',
7040
+ sub: ['Residential Real Estate', 'Commercial Real Estate', 'Property Management', 'Investment & BRRRR', 'Construction', 'Architecture', 'Interior Design'],
7041
+ },
7042
+ {
7043
+ id: 'ind_ecommerce',
7044
+ name: 'E-commerce',
7045
+ sub: ['Online Store', 'Dropshipping', 'Amazon FBA', 'Marketplace Selling', 'Retail', 'Inventory Management', 'Fulfillment & Logistics'],
7046
+ },
7047
+ {
7048
+ id: 'ind_education',
7049
+ name: 'Education',
7050
+ sub: ['Schools', 'Universities', 'Private Tutoring', 'Online Courses', 'EdTech', 'Training & Development'],
7051
+ },
7052
+ {
7053
+ id: 'ind_hospitality',
7054
+ name: 'Hospitality & Travel',
7055
+ sub: ['Hotels', 'Restaurants', 'Cafes & Bars', 'Travel Agencies', 'Tourism', 'Events & Catering', 'Transportation'],
7056
+ },
7057
+ {
7058
+ id: 'ind_professional',
7059
+ name: 'Professional Services',
7060
+ sub: ['Legal', 'Consulting', 'HR & Recruiting', 'Accounting Firms', 'Business Services', 'Management Consulting'],
7061
+ },
7062
+ {
7063
+ id: 'ind_manufacturing',
7064
+ name: 'Manufacturing',
7065
+ sub: ['Automotive', 'Industrial', 'Textile', 'Electronics', 'Food Production', 'Machinery', 'Chemicals'],
7066
+ },
7067
+ {
7068
+ id: 'ind_nonprofit',
7069
+ name: 'Nonprofit & Government',
7070
+ sub: ['NGOs', 'Municipality', 'Government Services', 'Public Health', 'Community Organizations', 'Education Programs'],
7071
+ },
7072
+ {
7073
+ id: 'ind_media',
7074
+ name: 'Media & Entertainment',
7075
+ sub: ['Film & Video', 'Music', 'Publishing', 'Gaming', 'News & Journalism', 'Influencers', 'Production Studios'],
7076
+ },
7077
+ {
7078
+ id: 'ind_logistics',
7079
+ name: 'Logistics & Transportation',
7080
+ sub: ['Shipping', 'Trucking', 'Last-Mile Delivery', 'Warehousing', 'Freight Forwarding', 'Route Optimization'],
7081
+ },
7082
+ {
7083
+ id: 'ind_energy',
7084
+ name: 'Energy & Utilities',
7085
+ sub: ['Solar', 'Oil & Gas', 'Electricity Providers', 'Water Utilities', 'Environmental Services', 'Renewable Energy'],
7086
+ },
7087
+ {
7088
+ id: 'ind_construction',
7089
+ name: 'Construction & Trades',
7090
+ sub: ['General Contracting', 'Roofing', 'Plumbing', 'HVAC', 'Electrical', 'Renovation', 'Engineering'],
7091
+ },
7092
+ {
7093
+ id: 'ind_food',
7094
+ name: 'Food & Beverage',
7095
+ sub: ['Restaurants', 'Catering', 'Food Manufacturing', 'Bakeries', 'Bars & Nightlife', 'Food Delivery'],
7096
+ },
7097
+ {
7098
+ id: 'ind_retail',
7099
+ name: 'Retail',
7100
+ sub: ['Physical Stores', 'Boutiques', 'Supermarkets', 'Consumer Goods', 'Fashion Retail', 'Home Goods'],
7101
+ },
7102
+ ];
7103
+
7104
+ const categoryNames = categories.map((c) => c.name);
7105
+ const allSubCategories = categories.flatMap((c) => c.sub);
7106
+
7107
+ const business_info_ret = await submit_chat_gpt_prompt({
7108
+ uid,
7109
+ prompt: `Research the company "${name}" (${email}). Identify their business size,
7110
+ main industry category, and specific sub-category based on the provided lists.`,
7111
+ model: 'gpt-5-nano',
7112
+ response_format: z.object({
7113
+ business_size: z.enum(['unknown', 'small', 'medium', 'large', 'enterprise']),
7114
+ business_category: z.enum(categoryNames).describe('The primary industry category name'),
7115
+ business_sub_category: z.enum(allSubCategories).describe('The specific niche within that category'),
7116
+ business_country: z.string().describe('Primary country of operation'),
7117
+ }),
7118
+ metadata: { func: 'get_business_info' },
7119
+ account_profile_info,
7120
+ tools: [{ type: 'web_search_preview' }],
7121
+ });
7122
+
7123
+ try {
7124
+ if (business_info_ret.code > -1) {
7125
+ const data = typeof business_info_ret.data === 'string' ? JSON.parse(business_info_ret.data) : business_info_ret.data;
7126
+
7127
+ return data;
7128
+ }
7129
+ } catch (error) {
7130
+ console.error('Schema validation or parsing error', error);
7131
+ }
7132
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4371",
3
+ "version": "1.1.4373",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",