Skip to content

Instantly share code, notes, and snippets.

@kxzk
Last active March 29, 2023 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kxzk/ec496e49f1c81c2a24077dadd2034589 to your computer and use it in GitHub Desktop.
Save kxzk/ec496e49f1c81c2a24077dadd2034589 to your computer and use it in GitHub Desktop.
function data_gpt -a prompt data
set prompt_input (echo "$prompt: $data" | string join ' ')
curl https://api.openai.com/v1/chat/completions -s \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "'$prompt_input'"}],
"temperature": 0.7
}' | jq -r '.choices[0].message.content'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment