gpt_inject!() { /* proc-macro */ }
Expand description
Allows you to write a prompt to GPT4 as a string literal argument to the macro. When the macro is compiled, the macro will find the file in which it was invoked and replace the macro call with the code generated by GPT4, along with a comment allowing you to further tweak the prompt.
For this to work, you MUST have a valid OpenAI API key that is allowed to access GPT4
stored in the environment variable OPENAI_API_KEY
such that whatever is compiling your
rust file has access to that environment variable.
i.e.:
ⓘ
use macro_gpt::*;
struct Something;
gpt_inject!("Make a trait defining a method called `foo` that prints hello world to the console and have `Something` implement it");
When you compile this, the file will re-write itself to look something like this, directly in your editor:
ⓘ
use macro_gpt::*;
struct Something;
// generated by: gpt_inject!("Make a trait defining a method called `foo` that prints hello world to the console and have `Something` implement it")
trait HelloWorld {
fn foo(&self);
}
impl HelloWorld for Something {
fn foo(&self) {
println!("Hello, world!");
}
}
// end of generated code