LoginSignup
0
0

GPTScriptの組み込みツール(built in tools)について

Posted at

毎度、ググっても出てこない小ネタを取り扱っております。
本記事は個人的な見解であり、筆者の所属するいかなる団体にも関係ございません。

0. はじめに

GPTScriptを使うときに必要になるのがビルトインツールです。このビルトインツールを使うことにより、GPTScriptを実行した場所荷あるファイルを読み込んだり、書き込んだり、インターネットからファイルをダウンロードしたり、検索したりすることができます。

その各種組み込みツールについて翻訳してみました。

1. 事前準備

GPTScriptは以下のバージョンで実行しました。

gptscript -v
gptscript version v0.5.0+5a8a685c

組み込みツール群の説明をファイルに保存

gptscript --list-tools > gptscript-intree-tools.md

このファイルを翻訳するgptscriptを以下のように作成

translate-to-japanese.gpt
tools: sys.read, sys.write

gptscript-built-in-tools.md ファイルを読み込んで日本語に翻訳した内容を元のファイルの拡張子はそのままで、ファイル名に_jaという文字を付け加えたファイル名で保存してください。
ファイルを翻訳するときに、```や```yamlで囲まれたMarkdownの書式のブロッククオートの中の部分は翻訳しないでください。

ファイルを書き出すときに日本語はUTF-8でエンコードしてください。

翻訳を実行

gptscript ./translate-to-japanese.gpt

実行結果

以下のファイルができあがる

gptscript-built-in-tools_ja.md

2. 組み込みツール群の説明

gptscript-built-in-tools_ja.md の翻訳結果ファイルを以下に貼ります。


Name: sys.abort
Description: 実行を中止します
Model: gpt-4-turbo-preview
Args: message: 中止を呼び出す原因となったエラーや予期しない結果の説明


Name: sys.append
Description: ファイルに内容を追加します
Model: gpt-4-turbo-preview
Args: content: 追加する内容
Args: filename: 追加するファイルの名前


Name: sys.download
Description: URLをダウンロードし、指定された場所にディスク上の内容を保存します
Model: gpt-4-turbo-preview
Args: location: (任意) ファイルを保存するディスク上の場所。場所が指定されていない場合は、一時的な場所が使用されます。ターゲットファイルが既に存在する場合は、overrideがtrueに設定されていない限り失敗します。
Args: override: trueの場合、場所にファイルが存在すると、ファイルは上書きされます。それ以外の場合は失敗します。デフォルトはfalseです
Args: url: ダウンロードするURL。httpまたはhttpsです。


Name: sys.exec
Description: コマンドを実行し、そのコマンドの出力を取得します
Model: gpt-4-turbo-preview
Args: command: 実行するコマンドとすべての適用可能な引数
Args: directory: コマンドの現在の作業ディレクトリとして使用するディレクトリ。引数が渡されない場合は、現在のディレクトリ"."が使用されます


Name: sys.find
Description: unix findコマンドのスタイルでパターンに一致するファイルを探すためにディレクトリを横断します
Model: gpt-4-turbo-preview
Args: directory: 検索するディレクトリ。引数が渡されない場合、現在のディレクトリ"."がデフォルトとして使用されます
Args: pattern: 探すファイルパターン。パターンは従来のunix glob形式で、*は任意の文字に、?は1文字に一致します


Name: sys.getenv
Description: OS環境変数の値を取得します
Model: gpt-4-turbo-preview
Args: name: 検索する環境変数名


Name: sys.http.get
Description: httpまたはhttps URLの内容をダウンロードします
Model: gpt-4-turbo-preview
Args: url: ダウンロードするURL


Name: sys.http.html2text
Description: httpまたはhttps URLの内容をダウンロードし、HTMLから変換されたレンダリングテキストとして内容を返します
Model: gpt-4-turbo-preview
Args: url: ダウンロードするURL


Name: sys.http.post
Description: POSTメソッドを使用してhttpまたはhttps URLに内容を書き込みます
Model: gpt-4-turbo-preview
Args: content: POSTする内容
Args: contentType: 内容の"content type"、例えばapplication/jsonやtext/plainなど
Args: url: POSTするURL


Name: sys.ls
Description: ディレクトリの内容をリストします
Model: gpt-4-turbo-preview
Args: dir: リストするディレクトリ


Name: sys.prompt
Description: ユーザーに入力を促します
Model: gpt-4-turbo-preview
Args: fields: 促すフィールドのコンマ区切りリスト
Args: message: ユーザーに表示するメッセージ
Args: sensitive: (trueまたはfalse) 入力を隠すべきかどうか


Name: sys.read
Description: ファイルの内容を読み取ります
Model: gpt-4-turbo-preview
Args: filename: 読み取るファイルの名前


Name: sys.remove
Description: 指定されたファイルを削除します
Model: gpt-4-turbo-preview
Args: location: 削除するファイル


Name: sys.stat
Description: 指定されたファイルのサイズ、変更時間、およびモードを取得します
Model: gpt-4-turbo-preview
Args: filepath: ファイルの完全なパスとファイル名


Name: sys.write
Description: 内容をファイルに書き込みます
Model: gpt-4-turbo-preview
Args: content: 書き込む内容
Args: filename: 書き込むファイルの名前

3. まとめ

まだ、これらの組み込みツール群の使い方を研究する必要がありますが、ひとまずどういうことができるツールがあるかどうかだけ書いておきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0