j1-template 2024.1.5 → 2024.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/themes/j1/layouts/content_generator_page.html +0 -34
  3. data/_includes/themes/j1/modules/searcher/generator.html +4 -1
  4. data/_includes/themes/j1/modules/searcher/procedures/topsearch.proc +59 -56
  5. data/assets/data/authclient.html +1 -8
  6. data/assets/data/banner.html +1 -7
  7. data/assets/data/fab.html +2 -13
  8. data/assets/data/footer.html +0 -3
  9. data/assets/data/galeries.html +2 -13
  10. data/assets/data/gemini-ui.html +74 -21
  11. data/assets/data/iframes.html +1 -4
  12. data/assets/data/masonry.html +1 -13
  13. data/assets/data/masterslider.html +10 -21
  14. data/assets/data/menu.html +6 -14
  15. data/assets/data/mmenu.html +6 -5
  16. data/assets/data/mmenu_toc.html +2 -1
  17. data/assets/data/panel.html +4 -11
  18. data/assets/data/particles.yml +8 -8
  19. data/assets/data/quicklinks.html +4 -23
  20. data/assets/data/rtext_resizer.html +3 -1
  21. data/assets/data/slick.html +9 -11
  22. data/assets/data/translator.html +0 -1
  23. data/assets/themes/j1/adapter/js/advertising.js +141 -172
  24. data/assets/themes/j1/adapter/js/algolia.js +61 -54
  25. data/assets/themes/j1/adapter/js/analytics.js +67 -47
  26. data/assets/themes/j1/adapter/js/asciidoctor.js +32 -20
  27. data/assets/themes/j1/adapter/js/attic.js +75 -69
  28. data/assets/themes/j1/adapter/js/bmd.js +195 -177
  29. data/assets/themes/j1/adapter/js/carousel.js +786 -761
  30. data/assets/themes/j1/adapter/js/chatbot.js +77 -35
  31. data/assets/themes/j1/adapter/js/clipboard.js +66 -49
  32. data/assets/themes/j1/adapter/js/comments.js +92 -70
  33. data/assets/themes/j1/adapter/js/cookieConsent.js +466 -462
  34. data/assets/themes/j1/adapter/js/customFunctions.js +52 -35
  35. data/assets/themes/j1/adapter/js/customModule.js +56 -46
  36. data/assets/themes/j1/adapter/js/docsearch.js +54 -34
  37. data/assets/themes/j1/adapter/js/dropdowns.js +65 -52
  38. data/assets/themes/j1/adapter/js/fab.js +123 -109
  39. data/assets/themes/j1/adapter/js/gallery.js +494 -476
  40. data/assets/themes/j1/adapter/js/gemini.js +933 -299
  41. data/assets/themes/j1/adapter/js/iconPicker.js +255 -235
  42. data/assets/themes/j1/adapter/js/iconPickerPage.js +279 -0
  43. data/assets/themes/j1/adapter/js/iframer.js +81 -61
  44. data/assets/themes/j1/adapter/js/j1.js +3285 -3222
  45. data/assets/themes/j1/adapter/js/lazyLoader.js +241 -222
  46. data/assets/themes/j1/adapter/js/lightbox.js +241 -241
  47. data/assets/themes/j1/adapter/js/logger.js +77 -66
  48. data/assets/themes/j1/adapter/js/lunr.js +688 -86
  49. data/assets/themes/j1/adapter/js/masonry.js +426 -411
  50. data/assets/themes/j1/adapter/js/masterslider.js +526 -527
  51. data/assets/themes/j1/adapter/js/mmenu.js +101 -66
  52. data/assets/themes/j1/adapter/js/navigator.js +291 -356
  53. data/assets/themes/j1/adapter/js/particles.js +61 -40
  54. data/assets/themes/j1/adapter/js/rangeSlider.js +65 -48
  55. data/assets/themes/j1/adapter/js/rouge.js +287 -269
  56. data/assets/themes/j1/adapter/js/rtable.js +309 -293
  57. data/assets/themes/j1/adapter/js/rtextResizer.js +57 -44
  58. data/assets/themes/j1/adapter/js/scroller.js +170 -133
  59. data/assets/themes/j1/adapter/js/slick.js +487 -485
  60. data/assets/themes/j1/adapter/js/slimSelect.js +290 -0
  61. data/assets/themes/j1/adapter/js/speak2me.js +124 -128
  62. data/assets/themes/j1/adapter/js/themeToggler.js +280 -260
  63. data/assets/themes/j1/adapter/js/{themer.js → themes.js} +145 -113
  64. data/assets/themes/j1/adapter/js/toccer.js +87 -54
  65. data/assets/themes/j1/adapter/js/translator.js +73 -70
  66. data/assets/themes/j1/adapter/js/waves.js +74 -58
  67. data/assets/themes/j1/core/css/themes/unolight/bootstrap.css +29 -11
  68. data/assets/themes/j1/core/css/themes/unolight/bootstrap.min.css +2 -2
  69. data/assets/themes/j1/core/js/template.js +474 -420
  70. data/assets/themes/j1/core/js/template.min.js +7 -7
  71. data/assets/themes/j1/core/js/template.min.js.map +1 -1
  72. data/assets/themes/j1/modules/carousel/css/theme/uno.css +4 -4
  73. data/assets/themes/j1/modules/carousel/css/theme/uno.min.css +1 -1
  74. data/assets/themes/j1/modules/clipboard/js/clipboard.js +0 -1
  75. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +4 -4
  76. data/assets/themes/j1/modules/iconPicker/css/theme/uno.css +58 -0
  77. data/assets/themes/j1/modules/iconPicker/css/theme/uno.min.css +16 -0
  78. data/assets/themes/j1/modules/iconPicker/js/universal-icon-picker.0.js +493 -0
  79. data/assets/themes/j1/modules/iconPicker/js/universal-icon-picker.js +7 -7
  80. data/assets/themes/j1/modules/lightGallery/js/plugins/lg-video.js +4 -4
  81. data/assets/themes/j1/modules/lightGallery/js/plugins/lg-video.min.js +2 -10
  82. data/assets/themes/j1/modules/lunr/css/j1.css +12 -6
  83. data/assets/themes/j1/modules/lunr/css/j1.min.css +1 -1
  84. data/assets/themes/j1/modules/lunr/js/j1.js +46 -43
  85. data/assets/themes/j1/modules/lunr/js/j1.min.js +1 -1
  86. data/assets/themes/j1/modules/masterslider/js/masterslider.js +1 -1
  87. data/assets/themes/j1/modules/scroller/js/scroller.js +64 -74
  88. data/assets/themes/j1/modules/scroller/js/scroller.min.js +1 -1
  89. data/assets/themes/j1/modules/slick/slider/css/theme/uno.css +4 -4
  90. data/assets/themes/j1/modules/slick/slider/css/theme/uno.min.css +1 -1
  91. data/assets/themes/j1/modules/slimSelect/js/select.js +1865 -1821
  92. data/assets/themes/j1/modules/slimSelect/js/select.min.js +2 -1
  93. data/assets/themes/j1/modules/themeSwitcher/js/switcher.js +87 -89
  94. data/assets/themes/j1/modules/themeSwitcher/js/switcher.min.js +1 -1
  95. data/assets/themes/j1/modules/videojs/js/plugins/vm/api/player.min.js +5 -7
  96. data/assets/themes/j1/modules/videojs/js/plugins/vm/api/v2.20.1/player.min.js +23 -0
  97. data/lib/j1/version.rb +1 -1
  98. data/lib/starter_web/Gemfile +2 -2
  99. data/lib/starter_web/README.md +5 -5
  100. data/lib/starter_web/_config.yml +1 -1
  101. data/lib/starter_web/_data/blocks/_panel.yml +775 -0
  102. data/lib/starter_web/_data/blocks/panel.yml +53 -53
  103. data/lib/starter_web/_data/j1_config.yml +3 -2
  104. data/lib/starter_web/_data/layouts/default.yml +0 -2
  105. data/lib/starter_web/_data/modules/_scroller.yml +102 -0
  106. data/lib/starter_web/_data/modules/carousel.yml +3 -3
  107. data/lib/starter_web/_data/modules/defaults/attics.yml +5 -5
  108. data/lib/starter_web/_data/modules/defaults/docsearch.yml +1 -1
  109. data/lib/starter_web/_data/modules/defaults/gemini.yml +204 -46
  110. data/lib/starter_web/_data/modules/defaults/{iconPicker.yml → icon_picker.yml} +6 -12
  111. data/lib/starter_web/_data/modules/defaults/lunr.yml +20 -5
  112. data/lib/starter_web/_data/modules/defaults/masterslider.yml +4 -4
  113. data/lib/starter_web/_data/modules/defaults/navigator.yml +20 -24
  114. data/lib/starter_web/_data/modules/defaults/particles.yml +3 -3
  115. data/lib/starter_web/_data/modules/defaults/slim_select.yml +54 -0
  116. data/lib/starter_web/_data/modules/defaults/{themer.yml → themes.yml} +171 -171
  117. data/lib/starter_web/_data/modules/defaults/toccer.yml +1 -1
  118. data/lib/starter_web/_data/modules/gallery.yml +33 -38
  119. data/lib/starter_web/_data/modules/gemini.yml +42 -3
  120. data/lib/starter_web/_data/modules/{iconPicker.yml → icon_picker.yml} +31 -3
  121. data/lib/starter_web/_data/modules/lunr.yml +12 -1
  122. data/lib/starter_web/_data/modules/masonry.yml +37 -38
  123. data/lib/starter_web/_data/modules/masterslider.yml +78 -95
  124. data/lib/starter_web/_data/modules/navigator_menu.yml +12 -20
  125. data/lib/starter_web/_data/modules/particles.yml +3 -3
  126. data/lib/starter_web/_data/modules/scroller.yml +3 -3
  127. data/lib/starter_web/_data/modules/slim_select.yml +110 -0
  128. data/lib/starter_web/_data/modules/{themer.yml → themes.yml} +4 -4
  129. data/lib/starter_web/_data/resources.yml +57 -47
  130. data/lib/starter_web/_data/templates/feed.xml +1 -1
  131. data/lib/starter_web/_includes/attributes.asciidoc +354 -355
  132. data/lib/starter_web/_plugins/asciidoctor/gemini-ui-block.rb +1 -1
  133. data/lib/starter_web/_plugins/asciidoctor/slim-select-block.rb +45 -0
  134. data/lib/starter_web/_plugins/index/lunr.rb +1 -1
  135. data/lib/starter_web/collections/asciidoc_skeletons/simple-post/_posts/yyyy-mm-dd-your-post-name.asciidoc +5 -2
  136. data/lib/starter_web/collections/posts/public/featured/_posts/0000-00-00-welcome-to-j1.adoc.erb +3 -3
  137. data/lib/starter_web/collections/posts/public/featured/_posts/2021-01-01-about-cookies.adoc +9 -9
  138. data/lib/starter_web/collections/posts/public/featured/_posts/2021-02-01-static-site-generators.adoc +4 -4
  139. data/lib/starter_web/collections/posts/public/featured/_posts/2022-02-01-about-j1.adoc +3 -2
  140. data/lib/starter_web/collections/posts/public/featured/_posts/2023-10-18-url-types.adoc +12 -12
  141. data/lib/starter_web/package.json +1 -1
  142. data/lib/starter_web/pages/public/about/features.adoc +1 -1
  143. data/lib/starter_web/pages/public/about/reporting_issues.adoc +1 -0
  144. data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/_includes/attributes.asciidoc +44 -44
  145. data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/documentation.adoc +1 -0
  146. data/lib/starter_web/pages/public/asciidoc_skeletons/multi-document/_includes/attributes.asciidoc +12 -12
  147. data/lib/starter_web/pages/public/blog/navigator/archive/allview.html +1 -1
  148. data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/attributes.asciidoc +42 -28
  149. data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/highlghter_rouge.adoc +1 -0
  150. data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/lunr_search.adoc +1 -0
  151. data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/present_audio_video.adoc +18 -2
  152. data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/present_images.adoc +500 -507
  153. data/lib/starter_web/pages/public/legal/en/100_copyright.adoc +6 -11
  154. data/lib/starter_web/pages/public/legal/en/200_impress.adoc +4 -11
  155. data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +5 -12
  156. data/lib/starter_web/pages/public/legal/en/400_comment_policy.adoc +5 -10
  157. data/lib/starter_web/pages/public/tools/previewer/_includes/attributes.asciidoc +10 -9
  158. data/lib/starter_web/pages/public/tools/previewer/preview_bootstrap_theme.adoc +77 -75
  159. metadata +50 -46
  160. data/lib/starter_web/pages/public/manuals/integrations/gemini/_includes/attributes.asciidoc +0 -47
  161. data/lib/starter_web/pages/public/manuals/integrations/gemini/_includes/documents/preview_google_adsense.asciidoc +0 -448
  162. data/lib/starter_web/pages/public/manuals/integrations/gemini/_includes/documents/readme +0 -0
  163. data/lib/starter_web/pages/public/manuals/integrations/gemini/_includes/tables/readme +0 -0
  164. data/lib/starter_web/pages/public/manuals/integrations/gemini/gemini.adoc +0 -525
  165. data/lib/starter_web/pages/public/manuals/integrations/gemini/security.asccidoc +0 -274
  166. data/lib/starter_web/pages/public/manuals/integrations/gemini/security.hrml +0 -560
  167. /data/lib/starter_web/pages/public/{legal/learn → learn}/bookshelf/article_previewer/viewer_biography.adoc +0 -0
  168. /data/lib/starter_web/pages/public/{legal/learn → learn}/bookshelf/article_previewer/viewer_fantasy.adoc +0 -0
  169. /data/lib/starter_web/pages/public/{legal/learn → learn}/bookshelf/article_previewer/viewer_romance.adoc +0 -0
  170. /data/lib/starter_web/pages/public/{legal/learn → learn}/bookshelf/jekyll_collections.adoc +0 -0
  171. /data/lib/starter_web/pages/public/{legal/learn → learn}/bookshelf/viewer_all_books.adoc +0 -0
  172. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/100_gistblock.asciidoc +0 -0
  173. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_bottom_info.asciidoc +0 -0
  174. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_bottom_left_warning.asciidoc +0 -0
  175. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_bottom_right_danger.asciidoc +0 -0
  176. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_central_success.asciidoc +0 -0
  177. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_full_height_left_info.asciidoc +0 -0
  178. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_full_height_right_success.asciidoc +0 -0
  179. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_table_bs_modal_examples.asciidoc +0 -0
  180. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_top_info.asciidoc +0 -0
  181. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_top_left_info.asciidoc +0 -0
  182. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/410_top_right_success.asciidoc +0 -0
  183. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/419_advanced_modals_demo.asciidoc +0 -0
  184. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/tables/bs_modal_examples.asciidoc +0 -0
  185. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/themes_bootstrap.asciidoc +0 -0
  186. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/_includes/documents/themes_rouge.asciidoc +0 -0
  187. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/asciidoc_extensions.adoc +0 -0
  188. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/bootstrap_themes.adoc +0 -0
  189. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/icon_fonts.adoc +0 -0
  190. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/modal_extentions.adoc +0 -0
  191. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/responsive_tables.adoc +0 -0
  192. /data/lib/starter_web/pages/public/{legal/learn → learn}/roundtrip/typography.adoc +0 -0
  193. /data/lib/starter_web/pages/public/{legal/learn → learn}/where_to_go.adoc +0 -0
@@ -1,274 +0,0 @@
1
- == Safety settings
2
-
3
- This guide describes the adjustable safety settings available for the
4
- Gemini API. During the prototyping stage, you can adjust safety settings
5
- on 4 dimensions to quickly assess if your application requires more or
6
- less restrictive configuration. By default, safety settings block
7
- content (including prompts) with medium or higher probability of being
8
- unsafe across any dimension. This baseline safety is designed to work
9
- for most use cases, so you should only adjust your safety settings if
10
- it's consistently required for your application.
11
-
12
- **Note:** Adjusting to lower safety settings will trigger a more indepth
13
- review process of your application.
14
-
15
- === Safety filters
16
-
17
- In addition to the adjustable safety filters, the Gemini API has
18
- built-in protections against core harms, such as content that endangers
19
- child safety. These types of harm are always blocked and cannot be
20
- adjusted.
21
-
22
- The adjustable safety filters cover the following categories:
23
-
24
- * Harassment
25
- * Hate speech
26
- * Sexually explicit
27
- * Dangerous
28
-
29
- These settings allow you, the developer, to determine what is
30
- appropriate for your use case. For example, if you're building a video
31
- game dialogue, you may deem it acceptable to allow more content that's
32
- rated as dangerous due to the nature of the game. Here are a few other
33
- example use cases that may need some flexibility in these safety
34
- settings:
35
-
36
- [cols=",",options="header",]
37
- |===
38
- |Use Case |Category
39
- |Anti-Harassment Training App |Hate speech, Sexually explicit
40
- |Screenplay Writer |Sexually explicit, Dangerous
41
- |Toxicity classifier |Harassment, Dangerous
42
- |===
43
-
44
- [[probability-vs]]
45
- ==== Probability versus severity
46
-
47
- The Gemini API blocks content based on the *probability* of content
48
- being unsafe and *not* the severity. This is important to consider
49
- because some content can have low probability of being unsafe even
50
- though the severity of harm could still be high. For example, comparing
51
- the sentences:
52
-
53
- . The robot punched me.
54
- . The robot slashed me up.
55
-
56
- Sentence 1 might result in a higher probability of being unsafe but you
57
- might consider sentence 2 to be a higher severity in terms of violence.
58
-
59
- Given this, it is important for each developer to carefully test and
60
- consider what the appropriate level of blocking is needed to support
61
- their key use cases while minimizing harm to end users.
62
-
63
- [[safety-settings]]
64
- ==== Safety Settings
65
-
66
- Safety settings are part of the request you send to the text service. It
67
- can be adjusted for each request you make to the API. The following
68
- table lists the categories that you can set and describes the type of
69
- harm that each category encompasses.
70
-
71
- [cols=",",options="header",]
72
- |===
73
- |Categories |Descriptions
74
- |Harassment |Negative or harmful comments targeting identity and/or
75
- protected attributes.
76
-
77
- |Hate speech |Content that is rude, disrespectful, or profane.
78
-
79
- |Sexually explicit |Contains references to sexual acts or other lewd
80
- content.
81
-
82
- |Dangerous |Promotes, facilitates, or encourages harmful acts.
83
- |===
84
-
85
- These definitions are in the
86
- https://ai.google.dev/api/rest/v1/HarmCategory[API reference] as well.
87
- The Gemini models only support `HARM_CATEGORY_HARASSMENT`,
88
- `HARM_CATEGORY_HATE_SPEECH`, `HARM_CATEGORY_SEXUALLY_EXPLICIT`, and
89
- `HARM_CATEGORY_DANGEROUS_CONTENT`. The other categories are used by PaLM
90
- 2 (Legacy) models.
91
-
92
- The following table describes the block settings you can adjust for each
93
- category. For example, if you set the block setting to *Block few* for
94
- the *Hate speech* category, everything that has a high probability of
95
- being hate speech content is blocked. But anything with a lower
96
- probability is allowed.
97
-
98
- If not set, the default block setting is *Block some* for all
99
- categories.
100
-
101
- [cols=",,",options="header",]
102
- |===
103
- |Threshold (Google AI Studio) |Threshold (API) |Description
104
- |Block none |BLOCK_NONE |Always show regardless of probability of unsafe
105
- content
106
-
107
- |Block few |BLOCK_ONLY_HIGH |Block when high probability of unsafe
108
- content
109
-
110
- |Block some |BLOCK_MEDIUM_AND_ABOVE |Block when medium or high
111
- probability of unsafe content
112
-
113
- |Block most |BLOCK_LOW_AND_ABOVE |Block when low, medium or high
114
- probability of unsafe content
115
-
116
- | |HARM_BLOCK_THRESHOLD_UNSPECIFIED |Threshold is unspecified, block
117
- using default threshold
118
- |===
119
-
120
- You can set these settings for each request you make to the text
121
- service. See the
122
- https://ai.google.dev/api/rest/v1/SafetySetting#harmblockthreshold[`HarmBlockThreshold`]
123
- API reference for details.
124
-
125
- ==== Safety feedback
126
-
127
- https://ai.google.dev/api/rest/v1/models/generateContent[`generateContent`]
128
- returns a
129
- https://ai.google.dev/api/rest/v1/GenerateContentResponse[`GenerateContentResponse`]
130
- which includes safety feedback.
131
-
132
- Prompt feedback is included in
133
- https://ai.google.dev/api/rest/v1/GenerateContentResponse#PromptFeedback[`promptFeedback`].
134
- If
135
- https://ai.google.dev/api/rest/v1/GenerateContentResponse#blockreason[`promptFeedback.blockReason`]
136
- is set, then the content of the prompt was blocked.
137
-
138
- Response candidate feedback is included in
139
- https://ai.google.dev/api/rest/v1/GenerateContentResponse#FinishReason[`finishReason`]
140
- and
141
- https://ai.google.dev/api/rest/v1/GenerateContentResponse#safetyrating[`safetyRatings`].
142
- If response content was blocked and the `finishReason` was `SAFETY`, you
143
- can inspect `safetyRatings` for more details. The safety rating includes
144
- the category and the probability of the harm classification. The content
145
- that was blocked is not returned.
146
-
147
- The probability returned correspond to the block confidence levels as
148
- shown in the following table:
149
-
150
- [cols=",",options="header",]
151
- |===
152
- |Probability |Description
153
- |NEGLIGIBLE |Content has a negligible probability of being unsafe
154
- |LOW |Content has a low probability of being unsafe
155
- |MEDIUM |Content has a medium probability of being unsafe
156
- |HIGH |Content has a high probability of being unsafe
157
- |===
158
-
159
- For example, if the content was blocked due to the harassment category
160
- having a high probability, the safety rating returned would have
161
- category equal to `HARASSMENT` and harm probability set to `HIGH`.
162
-
163
- [[safety-settings-ai-studio]]
164
- === Safety settings in Google AI Studio
165
-
166
- You can also adjust safety settings in Google AI Studio, but you cannot
167
- turn them off. To do so, in the *Run settings*, click *Edit safety
168
- settings*:
169
-
170
- image:/static/docs/images/safety_settings_button.png[Safety settings
171
- button,scaledwidth=50.0%]
172
-
173
- And use the knobs to adjust each setting:
174
-
175
- image:/static/docs/images/safety_settings_ui.png[Safety settings
176
- button,scaledwidth=50.0%]
177
-
178
- A [.material-icons]#warning# *No Content* message appears if the content
179
- is blocked. To see more details, hold the pointer over *No Content* and
180
- click [.material-icons]#warning# *Safety*.
181
-
182
- === Code examples
183
-
184
- This section shows how to use the safety settings in code using the
185
- python client library.
186
-
187
- ==== Request example
188
-
189
- The following is a python code snippet showing how to set safety
190
- settings in your `GenerateContent` call. This sets the harm categories
191
- `Harassment` and `Hate speech` to `BLOCK_LOW_AND_ABOVE` which blocks any
192
- content that has a low or higher probability of being harassment or hate
193
- speech.
194
-
195
- [source, python]
196
- ----
197
- from google.generativeai.types import HarmCategory, HarmBlockThreshold
198
-
199
- model = genai.GenerativeModel(model_name='gemini-pro-vision')
200
- response = model.generate_content(
201
-     ['Do these look store-bought or homemade?', img],
202
-     safety_settings={
203
-         HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
204
-         HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
205
-     }
206
- )
207
- ----
208
-
209
- ==== Response example
210
-
211
- The following shows a code snippet for parsing the safety feedback from
212
- the response.
213
-
214
- [source, python]
215
- ----
216
- try:
217
-   print(response.text)
218
- except ValueError:
219
-   # If the response doesn't contain text, check if the prompt was blocked.
220
-   print(response.prompt_feedback)
221
-   # Also check the finish reason to see if the response was blocked.
222
-   print(response.candidates[0].finish_reason)
223
-   # If the finish reason was SAFETY, the safety ratings have more details.
224
-   print(response.candidates[0].safety_ratings)
225
- ----
226
-
227
- === Next steps
228
-
229
- * See the https://ai.google.dev/api/[API reference] to learn more about
230
- the full API.
231
- * Review the link:/docs/safety_guidance[safety guidance] for a general
232
- look at safety considerations when developing with LLMs.
233
- * Learn more about assessing probability versus severity from the
234
- https://developers.perspectiveapi.com/s/about-the-api-score[Jigsaw team]
235
- * Learn more about the products that contribute to safety solutions like
236
- the
237
- https://medium.com/jigsaw/reducing-toxicity-in-large-language-models-with-perspective-api-c31c39b7a4d7[Perspective
238
- API].
239
- * You can use these safety settings to create a toxicity classifier. See
240
- the
241
- https://ai.google.dev/examples/train_text_classifier_embeddings[classification
242
- example] to get started.
243
-
244
- [[devsite-thumb-label-footer]]
245
- Was this helpful?
246
-
247
- image:data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iZGV2c2l0ZS10aHVtYi1pY29uIiB2aWV3Ym94PSIwIDAgMjQgMjQiIGFyaWEtaGlkZGVuPSJ0cnVlIj4KICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0yMSw3aC02LjMxbDAuOTUtNC41N2wwLjAzLTAuMzJjMC0wLjQxLTAuMTctMC43OS0wLjQ0LTEuMDZMMTQuMTcsMGMwLDAtNy4wOSw2Ljg1LTcuMTcsN0gydjEzaDE2IGMwLjgzLDAsMS41NC0wLjUsMS44NC0xLjIybDMuMDItNy4wNUMyMi45NSwxMS41LDIzLDExLjI2LDIzLDExVjlDMjMsNy45LDIyLjEsNywyMSw3eiBNNywxOEg0VjloM1YxOHogTTIxLDExbC0zLDdIOVY4bDQuMzQtNC4zNCBMMTIsOWg5VjExeiI+PC9wYXRoPgogICAgICAgICAgICAgIDwvc3ZnPg==[image]
248
-
249
- image:data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iZGV2c2l0ZS10aHVtYi1pY29uIiB2aWV3Ym94PSIwIDAgMjQgMjQiIGFyaWEtaGlkZGVuPSJ0cnVlIj4KICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0zLDE3aDYuMzFsLTAuOTUsNC41N2wtMC4wMywwLjMyYzAsMC40MSwwLjE3LDAuNzksMC40NCwxLjA2TDkuODMsMjRjMCwwLDcuMDktNi44NSw3LjE3LTdoNVY0SDYgQzUuMTcsNCw0LjQ2LDQuNSw0LjE2LDUuMjJsLTMuMDIsNy4wNUMxLjA1LDEyLjUsMSwxMi43NCwxLDEzdjJDMSwxNi4xLDEuOSwxNywzLDE3eiBNMTcsNmgzdjloLTNWNnogTTMsMTNsMy03aDl2MTBsLTQuMzQsNC4zNCBMMTIsMTVIM1YxM3oiPjwvcGF0aD4KICAgICAgICAgICAgICA8L3N2Zz4=[image]
250
-
251
- Send feedback
252
-
253
- Except as otherwise noted, the content of this page is licensed under
254
- the https://creativecommons.org/licenses/by/4.0/[Creative Commons
255
- Attribution 4.0 License], and code samples are licensed under the
256
- https://www.apache.org/licenses/LICENSE-2.0[Apache 2.0 License]. For
257
- details, see the https://developers.google.com/site-policies[Google
258
- Developers Site Policies]. Java is a registered trademark of Oracle
259
- and/or its affiliates.
260
-
261
- Last updated 2024-02-08 UTC.
262
-
263
- [\{ "type": "thumb-down", "id": "missingTheInformationINeed",
264
- "label":"Missing the information I need" },\{ "type": "thumb-down",
265
- "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many
266
- steps" },\{ "type": "thumb-down", "id": "outOfDate", "label":"Out of
267
- date" },\{ "type": "thumb-down", "id": "samplesCodeIssue",
268
- "label":"Samples / code issue" },\{ "type": "thumb-down", "id":
269
- "otherDown", "label":"Other" }] [\{ "type": "thumb-up", "id":
270
- "easyToUnderstand", "label":"Easy to understand" },\{ "type":
271
- "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },\{
272
- "type": "thumb-up", "id": "otherUp", "label":"Other" }]
273
-
274
- Need to tell us more?