Skip to content

Commit

Permalink
Include OS comment (Mac or Linux) so GPT-3 knows to run brew install …
Browse files Browse the repository at this point in the history
…vs. apt-get install, etc. (#7)

* Add a comment to tell GPT-3 which OS we're using (so it knows to run brew install vs. apt-get install, etc.)

* tweak prompt

Co-authored-by: Miguel Piedrafita <[email protected]>
  • Loading branch information
ndbroadbent and m1guelpf authored Dec 16, 2022
1 parent bbfaee9 commit 23a0fb2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,29 @@ fn main() {
std::process::exit(1);
});

let client = Client::new();
let mut spinner = Spinner::new(Spinners::BouncingBar, "Generating your command...".into());

let client = Client::new();
let os_hint = if cfg!(target_os = "macos") {
" (on macOS)"
} else if cfg!(target_os = "linux") {
" (on Linux)"
} else {
""
};

let response = client
.post("https://api.openai.com/v1/completions")
.json(&json!({
"top_p": 1,
"stop": "```",
"temperature": 0,
"suffix": "\n```",
"max_tokens": 1000,
"presence_penalty": 0,
"frequency_penalty": 0,
"model": "text-davinci-003",
"prompt": format!("{}:\n```bash\n#!/bin/bash\n", cli.prompt.join(" ")),
"stop": "```",
"prompt": format!("{}{}:\n```bash\n#!/bin/bash\n", cli.prompt.join(" "), os_hint),
}))
.header("Authorization", format!("Bearer {}", api_key))
.send()
Expand Down

0 comments on commit 23a0fb2

Please sign in to comment.