1
1
package com.google.firebase.quickstart.ai
2
2
3
+ import com.google.firebase.ai.type.FunctionDeclaration
3
4
import com.google.firebase.ai.type.GenerativeBackend
4
5
import com.google.firebase.ai.type.ResponseModality
6
+ import com.google.firebase.ai.type.Schema
7
+ import com.google.firebase.ai.type.Tool
5
8
import com.google.firebase.ai.type.content
6
9
import com.google.firebase.ai.type.generationConfig
7
10
import com.google.firebase.quickstart.ai.ui.navigation.Category
@@ -11,15 +14,15 @@ val FIREBASE_AI_SAMPLES = listOf(
11
14
Sample (
12
15
title = " Travel tips" ,
13
16
description = " The user wants the model to help a new traveler" +
14
- " with travel tips" ,
17
+ " with travel tips" ,
15
18
navRoute = " chat" ,
16
19
categories = listOf (Category .TEXT ),
17
20
systemInstructions = content {
18
21
text(
19
22
" 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."
23
26
)
24
27
},
25
28
chatHistory = listOf (
@@ -31,7 +34,7 @@ val FIREBASE_AI_SAMPLES = listOf(
31
34
role = " model"
32
35
text(
33
36
" 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."
35
38
)
36
39
},
37
40
content {
@@ -42,8 +45,8 @@ val FIREBASE_AI_SAMPLES = listOf(
42
45
role = " model"
43
46
text(
44
47
" 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."
47
50
)
48
51
}
49
52
),
@@ -57,8 +60,8 @@ val FIREBASE_AI_SAMPLES = listOf(
57
60
systemInstructions = content {
58
61
text(
59
62
" 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."
62
65
)
63
66
},
64
67
initialPrompt = content {
@@ -75,14 +78,14 @@ val FIREBASE_AI_SAMPLES = listOf(
75
78
content(" model" ) {
76
79
text(
77
80
" 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."
79
82
)
80
83
}
81
84
),
82
85
initialPrompt = content {
83
86
text(
84
87
" 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."
86
89
)
87
90
}
88
91
),
@@ -114,8 +117,8 @@ val FIREBASE_AI_SAMPLES = listOf(
114
117
)
115
118
text(
116
119
" 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."
119
122
)
120
123
}
121
124
),
@@ -139,8 +142,8 @@ val FIREBASE_AI_SAMPLES = listOf(
139
142
initialPrompt = content {
140
143
text(
141
144
" 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?"
144
147
)
145
148
},
146
149
generationConfig = generationConfig {
@@ -165,7 +168,7 @@ val FIREBASE_AI_SAMPLES = listOf(
165
168
)
166
169
text(
167
170
" 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?"
169
172
)
170
173
}
171
174
),
@@ -182,9 +185,9 @@ val FIREBASE_AI_SAMPLES = listOf(
182
185
)
183
186
text(
184
187
" 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:'"
188
191
)
189
192
}
190
193
),
@@ -198,16 +201,44 @@ val FIREBASE_AI_SAMPLES = listOf(
198
201
content(" model" ) {
199
202
text(
200
203
" Sure! Click on the attach button below and choose a" +
201
- " video file for me to describe."
204
+ " video file for me to describe."
202
205
)
203
206
}
204
207
),
205
208
initialPrompt = content {
206
209
text(
207
210
" 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."
210
213
)
211
214
}
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
+ ),
213
244
)
0 commit comments