Skip to content

Commit

Permalink
Merge pull request #45 from dfinke/add-spectre-console
Browse files Browse the repository at this point in the history
Add spectre console
  • Loading branch information
dfinke authored Nov 2, 2024
2 parents cb06e45 + 3c1b9a2 commit 487548b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ jobs:
- name: Run Continuous Integration
shell: pwsh
run: |
Install-Module -Name PwshSpectreConsole -Force
cd ./__tests__
Invoke-Pester -Output Detailed
6 changes: 4 additions & 2 deletions PSAI.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
PSAI brings OpenAI ChatGPT to PowerShell, leveraging advanced AI capabilities in your PowerShell scripts for dynamic, intelligent automation and data processing
'@

PowerShellVersion = '5.1'
PowerShellVersion = '7.1'

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @()
RequiredModules = @(
@{ModuleName = 'PwshSpectreConsole'; ModuleVersion = "2.1.1" ; GUID = "8c5ca00d-7f0f-4179-98bf-bdaebceaebc0" }
)

FunctionsToExport = @(
# Private
Expand Down
42 changes: 33 additions & 9 deletions Public/New-Agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ $PrintResponse = {
$script:messages += @($response.choices[0].message | ConvertTo-OAIMessage)

$script:messages += @(Invoke-OAIFunctionCall $response -Verbose:$this.ShowToolCalls)
# $response = Invoke-OAIChatCompletion -Messages $script:messages -Tools $this.Tools -Model $llmModel
} until ($response.choices.finish_reason -eq "stop")

return $response.choices[0].message.content
Expand All @@ -36,26 +35,51 @@ $InteractiveCLI = {
param(
$Message,
$User = 'User',
$Emoji = '😎',
$ExitOn
$Emoji = '😎'
# $ExitOn
)

if ($Message) {
$this.PrintResponse($Message) | Out-Host
}

if ($null -eq $ExitOn) {
$ExitOn = @("exit", "quit", "bye")
}
# if ($null -eq $ExitOn) {
# $ExitOn = @("exit", "quit", "bye")
# }

while ($true) {
$message = Read-Host "$Emoji $User"

if ($message -in $ExitOn) {
break
if ([string]::IsNullOrEmpty($Message)) {
Format-SpectrePanel -Data "Copied to clipboard." -Title "Information" -Border "Rounded" -Color "Green" | Out-Host
$agentResponse | clip
break
}

# if ($message -in $ExitOn) {
# break
# }

$this.PrintResponse($message) | Out-Host
# $this.PrintResponse($message) | Out-Host
$agentResponse = $this.PrintResponse($message)

$formatParams = @{
Data = (Get-SpectreEscapedText -Text $agentResponse)
Title = "Agent Response"
Border = "Rounded"
Color = "Blue"
}

Format-SpectrePanel @formatParams | Out-Host

$nextStepsParams = @{
Data = "Follow up, Enter to copy & quit, Ctrl+C to quit."
Title = "Next Steps"
Border = "Rounded"
Color = "Cyan1"
}

Format-SpectrePanel @nextStepsParams | Out-Host
}
}

Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v0.3.0

- Fix multi line description transpiled to Json
- Check if result is null from function calling. Set a default value so the operation continues, and the model has more info
- Added PwshSpectreConsole for console visuals

## v0.2.14

- Thanks again to [Axel](https://github.com/Agazoth)
Expand Down

0 comments on commit 487548b

Please sign in to comment.