@@ -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
5857const 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 ( / L i s t o f .* / g, '' ) ;
65+ // remove "Tutorial Title: " from the beginning of each topic, case insensitive
66+ topics = topics . replace ( / T u t o r i a l T i t l e : / 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