Skip to content

Commit 7f8834b

Browse files
ollyhowellthomasgauvin
authored andcommitted
Minor changes for grammar and clarity (#23535)
1 parent 8eda48b commit 7f8834b

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/content/docs/workers-ai/guides/tutorials/using-bigquery-with-workers-ai.mdx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ sidebar:
1616

1717
import { WranglerConfig } from "~/components";
1818

19-
The easiest way to get started with [Workers AI](/workers-ai/) is to try it out in the [Multi-modal Playground](https://multi-modal.ai.cloudflare.com/) and the [LLM playground](https://playground.ai.cloudflare.com/). If you decide that you want to integrate your code with Workers AI, you may then decide to then use its [REST API endpoints](/workers-ai/get-started/rest-api/) or via a [Worker binding](/workers-ai/configuration/bindings/).
19+
The easiest way to get started with [Workers AI](/workers-ai/) is to try it out in the [Multi-modal Playground](https://multi-modal.ai.cloudflare.com/) and the [LLM playground](https://playground.ai.cloudflare.com/). If you decide that you want to integrate your code with Workers AI, you may then decide to use its [REST API endpoints](/workers-ai/get-started/rest-api/) or a [Worker binding](/workers-ai/configuration/bindings/).
2020

21-
But, what about the data? What if what you want these models to ingest data that is stored outside Cloudflare?
21+
But what about the data? What if you want these models to ingest data that is stored outside Cloudflare?
2222

2323
In this tutorial, you will learn how to bring data from Google BigQuery to a Cloudflare Worker so that it can be used as input for Workers AI models.
2424

@@ -32,7 +32,7 @@ You will need:
3232

3333
## 1. Set up your Cloudflare Worker
3434

35-
To ingest the data into Cloudflare and feed it into Workers AI, you will be using a [Cloudflare Worker](/workers/). If you have not created one yet, please feel free to review our [tutorial on how to get started](/workers/get-started/).
35+
To ingest the data into Cloudflare and feed it into Workers AI, you will be using a [Cloudflare Worker](/workers/). If you have not created one yet, please review our [tutorial on how to get started](/workers/get-started/).
3636

3737
After following the steps to create a Worker, you should have the following code in your new Worker project:
3838

@@ -58,7 +58,7 @@ You should be seeing `Hello World!` in your browser:
5858
Hello World!
5959
```
6060

61-
If you are running into any issues during this step, please make sure to review [Worker's Get Started Guide](/workers/get-started/guide/).
61+
If you run into any issues during this step, please review the [Worker's Get Started Guide](/workers/get-started/guide/).
6262

6363
## 2. Import GCP Service key into the Worker as Secrets
6464

@@ -82,9 +82,9 @@ Your downloaded key JSON file from Google Cloud Platform should have the followi
8282
}
8383
```
8484

85-
For this tutorial, you will only be needing the values of the following fields: `client_email`, `private_key`, `private_key_id`, and `project_id`.
85+
For this tutorial, you will only need the values of the following fields: `client_email`, `private_key`, `private_key_id`, and `project_id`.
8686

87-
Instead of storing this information in plain text in the Worker, you will use [secrets](/workers/configuration/secrets/) to make sure its unencrypted content is only accessible via the Worker itself.
87+
Instead of storing this information in plain text in the Worker, you will use [Secrets](/workers/configuration/secrets/) to make sure its unencrypted content is only accessible via the Worker itself.
8888

8989
Import those three values from the JSON file into Secrets, starting with the field from the JSON key file called `client_email`, which we will now call `BQ_CLIENT_EMAIL` (you can use another variable name):
9090

@@ -96,7 +96,7 @@ You will be asked to enter a secret value, which will be the value of the field
9696

9797
:::note
9898

99-
Do not include any double quotes in the secret that you store, as the Secret will be already interpreted as a string.
99+
Do not include any double quotes in the secret that you store, as it will already be interpreted as a string.
100100

101101
:::
102102

@@ -120,7 +120,7 @@ npx wrangler secret put BQ_PRIVATE_KEY_ID
120120
npx wrangler secret put BQ_PROJECT_ID
121121
```
122122

123-
At this point, you have successfully imported three fields from the JSON key file downloaded from Google Cloud Platform into Cloudflare secrets to be used in a Worker.
123+
At this point, you have successfully imported three fields from the JSON key file downloaded from Google Cloud Platform into Cloudflare Secrets to be used in a Worker.
124124

125125
[Secrets](/workers/configuration/secrets/) are only made available to Workers once they are deployed. To make them available during development, [create a `.dev.vars`](/workers/configuration/secrets/#local-development-with-secrets) file to locally store these credentials and reference them as environment variables.
126126

@@ -133,9 +133,9 @@ BQ_PRIVATE_KEY_ID="<your_private_key_id>"
133133
BQ_PROJECT_ID="<your_project_id>"
134134
```
135135

136-
Make sure to include `.dev.vars` to your `.gitignore` file in your project to prevent getting your credentials uploaded to a repository if you are using a version control system.
136+
Make sure to include `.dev.vars` in your project `.gitignore` file to prevent your credentials being uploaded to a repository when using version control.
137137

138-
Check that secrets are loaded correctly in `src/index.js` by logging their values into a console output:
138+
Check the secrets are loaded correctly in `src/index.js` by logging their values into a console output, as follows:
139139

140140
```javascript
141141
export default {
@@ -176,7 +176,7 @@ For this tutorial, you will be using the [jose](https://www.npmjs.com/package/jo
176176
npm i jose
177177
```
178178

179-
To verify that the installation succeeded, you can run `npm list`, which lists all the installed packages and see if the `jose` dependency has been added:
179+
To verify that the installation succeeded, you can run `npm list`, which lists all the installed packages, to check if the `jose` dependency has been added:
180180

181181
```sh
182182
<project_name>@0.0.0
@@ -187,9 +187,9 @@ To verify that the installation succeeded, you can run `npm list`, which lists a
187187
188188
```
189189

190-
## 4. Generate JSON Web Token
190+
## 4. Generate JSON web token
191191

192-
Now that you have installed the `jose` library, it is time to import it and add a function to your code that generates a signed JWT:
192+
Now that you have installed the `jose` library, it is time to import it and add a function to your code that generates a signed JSON Web Token (JWT):
193193

194194
```javascript
195195
import * as jose from 'jose';
@@ -237,7 +237,7 @@ Now that you have created a JWT, it is time to do an API call to BigQuery to fet
237237

238238
With the JWT token created in the previous step, issue an API request to BigQuery's API to retrieve data from a table.
239239

240-
You will now query the table that you already have created in BigQuery as part of the prerequisites of this tutorial. This example uses a sampled version of the [Hacker News Corpus](https://www.kaggle.com/datasets/hacker-news/hacker-news-corpus) that was used under its MIT licence and uploaded to BigQuery.
240+
You will now query the table that you created in BigQuery earlier in this tutorial. This example uses a sampled version of the [Hacker News Corpus](https://www.kaggle.com/datasets/hacker-news/hacker-news-corpus) that was used under its MIT licence and uploaded to BigQuery.
241241

242242
```javascript
243243
const queryBQ = async (bqJWT, path) => {
@@ -270,11 +270,11 @@ export default {
270270
};
271271
```
272272

273-
Having the raw row data from BigQuery means that you can now format it in a JSON-like style up next.
273+
Having the raw row data from BigQuery means that you can now format it in a JSON-like style next.
274274

275275
## 6. Format results from the query
276276

277-
Now that you have retrieved the data from BigQuery, it is time to note that a BigQuery API response looks something like this:
277+
Now that you have retrieved the data from BigQuery, your BigQuery API response should look something like this:
278278

279279
```json
280280
{
@@ -330,7 +330,7 @@ Now that you have retrieved the data from BigQuery, it is time to note that a Bi
330330
}
331331
```
332332

333-
This format may be difficult to read and to work with when iterating through results, which will go on to do later in this tutorial. So you will now implement a function that maps the schema into each individual value, and the resulting output will be easier to read, as shown below. Each row corresponds to an object within an array.
333+
This format may be difficult to read and work with when iterating through results. So you will now implement a function that maps the schema into each individual value, and the resulting output will be easier to read, as shown below. Each row corresponds to an object within an array.
334334

335335
```javascript
336336
[
@@ -353,10 +353,10 @@ Create a `formatRows` function that takes a number of rows and fields returned f
353353

354354
```javascript
355355
const formatRows = (rowsWithoutFieldNames, fields) => {
356-
// Depending on the position of each value, it is known what field you should assign to it.
356+
// Index to fieldName
357357
const fieldsByIndex = new Map();
358358

359-
// Load all fields name and have their index in the array result as their key
359+
// Load all fields by name and have their index in the array result as their key
360360
fields.forEach((field, index) => {
361361
fieldsByIndex.set(index, field.name)
362362
})
@@ -500,11 +500,11 @@ Once you access `http://localhost:8787` you should see an output similar to the
500500
}
501501
```
502502

503-
The actual values and fields will mostly depend on the query made in Step 5 that are then fed into the LLMs models.
503+
The actual values and fields will mostly depend on the query made in Step 5 that is then fed into the LLM.
504504

505505
## Final result
506506

507-
All the code shown in the different steps are combined into the following code in `src/index.js`:
507+
All the code shown in the different steps is combined into the following code in `src/index.js`:
508508

509509
```javascript
510510
import * as jose from "jose";
@@ -677,12 +677,12 @@ This will create a public endpoint that you can use to access the Worker globall
677677
678678
In this tutorial, you have learnt how to integrate Google BigQuery and Cloudflare Workers by creating a GCP service account key and storing part of it as Worker secrets. This was later imported in the code, and by using the `jose` npm library, you created a JSON Web Token to authenticate the API query to BigQuery.
679679
680-
Once you obtained the results, you formatted them to later be passed to generative AI models via Workers AI to generate tags and to perform sentiment analysis on the extracted data.
680+
Once you obtained the results, you formatted them to pass to generative AI models via Workers AI to generate tags and to perform sentiment analysis on the extracted data.
681681
682682
## Next Steps
683683
684-
If, instead of displaying the results of ingesting the data to the AI model in a browser, your workflow requires fetching and store data (for example in [R2](/r2/) or [D1](/d1/)) on regular intervals, you may want to consider adding a [scheduled handler](/workers/runtime-apis/handlers/scheduled/) for this Worker. It allows triggering the Worker with a predefined cadence via a [Cron Trigger](/workers/configuration/cron-triggers/). Consider reviewing the Reference Architecture Diagrams on [Ingesting BigQuery Data into Workers AI](/reference-architecture/diagrams/ai/bigquery-workers-ai/).
684+
If, instead of displaying the results of ingesting the data to the AI model in a browser, your workflow requires fetching and store data (for example in [R2](/r2/) or [D1](/d1/)) on regular intervals, you may want to consider adding a [scheduled handler](/workers/runtime-apis/handlers/scheduled/) for this Worker. This enables you to trigger the Worker with a predefined cadence via a [Cron Trigger](/workers/configuration/cron-triggers/). Consider reviewing the Reference Architecture Diagrams on [Ingesting BigQuery Data into Workers AI](/reference-architecture/diagrams/ai/bigquery-workers-ai/).
685685
686-
A use case to ingest data from other sources, like you did in this tutorial, is to create a RAG system. If this sounds relevant to you, please check out the tutorial [Build a Retrieval Augmented Generation (RAG) AI](/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/).
686+
A use case to ingest data from other sources, like you did in this tutorial, is to create a RAG system. If this sounds relevant to you, please check out the [Build a Retrieval Augmented Generation (RAG) AI tutorial](/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/).
687687
688688
To learn more about what other AI models you can use at Cloudflare, please visit the [Workers AI](/workers-ai) section of our docs.

0 commit comments

Comments
 (0)