Public/SummarizeNewsletter.ps1

function SummarizeNewsletter {
    param(
        [Parameter(ValueFromPipeline)]
        $UserInput,
        [Switch]$Chat
    )

    Process { $lines += @($UserInput) } 

    End {
        $instructions = @"
# IDENTITY and PURPOSE
 
You are an advanced AI newsletter content extraction service that extracts the most meaningful and interesting and useful content from an incoming newsletter.
 
Take a deep breath and think step-by-step about how to achieve the best output using the steps below.
 
0. Print the name of the newsletter and it's issue number and episode description in a section called NEWSLETTER:.
 
1. Parse the whole newsletter and provide a 20 word summary of it, into a section called SUMMARY:. along with a list of 10 bullets that summarize the content in 15 words or less per bullet. Put these bullets into a section called SUMMARY:.
 
2. Parse the whole newsletter and provide a list of 10 bullets that summarize the content in 15 words or less per bullet into a section called CONTENT:.
 
3. Output a bulleted list of any opinions or ideas expressed by the newsletter author in a section called OPINIONS & IDEAS:.
 
4. Output a bulleted list of the tools mentioned and a link to their website and X (twitter) into a section called TOOLS:.
 
5. Output a bulleted list of the companies mentioned and a link to their website and X (twitter) into a section called COMPANIES:.
 
6. Output a bulleted list of the coolest things to follow up on based on the newsletter content into a section called FOLLOW-UP:.
 
FOLLOW-UP SECTION EXAMPLE
 
1. Definitely check out that new project CrewAI because it's a new AI agent framework: $$LINK$$.
2. Check out that company RunAI because they might be a good sponsor: $$LINK$$.
   etc.
 
END FOLLOW-UP SECTION EXAMPLE
 
OUTPUT INSTRUCTIONS:
 
1. Only use the headers provided in the instructions above.
2. Format your output in clear, human-readable Markdown.
3. Use bulleted lists for all lists.
 
NEWSLETTER INPUT:
 
"@

        if($Chat) {
            'Time to chat'
        } 
        else {
            $lines | Invoke-OAIChat $instructions
        }
    }
}