Skip to content

Commit

Permalink
Modify docs that invoke genkit init
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Chestnut committed May 13, 2024
1 parent 9239bd4 commit 8f9b1d9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
14 changes: 7 additions & 7 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 menuSuggestionFlow = onFlow({
name: 'menuSuggestionFlow',
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 menuSuggestionFlow '"Banana"' --auth '{"admin": true}'
```

By default the Firebase Auth plugin requires the auth header to be sent by the
Expand Down Expand Up @@ -169,8 +169,8 @@ 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 menuSuggestionFlow = onFlow({
name: 'menuSuggestionFlow',
inputSchema: z.string(),
outputSchema: z.string(),
// WARNING: Only do this if you have some other gatekeeping in place, like
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 menuSuggestionFlow = onFlow({
name: 'menuSuggestionFlow',
inputSchema: z.string(),
outputSchema: z.string(),

Expand Down
2 changes: 1 addition & 1 deletion docs/cloud-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ flow.

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

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

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

Expand Down
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
```

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"}'
```

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

0 comments on commit 8f9b1d9

Please sign in to comment.