@zodic/shared 0.0.150 → 0.0.151

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.
package/app/api/index.ts CHANGED
@@ -38,7 +38,7 @@ export const Api = (env: BackendBindings) => ({
38
38
  callTogether: {
39
39
  single: async (
40
40
  messages: ChatMessages,
41
- { model = 'deepseek-ai/DeepSeek-V3', options = {} }: DeepSeekOptions
41
+ { model = 'deepseek-ai/DeepSeek-V3', options = { } }: DeepSeekOptions
42
42
  ): Promise<string> => {
43
43
  try {
44
44
  const response = await together(env).chat.completions.create({
@@ -392,7 +392,8 @@ export class ConceptService {
392
392
  structuredContentEN: StructuredConceptContent;
393
393
  structuredContentPT: StructuredConceptContent;
394
394
  } {
395
- console.log('📌 Parsing structured content from ChatGPT response:', response);
395
+ console.log('📌 [START] Parsing structured content from ChatGPT response.');
396
+ console.log('🔹 [RAW RESPONSE]:', response);
396
397
 
397
398
  const sectionsEN = [
398
399
  'Core Identity',
@@ -411,18 +412,21 @@ export class ConceptService {
411
412
  ];
412
413
 
413
414
  // ✅ Match English and Portuguese content separately
414
- const enMatches = response.match(/EN:\s*([\s\S]+?)\s*PT:/);
415
- const ptMatches = response.match(/PT:\s*([\s\S]+)/);
415
+ const enMatches = response.match(/### EN:\s*([\s\S]+?)\s*### PT:/);
416
+ const ptMatches = response.match(/### PT:\s*([\s\S]+)/);
416
417
 
417
418
  if (!enMatches || !ptMatches) {
418
- console.error('❌ Missing English or Portuguese content in response.');
419
+ console.error('❌ [ERROR] Missing English or Portuguese content in response.');
419
420
  throw new Error('❌ Missing English or Portuguese content in response.');
420
421
  }
421
422
 
422
423
  const enContent = enMatches[1].trim();
423
424
  const ptContent = ptMatches[1].trim();
424
425
 
425
- // Function to clean AI artifacts (removes * and trims text)
426
+ console.log('[MATCH SUCCESS] Extracted English Content:', enContent.slice(0, 500) + '...'); // Log first 500 chars
427
+ console.log('✅ [MATCH SUCCESS] Extracted Portuguese Content:', ptContent.slice(0, 500) + '...'); // Log first 500 chars
428
+
429
+ // ✅ Function to clean AI artifacts (*, extra spaces, etc.)
426
430
  function cleanText(text: string): string {
427
431
  return text.replace(/\*/g, '').trim();
428
432
  }
@@ -430,12 +434,14 @@ export class ConceptService {
430
434
  // ✅ Function to extract structured sections from text
431
435
  function extractSections(text: string, sectionTitles: string[]) {
432
436
  return sectionTitles.map((title) => {
437
+ console.log(`🔍 [PROCESSING] Extracting section: "${title}"`);
438
+
433
439
  // ✅ Improved regex: Ensures section detection even with different AI formatting
434
- const regex = new RegExp(`${title}:\\s*([\\s\\S]+?)(?=\\n\\d|\\n[A-Z]|$)`);
440
+ const regex = new RegExp(`\\d+\\.\\s*${title}:\\s*([\\s\\S]+?)(?=\\n\\d+\\.\\s*[A-Z]|$)`);
435
441
  const match = text.match(regex);
436
442
 
437
443
  if (!match) {
438
- console.warn(`⚠️ Missing section: ${title}`);
444
+ console.warn(`⚠️ [WARNING] Missing section: "${title}"`);
439
445
  return { type: 'section', title, content: ['❌ Section Missing'] };
440
446
  }
441
447
 
@@ -443,16 +449,27 @@ export class ConceptService {
443
449
  const paragraphs = match[1]
444
450
  .trim()
445
451
  .split(/\n{2,}/) // Handles cases where paragraphs are separated by multiple new lines
446
- .map((p) => cleanText(p));
452
+ .map((p) => cleanText(p))
453
+ .filter((p) => p.length > 0); // Removes empty paragraphs
454
+
455
+ console.log(`✅ [EXTRACTED] "${title}" - Parsed Content:`, paragraphs);
447
456
 
448
457
  return { type: 'section', title, content: paragraphs };
449
458
  });
450
459
  }
451
460
 
452
461
  // ✅ Return parsed and cleaned structured content
462
+ const structuredContentEN = extractSections(enContent, sectionsEN);
463
+ const structuredContentPT = extractSections(ptContent, sectionsPT);
464
+
465
+ console.log('🎯 [FINAL RESULT] Parsed English Content:', JSON.stringify(structuredContentEN, null, 2));
466
+ console.log('🎯 [FINAL RESULT] Parsed Portuguese Content:', JSON.stringify(structuredContentPT, null, 2));
467
+
468
+ console.log('✅ [COMPLETE] Structured content parsing finished successfully.');
469
+
453
470
  return {
454
- structuredContentEN: extractSections(enContent, sectionsEN),
455
- structuredContentPT: extractSections(ptContent, sectionsPT),
471
+ structuredContentEN,
472
+ structuredContentPT,
456
473
  };
457
474
  }
458
475
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.150",
3
+ "version": "0.0.151",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {