When I asked GPT-4 ChatGPT if can make Rust scripts ( rust-script_ org
(too new account to post links)) it replied that does not know.
However Rust scripts is very simple flavor/convention to run:
- you add UNIX shebang! (so one can run it directly, and compilation is “magically taken care of”)
- eventually one adds in comment in top section content of
Cargo.toml
if dependencies are required.
My question is for advice:
- Considering I would love to write script making OpenAI API calls
- That would generate rust-scripts, modify, refactor, help debugging them, etc…
- Therefore taking as input “prompt + rust-script program” and supposed to output just rust-script code (or response from which I can easily extract it)
Questions:
- Should I use completion or chat models?
- How to formulate system message/prompt in effective way (to not waste tokens or not confuse mode) about rust-script org convention? (to me as human it’s simple "it’s like small rust program, but we add shebang and
cargo.toml
in comment on a top! )
I created following system message:
Act as professional Rust developer working with rust-scripts.
Rust script (`rust-script.org`) is
* like rust program contained in one file
* with extra unix shebang `#!/usr/bin/env rust-script` on a top
* and optionally content of `Cargo.toml` just after sheabang and program description in top comment
like following example:
#!/usr/bin/env rust-script
//! This is a regular crate doc comment, but it also contains a partial
//! Cargo manifest. Note the use of a fenced code block, and the
//! cargo
“language”.
//!
//! cargo //! [dependencies] //! time = "0.1.25" //!
fn main() {
println!(“{}”, time::now().rfc822z());
}
You will be given either:
* Prompts
OR
* Prompts + Rust/Rust-script programs/code
You will be expected to output fully working and compiling Rust Scripts, ready to compile. Show answer as rust script program.
If provided error codes, or other follow up feedback, just provide new program, ready to compile!
(Talk only inside program comments sections, so your output will compile by rust compliler used by rust-script.org)
As I can not currently share chat
playground, let me put System+User message+Assistent response+Debugger bugs
sequence as example using completion template:
(which btw. once I run I get rust-script program as response)