(req, res)
| 30 | } |
| 31 | |
| 32 | const findKeyInsight: NextApiHandler = async (req, res) => { |
| 33 | const { url } = req.body; |
| 34 | const cleanUrl = getCleanUrl(url); |
| 35 | |
| 36 | console.log(cleanUrl); |
| 37 | |
| 38 | const cached = await redis.get(cleanUrl); |
| 39 | |
| 40 | if (cached) { |
| 41 | return res.status(200).send(cached); |
| 42 | } |
| 43 | |
| 44 | return res.status(200).send("Sorry, had to turn this off due to API cost"); |
| 45 | |
| 46 | // const article = await extract(cleanUrl); |
| 47 | |
| 48 | // if (!article.title || !article.content) { |
| 49 | // return res.status(400).send("Couldn't extract article"); |
| 50 | // } |
| 51 | |
| 52 | // const cleanContent = stripHtml(article.content).result; |
| 53 | |
| 54 | // const insight1 = await openai.createCompletion({ |
| 55 | // model: "text-davinci-003", |
| 56 | // prompt: `What is the most surprising insight in this article: ${cleanContent}`, |
| 57 | // temperature: 0.6, |
| 58 | // max_tokens: 800, |
| 59 | // }); |
| 60 | |
| 61 | // const finalResult = insight1.data.choices[0].text; |
| 62 | |
| 63 | // await redis.set(cleanUrl, finalResult); |
| 64 | |
| 65 | // res.status(200).send(finalResult); |
| 66 | }; |
| 67 | |
| 68 | export default findKeyInsight; |
nothing calls this directly
no test coverage detected