Skip to content

Commit a094933

Browse files
authored
Update README.md (#155)
* Update README.md * Update README.md
1 parent f5e494c commit a094933

File tree

1 file changed

+45
-46
lines changed

1 file changed

+45
-46
lines changed

README.md

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -42,36 +42,35 @@ from the `google_generative_ai` and `firebase_vertexai` packages to the new
4242
`firebase_ai` package.
4343

4444
One change is that there is now a single `FirebaseProvider` that works for both
45-
Gemini and Vertex. Both of these providers served up the same models in the
46-
past, e.g. `gemini-2.0-flash`, but did so via different mechanisms; one was via
47-
an API key and the other was via a Firebase project. The other real difference
48-
was the billing model. When using the `firebase_ai` package, API key support has
49-
been dropped in favor of always requiring a Firebase project. The only remaining
50-
difference is the billing model, which [you can read about in the Firebase
51-
docs](https://firebase.google.com/docs/ai-logic/get-started?platform=flutter&api=dev#set-up-firebase).
45+
Gemini and Vertex. Both of these providers served the same models in the past,
46+
e.g. `gemini-2.0-flash`, but did so via different mechanisms: one used an API
47+
key and the other used a Firebase project. Another difference is the billing
48+
model. When using the `firebase_ai` package, API key support has been dropped in
49+
favor of always requiring a Firebase project. You can read about billing in the
50+
Firebase docs: https://firebase.google.com/docs/ai-logic/get-started?platform=flutter&api=dev#set-up-firebase
5251

53-
To migrate, the following code using the `GeminiProvider`:
52+
To migrate, the following code that uses the `GeminiProvider`:
5453

5554
```dart
56-
class ChatPage extends StatelessWidget {
57-
const ChatPage({super.key, required this.title});
58-
final String title;
55+
class ChatPage extends StatelessWidget {
56+
const ChatPage({super.key, required this.title});
57+
final String title;
5958
60-
@override
61-
Widget build(BuildContext context) {
62-
return Scaffold(
63-
appBar: AppBar(title: Text(title)),
64-
body: LlmChatView(
65-
provider: GeminiProvider( // this changes
66-
model: GenerativeModel( // and this changes
67-
model: 'gemini-2.0-flash',
68-
apiKey: 'GEMINI-API-KEY', // and this changes
69-
),
70-
),
59+
@override
60+
Widget build(BuildContext context) {
61+
return Scaffold(
62+
appBar: AppBar(title: Text(title)),
63+
body: LlmChatView(
64+
provider: GeminiProvider( // this changes
65+
model: GenerativeModel( // and this changes
66+
model: 'gemini-2.0-flash',
67+
apiKey: 'GEMINI-API-KEY', // and this changes
7168
),
72-
);
73-
}
74-
}
69+
),
70+
),
71+
);
72+
}
73+
}
7574
```
7675

7776
now becomes code that uses `googleAI()`:
@@ -92,25 +91,26 @@ class ChatPage extends StatelessWidget {
9291
}
9392
```
9493

95-
And the following code using the `VertexProvider`:
94+
And the following code that uses the `VertexProvider`:
9695

9796
```dart
9897
class ChatPage extends StatelessWidget {
9998
const ChatPage({super.key});
10099
101100
@override
102101
Widget build(BuildContext context) => Scaffold(
103-
appBar: AppBar(title: const Text(App.title)),
104-
body: LlmChatView(
105-
provider: VertexProvider( // this changes
106-
chatModel: FirebaseVertexAI.instance.generativeModel( // and this
107-
model: 'gemini-2.0-flash',
108-
),
109-
),
102+
appBar: AppBar(title: const Text(App.title)),
103+
body: LlmChatView(
104+
provider: VertexProvider( // this changes
105+
chatModel: FirebaseVertexAI.instance.generativeModel( // and this
106+
model: 'gemini-2.0-flash',
110107
),
111-
);
108+
),
109+
),
110+
);
112111
}
113112
```
113+
114114
becomes code that uses `vertexAI()`:
115115

116116
```dart
@@ -177,8 +177,7 @@ void main() async {
177177
2. **Configuration**
178178

179179
To use Firebase AI in your project, follow the steps described in [Get
180-
started with the Gemini API using the Firebase AI Logic SDKs
181-
](https://firebase.google.com/docs/ai-logic/get-started?api=dev).
180+
started with the Gemini API using the Firebase AI Logic SDKs](https://firebase.google.com/docs/ai-logic/get-started?api=dev).
182181

183182
After following these instructions, you're ready to use Firebase AI in your
184183
Flutter app. Start by initializing Firebase:
@@ -210,15 +209,15 @@ void main() async {
210209
211210
@override
212211
Widget build(BuildContext context) => Scaffold(
213-
appBar: AppBar(title: const Text(App.title)),
214-
body: LlmChatView(
215-
provider: FirebaseProvider(
216-
model: FirebaseAI.vertexAI().generativeModel(
217-
model: 'gemini-2.0-flash'
218-
),
219-
),
212+
appBar: AppBar(title: const Text(App.title)),
213+
body: LlmChatView(
214+
provider: FirebaseProvider(
215+
model: FirebaseAI.vertexAI().generativeModel(
216+
model: 'gemini-2.0-flash'
220217
),
221-
);
218+
),
219+
),
220+
);
222221
}
223222
```
224223

@@ -265,8 +264,8 @@ To enable network access on Android, ensure that your `AndroidManifest.xml` file
265264
- **File selection:**
266265
To enable users to select and attach files,
267266
follow the [usage instructions][file-setup] for `package:file_selector`.
268-
- **Image selection:**
269267

268+
- **Image selection:**
270269
To enable users to take or select a picture from their device, refer to
271270
the [installation instructions][image-setup] for `package:image_picker`.
272271

@@ -280,7 +279,7 @@ To enable network access on Android, ensure that your `AndroidManifest.xml` file
280279
## Samples
281280

282281
To run the [example apps][] in the `example/lib` directory, first replace the
283-
`example/lib/firebase_options.dart` file by running `flutterfire config` (you
282+
`example/lib/firebase_options.dart` file by running `flutterfire config` (you
284283
may need to manually delete this file first). The provided
285284
`firebase_options.dart` file is a placeholder for configuration needed by the
286285
examples.

0 commit comments

Comments
 (0)