Get more than one 1984 themed headline
The /bigbrother-news command could technically accept a count, but it always returned exactly one rewrite no matter what you passed.
First, rewriteHeadline was looping over the headlines array but always sending headline[0] to Groq, so it was rewriting the same headline count times. Second, the function returned an array but respond() was getting that array passed directly as text, which Slack rejects with a 500 because it expects a string. Fixed both, headline[i] in the loop, .join("\n") before responding. Also added a .replace(/^[""]|[""]$/g, "") strip because the model randomly decides whether to wrap its output in quotes or not and I’d rather it just didn’t.
The original code also only ever called rewriteHeadline with a single headline and had no loop at all, scaling it up to handle multiple rewrites sequentially meant restructuring the whole function.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.