PowerGPT
1.0.4
シェル スクリプトを書くのは難しくて退屈かもしれません。このモジュールは、PowerShell について何も知らなくても、Windows ターミナルで一般的なタスク/バッチ処理を数秒で実行するのに役立ちます。
次のようにPowerGPT <your task>
と入力して実行するだけで、残りの作業は GPT モデルが実行します。
$ PowerGPT " list all files in current folder with created date "
Will execute script:
-----
Get-ChildItem | Select-Object Name , CreationTime
-----
PowerShell の専門家にとっても、いくつかの単語を入力して AI モデルに面倒な作業を任せるほうが、確かに良い方法のように思えます ;)
スクリプトは PowerSell のみで実装され、PowerShell モジュールとしてパッケージ化されています。
-Chat
操作のサポートを追加します。メリット:安くて早い。短所: text-davinnci-3
モデルのような提案を生成できません。Invoke-RestMethod
エンコーディングを修正して、ほとんどの言語が機能するようになりました。 $ PowerGPT -Chat "列出所有文件"
我们使用`Get-ChildItem`来列出所有文件。
```
Get-ChildItem -Path "C:" -Recurse -File
```
这将列出C盘下所有文件,包括子文件夹中的文件。如果要列出当前文件夹下的所有文件,可以将`-Path`参数设置为`.`。
Will execute script:
-----
Get-ChildItem -Path "C:" -Recurse -File
-----
Install-Module PowerGPT
このモジュールを使用するには、OpenAI API キーが必要です。このコマンドは、最初の使用時に API キーの入力を求められます。 API キーをリセットするには、 -ResetConfig
オプションを使用します。
基本的な使い方:
$ PowerGPT " list all files in current folder with created date "
Will execute script:
-----
Get-ChildItem | Select-Object Name , CreationTime
-----
continue ?([ y ]es , [ n ]o):
$ PowerGPT " extract compressed.tar.gz "
Will execute script:
-----
# Extract compressed.tar.gz in Windows using PowerShell
# First, check if the tar command is available
if ( ! ( Get-Command tar - ErrorAction SilentlyContinue)) {
# If not, install the tar command
Invoke-WebRequest - Uri " http://gnuwin32.sourceforge.net/downlinks/tar.exe.zip " - OutFile " tar.exe.zip "
Expand-Archive - Path " tar.exe.zip " - DestinationPath " $ env: ProgramFiles GnuWin32 "
# Add the tar command to the PATH
$ env: Path += " ; $ env: ProgramFiles GnuWin32 "
}
# Extract the compressed.tar.gz file
tar - xvzf compressed.tar.gz
-----
continue ?([ y ]es , [ n ]o):
$ PowerGPT " print the first line of all the files that begin with poet_ in current folder "
Will execute script:
-----
Get-ChildItem - Path . - Filter " poet_* " | ForEach-Object { Get-Content $_ .FullName | Select-Object - First 1 }
-----
continue ?([ y ]es , [ n ]o):
複雑なタスクの場合、ツールはスマートに動作し、ユーザーに選択肢を提供します。
$ PowerGPT " print first lines and last lines for each file in current folder "
The description is too vague , do you mean:
[ 0 ] For each file in current directory , print the first line and then print the last line of the file.
[ 1 ] For each file in current directory , print the first line of the file. After that , for each file , print the last line of the file.
Choose one description that matches your task: : 1
Will execute script:
-----
Get-ChildItem | ForEach-Object {
$file = $_ .FullName
Write-Host " First line of $file : "
Get-Content $file - TotalCount 1
}
Get-ChildItem | ForEach-Object {
$file = $_ .FullName
Write-Host " Last line of $file : "
Get-Content $file - Tail 1
}
-----
continue ?([ y ]es , [ n ]o)
他の言語の共通ライブラリを使用してスクリプトを書くことも可能です。
$ PowerGPT " retrieve AzureDevops artifact for a build " - ShellVariant C #
The description is a little vague , do you mean:
[ 0 ] Use AzureDevops REST API to retrieve the artifact for a build.
[ 1 ] Use AzureDevops SDK to retrieve the artifact for a build.
Choose one description that matches your task , or [ n ]o: 0
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var organization = " your_organization " ;
var project = " your_project " ;
var buildId = " your_build_id " ;
var token = " your_token " ;
var client = new HttpClient();
client.DefaultRequestHeaders.Add( " Authorization " , $ " Bearer {token} " );
var url = $ " https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?api-version=5.1 " ;
var response = await client.GetAsync(url);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}