4 ms·
Given how strict OpenAI has been about what you can do with their API in the past and how hard it was to get some legitimate apps through approval, I would imag
by drusepth 4y ago
Given how strict OpenAI has been about what you can do with their API in the past and how hard it was to get some legitimate apps through approval, I would imagine they'd just shut this competitor's API access down.
- reset-password 4y agoHopefully there will be a plug-in-your-own-API-key open source thing then. Even better.
- b5n 4y agoThe future is now: gptask() { data=$(jq -n \ --arg message "$1" \ '{model: "gpt-3.5-turbo", max_tokens: 4000, messages: [{role: "user", content: $message}]}') response=$(curl -s https://api.openai.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OAIKEY" \ -d "$data") message=$(echo "$response" \ | jq '.choices[].message.content' \ | sed 's/^\"\\n\\n//;s/\"$//') echo -e "$message" } export OAIKEY=<YOUR_KEY> gptask "what is the url for hackernews"
- comment_ran 4y agoNot to sure how to make it one section, aka, one session mode, so chatgpi can understand the previous talk.
- _just7_ 4y agoJust use iteration where you continuously update the prompt to include previous messages
- _andrei_ 4y agoquick script #!/usr/bin/env bash set -uf -o pipefail IFS=$'\n\t' BOT='\033[33m' NC='\033[0m' messages=() trim() { local var="$*" var="${var#"${var%%[![:space:]]*}"}" var="${var%"${var##*[![:space:]]}"}" printf '%s' "$var" } function complete { local message="$1" local data messages+=("{\"role\": \"user\", \"content\": $(echo "$message" | jq -R -s '.')}") processed_messages=$(printf '%s,' "${messages[@]}") processed_messages="[${processed_messages::-1}]" data=$(jq -n \ --arg model "gpt-3.5-turbo" \ --argjson messages "$processed_messages" \ '{ model: $model, messages: $messages }' \ | sed 's/\]\[/,/g') response=$(curl -s https://api.openai.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d "$data") message=$(echo "$response" | jq '.choices[].message.content') printable_message=$(echo "$response" | jq -r '.choices[].message.content') printable_message=$(trim "$printable_message") echo -e "${BOT}Bot:${NC} $printable_message" messages+=("{\"role\": \"assistant\", \"content\": $message}") } while true; do read -r -p $'\e[35mYou:\e[0m ' message complete "$message" done