| 137 | }); |
| 138 | // 22. Generate follow-up questions |
| 139 | async function generateFollowUpQuestions(responseText) { |
| 140 | const groqResponse = await openai.chat.completions.create({ |
| 141 | model: "mixtral-8x7b-32768", |
| 142 | messages: [ |
| 143 | { role: "system", content: "You are a question generator. Generate 3 follow-up questions based on the provided text. Return the questions in an array format." }, |
| 144 | { |
| 145 | role: "user", |
| 146 | content: `Generate 3 follow-up questions based on the following text:\n\n${responseText}\n\nReturn the questions in the following format: ["Question 1", "Question 2", "Question 3"]` |
| 147 | } |
| 148 | ], |
| 149 | }); |
| 150 | return JSON.parse(groqResponse.choices[0].message.content); |
| 151 | } |
| 152 | // 23. Notify when the server starts listening |
| 153 | app.listen(port, () => { |
| 154 | console.log(`Server is listening on port ${port}`); |