MCPcopy Create free account
hub / github.com/Swizec/article-threader / handler

Function handler

pages/api/createTwitterThread.js:11–31  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

9);
10
11const handler = async (req, res) => {
12 const { url, tweetCount } = req.body;
13
14 const article = await extract(url);
15
16 if (!article.title || !article.content) {
17 res.send(400).text("Can't extract article");
18 }
19
20 const cleanContent = stripHtml(article.content);
21
22 const completion = await openai.createCompletion({
23 model: "text-davinci-003",
24 prompt: `You are a blogger trying to promote their latest article on social media. The title is "${article.title}". Write a twitter thread summarizing the following text in ${tweetCount} numbered tweets: ${cleanContent}`,
25 temperature: 0.4,
26 max_tokens: 800,
27 best_of: 2,
28 });
29
30 res.status(200).send(completion.data.choices[0].text.trim());
31};
32
33export default handler;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected