Skip to content

Commit 5650f20

Browse files
committed
feat: improve script
1 parent e34e0bb commit 5650f20

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/scripts/glossary.genai.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ script({
99
default: false,
1010
},
1111
},
12+
temperature: 0.1,
1213
});
1314

1415
// Find all markdown files under lessons, excluding translations
@@ -66,11 +67,15 @@ ${allContent}
6667
6768
2. For each term, provide a concise one-line definition (maximum 20 words)
6869
69-
3. Focus on terms that would be valuable for developers learning about AI and JavaScript
70+
3. Focus on terms that would be valuable for developers learning about AI and JavaScript. Avoid terms that are too basic or not relevant to the context of AI and JavaScript development
7071
7172
4. Exclude common programming terms that most developers would know (like "function", "variable", "array") and historical terms that are only there for the storytelling aspect of the lessons.
7273
73-
5. Format each entry as: **Term**: Definition
74+
5. Exclude terms that are too similar to existing terms. For example, "Chain of Thought" and "Chain of Thought Prompting" are too similar and should not both be included.
75+
76+
6. Format each entry as: **Term**: Definition
77+
78+
7. It's OK to not output anything if no new terms are found. In that case, just return an empty string.
7479
7580
${
7681
existingTerms.size > 0
@@ -85,6 +90,7 @@ Provide only the glossary entries, one per line, sorted alphabetically. Do not i
8590

8691
// Combine existing and new terms
8792
let finalGlossary = "";
93+
let glossarySize, previousSize = 0;
8894

8995
if (existingGlossary && !env.vars.force) {
9096
// Parse existing glossary and add new terms
@@ -132,6 +138,8 @@ if (existingGlossary && !env.vars.force) {
132138
finalGlossary += `- **${entry.term}**: ${entry.definition}\n`;
133139
}
134140

141+
previousSize = existingEntries.length;
142+
glossarySize = allEntries.length;
135143
console.log(`Added ${newEntries.length} new terms to existing glossary`);
136144
} else {
137145
// Create completely new glossary
@@ -153,9 +161,14 @@ if (existingGlossary && !env.vars.force) {
153161
finalGlossary += `- **${entry.term}**: ${entry.definition}\n`;
154162
}
155163

164+
glossarySize = entries.length;
156165
console.log(`Created new glossary with ${entries.length} terms`);
157166
}
158167

159168
// Write the glossary file
160169
await workspace.writeText(glossaryPath, finalGlossary);
161170
console.log(`Glossary saved to ${glossaryPath}`);
171+
172+
env.output.appendContent(`Glossary generated with ${glossarySize} terms (previously ${previousSize} terms).\n\n`);
173+
env.output.appendContent(`Glossary saved to \`${glossaryPath}\``);
174+

0 commit comments

Comments
 (0)