-
Notifications
You must be signed in to change notification settings - Fork 17
/
gpt-4-0314.sh
34 lines (23 loc) · 1014 Bytes
/
gpt-4-0314.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Set your OpenAI API key
export OPENAI_API_KEY="Your OPENAI API KEY"
# Set the model to use (e.g. "gpt-4-0314") - this is the most powerful and most expensive model
MODEL="gpt-4-0314"
# Set the prompt to use as input for the language model
PROMPT="$1"
# Set the number of tokens to generate
TOKEN_COUNT=500
# Set the temperature
TEMPERATURE=0.0
# Set the top_p value
TOP_P=1
# Set the frequency
FREQUENCY=0.5
# Set the presence
PRESENCE=0.5
# Generate text using the language model
OUTPUT=$(curl -sk -X POST -H "Authorization: Bearer $OPENAI_API_KEY" -H "Content-Type: application/json" -d "{\"model\":\"$MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"$PROMPT\"}],\"temperature\":$TEMPERATURE,\"top_p\":$TOP_P,\"frequency_penalty\":$FREQUENCY,\"presence_penalty\":$PRESENCE,\"max_tokens\":$TOKEN_COUNT}" https://api.openai.com/v1/chat/completions)
# Extract the text from the response
OUTPUT=$(echo "$OUTPUT" | jq -r '.choices[0].message.content')
# Print the output
echo "$OUTPUT"