@zodic/shared 0.0.210 → 0.0.211
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.
|
@@ -157,18 +157,22 @@ export class ConceptService {
|
|
|
157
157
|
descriptionPT: string;
|
|
158
158
|
poemPT: string[];
|
|
159
159
|
} {
|
|
160
|
-
console.log('📌
|
|
160
|
+
console.log('📌 Received AI response for parsing:', response);
|
|
161
161
|
|
|
162
162
|
// ✅ More flexible regex to handle variations in formatting
|
|
163
|
+
console.log('🔎 Attempting to match English section...');
|
|
163
164
|
const enMatch = response.match(
|
|
164
165
|
/EN:\s*(?:•\s*)?Name:\s*(.+?)\s*(?:•\s*)?Description:\s*([\s\S]+?)\s*(?:•\s*)?Poetic Passage:\s*([\s\S]+?)\s*(?=PT:|$)/
|
|
165
166
|
);
|
|
167
|
+
|
|
168
|
+
console.log('🔎 Attempting to match Portuguese section...');
|
|
166
169
|
const ptMatch = response.match(
|
|
167
|
-
/PT:\s*(?:•\s*)?Nome:\s*(.+?)\s*(?:•\s*)?Descrição:\s*([\s\S]+?)\s*(?:•\s*)?Passagem Poética:\s*([\s\S]+)/
|
|
170
|
+
/PT:\s*(?:•\s*)?Nome:\s*(.+?)\s*(?:•\s*)?Descrição:\s*([\s\S]+?)\s*(?:•\s*)?Passagem Poética:\s*([\s\S]+)/
|
|
168
171
|
);
|
|
169
172
|
|
|
170
173
|
if (!enMatch || !ptMatch) {
|
|
171
174
|
console.error('❌ Invalid basic info response format:', response);
|
|
175
|
+
console.log('❌ Regex match results:', { enMatch, ptMatch });
|
|
172
176
|
throw new Error('Invalid basic info response format');
|
|
173
177
|
}
|
|
174
178
|
|
|
@@ -176,14 +180,15 @@ export class ConceptService {
|
|
|
176
180
|
const cleanText = (text: string) => text.trim().replace(/\*/g, '');
|
|
177
181
|
|
|
178
182
|
// ✅ Parse and clean extracted content
|
|
183
|
+
console.log('✂️ Extracting and cleaning English content...');
|
|
179
184
|
const nameEN = cleanText(enMatch[1]);
|
|
180
185
|
const descriptionEN = cleanText(enMatch[2]);
|
|
181
186
|
const poemEN = enMatch[3]
|
|
182
187
|
.trim()
|
|
183
188
|
.split(/\n+/)
|
|
184
189
|
.map((line) => cleanText(line));
|
|
185
|
-
|
|
186
190
|
|
|
191
|
+
console.log('✂️ Extracting and cleaning Portuguese content...');
|
|
187
192
|
const namePT = cleanText(ptMatch[1]);
|
|
188
193
|
const descriptionPT = cleanText(ptMatch[2]);
|
|
189
194
|
const poemPT = ptMatch[3]
|
|
@@ -191,6 +196,15 @@ export class ConceptService {
|
|
|
191
196
|
.split(/\n+/)
|
|
192
197
|
.map((line) => cleanText(line));
|
|
193
198
|
|
|
199
|
+
console.log('📌 Extracted values before processing:', {
|
|
200
|
+
nameEN,
|
|
201
|
+
descriptionEN,
|
|
202
|
+
poemEN,
|
|
203
|
+
namePT,
|
|
204
|
+
descriptionPT,
|
|
205
|
+
poemPT,
|
|
206
|
+
});
|
|
207
|
+
|
|
194
208
|
// ✅ Determine appropriate replacement text based on conceptSlug
|
|
195
209
|
const conceptPlaceholder = `this ${
|
|
196
210
|
conceptSlug.charAt(0).toUpperCase() + conceptSlug.slice(1)
|
|
@@ -210,15 +224,18 @@ export class ConceptService {
|
|
|
210
224
|
};
|
|
211
225
|
|
|
212
226
|
// ✅ Ensure the concept name is not repeated in the description
|
|
227
|
+
console.log('🔄 Replacing concept name in descriptions...');
|
|
213
228
|
const cleanedDescriptionEN = replaceConceptName(descriptionEN, nameEN);
|
|
214
229
|
const cleanedDescriptionPT = replaceConceptName(descriptionPT, namePT);
|
|
215
230
|
|
|
216
231
|
// ✅ If the name appears in the poem, trigger a retry
|
|
232
|
+
console.log('🔍 Checking for concept name in poems...');
|
|
217
233
|
if (
|
|
218
234
|
poemEN.some((line) => line.includes(nameEN)) ||
|
|
219
235
|
poemPT.some((line) => line.includes(namePT))
|
|
220
236
|
) {
|
|
221
237
|
console.error('❌ Concept name detected in poem, triggering a retry.');
|
|
238
|
+
console.log('❌ Problematic lines:', { poemEN, poemPT });
|
|
222
239
|
throw new Error('Concept name found in poem, regenerating response.');
|
|
223
240
|
}
|
|
224
241
|
|