-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add call gemini for v2 #1134
base: main
Are you sure you want to change the base?
Conversation
Node/call-gemini/functions/index.js
Outdated
exports.callGemini = onCall({secrets: [geminiToken]}, async (request) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before calling Gemini, let's look for both appcheck and auth, but gate each with its own boolean parameter (https://firebase.google.com/docs/functions/config-env?gen=2nd#parameter_types) so devs can choose whether they want auth/app check or not.
Something like:
// ...imports
const appCheckRequired = defineBoolean("APP_CHECK_REQUIRED");
const authRequired = defineBoolean("AUTH_REQUIRED");
// ...other setup
exports.callGemini = onCall(
{
enforceAppCheck: appCheckRequired, // Reject requests with missing or invalid App Check tokens.
},
(request) => {
if (authRequired.val() && !request.auth) {
throw new HttpsError(
"failed-precondition",
"The function must be called while authenticated.",
);
}
// ...call Gemini
},
);
pnpm-workspace.yaml
Outdated
@@ -15,3 +15,4 @@ | |||
packages: | |||
- 'Node/**' | |||
- 'Node-1st-gen/**' | |||
- "!Node-1st-gen/image-maker/**" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove before merging
"@google/generative-ai": "^0.5.0", | ||
"firebase-admin": "^11.9.0", | ||
"firebase-functions": "^4.4.1", | ||
"node-fetch": "^2.6.7" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is node-fetch
needed for this sample?
No description provided.