Skip to content

Commit c3b91ab

Browse files
thedmailchrisraygill
authored andcommitted
docs: Third tranche of docs updates (#1871)
* 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]>
1 parent 2dcf527 commit c3b91ab

File tree

4 files changed

+95
-40
lines changed

4 files changed

+95
-40
lines changed

Diff for: docs/cloud-run.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ When you deploy your flows with Cloud Run, you have two options for
8484
authorization:
8585

8686
- **Cloud IAM-based authorization**: Use Google Cloud's native access management
87-
facilities to gate access to your endpoints. See
87+
facilities to gate access to your endpoints. For information on providing
88+
these credentials, see
8889
[Authentication](https://cloud.google.com/run/docs/authenticating/overview)
89-
in the Cloud Run docs for information on providing these credentials.
90+
in the Cloud Run docs.
9091

9192
- **Authorization policy defined in code**: Use the authorization policy feature
92-
of Genkit express plugin to verify authorization info using custom code. This is often,
93-
but not necessarily, token-based authorization.
93+
of the Genkit express plugin to verify authorization info using custom code.
94+
This is often, but not necessarily, token-based authorization.
9495

9596
If you want to define an authorization policy in code, use the `authPolicy`
9697
parameter in the flow definition:

Diff for: docs/devtools.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ npx genkit --help
3333

3434
### Genkit Developer UI
3535

36-
The Genkit Developer UI is a local web app that allows you to interactively
36+
The Genkit Developer UI is a local web app that lets you interactively
3737
work with models, flows, prompts, and other elements in your Genkit project.
3838

3939
The Developer UI is able to identify what Genkit components you have defined

Diff for: docs/firebase.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Cloud Functions for Firebase has an `onCallGenkit` method that lets you
44
quickly create a [callable function](https://firebase.google.com/docs/functions/callable?gen=2nd)
55
with a Genkit action (e.g. a Flow). These functions can be called using
6-
`genkit/beta/client`or the [Functions clientSDK](https://firebase.google.com/docs/functions/callable?gen=2nd#call_the_function),
6+
`genkit/beta/client`or the [Functions client SDK](https://firebase.google.com/docs/functions/callable?gen=2nd#call_the_function),
77
which automatically adds auth info.
88

99
## Before you begin

Diff for: docs/plugins/firebase.md

+88-34
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ use https://github.com/firebase/firebase-tools/blob/master/templates/init/functi
33

44
# Firebase plugin
55

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:
78

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
13+
Monitoring console.
1014

1115
## Installation
1216

@@ -20,13 +24,19 @@ npm install @genkit-ai/firebase
2024

2125
### Firebase Project Setup
2226

23-
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
29+
[Firebase console](https://console.firebase.google.com/).
30+
1. If deploying flows with Cloud functions,
31+
[upgrade your Firebase project](https://console.firebase.google.com/project/_/overview?purchaseBillingPlan=metered)
32+
to the Blaze plan.
33+
1. If you want to run code locally that exports telemetry, you need the
34+
[Google Cloud CLI](https://cloud.google.com/sdk/docs/install) tool installed.
2635

2736
### Firebase Admin SDK Initialization
2837

29-
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.
3040

3141
<!--See note above on prettier-ignore -->
3242
<!-- prettier-ignore -->
@@ -38,32 +48,49 @@ initializeApp({
3848
});
3949
```
4050

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:
4253

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.
4456

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.
4661

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()`.
4864

4965
### Credentials
5066

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:
5269

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.
5472

5573
- For other environments:
5674

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
76+
download the JSON key file. You can do so on the
77+
[Service account](https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk)
78+
page of the Firebase console.
79+
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.
5982

6083
## Features and usage
6184

6285
### Telemetry
6386

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.
6591

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):
6794

6895
- **Monitoring Metric Writer** (roles/monitoring.metricWriter)
6996
- **Cloud Trace Agent** (roles/cloudtrace.agent)
@@ -87,11 +114,18 @@ This plugin shares [configuration options](google-cloud.md#plugin-configuration)
87114

88115
You can use Cloud Firestore as a vector store for RAG indexing and retrieval.
89116

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.
91121

92-
#### Using GCLOUD_SERVICE_ACCOUNT_CREDS and Firestore
122+
#### Using `GCLOUD_SERVICE_ACCOUNT_CREDS` and Firestore
93123

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.
95129

96130
<!--See note above on prettier-ignore -->
97131
<!-- prettier-ignore -->
@@ -111,7 +145,8 @@ if (process.env.GCLOUD_SERVICE_ACCOUNT_CREDS) {
111145

112146
#### Define a Firestore retriever
113147

114-
Use `defineFirestoreRetriever()` to create a retriever for Firestore vector-based queries.
148+
Use `defineFirestoreRetriever()` to create a retriever for Firestore
149+
vector-based queries.
115150

116151
<!--See note above on prettier-ignore -->
117152
<!-- prettier-ignore -->
@@ -136,7 +171,8 @@ const retriever = defineFirestoreRetriever(ai, {
136171

137172
#### Retrieve documents
138173

139-
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`.
140176

141177
<!--See note above on prettier-ignore -->
142178
<!-- prettier-ignore -->
@@ -167,11 +203,16 @@ The following options can be passed to the `options` field in `ai.retrieve`:
167203
```
168204

169205
- **`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.
171209

172210
#### Populate Firestore with Embeddings
173211

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:
175216

176217
<!--See note above on prettier-ignore -->
177218
<!-- prettier-ignore -->
@@ -237,11 +278,16 @@ async function extractTextFromPdf(filePath: string) {
237278
}
238279
```
239280

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.)
241284

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:
243287

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.
245291

246292
The command looks like the following:
247293

@@ -251,21 +297,29 @@ The prior example requires the `embedding` field to be indexed to work. To creat
251297
--field-config=vector-config='{"dimension":"768","flat": "{}"}',field-path=yourEmbeddingField
252298
```
253299

254-
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.
255302

256303

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.
258306

259307
#### Learn more
260308

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.
263313

264314
### Deploy flows as Cloud Functions
265315

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)
319+
from a flow. It automatically supports
320+
streaming and JSON requests. You can use the
321+
[Cloud Functions client SDKs](https://firebase.google.com/docs/functions/callable?gen=2nd#call_the_function)
322+
to call them.
269323

270324
<!--See note above on prettier-ignore -->
271325
<!-- prettier-ignore -->

0 commit comments

Comments
 (0)