Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Permission issues with Corpus

I'm trying to run a Langchain example using a corpus I've already created and keep getting these errors. Not sure what I need. I tried setting an GOOGLE_API_KEY key but got the same error. I can query the corpus using below fine.

vertexai.init(project=PROJECT_ID, location="us-central1")

files = rag.list_files(corpus_name=CORPUS_NAME)

How do I give my project permission?

from langchain_google_genai import GoogleVectorStore
vector_store = GoogleVectorStore(
corpus_id=CORPUS_NAME
)

Corpus [corpus id] not found: 403 Request had insufficient authentication scopes. [reason: "ACCESS_TOKEN_SCOPE_INSUFFICIENT"
domain: "googleapis.com"
metadata {
key: "service"
value: "generativelanguage.googleapis.com"
}
metadata {
key: "method"
value: "google.ai.generativelanguage.v1beta.RetrieverService.GetCorpus"
}
]
Traceback (most recent call last):
File ".../rag.py", line 19, in <module>
vector_store = GoogleVectorStore(
^^^^^^^^^^^^^^^^^^
File "....site-packages/langchain_google_genai/google_vector_store.py", line 267, in __init__
self._retriever = _SemanticRetriever.from_ids(corpus_id, document_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "....site-packages/langchain_google_genai/google_vector_store.py", line 75, in from_ids
raise DoesNotExistsException(corpus_id=corpus_id)
langchain_google_genai.google_vector_store.DoesNotExistsException: No such corpus projects/134776362083/locations/us-central1/ragCorpora/1152921504606846976

0 1 191
1 REPLY 1

I created a service account to get around this issue but now I'm running into: google.api_core.exceptions.InvalidArgument: 400 * GetCorpusRequest.name: Corpus name does not match expected format or is too long.

I'm using the name returned:

rag_corpus = rag.create_corpus(
embedding_model_config=embedding_model_config,
)
print(f"Created RagCorpus: {rag_corpus.name}")
projects/134776362083/locations/us-central1/ragCorpora/2882303761517117440