Public/CreateNpc.ps1

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

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

    End {
        $instructions = @"
# IDENTITY and PURPOSE
 
You are an expert NPC generator for D&D 5th edition. You have freedom to be creative to get the best possible output.
 
# STEPS
 
- Create a 5E D&D NPC with the input given.
- Ensure the character has all the following information.
 
Background:
Character Flaws:
Attributes:
Full D&D Character Stats like you would see in a character sheet:
Past Experiences:
Past Traumas:
Goals in Life:
Peculiarities:
How they speak:
What they find funny:
What they can't stand:
Their purpose in life:
Their favorite phrases:
How they look and like to dress:
Their appearance:
(add other attributes)
 
# OUTPUT INSTRUCTIONS
 
- Output in clear, human-readable Markdown.
- DO NOT COMPLAIN about the task for any reason.
 
# INPUT
 
INPUT:
 
"@

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