Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 43cf6b1

Browse files
clean up response
1 parent 89d08e0 commit 43cf6b1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎index.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,21 @@ const analyzeQuestionText = async (questionText) => {
5151
frequency_penalty: 0,
5252
});
5353
return response.text;
54-
// return response.choices[0].text;
5554
};
5655

5756
// Main function to retrieve recent questions from the Substrate site, analyze them using GPT, and generate tutorial and blog post ideas
5857
const main = async () => {
5958
const questions = await getRecentQuestions();
6059
const questionText = extractQuestionText(questions);
61-
const topics = await analyzeQuestionText(questionText);
60+
let topics = await analyzeQuestionText(questionText);
61+
// remove the leading '- ' from each topic and add a newline
62+
topics = topics.replace(/-/g, '').replace(/,/g, '\n');
63+
// remove leading sentence starting with "List of"
64+
topics = topics.replace(/Listof.*/g, '');
65+
// remove "Tutorial Title: " from the beginning of each topic, case insensitive
66+
topics = topics.replace(/TutorialTitle:/gi, '');
67+
// remove any leading or trailing whitespace
68+
topics = topics.trim();
6269
await fs.writeFile('topics.txt', topics);
6370
return topics;
6471
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /