You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Docs: Edits to Auth doc for 1.0 GA
* Docs: Edits to Firebase doc for 1.0 GA
* Docs: Edits to Firebase doc for 1.0 GA
* Docs: Edits to Firebase doc for 1.0 GA
* Docs: Edits to Firebase doc for 1.0 GA
* Docs: Edits to Firebase doc for 1.0 GA
* Docs: Edits to Firebase doc for 1.0 GA
* Accepting typo-fix suggestion in docs/firebase.md
Co-authored-by: Chris Ray Gill <[email protected]>
---------
Co-authored-by: Chris Ray Gill <[email protected]>
Copy file name to clipboardExpand all lines: docs/plugins/firebase.md
+88-34
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,14 @@ use https://github.com/firebase/firebase-tools/blob/master/templates/init/functi
3
3
4
4
# Firebase plugin
5
5
6
-
The Firebase plugin provides integrations with Firebase services, allowing you to build intelligent and scalable AI applications. Key features include:
6
+
The Firebase plugin provides integrations with Firebase services, so you can
7
+
build intelligent and scalable AI applications. Key features include:
7
8
8
-
-**Firestore Vector Store**: Use Firestore for indexing and retrieval with vector embeddings.
9
-
-**Telemetry**: Export telemetry to [Google's Cloud operations suite](https://cloud.google.com/products/operations) that powers the Firebase Genkit Monitoring console.
9
+
-**Firestore Vector Store**: Use Firestore for indexing and retrieval
10
+
with vector embeddings.
11
+
-**Telemetry**: Export telemetry to
12
+
[Google's Cloud operations suite](https://cloud.google.com/products/operations) that powers the Firebase Genkit
1. All Firebase products require a Firebase project. You can create a new project or enable Firebase in an existing Google Cloud project using the [Firebase console](https://console.firebase.google.com/).
24
-
2. If deploying flows with Cloud Functions, [upgrade your Firebase project](https://console.firebase.google.com/project/_/overview?purchaseBillingPlan=metered) to the Blaze plan.
25
-
3. If you want to run code locally that exports telemetry, you need the [Google Cloud CLI](https://cloud.google.com/sdk/docs/install) tool installed.
27
+
1. All Firebase products require a Firebase project. You can create a new
28
+
project or enable Firebase in an existing Google Cloud project using the
You must initialize the Firebase Admin SDK in your application. This is not handled automatically by the plugin.
38
+
You must initialize the Firebase Admin SDK in your application.
39
+
This is not handled automatically by the plugin.
30
40
31
41
<!--See note above on prettier-ignore -->
32
42
<!-- prettier-ignore -->
@@ -38,32 +48,49 @@ initializeApp({
38
48
});
39
49
```
40
50
41
-
The plugin requires you to specify your Firebase project ID. You can specify your Firebase project ID in either of the following ways:
51
+
The plugin requires you to specify your Firebase project ID. You can specify
52
+
your Firebase project ID in either of the following ways:
42
53
43
-
- Set `projectId` in the `initializeApp()` configuration object as shown in the snippet above.
54
+
- Set `projectId` in the `initializeApp()` configuration object as shown
55
+
in the snippet above.
44
56
45
-
- Set the `GCLOUD_PROJECT` environment variable. If you're running your flow from a Google Cloud environment (Cloud Functions, Cloud Run, and so on), `GCLOUD_PROJECT` is automatically set to the project ID of the environment.
57
+
- Set the `GCLOUD_PROJECT` environment variable. If you're running your
58
+
flow from a Google Cloud environment (Cloud Functions, Cloud Run, and
59
+
so on), `GCLOUD_PROJECT` is automatically set to the project ID of the
60
+
environment.
46
61
47
-
If you set `GCLOUD_PROJECT`, you can omit the configuration parameter in `initializeApp()`.
62
+
If you set `GCLOUD_PROJECT`, you can omit the configuration
63
+
parameter in `initializeApp()`.
48
64
49
65
### Credentials
50
66
51
-
To provide Firebase credentials, you also need to set up Google Cloud Application Default Credentials. To specify your credentials:
67
+
To provide Firebase credentials, you also need to set up Google Cloud
68
+
Application Default Credentials. To specify your credentials:
52
69
53
-
- If you're running your flow from a Google Cloud environment (Cloud Functions, Cloud Run, and so on), this is set automatically.
70
+
- If you're running your flow from a Google Cloud environment (Cloud Functions,
71
+
- Cloud Run, and so on), this is set automatically.
54
72
55
73
- For other environments:
56
74
57
-
1. Generate service account credentials for your Firebase project and download the JSON key file. You can do so on the [Service account](https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk) page of the Firebase console.
58
-
2. Set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the file path of the JSON file that contains your service account key, or you can set the environment variable `GCLOUD_SERVICE_ACCOUNT_CREDS` to the content of the JSON file.
75
+
1. Generate service account credentials for your Firebase project and
1. Set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the file
80
+
path of the JSON file that contains your service account key, or you can set
81
+
the environment variable `GCLOUD_SERVICE_ACCOUNT_CREDS` to the content of the JSON file.
59
82
60
83
## Features and usage
61
84
62
85
### Telemetry
63
86
64
-
Firebase Genkit Monitoring is powered by Google's Cloud operation suite. This requires telemetry related API's to be enabled for your project. Please refer to the [Google Cloud plugin](google-cloud.md#set-up-a-google-cloud-account) documentation for more details.
87
+
Firebase Genkit Monitoring is powered by Google's Cloud operation suite. This
88
+
requires telemetry related API's to be enabled for your project. Please refer
89
+
to the [Google Cloud plugin](google-cloud.md#set-up-a-google-cloud-account)
90
+
documentation for more details.
65
91
66
-
Grant the following roles to the **"Default compute service account"** within the [Google Cloud IAM Console](https://console.cloud.google.com/iam-admin/iam):
92
+
Grant the following roles to the **"Default compute service account"** within
93
+
the [Google Cloud IAM Console](https://console.cloud.google.com/iam-admin/iam):
@@ -87,11 +114,18 @@ This plugin shares [configuration options](google-cloud.md#plugin-configuration)
87
114
88
115
You can use Cloud Firestore as a vector store for RAG indexing and retrieval.
89
116
90
-
This section contains information specific to the `firebase` plugin and Cloud Firestore's vector search feature. See the [Retrieval-augmented generation](/../rag.md) page for a more detailed discussion on implementing RAG using Genkit.
117
+
This section contains information specific to the `firebase` plugin and Cloud
118
+
Firestore's vector search feature. See the
119
+
[Retrieval-augmented generation](/../rag.md) page for a more detailed
120
+
discussion on implementing RAG using Genkit.
91
121
92
-
#### Using GCLOUD_SERVICE_ACCOUNT_CREDS and Firestore
122
+
#### Using `GCLOUD_SERVICE_ACCOUNT_CREDS` and Firestore
93
123
94
-
If you are using service account credentials by passing credentials directly via `GCLOUD_SERVICE_ACCOUNT_CREDS` and are also using Firestore as a vector store, you will need to pass credentials directly to the Firestore instance during initialization or the singleton may be initialized with application default credentials depending on plugin initialization order.
124
+
If you are using service account credentials by passing credentials directly
125
+
via `GCLOUD_SERVICE_ACCOUNT_CREDS` and are also using Firestore as a vector
126
+
store, you need to pass credentials directly to the Firestore instance
127
+
during initialization or the singleton may be initialized with application
128
+
default credentials depending on plugin initialization order.
95
129
96
130
<!--See note above on prettier-ignore -->
97
131
<!-- prettier-ignore -->
@@ -111,7 +145,8 @@ if (process.env.GCLOUD_SERVICE_ACCOUNT_CREDS) {
111
145
112
146
#### Define a Firestore retriever
113
147
114
-
Use `defineFirestoreRetriever()` to create a retriever for Firestore vector-based queries.
148
+
Use `defineFirestoreRetriever()` to create a retriever for Firestore
To retrieve documents using the defined retriever, pass the retriever instance and query options to `ai.retrieve`.
174
+
To retrieve documents using the defined retriever, pass the retriever instance
175
+
and query options to `ai.retrieve`.
140
176
141
177
<!--See note above on prettier-ignore -->
142
178
<!-- prettier-ignore -->
@@ -167,11 +203,16 @@ The following options can be passed to the `options` field in `ai.retrieve`:
167
203
```
168
204
169
205
-**`collection`**: *(string)*
170
-
Override the default collection specified in the retriever configuration. This is useful for querying subcollections or dynamically switching between collections.
206
+
Override the default collection specified in the retriever configuration.
207
+
- This is useful for querying subcollections or dynamically switching between
208
+
- collections.
171
209
172
210
#### Populate Firestore with Embeddings
173
211
174
-
To populate your Firestore collection, use an embedding generator along with the Admin SDK. For example, the menu ingestion script from the [Retrieval-augmented generation](http://../rag.md) page could be adapted for Firestore in the following way:
212
+
To populate your Firestore collection, use an embedding generator along with
213
+
the Admin SDK. For example, the menu ingestion script from the
214
+
[Retrieval-augmented generation](http://../rag.md) page could be adapted for
215
+
Firestore in the following way:
175
216
176
217
<!--See note above on prettier-ignore -->
177
218
<!-- prettier-ignore -->
@@ -237,11 +278,16 @@ async function extractTextFromPdf(filePath: string) {
237
278
}
238
279
```
239
280
240
-
Firestore depends on indexes to provide fast and efficient querying on collections. (Note that "index" here refers to database indexes, and not Genkit's indexer and retriever abstractions.)
281
+
Firestore depends on indexes to provide fast and efficient querying on
282
+
collections. (Note that "index" here refers to database indexes, and not
283
+
Genkit's indexer and retriever abstractions.)
241
284
242
-
The prior example requires the `embedding` field to be indexed to work. To create the index:
285
+
The prior example requires the `embedding` field to be indexed to work.
286
+
To create the index:
243
287
244
-
- Run the `gcloud` command described in the [Create a single-field vector index](https://firebase.google.com/docs/firestore/vector-search?authuser=0#create_and_manage_vector_indexes) section of the Firestore docs.
288
+
- Run the `gcloud` command described in the
289
+
[Create a single-field vector index](https://firebase.google.com/docs/firestore/vector-search?authuser=0#create_and_manage_vector_indexes)
290
+
section of the Firestore docs.
245
291
246
292
The command looks like the following:
247
293
@@ -251,21 +297,29 @@ The prior example requires the `embedding` field to be indexed to work. To creat
However, the correct indexing configuration depends on the queries you will make and the embedding model you're using.
300
+
However, the correct indexing configuration depends on the queries you
301
+
make and the embedding model you're using.
255
302
256
303
257
-
- Alternatively, call `ai.retrieve()` and Firestore will throw an error with the correct command to create the index.
304
+
- Alternatively, call `ai.retrieve()` and Firestore will throw an error with
305
+
the correct command to create the index.
258
306
259
307
#### Learn more
260
308
261
-
- See the [Retrieval-augmented generation](http://../rag.md) page for a general discussion on indexers and retrievers in Genkit.
262
-
- See [Search with vector embeddings](https://firebase.google.com/docs/firestore/vector-search) in the Cloud Firestore docs for more on the vector search feature.
309
+
- See the [Retrieval-augmented generation](http://../rag.md) page for a general discussion
310
+
on indexers and retrievers in Genkit.
311
+
- See [Search with vector embeddings](https://firebase.google.com/docs/firestore/vector-search) in the Cloud Firestore docs for more
312
+
on the vector search feature.
263
313
264
314
### Deploy flows as Cloud Functions
265
315
266
-
To deploy a flow with Cloud Functions, use the Firebase Functions library's native support for genkit. The `onCallGenkit` method allows
267
-
you to create a [callable function](https://firebase.google.com/docs/functions/callable?gen=2nd) from a flow. It will automatically support
268
-
streaming and JSON requests. You can use the [Cloud Functions client SDKs](https://firebase.google.com/docs/functions/callable?gen=2nd#call_the_function) to call them.
316
+
To deploy a flow with Cloud Functions, use the Firebase Functions library's
317
+
built-in support for genkit. The `onCallGenkit` method lets
318
+
you to create a [callable function](https://firebase.google.com/docs/functions/callable?gen=2nd)
0 commit comments