Skip to content

Commit 1575cc2

Browse files
committed
Temporarily display text Bidi responses in TestApp
1 parent e783431 commit 1575cc2

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

FirebaseAI/Tests/TestApp/Sources/ContentView.swift

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,40 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import FirebaseAI
1516
import SwiftUI
1617

1718
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+
1831
var body: some View {
1932
VStack {
20-
Image(systemName: "globe")
21-
.imageScale(.large)
22-
.foregroundStyle(.tint)
23-
Text("Hello, world!")
33+
List(responses, id: \.self) {
34+
Text($0)
35+
}
2436
}
2537
.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+
}
2649
}
2750
}
2851

0 commit comments

Comments
 (0)