{"flow":{"id":35,"summary":"Do sentiment analysis on recent HackerNews mentions","versions":[147,151],"created_by":"adam186","created_at":"2022-12-28T16:48:08.216Z","votes":0,"approved":true,"apps":["hackernews","openai"],"value":{"modules":[{"id":"d","value":{"path":"hub/407/hackernews/trigger_everytime_a_new_item_text_on_hackernews_match_at_least_one_mention","type":"script","input_transforms":{"mentions":{"expr":"flow_input.phrases","type":"javascript"}}},"summary":"Get HackerNews mentions - trigger","stop_after_if":{"expr":"result == undefined || Array.isArray(result) && result.length == 0","skip_if_stopped":true},"input_transforms":{}},{"id":"b","value":{"path":"hub/402/openai/create_completion","type":"script","input_transforms":{"n":{"type":"static","value":null},"auth":{"expr":"","type":"javascript"},"echo":{"type":"static","value":null},"stop":{"type":"static","value":""},"model":{"type":"static","value":"text-davinci-003"},"top_p":{"type":"static","value":1},"prompt":{"expr":"`Classify the sentiment in these mentions:\n${results.d.map((m, i) => `${i}. \"${m.text.replaceAll('\"', '\\'')}\"\\n`)}\nSentiment ratings:`","type":"javascript"},"stream":{"type":"static","value":null},"suffix":{"type":"static","value":""},"best_of":{"type":"static","value":null},"logprobs":{"type":"static","value":null},"logit_bias":{"type":"static","value":null},"max_tokens":{"type":"static","value":60},"temperature":{"type":"static","value":0},"presence_penalty":{"type":"static","value":0},"frequency_penalty":{"type":"static","value":0}}},"summary":"Get mention sentiments","stop_after_if":null,"input_transforms":{}},{"id":"c","value":{"lock":"","path":null,"type":"rawscript","content":"export async function main(mentions: Record<string, string | number>[], sentiments: string) {\n  const sentimentArray = sentiments.trim().split('\\n').map(s => s.split('. ')[1])\n  return mentions.map(({by, id, text}, i) => {\n    return {\n      by,\n      id,\n      text,\n      sentiment: sentimentArray[i]\n    }\n  })\n}\n","language":"deno","input_transforms":{"mentions":{"expr":"results.d","type":"javascript"},"sentiments":{"expr":"`${results.b.choices[0].text}`","type":"javascript"}}},"summary":"Format results","stop_after_if":null,"input_transforms":{}}],"failure_module":null},"schema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["phrases"],"properties":{"phrases":{"type":"array","items":{"type":"string"},"format":"","description":""}}},"description":"Get recent HackerNews posts and comments that mention given phrases and do sentiment analysis on them.","recording":null,"vcreated_at":"2022-12-30T13:16:02.109Z","vcreated_by":"adam186","comments":[]}}