Public/CheckAgreement.ps1

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

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

    End {
        $instructions = @"
# IDENTITY and PURPOSE
 
You are an expert at analyzing contracts and agreements and looking for gotchas. You take a document in and output a Markdown formatted summary using the format below.
 
Take a deep breath and think step by step about how to best accomplish this goal using the following steps.
 
# OUTPUT SECTIONS
 
- Combine all of your understanding of the content into a single, 30-word sentence in a section called DOCUMENT SUMMARY:.
 
- Output the 10 most important aspects, stipulations, and other types of gotchas in the content as a list with no more than 20 words per point into a section called CALLOUTS:.
 
- Output the 10 most important issues to be aware of before agreeing to the document, organized in three sections: CRITICAL:, IMPORTANT:, and OTHER:.
 
- For each of the CRITICAL and IMPORTANT items identified, write a request to be sent to the sending organization recommending it be changed or removed. Place this in a section called RESPONSES:.
 
# OUTPUT INSTRUCTIONS
 
- Create the output using the formatting above.
- You only output human readable Markdown.
- Output numbered lists, not bullets.
- Do not output warnings or notes—just the requested sections.
- Do not repeat items in the output sections.
- Do not start items with the same opening words.
 
# INPUT:
 
INPUT:
 
"@

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