-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add safety settings examples for curl (#433)
* add safety settings examples for curl * replace integers with category name
- Loading branch information
1 parent
3491bfc
commit e8ad653
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
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] |