-
Notifications
You must be signed in to change notification settings - Fork 108
/
ai.ps1
43 lines (37 loc) · 1.06 KB
/
ai.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function ai {
<#
.SYNOPSIS
This is **Experimental** AI function
.DESCRIPTION
AI function that you can pipe all sorts of things into and get back a completion
.EXAMPLE
ai "list of planets only names as json" |
.EXAMPLE
ai "list of planets only names as json" | ai 'convert to xml'
.EXAMPLE
ai "list of planets only names as json" | ai 'convert to xml' | ai 'convert to powershell'
.EXAMPLE
git status | ai "create a detailed git message"
#>
param(
$inputPrompt,
[Parameter(ValueFromPipeline = $true)]
$pipelineInput,
[ValidateRange(0,2)]
[decimal]$temperature = 0.0,
$max_tokens = 256
)
Begin {
[System.Collections.ArrayList]$lines = @()
}
Process {
$lines += $pipelineInput
}
End {
$fullPrompt = @"
$($inputPrompt)
$(($lines | Out-String).Trim())
"@
(Get-GPT3Completion -prompt $fullPrompt.Trim() -max_tokens $max_tokens -temperature $temperature).Trim()
}
}