Skip to content

Commit 9dd6b15

Browse files
committed
update snippets for SafetySettings and blob
1 parent 41a23cb commit 9dd6b15

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

vertexai/app/src/main/java/com/google/firebase/example/vertexai/java/ConfigurationViewModel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.google.firebase.vertexai.FirebaseVertexAI;
66
import com.google.firebase.vertexai.GenerativeModel;
77
import com.google.firebase.vertexai.java.GenerativeModelFutures;
8-
import com.google.firebase.vertexai.type.BlockThreshold;
8+
import com.google.firebase.vertexai.type.HarmBlockThreshold;
99
import com.google.firebase.vertexai.type.GenerationConfig;
1010
import com.google.firebase.vertexai.type.HarmCategory;
1111
import com.google.firebase.vertexai.type.RequestOptions;
@@ -39,7 +39,7 @@ void configModelParams() {
3939

4040
void configSafetySettings() {
4141
SafetySetting harassmentSafety1 = new SafetySetting(HarmCategory.HARASSMENT,
42-
BlockThreshold.ONLY_HIGH);
42+
HarmBlockThreshold.ONLY_HIGH, null);
4343

4444
GenerativeModel gm1 = FirebaseVertexAI.Companion.getInstance().generativeModel(
4545
"MODEL_NAME",
@@ -51,10 +51,10 @@ void configSafetySettings() {
5151

5252
// [START vertexai_safety_settings]
5353
SafetySetting harassmentSafety = new SafetySetting(HarmCategory.HARASSMENT,
54-
BlockThreshold.ONLY_HIGH);
54+
HarmBlockThreshold.ONLY_HIGH, null);
5555

5656
SafetySetting hateSpeechSafety = new SafetySetting(HarmCategory.HATE_SPEECH,
57-
BlockThreshold.MEDIUM_AND_ABOVE);
57+
HarmBlockThreshold.MEDIUM_AND_ABOVE, null);
5858

5959
GenerativeModel gm = FirebaseVertexAI.Companion.getInstance().generativeModel(
6060
"MODEL_NAME",

vertexai/app/src/main/java/com/google/firebase/example/vertexai/java/GenerateContentViewModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void generateContentWithVideo(Executor executor, Uri videoUri) {
258258
stream.close();
259259

260260
Content prompt = new Content.Builder()
261-
.addBlob("video/mp4", videoBytes)
261+
.addInlineData(videoBytes, "video/mp4")
262262
.addText("What is in the video?")
263263
.build();
264264

@@ -298,7 +298,7 @@ void generateContentWithVideoStream(
298298
stream.close();
299299

300300
Content prompt = new Content.Builder()
301-
.addBlob("video/mp4", videoBytes)
301+
.addInlineData(videoBytes, "video/mp4")
302302
.addText("What is in the video?")
303303
.build();
304304

vertexai/app/src/main/java/com/google/firebase/example/vertexai/kotlin/ConfigurationViewModel.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.google.firebase.example.vertexai.kotlin
22

33
import androidx.lifecycle.ViewModel
44
import com.google.firebase.Firebase
5-
import com.google.firebase.vertexai.type.BlockThreshold
5+
import com.google.firebase.vertexai.type.HarmBlockThreshold
66
import com.google.firebase.vertexai.type.HarmCategory
77
import com.google.firebase.vertexai.type.SafetySetting
88
import com.google.firebase.vertexai.type.generationConfig
@@ -30,13 +30,13 @@ class ConfigurationViewModel : ViewModel() {
3030
val generativeModel1 = Firebase.vertexAI.generativeModel(
3131
modelName = "MODEL_NAME",
3232
safetySettings = listOf(
33-
SafetySetting(HarmCategory.HARASSMENT, BlockThreshold.ONLY_HIGH)
33+
SafetySetting(HarmCategory.HARASSMENT, HarmBlockThreshold.ONLY_HIGH)
3434
)
3535
)
3636

3737
// [START vertexai_safety_settings]
38-
val harassmentSafety = SafetySetting(HarmCategory.HARASSMENT, BlockThreshold.ONLY_HIGH)
39-
val hateSpeechSafety = SafetySetting(HarmCategory.HATE_SPEECH, BlockThreshold.MEDIUM_AND_ABOVE)
38+
val harassmentSafety = SafetySetting(HarmCategory.HARASSMENT, HarmBlockThreshold.ONLY_HIGH)
39+
val hateSpeechSafety = SafetySetting(HarmCategory.HATE_SPEECH, HarmBlockThreshold.MEDIUM_AND_ABOVE)
4040

4141
val generativeModel = Firebase.vertexAI.generativeModel(
4242
modelName = "MODEL_NAME",

vertexai/app/src/main/java/com/google/firebase/example/vertexai/kotlin/GenerateContentViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class GenerateContentViewModel : ViewModel() {
154154
val bytes = stream.readBytes()
155155

156156
val prompt = content {
157-
blob("video/mp4", bytes)
157+
inlineData(bytes, "video/mp4")
158158
text("What is in the video?")
159159
}
160160

@@ -181,7 +181,7 @@ class GenerateContentViewModel : ViewModel() {
181181
val bytes = stream.readBytes()
182182

183183
val prompt = content {
184-
blob("video/mp4", bytes)
184+
inlineData(bytes, "video/mp4")
185185
text("What is in the video?")
186186
}
187187

0 commit comments

Comments
 (0)