Last active
January 4, 2023 19:58
-
-
Save wandy-dev/b8c95039c8a1894ca88ecaa1453bfe1e to your computer and use it in GitHub Desktop.
GPT chat bot for the terminal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
api_call() { | |
curl --no-progress-meter https://api.openai.com/v1/completions \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer your-api-key" \ | |
-d "{ | |
\"model\": \"text-davinci-003\", | |
\"prompt\": \"$@\", | |
\"temperature\": 0, | |
\"max_tokens\": 1024 | |
}" | jq ".choices" | jq '.[0].text' | sed 's/\"//g' | sed 's/\\n//g' | |
} | |
while true; do | |
read -p "You: " | |
response=$(api_call "$REPLY") | |
echo "GPT: $response" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment