@zodic/shared 0.0.214 → 0.0.216
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/services/ConceptService.ts +22 -6
- package/package.json +1 -1
- package/utils/buildMessages.ts +50 -41
|
@@ -1089,19 +1089,35 @@ export class ConceptService {
|
|
|
1089
1089
|
break;
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
1092
|
-
console.log(`📝 Raw AI Response
|
|
1092
|
+
console.log(`📝 Raw AI Response:\n${aiResponse}`);
|
|
1093
1093
|
|
|
1094
|
-
// ✅
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1094
|
+
// ✅ Correctly map concept names and gendered articles
|
|
1095
|
+
const conceptMapping = {
|
|
1096
|
+
amulet: { en: "Amulet", pt: "Amuleto", articlePT: "O" },
|
|
1097
|
+
crown: { en: "Crown", pt: "Coroa", articlePT: "A" },
|
|
1098
|
+
scepter: { en: "Scepter", pt: "Cetro", articlePT: "O" },
|
|
1099
|
+
lantern: { en: "Lantern", pt: "Candeia", articlePT: "A" },
|
|
1100
|
+
ring: { en: "Ring", pt: "Anel", articlePT: "O" },
|
|
1101
|
+
orb: { en: "Orb", pt: "Orbe", articlePT: "O" },
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
const { en: conceptEN, pt: conceptPT, articlePT } = conceptMapping[conceptSlug] || {
|
|
1105
|
+
en: conceptSlug,
|
|
1106
|
+
pt: conceptSlug,
|
|
1107
|
+
articlePT: "O", // Default to "O" if concept is missing
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
// ✅ Strict regex matching for English and Portuguese
|
|
1111
|
+
const enMatch = aiResponse.match(new RegExp(`EN:\\s*The ${conceptEN} of [A-Za-z\\s]+`));
|
|
1112
|
+
const ptMatch = aiResponse.match(new RegExp(`PT:\\s*${articlePT} ${conceptPT} de [A-Za-z\\s]+`));
|
|
1097
1113
|
|
|
1098
1114
|
if (!enMatch || !ptMatch) {
|
|
1099
1115
|
console.error(`❌ Invalid AI response format! Retrying...`);
|
|
1100
1116
|
continue;
|
|
1101
1117
|
}
|
|
1102
1118
|
|
|
1103
|
-
newNameEN = enMatch[0].replace(/^EN:\s
|
|
1104
|
-
newNamePT = ptMatch[0].replace(/^PT:\s
|
|
1119
|
+
newNameEN = enMatch[0].replace(/^EN:\s*/, '').trim();
|
|
1120
|
+
newNamePT = ptMatch[0].replace(/^PT:\s*/, '').trim();
|
|
1105
1121
|
|
|
1106
1122
|
console.log(`🎨 Extracted Names: EN - "${newNameEN}", PT - "${newNamePT}"`);
|
|
1107
1123
|
|
package/package.json
CHANGED
package/utils/buildMessages.ts
CHANGED
|
@@ -188,52 +188,61 @@ export const buildLLMMessages = (env: BackendBindings) => ({
|
|
|
188
188
|
}: {
|
|
189
189
|
oldNameEN: string;
|
|
190
190
|
description: string;
|
|
191
|
-
conceptSlug:
|
|
191
|
+
conceptSlug: Concept;
|
|
192
192
|
recentNames?: string[];
|
|
193
|
-
}): ChatMessages =>
|
|
194
|
-
{
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
}): ChatMessages => {
|
|
194
|
+
const conceptNameMap: Record<Concept, Record<'en' | 'pt', string>> = {
|
|
195
|
+
crown: { en: 'The Crown of', pt: 'A Coroa de' },
|
|
196
|
+
scepter: { en: 'The Scepter of', pt: 'O Cetro de' },
|
|
197
|
+
amulet: { en: 'The Amulet of', pt: 'O Amuleto de' },
|
|
198
|
+
ring: { en: 'The Ring of', pt: 'O Anel de' },
|
|
199
|
+
lantern: { en: 'The Lantern of', pt: 'A Candeia de' },
|
|
200
|
+
orb: { en: 'The Orb of', pt: 'O Orbe de' },
|
|
201
|
+
} as const;
|
|
202
|
+
|
|
203
|
+
// ✅ Get the correct mapped names
|
|
204
|
+
const conceptMapping = conceptNameMap[conceptSlug] || {
|
|
205
|
+
en: `The ${conceptSlug} of`,
|
|
206
|
+
pt: `O ${conceptSlug} de`,
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
return [
|
|
210
|
+
{
|
|
211
|
+
role: 'system',
|
|
212
|
+
content: `
|
|
213
|
+
You are an expert in mystical and symbolic naming. Your task is to generate a new, unique name for a given concept while ensuring it aligns with its description.
|
|
214
|
+
|
|
215
|
+
Guidelines:
|
|
216
|
+
• The name must have exactly six words.
|
|
217
|
+
• It must start with "${conceptMapping.en}" in English and "${conceptMapping.pt}" in Portuguese.
|
|
218
|
+
• The last three words should be distinct, meaningful, and thematically relevant.
|
|
219
|
+
• It should reflect the concept’s core essence such as protection, transformation, or resilience.
|
|
220
|
+
• Avoid generic, redundant, or overly abstract terms.
|
|
221
|
+
• The name must not match any of the recently generated names.
|
|
222
|
+
• If the given name is something like "EN:", create a new fresh name following the guidelines and using the description as reference.
|
|
223
|
+
|
|
224
|
+
Example of a valid format:
|
|
225
|
+
${conceptMapping.en} Strong Radiant Will
|
|
226
|
+
|
|
227
|
+
No explanations or additional text. Return only the names exactly in the following format:
|
|
198
228
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
• It must start with "The ${conceptSlug} of" in English and "O ${conceptSlug} de" in Portuguese.
|
|
202
|
-
• The last three words should be distinct, meaningful, and thematically relevant.
|
|
203
|
-
• It should reflect the concept’s core essence such as protection, transformation, or resilience.
|
|
204
|
-
• Avoid generic, redundant, or overly abstract terms.
|
|
205
|
-
• Ensure it does not resemble the previous name.
|
|
206
|
-
• The name must not match any of the recently generated names.
|
|
229
|
+
EN:
|
|
230
|
+
${conceptMapping.en} [New Symbolic Concept]
|
|
207
231
|
|
|
208
|
-
|
|
209
|
-
|
|
232
|
+
PT:
|
|
233
|
+
${conceptMapping.pt} [Novo Conceito Simbólico]
|
|
234
|
+
`,
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
role: 'user',
|
|
238
|
+
content: `
|
|
210
239
|
• Previous Name Already Used: ${oldNameEN}
|
|
211
|
-
• Recently Generated Names: ${
|
|
240
|
+
• Recently Generated Names (Do not use these): ${
|
|
212
241
|
recentNames.length > 0 ? recentNames.join(', ') : 'None'
|
|
213
242
|
}
|
|
214
243
|
• Description: ${description}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
• New Name: The ${conceptSlug} of [New Symbolic Concept]
|
|
220
|
-
|
|
221
|
-
PT:
|
|
222
|
-
• Novo Nome: O ${conceptSlug} de [Novo Conceito Simbólico]
|
|
223
|
-
|
|
224
|
-
No explanations or additional text. Return only the names.
|
|
225
|
-
`,
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
role: 'user',
|
|
229
|
-
content: `
|
|
230
|
-
• Concept Name: ${conceptSlug}
|
|
231
|
-
• Previous Name Already Used: ${oldNameEN}
|
|
232
|
-
• Recently Generated Names: ${
|
|
233
|
-
recentNames.length > 0 ? recentNames.join(', ') : 'None'
|
|
234
|
-
}
|
|
235
|
-
• Description: ${description}
|
|
236
|
-
`,
|
|
237
|
-
},
|
|
238
|
-
],
|
|
244
|
+
`,
|
|
245
|
+
},
|
|
246
|
+
];
|
|
247
|
+
},
|
|
239
248
|
});
|