Created
March 28, 2023 06:48
-
-
Save benigumocom/4d67aeaaf07b45519b0d812737bbd94a to your computer and use it in GitHub Desktop.
OpenAI Chat Completion
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/sh | |
| while read -r question | |
| do | |
| answer=$( | |
| curl \ | |
| -sH POST "https://api.openai.com/v1/chat/completions" \ | |
| -H "Content-Type: application/json;charset=utf-8" \ | |
| -H "Authorization: Bearer $OPENAI_API_KEY" \ | |
| -d "{ | |
| \"model\": \"gpt-3.5-turbo\", | |
| \"messages\": [ | |
| {\"role\": \"user\", \"content\": \"$question\"} | |
| ] | |
| }" | \ | |
| jq -r '.choices[].message.content' | |
| ) | |
| echo | |
| echo "$answer" | |
| echo | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment