Skip to content

Commit

Permalink
Update text_generation.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
logankilpatrick authored Sep 16, 2024
1 parent b5d2e56 commit 8648f97
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,23 @@ import com.google.ai.sample.R

suspend fun textGenTextOnlyPrompt() {
// [START text_gen_text_only_prompt]
val generativeModel =
GenerativeModel(
// Specify a Gemini model appropriate for your use case
modelName = "gemini-1.5-flash",
// Access your API key as a Build Configuration variable (see "Set up your API key" above)
apiKey = BuildConfig.apiKey)
import com.google.ai.client.generativeai.GenerativeModel
val geminiApiKey = BuildConfig.geminiApiKey

val prompt = "Write a story about a magic backpack."
val generativeModel = GenerativeModel( modelName = "gemini-1.5-flash", apiKey = BuildConfig.geminiApiKey)

val prompt = "Explain how AI works"
val response = generativeModel.generateContent(prompt)
print(response.text)
// [END text_gen_text_only_prompt]
}

suspend fun textGenTextOnlyPromptStreaming() {
// [START text_gen_text_only_prompt_streaming]
val generativeModel =
GenerativeModel(
// Specify a Gemini model appropriate for your use case
modelName = "gemini-1.5-flash",
// Access your API key as a Build Configuration variable (see "Set up your API key" above)
apiKey = BuildConfig.apiKey)
import com.google.ai.client.generativeai.GenerativeModel
val geminiApiKey = BuildConfig.geminiApiKey

val generativeModel = GenerativeModel(modelName = "gemini-1.5-flash", apiKey = BuildConfig.apiKey)

val prompt = "Write a story about a magic backpack."
// Use streaming with text-only input
Expand Down

0 comments on commit 8648f97

Please sign in to comment.