@xuda.io/ai_module 1.1.4632 → 1.1.4634

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 +36 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1749,7 +1749,7 @@ export const get_chat_conversation = async function (req) {
1749
1749
  await db_module.save_app_couch_doc(account_profile_info.app_id, conversation_item_doc);
1750
1750
  }
1751
1751
 
1752
- return { code: 15, data: { conversation_items, ...conversation_doc } };
1752
+ return { code: 15, data: { conversation: conversation_items, ...conversation_doc } };
1753
1753
  } catch (err) {
1754
1754
  return { code: -15, data: err.message };
1755
1755
  }
@@ -7161,3 +7161,38 @@ export const get_name_from_email_addr = async function (uid, email, account_prof
7161
7161
  console.error('Error in get_name_from_email_addr:', error);
7162
7162
  }
7163
7163
  };
7164
+
7165
+ export const categorize_email_subject = async function (uid, subject, account_profile_info) {
7166
+ const email_categories = [];
7167
+ const categoryNames = categories.map((c) => c.name);
7168
+ const allSubCategories = categories.flatMap((c) => c.sub);
7169
+
7170
+ const email_category_ret = await submit_chat_gpt_prompt({
7171
+ uid,
7172
+ prompt: `categorize the email subject: "${subject}".
7173
+ `,
7174
+ model: 'gpt-5-nano',
7175
+ response_format: z.object({
7176
+ email_category: z.enum(email_categories),
7177
+ }),
7178
+ metadata: { func: 'categorize_email_subject' },
7179
+ account_profile_info,
7180
+ });
7181
+
7182
+ try {
7183
+ if (business_info_ret.code > -1) {
7184
+ const data = typeof business_info_ret.data === 'string' ? JSON.parse(business_info_ret.data) : business_info_ret.data;
7185
+
7186
+ // Standardize country to uppercase
7187
+ if (data.business_country) data.business_country = data.business_country.toUpperCase();
7188
+
7189
+ // Logic to attach the ID for your database
7190
+ const matched = categories.find((c) => c.name === data.business_category);
7191
+ data.business_category_id = matched ? matched.id : null;
7192
+
7193
+ return data;
7194
+ }
7195
+ } catch (error) {
7196
+ console.error('Error in get_business_info:', error);
7197
+ }
7198
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4632",
3
+ "version": "1.1.4634",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",