humanloop / awesome-chatgpt

Curated list of awesome tools, demos, docs for ChatGPT and GPT-3
8.2k stars 523 forks source link

chatgpt-cli: The CLI tool of chatgpt supports REPL and pipeline operations #84

Open vvtommy opened 1 year ago

vvtommy commented 1 year ago

Simply type chatgpt and hit enter to start the conversation

截屏2023-03-07 00 12 29

If you wanna use the ChatGPT command-line tool like a pro, just pipe your input into it and you're good to go.

cat ./awsome-prompt.txt | chatgpt --json | jq -r '.usage.total_tokens'

even instead of jq

$ cat ./awsome-prompt.txt | chatgpt --json | \
  chatgpt 'Calculate the amount spent on tokens, given that you acted as a JSON parser and \
    the cost is $0.0002 per 1k tokens. The total number of tokens used can be determined from \
    the attribute .usage.total_tokens'

The total tokens used are 44.
Cost per 1k tokens is $0.0002.
So, the cost for 44 tokens can be calculated as:
(44/1000) * $0.0002 = $0.0000088
Therefore, the amount spent on tokens is $0.0000088.

Use heredoc to support multiple-line input.

截屏2023-03-07 01 35 56

proxy support 🪜

$ HTTPS_PROXY=127.0.0.1:7890 chatgpt