@xuda.io/ai_module 1.1.4640 → 1.1.4641

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 +43 -43
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -7364,7 +7364,6 @@ Category:`;
7364
7364
  }
7365
7365
  };
7366
7366
 
7367
-
7368
7367
  export const categorize_ai_prompt = async function (uid, prompt_text, account_profile_info) {
7369
7368
  const ai_prompt_categories = [
7370
7369
  // Creative & Content Generation (1-15)
@@ -7383,7 +7382,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7383
7382
  'Resume / Cover Letter',
7384
7383
  'Business Communication',
7385
7384
  'Technical Documentation',
7386
-
7385
+
7387
7386
  // Analysis & Research (16-30)
7388
7387
  'Data Analysis Request',
7389
7388
  'Research Assistance',
@@ -7400,7 +7399,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7400
7399
  'Document Analysis',
7401
7400
  'Text Summarization',
7402
7401
  'Comparative Analysis',
7403
-
7402
+
7404
7403
  // Technical & Programming (31-45)
7405
7404
  'Code Generation',
7406
7405
  'Bug Fixing',
@@ -7417,7 +7416,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7417
7416
  'Programming Tutorial',
7418
7417
  'Code Translation',
7419
7418
  'Technical Support',
7420
-
7419
+
7421
7420
  // Learning & Education (46-60)
7422
7421
  'Concept Explanation',
7423
7422
  'Homework Help',
@@ -7434,7 +7433,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7434
7433
  'Course Design',
7435
7434
  'Teaching Material',
7436
7435
  'Knowledge Assessment',
7437
-
7436
+
7438
7437
  // Business & Strategy (61-75)
7439
7438
  'Business Strategy',
7440
7439
  'Marketing Strategy',
@@ -7451,7 +7450,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7451
7450
  'Negotiation Strategy',
7452
7451
  'Leadership Advice',
7453
7452
  'Management Consulting',
7454
-
7453
+
7455
7454
  // Personal & Lifestyle (76-90)
7456
7455
  'Personal Advice',
7457
7456
  'Relationship Advice',
@@ -7468,7 +7467,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7468
7467
  'Hobby Assistance',
7469
7468
  'Recipe Creation',
7470
7469
  'Event Planning',
7471
-
7470
+
7472
7471
  // Analysis & Problem Solving (91-105)
7473
7472
  'Problem Solving',
7474
7473
  'Decision Making',
@@ -7485,7 +7484,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7485
7484
  'Prediction Request',
7486
7485
  'Forecasting',
7487
7486
  'Simulation Request',
7488
-
7487
+
7489
7488
  // Specialized Domains (106-120)
7490
7489
  'Legal Analysis',
7491
7490
  'Medical Information',
@@ -7502,7 +7501,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7502
7501
  'Cybersecurity',
7503
7502
  'Climate / Environment',
7504
7503
  'Public Policy',
7505
-
7504
+
7506
7505
  // Interactive & Conversational (121-130)
7507
7506
  'Roleplaying / Simulation',
7508
7507
  'Debate / Discussion',
@@ -7514,7 +7513,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7514
7513
  'Trivia / Quiz',
7515
7514
  'Joke Generation',
7516
7515
  'Conversational Companion',
7517
-
7516
+
7518
7517
  // Meta & System (131-140)
7519
7518
  'Prompt Engineering',
7520
7519
  'AI Capabilities Question',
@@ -7526,7 +7525,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7526
7525
  'Fact Checking',
7527
7526
  'Source Verification',
7528
7527
  'Translation Request',
7529
-
7528
+
7530
7529
  // Creative Arts (141-150)
7531
7530
  'Visual Art Description',
7532
7531
  'Art Style Analysis',
@@ -7538,7 +7537,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7538
7537
  'Creative Critique',
7539
7538
  'Artistic Inspiration',
7540
7539
  'Design Feedback',
7541
-
7540
+
7542
7541
  // Analysis & Processing (151-160)
7543
7542
  'Sentiment Analysis',
7544
7543
  'Text Classification',
@@ -7550,7 +7549,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7550
7549
  'Grammar Correction',
7551
7550
  'Style Improvement',
7552
7551
  'Tone Adjustment',
7553
-
7552
+
7554
7553
  // Planning & Organization (161-170)
7555
7554
  'Schedule Planning',
7556
7555
  'Task Management',
@@ -7562,7 +7561,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7562
7561
  'Checklist Creation',
7563
7562
  'Work Breakdown',
7564
7563
  'Deadline Management',
7565
-
7564
+
7566
7565
  // Communication & Social (171-180)
7567
7566
  'Conflict Resolution',
7568
7567
  'Communication Strategy',
@@ -7574,7 +7573,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7574
7573
  'Community Management',
7575
7574
  'Crisis Communication',
7576
7575
  'Reputation Management',
7577
-
7576
+
7578
7577
  // Technical Support & Operations (181-190)
7579
7578
  'IT Support',
7580
7579
  'System Troubleshooting',
@@ -7586,7 +7585,7 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7586
7585
  'Customer Support',
7587
7586
  'Service Desk',
7588
7587
  'Incident Response',
7589
-
7588
+
7590
7589
  // Data & Analytics (191-200)
7591
7590
  'Data Visualization',
7592
7591
  'Report Generation',
@@ -7597,15 +7596,18 @@ export const categorize_ai_prompt = async function (uid, prompt_text, account_pr
7597
7596
  'User Behavior Analysis',
7598
7597
  'Conversion Optimization',
7599
7598
  'Analytics Setup',
7600
- 'Data Cleaning'
7601
- ] as const;
7599
+ 'Data Cleaning',
7600
+ ];
7602
7601
 
7603
7602
  const prompt = `Categorize the AI prompt into one of these exact categories:
7604
7603
 
7605
7604
  AI Prompt: "${prompt_text.substring(0, 500)}${prompt_text.length > 500 ? '...' : ''}"
7606
7605
 
7607
7606
  Available Categories (200 total, showing first 20 as examples):
7608
- ${ai_prompt_categories.slice(0, 20).map((cat, index) => `${index + 1}. ${cat}`).join('\n')}
7607
+ ${ai_prompt_categories
7608
+ .slice(0, 20)
7609
+ .map((cat, index) => `${index + 1}. ${cat}`)
7610
+ .join('\n')}
7609
7611
  [Full list of 200 categories available to the system]
7610
7612
 
7611
7613
  Instructions:
@@ -7634,23 +7636,21 @@ Category:`;
7634
7636
  secondary_category: z.string().optional(),
7635
7637
  complexity_level: z.enum(['Basic', 'Intermediate', 'Advanced', 'Expert']).optional(),
7636
7638
  }),
7637
- metadata: {
7638
- func: 'categorize_ai_prompt',
7639
+ metadata: {
7640
+ func: 'categorize_ai_prompt',
7639
7641
  prompt_length: prompt_text.length,
7640
7642
  prompt_hash: await hashPrompt(prompt_text), // Optional: hash for deduplication
7641
- timestamp: new Date().toISOString()
7643
+ timestamp: new Date().toISOString(),
7642
7644
  },
7643
7645
  account_profile_info,
7644
7646
  });
7645
7647
 
7646
7648
  if (prompt_category_ret && prompt_category_ret.code > -1) {
7647
- const data = typeof prompt_category_ret.data === 'string'
7648
- ? JSON.parse(prompt_category_ret.data)
7649
- : prompt_category_ret.data;
7650
-
7649
+ const data = typeof prompt_category_ret.data === 'string' ? JSON.parse(prompt_category_ret.data) : prompt_category_ret.data;
7650
+
7651
7651
  // Additional analysis based on category
7652
7652
  const analysis = await analyzePromptComplexity(prompt_text, data.prompt_category);
7653
-
7653
+
7654
7654
  return {
7655
7655
  success: true,
7656
7656
  category: data.prompt_category,
@@ -7662,7 +7662,7 @@ Category:`;
7662
7662
  domain: getDomainFromCategory(data.prompt_category),
7663
7663
  requires_specialized_knowledge: analysis.requires_specialized_knowledge,
7664
7664
  prompt_preview: prompt_text.substring(0, 200),
7665
- timestamp: new Date().toISOString()
7665
+ timestamp: new Date().toISOString(),
7666
7666
  };
7667
7667
  } else {
7668
7668
  return {
@@ -7673,7 +7673,7 @@ Category:`;
7673
7673
  complexity: 'Basic',
7674
7674
  prompt_preview: prompt_text.substring(0, 200),
7675
7675
  error: prompt_category_ret?.message || 'API call failed',
7676
- timestamp: new Date().toISOString()
7676
+ timestamp: new Date().toISOString(),
7677
7677
  };
7678
7678
  }
7679
7679
  } catch (error) {
@@ -7686,7 +7686,7 @@ Category:`;
7686
7686
  complexity: 'Basic',
7687
7687
  prompt_preview: prompt_text.substring(0, 200),
7688
7688
  error: error.message,
7689
- timestamp: new Date().toISOString()
7689
+ timestamp: new Date().toISOString(),
7690
7690
  };
7691
7691
  }
7692
7692
  };
@@ -7698,7 +7698,7 @@ async function hashPrompt(text) {
7698
7698
  const data = encoder.encode(text);
7699
7699
  const hashBuffer = await crypto.subtle.digest('SHA-256', data);
7700
7700
  const hashArray = Array.from(new Uint8Array(hashBuffer));
7701
- return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
7701
+ return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
7702
7702
  }
7703
7703
 
7704
7704
  async function analyzePromptComplexity(prompt, category) {
@@ -7708,10 +7708,10 @@ async function analyzePromptComplexity(prompt, category) {
7708
7708
  const hasTechnicalTerms = /(\bAPI\b|\balgorithm\b|\bdebug\b|\banalysis\b)/i.test(prompt);
7709
7709
  const hasMultipleSteps = /(first|then|next|finally|step 1|step 2)/i.test(prompt);
7710
7710
  const requiresResearch = /(research|find|look up|investigate)/i.test(prompt);
7711
-
7711
+
7712
7712
  let complexity = 'Basic';
7713
7713
  let estimatedTokens = Math.ceil(wordCount * 1.3); // Rough estimation
7714
-
7714
+
7715
7715
  if (wordCount > 100 || hasTechnicalTerms || hasMultipleSteps) {
7716
7716
  complexity = 'Intermediate';
7717
7717
  }
@@ -7721,31 +7721,31 @@ async function analyzePromptComplexity(prompt, category) {
7721
7721
  if (wordCount > 500 || category.includes('Research') || category.includes('Analysis')) {
7722
7722
  complexity = 'Expert';
7723
7723
  }
7724
-
7724
+
7725
7725
  return {
7726
7726
  complexity,
7727
7727
  estimated_tokens: estimatedTokens,
7728
7728
  requires_specialized_knowledge: hasTechnicalTerms || requiresResearch,
7729
7729
  word_count: wordCount,
7730
- sentence_count: sentenceCount
7730
+ sentence_count: sentenceCount,
7731
7731
  };
7732
7732
  }
7733
7733
 
7734
7734
  function getDomainFromCategory(category) {
7735
7735
  // Map categories to broader domains
7736
7736
  const domainMap = {
7737
- 'Creative': /writing|story|poetry|creative|art|design/i,
7738
- 'Technical': /code|programming|technical|software|api|database/i,
7739
- 'Business': /business|marketing|sales|strategy|management/i,
7740
- 'Academic': /research|study|homework|academic|education/i,
7741
- 'Personal': /advice|personal|relationship|health|fitness/i,
7742
- 'Analytical': /analysis|data|statistical|trend|forecast/i
7737
+ Creative: /writing|story|poetry|creative|art|design/i,
7738
+ Technical: /code|programming|technical|software|api|database/i,
7739
+ Business: /business|marketing|sales|strategy|management/i,
7740
+ Academic: /research|study|homework|academic|education/i,
7741
+ Personal: /advice|personal|relationship|health|fitness/i,
7742
+ Analytical: /analysis|data|statistical|trend|forecast/i,
7743
7743
  };
7744
-
7744
+
7745
7745
  for (const [domain, pattern] of Object.entries(domainMap)) {
7746
7746
  if (pattern.test(category)) {
7747
7747
  return domain;
7748
7748
  }
7749
7749
  }
7750
7750
  return 'General';
7751
- }
7751
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4640",
3
+ "version": "1.1.4641",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",