Skip to content

Commit e8ad653

Browse files
add safety settings examples for curl (#433)
* add safety settings examples for curl * replace integers with category name
1 parent 3491bfc commit e8ad653

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

samples/rest/safety_settings.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
set -eu
2+
3+
echo "[START safety_settings]"
4+
# [START safety_settings]
5+
echo '{
6+
"safetySettings": [
7+
{'category': HARM_CATEGORY_HARASSMENT, 'threshold': BLOCK_ONLY_HIGH}
8+
],
9+
"contents": [{
10+
"parts":[{
11+
"text": "'I support Martians Soccer Club and I think Jupiterians Football Club sucks! Write a ironic phrase about them.'"}]}]}' > request.json
12+
13+
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=$GOOGLE_API_KEY" \
14+
-H 'Content-Type: application/json' \
15+
-X POST \
16+
-d @request.json 2> /dev/null > tee response.json
17+
18+
jq .promptFeedback > response.json
19+
# [END safety_settings]
20+
21+
echo "[START safety_settings_multi]"
22+
# [START safety_settings_multi]
23+
echo '{
24+
"safetySettings": [
25+
{'category': HARM_CATEGORY_HARASSMENT, 'threshold': BLOCK_ONLY_HIGH},
26+
{'category': HARM_CATEGORY_HATE_SPEECH, 'threshold': BLOCK_MEDIUM_AND_ABOVE}
27+
],
28+
"contents": [{
29+
"parts":[{
30+
"text": "'I support Martians Soccer Club and I think Jupiterians Football Club sucks! Write a ironic phrase about them.'"}]}]}' > request.json
31+
32+
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=$GOOGLE_API_KEY" \
33+
-H 'Content-Type: application/json' \
34+
-X POST \
35+
-d @request.json 2> /dev/null > response.json
36+
37+
jq .promptFeedback > response.json
38+
# [END safety_settings_multi]

0 commit comments

Comments
 (0)