Closed cabljac closed 2 months ago
I believe this is actually coming from the embed call
Updated repro:
import { textEmbeddingGecko } from "@genkit-ai/vertexai";
import { Document } from "@genkit-ai/ai/retriever";
import { firebase } from "@genkit-ai/firebase";
import { vertexAI } from "@genkit-ai/vertexai";
import { configureGenkit } from "@genkit-ai/core";
import { defineFlow } from "@genkit-ai/flow";
import { embed } from "@genkit-ai/ai/embedder";
if (!process.env.GOOGLE_APPLICATION_CREDENTIALS) {
throw new Error(
"GOOGLE_APPLICATION_CREDENTIALS environment variable is not set."
);
}
configureGenkit({
plugins: [
firebase(),
vertexAI({
location: "us-central1", // fails whether this is set or not
projectId: "<REDACTED>", // fails whether this is set or not
// googleAuth: { keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS }, // fails whether this is set or not
}),
],
logLevel: "debug",
traceStore: "firebase",
});
export const myFlow = defineFlow(
{
name: "myFlow",
},
async () => {
const embedding = await embed({
embedder: textEmbeddingGecko,
content: Document.fromText("Hello, world!"),
});
console.info(embedding);
}
);
This works:
import { firebase } from "@genkit-ai/firebase";
import { vertexAI } from "@genkit-ai/vertexai";
import { configureGenkit } from "@genkit-ai/core";
if (!process.env.GOOGLE_APPLICATION_CREDENTIALS) {
throw new Error(
"GOOGLE_APPLICATION_CREDENTIALS environment variable is not set."
);
}
configureGenkit({
plugins: [firebase(), vertexAI({
googleAuth: {
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
},
location: "us-central1",
})],
logLevel: "debug",
traceStore: "firebase",
});
Do we need to add scopes manually here?
@ssbushi can you take a look when you get a chance?
Thanks @cabljac
I ran into the exact same issue when testing out ChromaDB deployed. It has nothing to do with Firestore (or ChromaDB) but the missing scope for Vertex AI. This only happens when GOOGLE_APPLICATION_CREDENTIALS
is used for app credentials and does not occur if using gcloud auth
instead.
You seem to have found the workaround -- thanks for that. We should definitely not require explicit scopes set here, I can update the plugin to reflect that.
Describe the bug
EDIT: See comments, this isn't to do with the retriever, it's to do with the embed method and authentication to GCP
I was investigating https://github.com/firebase/genkit/issues/452 and when I attempt to retrieve some docs following the official documentation for firestore retrievers, i get this a 400 error. Here are the logs:
To Reproduce I ran
genkit init
to bootstrap up a project. I created a fairly minimal example here:Expected behavior I would expect docs to be retrieved, and not to hit some authentication error. If I manually try to retrieve docs with firebase admin, i do not hit this error.
Runtime (please complete the following information):
Node version
node --version
at paste here I have experienced this on v20.11.1 and v18.19.1