@xuda.io/ai_module 1.1.4635 → 1.1.4637

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 +101 -16
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -7163,27 +7163,112 @@ export const get_name_from_email_addr = async function (uid, email, account_prof
7163
7163
  };
7164
7164
 
7165
7165
  export const categorize_email_subject = async function (uid, subject, account_profile_info) {
7166
- const email_categories = [];
7166
+ // Define comprehensive email categories
7167
+ const email_categories = [
7168
+ 'Meeting Invitations',
7169
+ 'Meeting Updates / Cancellations',
7170
+ 'Team Announcements',
7171
+ 'One-on-One Requests',
7172
+ 'Project Collaboration',
7173
+ 'Job Applications',
7174
+ 'Interview Scheduling',
7175
+ 'Contract / Agreement',
7176
+ 'Invoice / Billing',
7177
+ 'Business Proposal',
7178
+ 'Client Inquiry',
7179
+ 'Sales / Promotional',
7180
+ 'Partnership Opportunity',
7181
+ 'Report / Analysis',
7182
+ 'Performance Review',
7183
+ 'Payment Received',
7184
+ 'Payment Request / Reminder',
7185
+ 'Subscription Renewal',
7186
+ 'Order Confirmation',
7187
+ 'Shipping Notification',
7188
+ 'Refund / Return',
7189
+ 'Account Verification',
7190
+ 'Password Reset',
7191
+ 'Security Alert',
7192
+ 'Privacy Policy Update',
7193
+ 'Terms of Service Change',
7194
+ 'Event Invitation (Social)',
7195
+ 'Connection Request',
7196
+ 'Newsletter',
7197
+ 'Blog / Content Update',
7198
+ 'Survey / Feedback Request',
7199
+ 'System Maintenance',
7200
+ 'Software Update',
7201
+ 'Service Outage',
7202
+ 'New Feature Announcement',
7203
+ 'Course Enrollment',
7204
+ 'Webinar Invitation',
7205
+ 'Certification / Training',
7206
+ 'Research / Study Invitation',
7207
+ 'Appointment Reminder',
7208
+ 'Health Tips / Newsletter',
7209
+ 'Prescription Ready',
7210
+ 'Travel Booking Confirmation',
7211
+ 'Flight / Hotel Updates',
7212
+ 'Event Tickets',
7213
+ 'Notification / Alert',
7214
+ 'Confirmation (General)',
7215
+ 'Welcome / Onboarding',
7216
+ 'Follow-up / Reminder',
7217
+ 'Miscellaneous / Unclassified',
7218
+ ];
7167
7219
 
7168
- const email_category_ret = await submit_chat_gpt_prompt({
7169
- uid,
7170
- prompt: `categorize the email subject: "${subject}".
7171
- `,
7172
- model: 'gpt-5-nano',
7173
- response_format: z.object({
7174
- email_category: z.enum(email_categories),
7175
- }),
7176
- metadata: { func: 'categorize_email_subject' },
7177
- account_profile_info,
7178
- });
7220
+ // Create a more detailed prompt with context
7221
+ const prompt = `Categorize the email subject into one of these exact categories:
7222
+
7223
+ Email Subject: "${subject}"
7224
+
7225
+ Available Categories:
7226
+ ${email_categories.map((cat, index) => `${index + 1}. ${cat}`).join('\n')}
7227
+
7228
+ Instructions:
7229
+ 1. Choose the single most relevant category
7230
+ 2. Return only the exact category name as it appears above
7231
+ 3. If unsure, choose "Miscellaneous / Unclassified"
7232
+
7233
+ Category:`;
7179
7234
 
7180
7235
  try {
7181
- if (email_category_ret.code > -1) {
7182
- const data = typeof email_category_ret.data === 'string' ? JSON.parse(email_category_ret.data) : business_info_ret.data;
7236
+ const email_category_ret = await submit_chat_gpt_prompt({
7237
+ uid,
7238
+ prompt: prompt,
7239
+ model: 'gpt-4o-mini', // Updated to a valid model name (gpt-5-nano doesn't exist)
7240
+ response_format: z.object({
7241
+ email_category: z.enum(email_categories),
7242
+ }),
7243
+ metadata: { func: 'categorize_email_subject', subject: subject.substring(0, 100) }, // Add subject for tracking
7244
+ account_profile_info,
7245
+ });
7183
7246
 
7184
- return data;
7247
+ if (email_category_ret && email_category_ret.code > -1) {
7248
+ // Parse the response data
7249
+ const data = typeof email_category_ret.data === 'string' ? JSON.parse(email_category_ret.data) : email_category_ret.data; // Fixed variable name (was business_info_ret.data)
7250
+
7251
+ return {
7252
+ success: true,
7253
+ category: data.email_category,
7254
+ subject: subject,
7255
+ };
7256
+ } else {
7257
+ console.warn('Failed to categorize email subject:', email_category_ret?.message);
7258
+ return {
7259
+ success: false,
7260
+ category: 'Miscellaneous / Unclassified',
7261
+ subject: subject,
7262
+ error: email_category_ret?.message || 'Unknown error',
7263
+ };
7185
7264
  }
7186
7265
  } catch (error) {
7187
- console.error('Error in get_business_info:', error);
7266
+ console.error('Error in categorize_email_subject:', error);
7267
+ return {
7268
+ success: false,
7269
+ category: 'Miscellaneous / Unclassified',
7270
+ subject: subject,
7271
+ error: error.message,
7272
+ };
7188
7273
  }
7189
7274
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4635",
3
+ "version": "1.1.4637",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",