File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
misc/src/main/java/com/example/snippets/ai Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 1717package com.example.snippets.ai
1818
1919import com.google.firebase.Firebase
20+ import com.google.firebase.ai.GenerativeModel
2021import com.google.firebase.ai.ai
2122import com.google.firebase.ai.type.GenerativeBackend
22- import kotlinx.coroutines.CoroutineScope
23- import kotlinx.coroutines.launch
2423
2524class VertexAiGeminiApi {
2625
@@ -29,13 +28,12 @@ class VertexAiGeminiApi {
2928 .generativeModel(" gemini-2.5-flash" )
3029 // [END android_snippets_vertex_ai_gemini_api_model]
3130
32- fun generateText ( scope : CoroutineScope ) {
33- // [START android_snippets_vertex_ai_generate_content]
31+ // [START android_snippets_vertex_ai_generate_content]
32+ suspend fun generateText ( model : GenerativeModel ) {
3433 // Note: generateContent() is a suspend function, which integrates well
3534 // with existing Kotlin code.
36- scope.launch {
37- val response = model.generateContent(" Write a story about a magic backpack." )
38- }
39- // [END android_snippets_vertex_ai_generate_content]
35+ val response = model.generateContent(" Write a story about a magic backpack." )
36+ // ...
4037 }
38+ // [END android_snippets_vertex_ai_generate_content]
4139}
You can’t perform that action at this time.
0 commit comments