@@ -4,11 +4,13 @@ Call the Vertex AI Gemini API with Remote Config and App Check
4
4
Introduction
5
5
------------
6
6
7
- This is a sample callable function that authenticates calling apps with App
7
+ This is a sample callable function that authenticates clients with App
8
8
Check and then sends queries to Gemini using the Vertex AI Gemini API. Vertex
9
- AI model parameters are controlled using the Remote Config server
10
- functionality provided by the Firebase Admin SDK for Node.js. Use the client
11
- provided in ` client/ ` to access the function through basic web page.
9
+ AI model parameters (including the model itself) are controlled by
10
+ Remote Config server features included in the Firebase Admin SDK for
11
+ Node.js.
12
+
13
+ Use the web client provided in ` client/ ` to test the function.
12
14
13
15
- [ Read more about Remote Config for servers] ( https://firebase.google.com/docs/remote-config/server ) .
14
16
- [ Read more about App Check] ( https://firebase.google.com/docs/app-check ) .
@@ -26,22 +28,44 @@ Get Started
26
28
---------------
27
29
28
30
1 . Follow the instructions in client/README.md to create a Firebase project,
29
- enable ReCAPTCHA Enterprise, enable Firebase App Check, and add your
30
- Firebase config and ReCAPTCHA Enterprise key to the client config.
31
+ enable ReCAPTCHA Enterprise, enable and enforce Firebase App Check, and add
32
+ your Firebase config and ReCAPTCHA Enterprise key to the client config.
33
+
31
34
2 . Enable [ recommended Vertex AI APIs] ( https://console.cloud.google.com/vertex-ai ) .
35
+
32
36
3 . Configure a Remote Config server template on the Firebase console. Use the template
33
37
described in
34
38
[ Use server side Remote Config with Cloud Functions and Vertex
35
39
AI] ( https://firebase.google.com/docs/remote-config/solution-server#implementation-create-template ) ,
36
- which contains all of the parameters used in the function sample.
40
+ which contains all of the parameters used in this function sample.
41
+
37
42
4 . Install dependencies: ` cd functions && npm install `
38
- 5 . If you haven't already done so, install firebase-tools: ` npm i firebase-tools@latest `
39
- 6 . Log into Firebase: ` firebase login `
43
+
44
+ 5 . If you haven't already done so, install firebase-tools:
45
+
46
+ ` npm i firebase-tools@latest `
47
+
48
+ 6 . Log into Firebase:
49
+
50
+ ` firebase login `
51
+
40
52
7 . Deploy the function. We recommend testing in the
41
- [ Firebase emulator] ( https://firebase.google.com/docs/remote-config/solution-server#implementation-deploy-and-test-in-emulator ) .
53
+ [ Firebase emulator] ( https://firebase.google.com/docs/remote-config/solution-server#implementation-deploy-and-test-in-emulator ) :
54
+
55
+ ` firebase emulators:start `
56
+
42
57
8 . If testing in the emulator, verify that ` testMode ` is set to ` true ` in
43
- ` client/main.ts ` , then start the client: ` cd public && npm run dev `
44
- 9 . Open the [ client app in a browser] ( http://localhost:5173 ) and enter a
58
+ ` client/main.ts ` , then start the client:
59
+
60
+ ` cd client && npm run dev `
61
+
62
+ TIP: If you're using the emulator, you can deploy both the function and hosting
63
+ to the emulator. From the ` client ` directory, run ` npm run build ` .
64
+ Then, from the parent directory, run ` firebase server --only functions,hosting ` .
65
+ Open http://localhost:5000 to access and test the web client's connection
66
+ to the ` callVertexWithRC ` function.
67
+
68
+ 0 . Open the [ client app in a browser] ( http://localhost:5173 ) and enter a
45
69
prompt. To access the Vertex AI Gemini API, make sure that you have
46
70
set the ` is_vertex_enabled ` boolean parameter in your Remote Config
47
71
server template to ` true ` .
0 commit comments