Fraser commited on
Commit
83f8807
·
1 Parent(s): 01393b5
src/lib/components/PicletGenerator/PicletGenerator.svelte CHANGED
@@ -366,8 +366,14 @@ CRITICAL RULES:
366
  const canonicalMatch = responseText.match(/\*{0,2}#\s*Canonical Object\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#)/m);
367
  const variationMatch = responseText.match(/\*{0,2}#\s*Variation\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#)/m);
368
 
369
- workflowState.objectName = canonicalMatch ? canonicalMatch[1].trim().toLowerCase() : 'unknown';
370
- const variationText = variationMatch ? variationMatch[1].trim() : '';
 
 
 
 
 
 
371
  workflowState.objectAttributes = variationText && variationText !== 'NONE' && variationText !== 'canonical' ? [variationText.toLowerCase()] : [];
372
 
373
  console.log('Parsed specific object:', workflowState.objectName);
@@ -528,6 +534,7 @@ Create a concise visual description (1-3 sentences, max 100 words). Focus only o
528
  let monsterName = monsterNameMatch ? monsterNameMatch[1].trim() : 'Unknown Monster';
529
 
530
  // Clean and truncate name
 
531
  if (monsterName.includes(',')) {
532
  monsterName = monsterName.split(',')[0].trim();
533
  }
@@ -549,6 +556,7 @@ Create a concise visual description (1-3 sentences, max 100 words). Focus only o
549
  // Extract primary type (handle both plain and bold markdown headers)
550
  const primaryTypeMatch = workflowState.picletConcept.match(/\*{0,2}#\s*Primary Type\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#|$)/m);
551
  let primaryType: any = primaryTypeMatch ? primaryTypeMatch[1].trim().toLowerCase() : 'beast';
 
552
 
553
  // Extract description (handle both plain and bold markdown headers)
554
  const descriptionMatch = workflowState.picletConcept.match(/\*{0,2}#\s*Monster Description\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#|$)/m);
@@ -568,13 +576,13 @@ Create a concise visual description (1-3 sentences, max 100 words). Focus only o
568
  const heightMatch = physicalStatsText.match(/Height:\s*(.+)/i);
569
  const weightMatch = physicalStatsText.match(/Weight:\s*(.+)/i);
570
 
571
- height = heightMatch ? heightMatch[1].trim() : undefined;
572
- weight = weightMatch ? weightMatch[1].trim() : undefined;
573
  }
574
 
575
  // Extract personality (handle both plain and bold markdown headers)
576
  const personalityMatch = workflowState.picletConcept.match(/\*{0,2}#\s*Personality\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#|$)/m);
577
- let personality = personalityMatch ? personalityMatch[1].trim() : undefined;
578
 
579
  // Create stats with physical characteristics
580
  const stats: PicletStats = {
 
366
  const canonicalMatch = responseText.match(/\*{0,2}#\s*Canonical Object\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#)/m);
367
  const variationMatch = responseText.match(/\*{0,2}#\s*Variation\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#)/m);
368
 
369
+ // Clean up extracted values (remove curly braces and quotes that GPT-OSS sometimes adds)
370
+ let objectName = canonicalMatch ? canonicalMatch[1].trim().toLowerCase() : 'unknown';
371
+ objectName = objectName.replace(/^[{"]|["}]$/g, '').replace(/^.*:\s*["']|["']$/g, '').trim();
372
+
373
+ let variationText = variationMatch ? variationMatch[1].trim() : '';
374
+ variationText = variationText.replace(/^[{"]|["}]$/g, '').replace(/^.*:\s*["']|["']$/g, '').trim();
375
+
376
+ workflowState.objectName = objectName;
377
  workflowState.objectAttributes = variationText && variationText !== 'NONE' && variationText !== 'canonical' ? [variationText.toLowerCase()] : [];
378
 
379
  console.log('Parsed specific object:', workflowState.objectName);
 
534
  let monsterName = monsterNameMatch ? monsterNameMatch[1].trim() : 'Unknown Monster';
535
 
536
  // Clean and truncate name
537
+ monsterName = monsterName.replace(/^[{"]|["}]$/g, '').trim(); // Remove curly braces and quotes
538
  if (monsterName.includes(',')) {
539
  monsterName = monsterName.split(',')[0].trim();
540
  }
 
556
  // Extract primary type (handle both plain and bold markdown headers)
557
  const primaryTypeMatch = workflowState.picletConcept.match(/\*{0,2}#\s*Primary Type\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#|$)/m);
558
  let primaryType: any = primaryTypeMatch ? primaryTypeMatch[1].trim().toLowerCase() : 'beast';
559
+ primaryType = primaryType.replace(/^[{"]|["}]$/g, '').trim(); // Remove curly braces and quotes
560
 
561
  // Extract description (handle both plain and bold markdown headers)
562
  const descriptionMatch = workflowState.picletConcept.match(/\*{0,2}#\s*Monster Description\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#|$)/m);
 
576
  const heightMatch = physicalStatsText.match(/Height:\s*(.+)/i);
577
  const weightMatch = physicalStatsText.match(/Weight:\s*(.+)/i);
578
 
579
+ height = heightMatch ? heightMatch[1].trim().replace(/^[{"]|["}]$/g, '').trim() : undefined;
580
+ weight = weightMatch ? weightMatch[1].trim().replace(/^[{"]|["}]$/g, '').trim() : undefined;
581
  }
582
 
583
  // Extract personality (handle both plain and bold markdown headers)
584
  const personalityMatch = workflowState.picletConcept.match(/\*{0,2}#\s*Personality\s*\*{0,2}\s*\n([\s\S]*?)(?=^\*{0,2}#|$)/m);
585
+ let personality = personalityMatch ? personalityMatch[1].trim().replace(/^[{"]|["}]$/g, '').trim() : undefined;
586
 
587
  // Create stats with physical characteristics
588
  const stats: PicletStats = {
src/lib/components/PicletGenerator/PicletResult.svelte CHANGED
@@ -34,10 +34,15 @@
34
  };
35
 
36
  // Create piclet instance asynchronously with discovery data
 
 
 
 
37
  generatedDataToPicletInstance(
38
  picletData,
39
  workflowState.objectName || undefined,
40
- workflowState.objectAttributes || undefined,
 
41
  workflowState.visualDetails || undefined
42
  ).then(instance => {
43
  picletInstance = { ...instance, id: 0 }; // Add temporary id for display
 
34
  };
35
 
36
  // Create piclet instance asynchronously with discovery data
37
+ const variation = workflowState.objectAttributes && workflowState.objectAttributes.length > 0
38
+ ? workflowState.objectAttributes[0]
39
+ : undefined;
40
+
41
  generatedDataToPicletInstance(
42
  picletData,
43
  workflowState.objectName || undefined,
44
+ variation,
45
+ workflowState.objectAttributes,
46
  workflowState.visualDetails || undefined
47
  ).then(instance => {
48
  picletInstance = { ...instance, id: 0 }; // Add temporary id for display