Skip to content

Commit

Permalink
Bug fixes and better docs
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rishi255 authored Oct 3, 2024
2 parents c95dc50 + 84d7868 commit 877393b
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 204 deletions.
Original file line number Diff line number Diff line change
@@ -1,59 +1,66 @@
---
external help file: PoshCodex-help.xml
Module Name: PoshCodex
online version:
schema: 2.0.0
---

# Write-Completion

## SYNOPSIS

This function is called when the keybind is hit, and should only be called by hitting the keybind, NOT manually because that would defeat the purpose of completion (since this function reads the current buffer and tries to generate the completion).

## SYNTAX

```
Write-Completion [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION

Check help for the module to learn more.

PS> Get-Help PoshCodex

## EXAMPLES

## PARAMETERS

### -ProgressAction

{{ Fill ProgressAction Description }}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### None (reads current buffer)
## OUTPUTS
### None (writes to console)
## NOTES
## RELATED LINKS
---
external help file: PoshCodex-help.xml
Module Name: PoshCodex
online version:
schema: 2.0.0
---

# Enter-CompletionKeybind

## SYNOPSIS

{{ Change the completion keybind for PoshCodex by reading user input. }}

## SYNTAX

```
Enter-CompletionKeybind [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION

{{ }}

## EXAMPLES

### Example 1

```powershell
PS C:\> {{ Add example code here }}
```

{{ Add example description here }}

## PARAMETERS

### -ProgressAction

{{ Fill ProgressAction Description }}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS
111 changes: 0 additions & 111 deletions PoshCodex/Docs/Set-CompletionKeybind.md

This file was deleted.

8 changes: 4 additions & 4 deletions PoshCodex/Source/Private/Invoke-Ollama-Api.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ function Invoke-Ollama-Api {
$BUFFER
)

# [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($line)
# [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
$ollama_model = [Environment]::GetEnvironmentVariable('OLLAMA_MODEL', 'User')
$ollama_host = [Environment]::GetEnvironmentVariable('OLLAMA_HOST', 'User')

$data = @{
model = "$env:OLLAMA_MODEL"
model = "$ollama_model"
prompt = $BUFFER
stream = $false
}

$json_output = Invoke-RestMethod -Method POST `
-Uri "$env:OLLAMA_HOST/api/generate" `
-Uri "$ollama_host/api/generate" `
-Body ($data | ConvertTo-Json) `
-ContentType 'application/json; charset=utf-8';

Expand Down
3 changes: 3 additions & 0 deletions PoshCodex/Source/Private/Set-CompletionKeybind.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ function Set-CompletionKeybind {
-BriefDescription Write-Completion `
-LongDescription 'Autocomplete the command' `
-ScriptBlock { Write-Completion }

# Update env var with new keybind
[Environment]::SetEnvironmentVariable('AUTOCOMPLETE_KEYBIND', $new_keybind, [System.EnvironmentVariableTarget]::User)
}
6 changes: 1 addition & 5 deletions PoshCodex/Source/Public/Enter-CompletionKeybind.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,5 @@ function Enter-CompletionKeybind {
# get old keybind, call set keybind for new
$old_autocomplete_keybind = [Environment]::GetEnvironmentVariable('AUTOCOMPLETE_KEYBIND', 'User')
Set-CompletionKeybind $old_autocomplete_keybind $new_autocomplete_keybind
Write-Host "New keybind set: $new_autocomplete_keybind"

# Update env var with new keybind
[Environment]::SetEnvironmentVariable('AUTOCOMPLETE_KEYBIND', $new_autocomplete_keybind, [System.EnvironmentVariableTarget]::User)
# Write-Host "Value of newly set env var: $([Environment]::GetEnvironmentVariable('AUTOCOMPLETE_KEYBIND', 'User'))"
Write-Host "New keybind set: $([Environment]::GetEnvironmentVariable('AUTOCOMPLETE_KEYBIND', 'User'))"
}
7 changes: 3 additions & 4 deletions PoshCodex/Source/Scripts/Initialize-Module-On-Import.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
## Set necessary environment variables:

[System.Environment]::SetEnvironmentVariable('OLLAMA_HOST', 'http://localhost:11434', [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable('OLLAMA_MODEL', 'rishi255/posh_codex_model', [System.EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable('OLLAMA_HOST', 'http://localhost:11434', [System.EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable('OLLAMA_MODEL', 'rishi255/posh_codex_model', [System.EnvironmentVariableTarget]::User)


## Set default keybind:

$default_keybind = 'Ctrl+Shift+O'
Set-CompletionKeybind $null $default_keybind;
[Environment]::SetEnvironmentVariable('AUTOCOMPLETE_KEYBIND', $default_keybind, [System.EnvironmentVariableTarget]::User)
Set-CompletionKeybind $null $default_keybind;
4 changes: 2 additions & 2 deletions PoshCodex/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ task Build {
}
else {
# Write-Verbose -Message 'Removing old Help files, to generate new files.'
# Remove-Item -Path ".\Docs\*.*" -Exclude "about_*"
# Remove-Item -Path '.\Docs\*.*' -Exclude 'about_*'
if (Get-Module -Name $($ModuleName)) {
# Write-Verbose -Message "Module: $($ModuleName) is imported into session, updating Help Files"
# New-MarkdownHelp -Module $ModuleName -OutputFolder ".\Docs"
# New-MarkdownHelp -Module $ModuleName -OutputFolder '.\Docs'
Update-MarkdownHelp '.\Docs'
New-ExternalHelp '.\Docs' -OutputPath ".\Output\$($ModuleName)\$($ModuleVersion)\en-US\"
}
Expand Down
Loading

0 comments on commit 877393b

Please sign in to comment.