Crate hey_chat_gpt

Source
Expand description

§A proc-macro to delegate implementation to the ChatGPT API.

ChatGPT APIに実装を代行してもらうマクロです。

This crate requires nightly toolchain!

本クレートでは nightly ツールチェイン必須です!

use hey_chat_gpt::take_care_of_the_rest;

fn main() {
    println!("{}", fib(10));
}

take_care_of_the_rest!();

The difference between the two macros is whether they are in English or Japanese.

この2つのマクロの違いは、英語か日本語かです。

Please see the links for each macro for more details.

詳細は各マクロのリンク先で読んでください。

§Preparation

To compile, run the below command.

OPENAI_API_KEY=sk-YOUR-API-KEY RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo +nightly run
  • OPENAI_API_KEY: api key.
  • RUSTFLAGS=...: to enable source_file method of Span.
  • cargo +nightly run: the reason of specify nightly is same as above.

These settings can also be enable by setting files.

.cargo/config.toml

[build]
rustflags = ["--cfg=procmacro2_semver_exempt"]

[env]
OPENAI_API_KEY = "sk-YOUR-API-KEY"

rust-toolchain.toml

[toolchain]
channel = "nightly"

In this case, the options are not necessary.

cargo run

§Cache

Responses from ChatGPT are stored in the gpt_responses directory and used as a cache when the code remains unchanged. If you get undesirable code or an error response from ChatGPT, remove those cache files before trying to compile again.

§使用のための準備

コンパイルするには以下を実行します。

OPENAI_API_KEY=sk-YOUR-API-KEY RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo +nightly run
  • OPENAI_API_KEY: 取得してきたOpenAIのAPIキーを設定してください。
  • RUSTFLAGS=...: Spansource_file メソッドを使用するために指定しています。
  • cargo +nightly run: nightly の指定理由は上記と同じです。

設定ファイルを通しての設定も可能です。

.cargo/config.toml

[build]
rustflags = ["--cfg=procmacro2_semver_exempt"]

[env]
OPENAI_API_KEY = "sk-YOUR-API-KEY"

rust-toolchain.toml

[toolchain]
channel = "nightly"

この場合オプションは不要になります。

cargo run

§キャッシュファイルについて

ChatGPTからの返答は gpt_responses ディレクトリに保存され、コードが変わらないうちはこちらのキャッシュがコンパイルに利用されます。もし望まない結果になったりエラーレスポンスが帰ってきた場合は、キャッシュファイルを削除の上再コンパイルしてみてください。

Macros§

abracadabra
An alias for take_care_of_the_rest.
back_me_up
An alias for take_care_of_the_rest.
deliver_it
An alias for take_care_of_the_rest.
do_it
An alias for take_care_of_the_rest.
finish_it
An alias for take_care_of_the_rest.
get_it_done
An alias for take_care_of_the_rest.
give_it_a_go
An alias for take_care_of_the_rest.
go_ahead
An alias for take_care_of_the_rest.
help_me
An alias for take_care_of_the_rest.
just_do_it
An alias for take_care_of_the_rest.
lend_a_hand
An alias for take_care_of_the_rest.
magic
An alias for take_care_of_the_rest.
make_it_happen
An alias for take_care_of_the_rest.
perform_miracle
An alias for take_care_of_the_rest.
save_me
An alias for take_care_of_the_rest.
take_care_of_the_rest
A macro to delegate implementation to the ChatGPT API.
try_it
An alias for take_care_of_the_rest.
wave_your_wand
An alias for take_care_of_the_rest.
wrap_it_up
An alias for take_care_of_the_rest.
あとは任せた
ChatGPT APIに実装を代行してもらうマクロです。
これやって
あとは任せた へのエイリアス。
やって
あとは任せた へのエイリアス。
やり遂げて
あとは任せた へのエイリアス。
仕上げて
あとは任せた へのエイリアス。
何とかして
あとは任せた へのエイリアス。
作って
あとは任せた へのエイリアス。
助けて
あとは任せた へのエイリアス。
奇跡を起こして
あとは任せた へのエイリアス。
完成させて
あとは任せた へのエイリアス。
実現して
あとは任せた へのエイリアス。
手を貸して
あとは任せた へのエイリアス。
手伝って
あとは任せた へのエイリアス。
最後まで頼む
あとは任せた へのエイリアス。
終わらせて
あとは任せた へのエイリアス。
進めて
あとは任せた へのエイリアス。
頼む
あとは任せた へのエイリアス。
魔法を見せて
あとは任せた へのエイリアス。