@xuda.io/ai_module 1.1.4768 → 1.1.4770

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 (3) hide show
  1. package/index.mjs +59 -58
  2. package/old.mjs +18 -4
  3. package/package.json +1 -1
package/index.mjs CHANGED
@@ -7519,6 +7519,65 @@ Category:`;
7519
7519
  };
7520
7520
 
7521
7521
  export const categorize_ai_prompt = async function (uid, prompt_text, account_profile_info) {
7522
+ // Helper functions (would be defined elsewhere)
7523
+ async function hashPrompt(text) {
7524
+ // Simple hash function for deduplication
7525
+ const encoder = new TextEncoder();
7526
+ const data = encoder.encode(text);
7527
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data);
7528
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
7529
+ return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
7530
+ }
7531
+
7532
+ async function analyzePromptComplexity(prompt, category) {
7533
+ // Analyze prompt complexity based on various factors
7534
+ const wordCount = prompt.split(/\s+/).length;
7535
+ const sentenceCount = prompt.split(/[.!?]+/).length;
7536
+ const hasTechnicalTerms = /(\bAPI\b|\balgorithm\b|\bdebug\b|\banalysis\b)/i.test(prompt);
7537
+ const hasMultipleSteps = /(first|then|next|finally|step 1|step 2)/i.test(prompt);
7538
+ const requiresResearch = /(research|find|look up|investigate)/i.test(prompt);
7539
+
7540
+ let complexity = 'Basic';
7541
+ let estimatedTokens = Math.ceil(wordCount * 1.3); // Rough estimation
7542
+
7543
+ if (wordCount > 100 || hasTechnicalTerms || hasMultipleSteps) {
7544
+ complexity = 'Intermediate';
7545
+ }
7546
+ if (wordCount > 300 || requiresResearch || category.includes('Advanced') || category.includes('Expert')) {
7547
+ complexity = 'Advanced';
7548
+ }
7549
+ if (wordCount > 500 || category.includes('Research') || category.includes('Analysis')) {
7550
+ complexity = 'Expert';
7551
+ }
7552
+
7553
+ return {
7554
+ complexity,
7555
+ estimated_tokens: estimatedTokens,
7556
+ requires_specialized_knowledge: hasTechnicalTerms || requiresResearch,
7557
+ word_count: wordCount,
7558
+ sentence_count: sentenceCount,
7559
+ };
7560
+ }
7561
+
7562
+ function getDomainFromCategory(category) {
7563
+ // Map categories to broader domains
7564
+ const domainMap = {
7565
+ Creative: /writing|story|poetry|creative|art|design/i,
7566
+ Technical: /code|programming|technical|software|api|database/i,
7567
+ Business: /business|marketing|sales|strategy|management/i,
7568
+ Academic: /research|study|homework|academic|education/i,
7569
+ Personal: /advice|personal|relationship|health|fitness/i,
7570
+ Analytical: /analysis|data|statistical|trend|forecast/i,
7571
+ };
7572
+
7573
+ for (const [domain, pattern] of Object.entries(domainMap)) {
7574
+ if (pattern.test(category)) {
7575
+ return domain;
7576
+ }
7577
+ }
7578
+ return 'General';
7579
+ }
7580
+
7522
7581
  const ai_prompt_categories = [
7523
7582
  // Creative & Content Generation (1-15)
7524
7583
  'Creative Writing',
@@ -7845,64 +7904,6 @@ Category:`;
7845
7904
  }
7846
7905
  };
7847
7906
 
7848
- // Helper functions (would be defined elsewhere)
7849
- async function hashPrompt(text) {
7850
- // Simple hash function for deduplication
7851
- const encoder = new TextEncoder();
7852
- const data = encoder.encode(text);
7853
- const hashBuffer = await crypto.subtle.digest('SHA-256', data);
7854
- const hashArray = Array.from(new Uint8Array(hashBuffer));
7855
- return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
7856
- }
7857
-
7858
- async function analyzePromptComplexity(prompt, category) {
7859
- // Analyze prompt complexity based on various factors
7860
- const wordCount = prompt.split(/\s+/).length;
7861
- const sentenceCount = prompt.split(/[.!?]+/).length;
7862
- const hasTechnicalTerms = /(\bAPI\b|\balgorithm\b|\bdebug\b|\banalysis\b)/i.test(prompt);
7863
- const hasMultipleSteps = /(first|then|next|finally|step 1|step 2)/i.test(prompt);
7864
- const requiresResearch = /(research|find|look up|investigate)/i.test(prompt);
7865
-
7866
- let complexity = 'Basic';
7867
- let estimatedTokens = Math.ceil(wordCount * 1.3); // Rough estimation
7868
-
7869
- if (wordCount > 100 || hasTechnicalTerms || hasMultipleSteps) {
7870
- complexity = 'Intermediate';
7871
- }
7872
- if (wordCount > 300 || requiresResearch || category.includes('Advanced') || category.includes('Expert')) {
7873
- complexity = 'Advanced';
7874
- }
7875
- if (wordCount > 500 || category.includes('Research') || category.includes('Analysis')) {
7876
- complexity = 'Expert';
7877
- }
7878
-
7879
- return {
7880
- complexity,
7881
- estimated_tokens: estimatedTokens,
7882
- requires_specialized_knowledge: hasTechnicalTerms || requiresResearch,
7883
- word_count: wordCount,
7884
- sentence_count: sentenceCount,
7885
- };
7886
- }
7887
-
7888
- function getDomainFromCategory(category) {
7889
- // Map categories to broader domains
7890
- const domainMap = {
7891
- Creative: /writing|story|poetry|creative|art|design/i,
7892
- Technical: /code|programming|technical|software|api|database/i,
7893
- Business: /business|marketing|sales|strategy|management/i,
7894
- Academic: /research|study|homework|academic|education/i,
7895
- Personal: /advice|personal|relationship|health|fitness/i,
7896
- Analytical: /analysis|data|statistical|trend|forecast/i,
7897
- };
7898
-
7899
- for (const [domain, pattern] of Object.entries(domainMap)) {
7900
- if (pattern.test(category)) {
7901
- return domain;
7902
- }
7903
- }
7904
- return 'General';
7905
- }
7906
7907
  export const categorize_text_message = async function (uid, text_message, account_profile_info) {
7907
7908
  const text_message_categories = [
7908
7909
  // Personal Communication (1-20)
package/old.mjs CHANGED
@@ -2087,8 +2087,6 @@ for await (let account_profile of profile_requests_from_res.docs) {
2087
2087
  // }
2088
2088
  // };
2089
2089
 
2090
-
2091
-
2092
2090
  // export const get_business_info = async function (uid, name, email, account_profile_info) {
2093
2091
  // // ========== HELPER FUNCTIONS ==========
2094
2092
 
@@ -4635,8 +4633,6 @@ for await (let account_profile of profile_requests_from_res.docs) {
4635
4633
  // }
4636
4634
  // };
4637
4635
 
4638
-
4639
-
4640
4636
  // export const get_business_info = async function (uid, name, email, account_profile_info) {
4641
4637
  // // Extract lists from your JSON categories array
4642
4638
  // const categories = [
@@ -4774,3 +4770,21 @@ for await (let account_profile of profile_requests_from_res.docs) {
4774
4770
  // console.error('Error in get_business_info:', error);
4775
4771
  // }
4776
4772
  // };
4773
+
4774
+ // async function normalizeBase64To1024(base64Image) {
4775
+ // const inputBuffer = Buffer.from(base64Image, 'base64');
4776
+
4777
+ // const normalizedBuffer = await sharp(inputBuffer)
4778
+ // .resize(1024, 1024, {
4779
+ // fit: 'contain', // Preserve aspect ratio, fit within 211x211
4780
+ // background: { r: 0, g: 0, b: 0, alpha: 0 }, // Transparent background for padding
4781
+ // })
4782
+ // .png({
4783
+ // quality: 100,
4784
+ // compressionLevel: 9,
4785
+ // force: true,
4786
+ // })
4787
+ // .toBuffer();
4788
+
4789
+ // return normalizedBuffer.toString('base64'); // Return normalized base64 string
4790
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4768",
3
+ "version": "1.1.4770",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",