-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from Agazoth/EnhanceToolParameter
EnhanceToolParameter
- Loading branch information
Showing
8 changed files
with
128 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
function Invoke-QuickPrompt { | ||
[CmdletBinding()] | ||
param( | ||
[string]$targetPrompt, | ||
[Parameter(ValueFromPipeline = $true)] | ||
[object]$pipelineInput, | ||
[switch]$OutputOnly | ||
) | ||
|
||
Begin { | ||
$additionalInstructions = @() | ||
|
||
} | ||
|
||
Process { | ||
$additionalInstructions += $pipelineInput | ||
} | ||
|
||
End { | ||
|
||
$prompt = "work it" | ||
if ($targetPrompt) { | ||
$prompt = $targetPrompt | ||
} | ||
|
||
$instructions += @" | ||
<date>$(Get-Date)</date> | ||
<current directory>$($pwd)</current directory> | ||
- You are a terminal assistant. You are a software and data science expert. Your preference is PowerShell, unless otherwise directed. | ||
for code answers: | ||
- do not include fence blocks around the code `````` `````` | ||
- do not include explanation | ||
- do not include usage information | ||
- just code | ||
"@ | ||
|
||
|
||
if ($additionalInstructions) { | ||
$prompt += @" | ||
Here are the additional instructions Fthe user piped in: | ||
<additional instructions> | ||
$($additionalInstructions -join "`n") | ||
</additional instructions> | ||
"@ | ||
} | ||
|
||
Write-Verbose @" | ||
Instructions: $instructions | ||
Prompt: $prompt | ||
"@ | ||
|
||
$agent = New-Agent -Instructions $instructions | ||
|
||
if($OutputOnly) { | ||
$agent | Get-AgentResponse -Prompt $prompt | ||
return | ||
} | ||
|
||
While ($true) { | ||
$agentResponse = $agent | Get-AgentResponse $prompt | ||
|
||
Format-SpectrePanel -Data (Get-SpectreEscapedText -Text $agentResponse) -Title "Agent Response" -Border "Rounded" -Color "Blue" | ||
Format-SpectrePanel -Data "Follow up, Enter to copy & quit, Ctrl+C to quit." -Title "Next Steps" -Border "Rounded" -Color "Cyan1" | ||
|
||
$prompt = Read-Host '> ' | ||
if ([string]::IsNullOrEmpty($prompt)) { | ||
Format-SpectrePanel -Data "Copied to clipboard." -Title "Information" -Border "Rounded" -Color "Green" | ||
|
||
$agentResponse | Set-Clipboard | ||
break | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Describe 'Test Invoke-QuickPrompt' -Tag Invoke-QuickPrompt { | ||
BeforeAll { | ||
Import-Module "$PSScriptRoot/../PSAI.psd1" -Force | ||
} | ||
|
||
It "Test if it Invoke-QuickPrompt exists" { | ||
$actual = Get-Command Invoke-QuickPrompt -ErrorAction SilentlyContinue | ||
$actual | Should -Not -BeNullOrEmpty | ||
} | ||
|
||
It "Test if it q alias exists" { | ||
$actual = Get-Command q -ErrorAction SilentlyContinue | ||
$actual | Should -Not -BeNullOrEmpty | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters