Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions docs/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ You can use Firebase Auth to protect your flows defined with `onFlow()`:
import { firebaseAuth } from '@genkit-ai/firebase/auth';
import { onFlow } from '@genkit-ai/firebase/functions';

export const jokeFlow = onFlow({
name: 'jokeFlow',
export const selfSummaryFlow = onFlow({
name: 'selfSummaryFlow',
inputSchema: z.string(),
outputSchema: z.string(),
authPolicy: firebaseAuth((user) => {
Expand All @@ -140,7 +140,7 @@ above. When running this flow during development, you would pass the user object
in the same way:

```posix-terminal
genkit flow:run jokeFlow '"Banana"' --auth '{"admin": true}'
genkit flow:run selfSummaryFlow '{"uid": "abc-def"}' --auth '{"admin": true}'
```

By default the Firebase Auth plugin requires the auth header to be sent by the
Expand Down Expand Up @@ -169,14 +169,14 @@ indicate to the library that you are forgoing authorization checks by using the
```ts
import { onFlow, noAuth } from '@genkit-ai/firebase/functions';

export const jokeFlow = onFlow({
name: 'jokeFlow',
export const selfSummaryFlow = onFlow({
name: 'selfSummaryFlow',
inputSchema: z.string(),
outputSchema: z.string(),
// WARNING: Only do this if you have some other gatekeeping in place, like
// Cloud IAM!
authPolicy: noAuth(),
}, (joke) => {...})
}, (subject) => {...})
```

### Client integrity
Expand All @@ -190,8 +190,8 @@ the following configuration options to your `onFlow()`:
```ts
import { onFlow } from '@genkit-ai/firebase/functions';

export const jokeFlow = onFlow({
name: 'jokeFlow',
export const selfSummaryFlow = onFlow({
name: 'selfSummaryFlow',
inputSchema: z.string(),
outputSchema: z.string(),

Expand All @@ -202,7 +202,7 @@ export const jokeFlow = onFlow({
consumeAppCheckToken: true,

authPolicy: ...,
}, (joke) => {...})
}, (subject) => {...})
```

## Non-Firebase HTTP authorization
Expand Down
6 changes: 3 additions & 3 deletions docs/cloud-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ flow.

1. In the developer UI (http://localhost:4000/), run the flow:

1. Click **jokeFlow**.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some references below that need to be updated.

L129-131 - subject matter doesn't work as well w/ menuSuggestionFlow

L162-166 curls jokeFlow w/ banana as input.

1. Click **menuSuggestionFlow**.

1. On the **Input JSON** tab, provide a subject for the model:

```json
"AI app developers"
"banana"
```

1. Click **Run**.
Expand Down Expand Up @@ -160,7 +160,7 @@ After deployment finishes, the tool will print the service URL. You can test
it with `curl`:

```posix-terminal
curl -X POST https://<service-url>/jokeFlow \
curl -X POST https://<service-url>/menuSuggestionFlow \
-H "Authorization: Bearer $(gcloud auth print-identity-token)" \
-H "Content-Type: application/json" -d '{"data": "banana"}'
```
4 changes: 2 additions & 2 deletions docs/deploy-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ sample flow.
```posix-terminal
npm run build

genkit flow:run jokeFlow "\"banana\"" -s
genkit flow:run menuSuggestionFlow "\"banana\"" -s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this still take "banana" as input?

```

1. **Optional**: Start the developer UI:
Expand All @@ -104,7 +104,7 @@ sample flow.
Then, in another window:

```posix-terminal
curl -X POST "http://127.0.0.1:3400/jokeFlow?stream=true" -H "Content-Type: application/json" -d '{"data": "banana"}'
curl -X POST "http://127.0.0.1:3400/menuSuggestionFlow?stream=true" -H "Content-Type: application/json" -d '{"data": "banana"}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this still take "banana" as input?

```

1. If everything's working as expected, you can deploy the flow to the provider
Expand Down
25 changes: 14 additions & 11 deletions docs/firebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ deploying the default sample flow to Firebase.
next section), in the `httpsOptions` parameter, set a CORS policy:

```js
export const jokeFlow = onFlow(
export const menuSuggestionFlow = onFlow(
{
name: 'jokeFlow',
name: 'menuSuggestionFlow',
// ...
httpsOptions: { cors: '*' }, // Add this line.
},
Expand All @@ -150,7 +150,7 @@ deploying the default sample flow to Firebase.

2. In the developer UI (http://localhost:4000/), run the flow:

1. Click **jokeFlow**.
1. Click **menuSuggestionFlow**.

2. On the **Input JSON** tab, provide a subject for the model:

Expand Down Expand Up @@ -243,8 +243,8 @@ app:
</div>
<div id="callGenkit" hidden>
Subject: <input type="text" id="subject" />
<button id="tellJoke">Tell me a joke</button>
<p id="joke"></p>
<button id="suggestMenuItem">Suggest a menu item</button>
<p id="menuItem"></p>
</div>
<script type="module">
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.10.0/firebase-app.js';
Expand All @@ -262,11 +262,14 @@ app:
const firebaseConfig = await fetch('/__/firebase/init.json');
initializeApp(await firebaseConfig.json());

async function generateJoke() {
const jokeFlow = httpsCallable(getFunctions(), 'jokeFlow');
async function generateMenuItem() {
const jokeFlow = httpsCallable(
getFunctions(),
'menuSuggestionFlow'
);
const subject = document.querySelector('#subject').value;
const response = await jokeFlow(subject);
document.querySelector('#joke').innerText = response.data;
const response = await menuSuggestionFlow(subject);
document.querySelector('#menuItem').innerText = response.data;
}

function signIn() {
Expand All @@ -277,8 +280,8 @@ app:
.querySelector('#signinBtn')
.addEventListener('click', signIn);
document
.querySelector('#tellJoke')
.addEventListener('click', generateJoke);
.querySelector('#suggestMenuItem')
.addEventListener('click', generateMenuItem);

const signinEl = document.querySelector('#signin');
const genkitEl = document.querySelector('#callGenkit');
Expand Down