├── Invoke-GenerateContent.ps1
├── README.md
└── media
└── UI.png
/Invoke-GenerateContent.ps1:
--------------------------------------------------------------------------------
1 | #Requires -Module PowerShellAI
2 | [CmdletBinding()]
3 | param(
4 | [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
5 | [int]$max_tokens = 256,
6 | [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
7 | [decimal]$temperature = .7
8 | )
9 |
10 | Add-Type -AssemblyName presentationframework
11 |
12 | $XAML = @'
13 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | Analytical
38 | Argumentative
39 | Cause and Effect
40 | Compare and Contrast
41 | Critical
42 | Descriptive
43 | Expository
44 | Formal
45 | Humorous
46 | Informal
47 | Inspirational
48 | Narrative
49 | Objective
50 | Persuasive
51 | Reflective
52 | Romantic
53 | Satirical
54 | Subjective
55 | Tragic
56 |
57 |
58 |
59 |
60 | Tweet
61 | Blog Post
62 | YouTube Description
63 |
64 |
65 |
66 |
76 |
77 |
78 |
79 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | The maximum number of tokens to generate. By default, this is 256 or whatever you provided as an input parameter value to the script. The maximum is 2048.
103 |
104 |
105 |
106 |
107 |
108 | '@
109 |
110 | function SaveFileDialog([string]$title, [string]$filter, [string]$defaultExt) {
111 | $dialog = New-Object Microsoft.Win32.SaveFileDialog
112 | $dialog.Title = $title
113 | $dialog.Filter = $filter
114 | $dialog.DefaultExt = $defaultExt
115 | $null = $dialog.ShowDialog()
116 | $dialog.FileName
117 | }
118 |
119 | $Window = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader ([xml]$XAML)))
120 |
121 | $tbTopic = $Window.FindName("tbTopic")
122 | $tbResult = $Window.FindName("tbResult")
123 | $cboTone = $Window.FindName("cboTone")
124 | $cboType = $Window.FindName("cboType")
125 | $btnGetGPt3 = $Window.FindName("btnGetGPt3")
126 | $btnSave = $Window.FindName("btnSave")
127 | $tbHowMany = $Window.FindName("tbHowMany")
128 | $tbMaxTokens = $Window.FindName("tbMaxTokens")
129 | $tbMaxTokens.Text = $max_tokens
130 |
131 | $btnSave.Add_Click({
132 | $Window.Cursor = [System.Windows.Input.Cursors]::Wait
133 | $Window.Title = 'Saving ...'
134 | $filename = SaveFileDialog -title 'Save Result' -filter 'Text Files (*.txt)|*.txt|All Files (*.*)|*.*' -defaultExt '.txt'
135 | if ($filename) {
136 | $tbResult.Text | Out-File -FilePath $filename -Encoding UTF8
137 | }
138 | $Window.Title = 'PowerShell - AI Content Generator'
139 | $Window.Cursor = [System.Windows.Input.Cursors]::Arrow
140 | })
141 |
142 | $btnGetGPt3.Add_Click({
143 | $result = @()
144 | $Window.Cursor = [System.Windows.Input.Cursors]::Wait
145 | $Window.Title = 'Generating - {0} {1} ...' -f $cboTone.Text, $cboType.Text
146 | $prompt = 'Write a {0} in the style tone {1} about {2}' -f $cboType.Text, $cboTone.Text, $tbTopic.Text
147 |
148 | Write-Verbose $prompt
149 |
150 | for ($i = 0; $i -lt $tbHowMany.Text; $i++) {
151 | if ($tbMaxTokens.Text -gt 0) {
152 | $result += Get-GPT3Completion -prompt $prompt -max_tokens $tbMaxTokens.Text -temperature $temperature
153 | }
154 | else {
155 | $result += Get-GPT3Completion -prompt $prompt -max_tokens $max_tokens -temperature $temperature
156 | }
157 | }
158 | $tbResult.Text = $result -join "`n"
159 | $Window.Title = 'PowerShell - AI Content Generator'
160 | $Window.Cursor = [System.Windows.Input.Cursors]::Arrow
161 | })
162 |
163 |
164 | $null = $Window.ShowDialog()
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Invoke-GenerateContent
2 |
3 | Invoke-GenerateContent is a PowerShell script that uses Generative Pre-trained Transformer (GPT) to generate content for tweets, blogs, and YouTube descriptions. It provides a user interface (UI) to help you create prose in many different tones.
4 |
5 | ## Features
6 |
7 | - Generate content for tweets, blogs, and YouTube descriptions
8 | - Generate content in many different tones
9 | - User-friendly UI
10 | - Easy to use
11 |
12 | ## Requirements
13 |
14 | - PowerShell 5.1 or higher
15 | - PowerShellAI - `Install-Module -Name PowerShellAI`
16 |
17 | ## Installation
18 |
19 | 1. Download (copy the content of) the Invoke-GenerateContent.ps1 script from this repository.
20 | 2. Open a PowerShell window and navigate to the directory where the script is located.
21 | 3. Run the script with the command `.\Invoke-GenerateContent.ps1`.
22 |
23 | ## Video
24 |
25 | 🚀 Discover the power of GPT and PowerShell combined in this incredible video! I've built a unique UI that lets you generate content like never before. Just provide a topic, choose the tone, and select the type (tweet, blog, or YouTube description). Watch as I showcase this innovative tool that streamlines content creation and saves you time. Say goodbye to writer's block and hello to endless possibilities!
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | ## Usage
36 |
37 | 1. After running the script, you will be presented with a UI.
38 | 2. Select the type of content you want to generate (tweet, blog, or YouTube description).
39 | 3. Select the tone of the content you want to generate.
40 | 4. Enter the text you want to use as a starting point
41 |
42 |
43 |
44 | 
--------------------------------------------------------------------------------
/media/UI.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dfinke/PowerShellAI-ContentGenerator/HEAD/media/UI.png
--------------------------------------------------------------------------------