Coder Social home page Coder Social logo

mutaguchi / powergenerativetoolkit Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 13 KB

LLM-powered comprehensive PowerShell module for generating, transforming, and completing all kinds of text, including PowerShell functions.

License: MIT License

PowerShell 100.00%

powergenerativetoolkit's Introduction

PowerGenerativeToolkit

PowerGenerativeToolkit is a comprehensive PowerShell module that leverages LLM to generate, transform, and complete all kinds of text, including PowerShell functions. This module makes it easy to create new functions or enhance existing ones by automating the generation process and providing powerful text manipulation capabilities.

日本語版ドキュメントはこの下に用意しています。(A Japanese version of the documentation is available below.)

Features

  • Utilizes OpenAI's API to access gpt-3.5-turbo (default) and gpt-4 language models
  • Generates, transforms, and completes various types of text, including PowerShell functions
  • Optimized for use in English or Japanese environments, but can also work with other language settings

System Requirements

  • PowerShell 7.0 or later

Installation

  1. Download the .zip file and extract its contents
  2. Place the extracted folder in your PowerShell module directory, or use Import-Module with the specified PowerGenerativeToolkit.psd1 path to import the module directly

Configuration

To use PowerGenerativeToolkit, you'll need to set the OPENAI_API_KEY environment variable with your OpenAI API key.

Usage

Currently, only the Convert-PGTString command has been implemented. Here's an example of how to use the command:

PS> $env:OPENAI_API_KEY = "your api key"
PS> Import-Module PowerGenerativeToolkit
PS> "Toshio Yamada", "Saito Hanako" | Convert-PGTString -Example "Daisuke Mutaguchi=D. Mutaguchi"
T. Yamada
S. Hanako

"frog", "cat", "dog" | Convert-PGTString -Rule "transform into a stronger name" -IncludeInput

Input    Output
-----    ------
frog     Temporalis Amphibia
cat      Felis Magnificus
dog      Canis Regalis

1, 2, 3 | Convert-PGTString -Example @{before=5; after=10} -IncludeInput

    Rule:  Double the given number

Input Output
----- ------
1     2
2     4
3     6

PS> $function = "Extracts only even numbers from a given numeric array" | Convert-PGTString -Rule "Generate powershell functions"
PS> $function
function Get-EvenNumbers {
    param(
        [Parameter(Mandatory=$true)]
        [int[]]$numbers
    )

    $evenNumbers = @()
    foreach($number in $numbers) {
        if($number % 2 -eq 0) {
            $evenNumbers += $number
        }
    }

    return ,$evenNumbers
}

PS> Invoke-Expression $function
PS> Get-EvenNumbers @(1..7)
2
4
6

You can find other examples by running Get-Help Convert-PGTString -Detailed.

Important Note

Functions in the PowerGenerativeToolkit module, such as Convert-PGTString, only invoke the OpenAI API once, even when multiple values are passed as input via a pipeline or parameters. However, if you execute the function within a loop construct like foreach, the API will be called multiple times. It is generally recommended to avoid executing the function within a loop.

Disclaimer

Please be aware that this module uses OpenAI's API, which may have associated usage fees. Use the module at your own risk, and always be mindful of potential costs.

PowerGenerativeToolkit

PowerGenerativeToolkitは、LLMを利用してPowerShell関数を含むあらゆる種類のテキストを生成・変換・補完するための包括的なPowerShellモジュールです。

機能

  • OpenAIのAPIを利用して、gpt-3.5-turbo(デフォルト)およびgpt-4を使用可能
  • PowerShell関数を含むさまざまなタイプのテキストを生成、変換、補完(現在は変換のみサポート)
  • 日本語も問題なく利用できます

動作環境

  • PowerShell 7.0以降

インストール

  1. .zipファイルをダウンロードし、内容を解凍します
  2. 解凍したフォルダをPowerShellモジュールディレクトリに配置するか、Import-Moduleを使ってPowerGenerativeToolkit.psd1のパスを指定してモジュールを直接インポートします

設定

PowerGenerativeToolkitを使用するには、OPENAI_API_KEY環境変数にOpenAI APIキーを設定する必要があります。

使用方法

現在、Convert-PGTStringコマンドのみが実装されています。使用例については英語版ドキュメント参照。 他の例はGet-Help Convert-PGTString -Detailedで見ることができます。

GPT-3.5/4には日本語も通りますが、英語でRuleやExampleを与えた方が精度が上がるので、適宜、-CultureInfo en-USパラメータを指定すると良いでしょう。

注意

PowerGenerativeToolkitモジュールの関数、例えばConvert-PGTStringなどは、パイプラインやパラメータを通じて複数の値が入力された場合でも、OpenAI APIを1回だけ呼び出します。ただし、foreachなどのループ構文内で関数を実行すると、APIが複数回呼び出されてしまいます。通常は、ループ構文内で関数を実行しないよう、注意してください。

免責事項

このモジュールはOpenAIのAPIを使用しており、利用料金が発生します。また、モジュールのご利用は自己責任でお願いします。

powergenerativetoolkit's People

Contributors

mutaguchi avatar

Stargazers

Voytas avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.