Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions scripts/best-practice-content.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ const BEST_PRACTICE_CONTENT_DIR = path.join(
);
const OpenAI = require('openai');

const openai = new OpenAI({
apiKey: OPEN_AI_API_KEY,
});
// OpenAI client is initialised inside writeTopicContent
// to limit the API key scope to function-level only.
// This avoids holding the API key at module scope.

function getFilesInFolder(folderPath, fileList = {}) {
const files = fs.readdirSync(folderPath);

files.forEach((file) => {
const filePath = path.join(folderPath, file);
const safeName = path.basename(file);
const filePath = `${path.normalize(folderPath)}${path.sep}${safeName}`;
const stats = fs.statSync(filePath);

if (stats.isDirectory()) {
Expand All @@ -57,6 +58,7 @@ function getFilesInFolder(folderPath, fileList = {}) {
}

function writeTopicContent(topicTitle) {
const openai = new OpenAI({ apiKey: OPEN_AI_API_KEY });
let prompt = `I will give you a topic and you need to write a brief paragraph with examples (if possible) about why it is important for the "${bestPracticeTitle}". Just reply to the question without adding any other information about the prompt and use simple language. Also do not start your sentences with "XYZ is important because..". Your format should be as follows:

# (Put a heading for the topic)
Expand Down
1 change: 0 additions & 1 deletion scripts/gemini-roadmap-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const __dirname = path.dirname(__filename);

// Usage: tsx ./scripts/editor-roadmap-content.ts <roadmapId>
const GEMINI_API_KEY = process.env.GEMINI_API_KEY;
console.log('GEMINI_API_KEY:', GEMINI_API_KEY);
const ROADMAP_CONTENT_DIR = path.join(__dirname, '../src/data/roadmaps');
const roadmapId = process.argv[2];

Expand Down