11package com.google.firebase.quickstart.ai
22
3+ import com.google.firebase.ai.type.FunctionDeclaration
34import com.google.firebase.ai.type.GenerativeBackend
45import com.google.firebase.ai.type.ResponseModality
6+ import com.google.firebase.ai.type.Schema
7+ import com.google.firebase.ai.type.Tool
58import com.google.firebase.ai.type.content
69import com.google.firebase.ai.type.generationConfig
710import com.google.firebase.quickstart.ai.ui.navigation.Category
@@ -11,15 +14,15 @@ val FIREBASE_AI_SAMPLES = listOf(
1114 Sample (
1215 title = " Travel tips" ,
1316 description = " The user wants the model to help a new traveler" +
14- " with travel tips" ,
17+ " with travel tips" ,
1518 navRoute = " chat" ,
1619 categories = listOf (Category .TEXT ),
1720 systemInstructions = content {
1821 text(
1922 " You are a Travel assistant. You will answer" +
20- " questions the user asks based on the information listed" +
21- " in Relevant Information. Do not hallucinate. Do not use" +
22- " the internet."
23+ " questions the user asks based on the information listed" +
24+ " in Relevant Information. Do not hallucinate. Do not use" +
25+ " the internet."
2326 )
2427 },
2528 chatHistory = listOf (
@@ -31,7 +34,7 @@ val FIREBASE_AI_SAMPLES = listOf(
3134 role = " model"
3235 text(
3336 " You should book flights a couple of months ahead of time." +
34- " It will be cheaper and more flexible for you."
37+ " It will be cheaper and more flexible for you."
3538 )
3639 },
3740 content {
@@ -42,8 +45,8 @@ val FIREBASE_AI_SAMPLES = listOf(
4245 role = " model"
4346 text(
4447 " If you are traveling outside your own country, make sure" +
45- " your passport is up-to-date and valid for more" +
46- " than 6 months during your travel."
48+ " your passport is up-to-date and valid for more" +
49+ " than 6 months during your travel."
4750 )
4851 }
4952 ),
@@ -57,8 +60,8 @@ val FIREBASE_AI_SAMPLES = listOf(
5760 systemInstructions = content {
5861 text(
5962 " You are a chatbot for the county's performing and fine arts" +
60- " program. You help students decide what course they will" +
61- " take during the summer."
63+ " program. You help students decide what course they will" +
64+ " take during the summer."
6265 )
6366 },
6467 initialPrompt = content {
@@ -75,14 +78,14 @@ val FIREBASE_AI_SAMPLES = listOf(
7578 content(" model" ) {
7679 text(
7780 " Of course! Click on the attach button" +
78- " below and choose an audio file for me to summarize."
81+ " below and choose an audio file for me to summarize."
7982 )
8083 }
8184 ),
8285 initialPrompt = content {
8386 text(
8487 " I have attached the audio file. Please analyze it and summarize the contents" +
85- " of the audio as bullet points."
88+ " of the audio as bullet points."
8689 )
8790 }
8891 ),
@@ -114,8 +117,8 @@ val FIREBASE_AI_SAMPLES = listOf(
114117 )
115118 text(
116119 " Write a short, engaging blog post based on this picture." +
117- " It should include a description of the meal in the" +
118- " photo and talk about my journey meal prepping."
120+ " It should include a description of the meal in the" +
121+ " photo and talk about my journey meal prepping."
119122 )
120123 }
121124 ),
@@ -139,8 +142,8 @@ val FIREBASE_AI_SAMPLES = listOf(
139142 initialPrompt = content {
140143 text(
141144 " Hi, can you create a 3d rendered image of a pig " +
142- " with wings and a top hat flying over a happy " +
143- " futuristic scifi city with lots of greenery?"
145+ " with wings and a top hat flying over a happy " +
146+ " futuristic scifi city with lots of greenery?"
144147 )
145148 },
146149 generationConfig = generationConfig {
@@ -165,7 +168,7 @@ val FIREBASE_AI_SAMPLES = listOf(
165168 )
166169 text(
167170 " The first document is from 2013, and the second document is" +
168- " from 2023. How did the standard deduction evolve?"
171+ " from 2023. How did the standard deduction evolve?"
169172 )
170173 }
171174 ),
@@ -182,9 +185,9 @@ val FIREBASE_AI_SAMPLES = listOf(
182185 )
183186 text(
184187 " Generate 5-10 hashtags that relate to the video content." +
185- " Try to use more popular and engaging terms," +
186- " e.g. #Viral. Do not add content not related to" +
187- " the video.\n Start the output with 'Tags:'"
188+ " Try to use more popular and engaging terms," +
189+ " e.g. #Viral. Do not add content not related to" +
190+ " the video.\n Start the output with 'Tags:'"
188191 )
189192 }
190193 ),
@@ -198,16 +201,44 @@ val FIREBASE_AI_SAMPLES = listOf(
198201 content(" model" ) {
199202 text(
200203 " Sure! Click on the attach button below and choose a" +
201- " video file for me to describe."
204+ " video file for me to describe."
202205 )
203206 }
204207 ),
205208 initialPrompt = content {
206209 text(
207210 " I have attached the video file. Provide a description of" +
208- " the video. The description should also contain" +
209- " anything important which people say in the video."
211+ " the video. The description should also contain" +
212+ " anything important which people say in the video."
210213 )
211214 }
212- )
215+ ),
216+ Sample (
217+ title = " Weather Chat" ,
218+ description = " Use function calling to get the weather conditions" +
219+ " for a specific US city on a specific date." ,
220+ navRoute = " chat" ,
221+ categories = listOf (Category .TEXT , Category .FUNCTION_CALLING ),
222+ tools = listOf (
223+ Tool .functionDeclarations(
224+ listOf (
225+ FunctionDeclaration (
226+ " fetchWeather" ,
227+ " Get the weather conditions for a specific US city on a specific date." ,
228+ mapOf (
229+ " city" to Schema .string(" The US city of the location." ),
230+ " state" to Schema .string(" The US state of the location." ),
231+ " date" to Schema .string(
232+ " The date for which to get the weather." +
233+ " Date must be in the format: YYYY-MM-DD."
234+ ),
235+ ),
236+ )
237+ )
238+ )
239+ ),
240+ initialPrompt = content {
241+ text(" What was the weather in Boston, MA on October 17, 2024?" )
242+ }
243+ ),
213244)
0 commit comments