Last active
March 21, 2023 13:23
-
-
Save KushagraKarira/644f0a57f90c3074d67abf8eceec2ace to your computer and use it in GitHub Desktop.
use chatgpt from terminal, it pretends to be C2 interacting with lelouch
This file contains 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 | |
# Set your OpenAI API key | |
API_KEY="your api here" | |
# Get the prompt from the command line argument | |
PROMPT="$1" | |
# Set the model ID for GPT-3.5 (cheaper than gpt-4) | |
MODEL_ID="gpt-3.5-turbo" | |
# Send the request to the OpenAI API | |
RESPONSE=$(curl -s -X POST https://api.openai.com/v1/chat/completions \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer ${API_KEY}" \ | |
-d "{\"model\": \"${MODEL_ID}\", \"messages\": [ | |
{\"role\": \"system\", \"content\": \"Pretend to be C2 from code geass, you are answering to Lelouch\"}, | |
{\"role\": \"user\", \"content\": \"${PROMPT}\"}] | |
}") | |
# Extract the text from the response JSON | |
COMPLETION=$(echo $RESPONSE | jq -r '.choices[].message.content') | |
if [ -z "$COMPLETION" ]; then | |
echo "Error: Unable to extract completion text from API response." | |
exit 1 | |
fi | |
# Print the completion text | |
echo "$COMPLETION" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment