{"id":14980400,"url":"https://github.com/boeegh/pschat","last_synced_at":"2025-10-30T20:24:24.835Z","repository":{"id":150856813,"uuid":"614972411","full_name":"boeegh/PsChat","owner":"boeegh","description":"PsChat is a Powershell module that allows the user to use OpenAI Chat Completion in the shell.","archived":false,"fork":false,"pushed_at":"2023-12-25T14:33:08.000Z","size":1522,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T20:11:24.567Z","etag":null,"topics":["chatgpt","openai","openai-api","powershell","powershell-core","powershell-module"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boeegh.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-16T17:28:58.000Z","updated_at":"2024-03-03T05:50:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"41fb7062-7e7f-44d9-8b13-e79bf696f985","html_url":"https://github.com/boeegh/PsChat","commit_stats":{"total_commits":41,"total_committers":1,"mean_commits":41.0,"dds":0.0,"last_synced_commit":"4e03f80edb0c6631b3c7c696ea475e52c9f9a3fc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boeegh%2FPsChat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boeegh%2FPsChat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boeegh%2FPsChat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boeegh%2FPsChat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boeegh","download_url":"https://codeload.github.com/boeegh/PsChat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238743882,"owners_count":19523195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","openai","openai-api","powershell","powershell-core","powershell-module"],"created_at":"2024-09-24T14:01:43.219Z","updated_at":"2025-10-29T00:30:29.454Z","avatar_url":"https://github.com/boeegh.png","language":"PowerShell","readme":"# PsChat - OpenAIs ChatGPT for PowerShell\nPsChat is a Powershell module that allows the user to use OpenAI Chat Completion in the shell. If you spend a lot of time in Powershell, this may be useful to you.\n\nThe module consists of two functions:\n* `Invoke-PsChat` - Chat UI, similiar to OpenAI web interface\n* `Get-PsChatAnswer` - Pipeable function that allows more direct access to the API\n\nI made it to use and explore ChatGPT the place, I mostly find myself: In the shell.\n\nThe module requires OpenAI API access. You can get an API key from: https://platform.openai.com/signup\n\n## News\n* 2023-12-15 - Audio (TTS) support, see `SaveAudio` extension and [example](examples/dual-minded.ps1)\n* 2023-11-14 - Example of using [non-OpenAI API in examples](examples/alternative-api.ps1)\n* 2023-10-22 - Better copy-paste support (press ALT-P + V)\n* 2023-10-01 - Support for function calling, end-to-end tests\n\n## Getting started\n```Powershell\n# install module from PSGallery\nInstall-Module PsChat -Force\n\n# get an openai api key and put it in a env variable\n$ENV:OPENAI_AUTH_TOKEN=\"my-secret-token\"\n\n# start a chat session\nInvoke-PsChat\n```\n\n## Usage\n```Powershell\n# start a chat session with a question\nInvoke-PsChat \"Lets talk Powershell\"\n\n# ask single question\nInvoke-PsChat \"How is Powershell compared to Zsh\" -Single\n\n# ask single question using functions, result as PSObject\nInvoke-PsChat -Single -Question \"Whats the uptime?\" `\n     -Functions_Names @(\"Get-Uptime\") `\n     -NonInteractive\n\n# does the same using Get-PsChatAnswer\nGet-PsChatAnswer \"What is your name?\n\n# pipe in question\n\"Hello OpenAI\" | Get-PsChatAnswer\n\n# post an entire dialog to the api\n$dialog = @(\n    @{ \"role\"=\"user\"; \"content\"=\"Hello OpenAI. Can we talk Powershell?\" },\n    @{ \"role\"=\"assistant\"; \"content\"=\"Hello! Of course, we can talk about PowerShell. What would you like to know or discuss?\" },\n    @{ \"role\"=\"user\"; \"content\"=\"How does piping work?\" }\n)\nGet-PsChatAnswer -InputObject $dialog -NoEnumerate\n\n# for parameters you can use Get-Help\nGet-Help Invoke-PsChat\nGet-Help Get-PsChatAnswer\n```\n\n## Screenshot(s)\nStarted using alias 'q':\n![Screenshot of the chat UI.](/assets/Screenshot-Invoke-PsChat.png)\n\nAsking for help (available commands) in the chat:\n![Screenshot of the chat having pressed H.](/assets/Screenshot-In-Chat-Help.png)\n\n## Examples\n* [Dual Minded](examples/dual-minded.ps1): Dual-minded makes OpenAI have both sides of a conversation. Now with audio-support!\n* [Bad Code Finder](examples/bad-code-finder.ps1): Powershell script that traverses source codes and uses GPT to find sensitive data. Usage: Download the ps1-file, run it (with $ENV:OPENAI_AUTH_TOKEN set) in a directory containing source code.\n* [Save and Load](examples/save-and-load-chats.ps1): Simple examples of saving and preloading context for chats.\n* [Alternative API](examples/alternative-api.ps1): Using another API, such as a local model using https://github.com/abetlen/llama-cpp-python/.\n\n## Extensions\nThe following extensions are available:\n* `AutoSave` - Saves the chat to json (which can later be loaded back in using `PreLoad`)\n* `WordCountWarning` - Informs the user when a certain word-count is reached (for cost-saving purposes)\n* `PreLoad` - Preloads messages from a file or string. Optionally \"lock\" the loaded messages\n* `Commands` - In-chat commands, such as clipboard access and API settings\n* `ShortTerm` - ShortTerm(Memory) starts pruning early messages when a certain word threshold is reached - in order to avoid token limit\n* `Functions` - Allows OpenAI chat to call Powershell functions during an answer/chat-completion\n* `Api` - Allows you to set chat-completion API parameters, such as base-url, model and temperature\n* `SaveAudio` - NEW: Allows you generate audio using the TTS api. Requires ffmpeg (install it using homebrew, apt or choco)\n\nExtensions can have multiple parameters, that can be set when calling `Invoke-PsChat`, such as `Invoke-PsChat -Api_Model \"gpt-4\"`.\nWith multiple parameters a Powershell alias can come in handy:\n```Powershell\n# setup function\nfunction Invoke-PsChat-Yaml { Invoke-PsChat -Api_Model \"gpt-4\" -PreLoad_Prompt \"Answer only with YAML\" -PreLoad_Lock $true }\n\n# define alias\nNew-Alias -Name q -Value Invoke-PsChat-Yaml -Force -Option AllScope -Description 'Usage: q \"What is consciousness?\"'\n\n# usage\nq \"Describe the rules of tic-tac-toe?\"\n```\n\n### List of extension parameters\nAll extension parameters are optional.\n| Extension | Parameter | Type | Description |\n| --- | --- | --- | --- |\n| Api | Enabled | bool | Enable/disable extension. Defaults to `$true`. |\n| Api | Verbose | bool | If `$true` writes out parameters on startup |\n| Api | AuthToken | string | OpenAI auth token to use |\n| Api | Model | string | Model name, eg. `gpt-4` |\n| Api | Temperature | decimal | Model temperature |\n| Api | Top_P | decimal | Model top_p |\n| Api | Baseurl | string | Base url for model API |\n| AutoSave | Enabled | bool | Enable/disable extension. Defaults to `$false`. |\n| AutoSave | Path | string | Specifies the path the chat will be saved to, eg. `~/my-chat.json`. If not specified the path `./pschat-$(Get-Date -Format \"yyyy-MM-dd-HHmmss\").json` will be used. |\n| Functions | Enabled | bool | Enable/disable extension. Defaults to `$true`. |\n| Functions | Names | string[] | Powershell functions to expose in the chat. Eg. `@( \"Get-Uptime\" )` |\n| PreLoad | Prompt | string | Simple prompt to start chat with. |\n| PreLoad | Role | string | Role for `Prompt`, for OpenAI can be `user`, `assistant` or `system`. |\n| PreLoad | Path | string | Load chat from this path eg. `./my-chat.json`. |\n| PreLoad | Objects | object[] | Allows preloading based on PsObjects, eg. `@( @{ \"Role\"=\"system\"; \"Content\"=\"Hi!\"; \"Locked\"=$true } )` |\n| PreLoad | Verbose | bool | Makes the extension more talkative. |\n| PreLoad | Lock | bool | Locks the preloaded prompt/chat, so an extension like `ShortTerm` does not affect them. |\n| SaveAudio | Enabled | bool | Enable/disable extension. Defaults to `$true`. |\n| SaveAudio | Path | string | Output file path. Defaults to autogenerated based on timestamp. |\n| SaveAudio | Model | string | Optional TTS model to use |\n| SaveAudio | UserVoice | string | Maps to OpenAI voice parameter for users voice |\n| SaveAudio | AssistantVoice | string | Maps to OpenAI voice parameter for assistants voice |\n| SaveAudio | Response_Format | string | Maps to OpenAI Response_Format paramter |\n| SaveAudio | Speed | decimal | Maps to OpenAI speed parameter |\n| SaveAudio | ShowProgress | bool | Shows Powershell progress bar while processing. Defaults to `$true` |\n| SaveAudio | ConcatUsingFfmpeg | bool | FFmpeg: Merge audio clips using ffmpeg. Defaults to `$true` |\n| SaveAudio | TurnDelay | int | FFmpeg: Amount of time in ms between each audio clip. Defaults to `600` |\n| SaveAudio | FfmpegExecutablePath | string | FFmpeg: Executable to use |\n| SaveAudio | FfmpegQuality | int | FFmpeg: Audio quality from 1 (best) - 10 (worst). Defaults to `3` |\n| ShortTerm | Enabled | bool | Enable/disable extension. Defaults to `$true`. |\n| ShortTerm | Verbose | bool | Makes the extension more talkative. |\n| ShortTerm | Compress | bool | Compresses messages that are due to be removed. |\n| ShortTerm | CompressPrompt | string | Prompt to use when compressing messages to be \"forgotten\". |\n| ShortTerm | TokenCountThreshold | int | Number of (approx) tokens that triggers removal of the oldest messages. Defaults to model context size minus 1.000. |\n| ShortTerm | WordCountThreshold | int | Same as TokenCountThreshold, but based on words. Considered deprecated. |\n\n## Commands\nCommands are extensions for the UI chat, such as changing the model on-the-fly. These are available when the user enters `'h'` in the chat.\n\n## Dev notes\nFor development this approach seems to work best:\n```Powershell\n# open chat ui (talkative, with debug)\npwsh -NoProfile -Command { Remove-Module PsChat -Force; $DebugPreference=\"Continue\"; Import-Module ./src/PsChat/PsChat.psd1 -Verbose -Force \u0026\u0026 Invoke-PsChat }\n\n# get anwer (quiet)\npwsh -NoProfile -Command { Remove-Module PsChat -ErrorAction SilentlyContinue; Import-Module ./src/PsChat/PsChat.psd1 -Force \u0026\u0026 Get-PsChatAnswer \"hello\" }\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboeegh%2Fpschat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboeegh%2Fpschat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboeegh%2Fpschat/lists"}