Skip to content

Commit

Permalink
add safety settings examples for curl (#433)
Browse files Browse the repository at this point in the history
* add safety settings examples for curl

* replace integers with category name
  • Loading branch information
shilpakancharla authored Jul 17, 2024
1 parent 3491bfc commit e8ad653
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions samples/rest/safety_settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
set -eu

echo "[START safety_settings]"
# [START safety_settings]
echo '{
"safetySettings": [
{'category': HARM_CATEGORY_HARASSMENT, 'threshold': BLOCK_ONLY_HIGH}
],
"contents": [{
"parts":[{
"text": "'I support Martians Soccer Club and I think Jupiterians Football Club sucks! Write a ironic phrase about them.'"}]}]}' > request.json

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d @request.json 2> /dev/null > tee response.json

jq .promptFeedback > response.json
# [END safety_settings]

echo "[START safety_settings_multi]"
# [START safety_settings_multi]
echo '{
"safetySettings": [
{'category': HARM_CATEGORY_HARASSMENT, 'threshold': BLOCK_ONLY_HIGH},
{'category': HARM_CATEGORY_HATE_SPEECH, 'threshold': BLOCK_MEDIUM_AND_ABOVE}
],
"contents": [{
"parts":[{
"text": "'I support Martians Soccer Club and I think Jupiterians Football Club sucks! Write a ironic phrase about them.'"}]}]}' > request.json

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d @request.json 2> /dev/null > response.json

jq .promptFeedback > response.json
# [END safety_settings_multi]

0 comments on commit e8ad653

Please sign in to comment.