File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed
FirebaseAI/Tests/TestApp/Sources Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change 12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ import FirebaseAI
15
16
import SwiftUI
16
17
17
18
struct ContentView : View {
19
+ // TODO: Revert changes in this file. For prototyping purposes only.
20
+ let liveModel : LiveGenerativeModel = {
21
+ // let firebaseAI = FirebaseAI.firebaseAI(backend: .vertexAI())
22
+ let firebaseAI = FirebaseAI . firebaseAI ( )
23
+ return firebaseAI. liveModel (
24
+ modelName: " gemini-2.0-flash-live-001 " ,
25
+ generationConfig: LiveGenerationConfig ( responseModalities: [ . text] )
26
+ )
27
+ } ( )
28
+
29
+ @State private var responses : [ String ] = [ ]
30
+
18
31
var body : some View {
19
32
VStack {
20
- Image ( systemName: " globe " )
21
- . imageScale ( . large)
22
- . foregroundStyle ( . tint)
23
- Text ( " Hello, world! " )
33
+ List ( responses, id: \. self) {
34
+ Text ( $0)
35
+ }
24
36
}
25
37
. padding ( )
38
+ . task {
39
+ do {
40
+ let liveSession = try await liveModel. connect ( )
41
+ try await liveSession. sendMessage ( " Why is the sky blue? " )
42
+ for try await response in liveSession. responses {
43
+ responses. append ( String ( describing: response) )
44
+ }
45
+ } catch {
46
+ print ( error)
47
+ }
48
+ }
26
49
}
27
50
}
28
51
You can’t perform that action at this time.
0 commit comments