I am trying to use the Vertex AI search grounding. I followed this notebook.
I keep getting a InvalidArgument: 400 Request contains an invalid argument.
this is my stripped down code:
import vertexai
from vertexai.generative_models import Tool, GenerativeModel
from vertexai.preview.generative_models import grounding as preview_grounding
DATA_STORE_ID = "xxxx_1720852873938"
DATA_STORE_PROJECT_ID = "xxxxx"
DATA_STORE_REGION="global"
vertexai.init(project=DATA_STORE_PROJECT_ID, location='us-central1')
datastore = f"projects/{DATA_STORE_PROJECT_ID}/locations/{DATA_STORE_REGION}/collections/default_collection/dataStores/{DATA_STORE_ID}"
tool = Tool.from_retrieval(
preview_grounding.Retrieval(preview_grounding.VertexAISearch(datastore=datastore))
)
model = GenerativeModel("gemini-1.5-pro-001")
PROMPT = "what does a F rating mean?"
response = model.generate_content(PROMPT, tools=[tool])
print(response)
The interesting thing is that vertex studio fails with the same error.
it seems that the error message has been updated now and the documentation too:
InvalidArgument: 400 Cannot use enterprise edition features (website search, multi-modal search, extractive answers/segments, etc.) in a standard edition search engine. Please follow [https://cloud.google.com/generative-ai-app-builder/docs/enterprise-edition#toggle-enterprise](https://cloud.google.com/generative-ai-app-builder/docs/enterprise-edition#toggle-enterprise) to enable Enterprise edition.
For anyone with the same issue: You need to create a dummy App in agent builder and associate the data store to it. Then enable Enterprise Edition in the configuration of the app before using it for grounding.
I have created a dummy app with enterprise enabled feature and connected it to a data store which is connected to a gcs pdf file with synchronization every 24 hours.
I am using Gemini flash model: gemini-1.5-flash-001
This is my sample code which always is still returning error:: 400 Request contains an invalid argument. Any suggestions
I also created a generic search app with enterprise enabled and connected it to the above schema.
I am using the following code to use the data store in my vertex ai search and get the “InvalidArgument: 400 Request contains an invalid argument.” error. Any help would be appreciated.
mport vertexai
from IPython.display import Markdown, display
from vertexai.preview.generative_models import (
GenerationConfig,
GenerativeModel,
Tool,
grounding,
)
DATA_STORE_ID = "care-plan-templates_1726575266786"
DATA_STORE_PROJECT_ID = 'xxxxx'
DATA_STORE_REGION = 'global'
# TODO (developer): update project_id
vertexai.init(project=DATA_STORE_PROJECT_ID, location="us-central1")
model = GenerativeModel("gemini-1.0-pro")
data_store = f"projects/{DATA_STORE_PROJECT_ID}/locations/{DATA_STORE_REGION}/collections/default_collection/dataStores/{DATA_STORE_ID}"
tool = Tool.from_retrieval(
grounding.Retrieval(
grounding.VertexAISearch(datastore=data_store)
)
)
prompt = "what is the care plan for the chronic condition asthma?"
# try:
response = model.generate_content(prompt,
tools=[tool],
generation_config=GenerationConfig(
temperature=0.0,
),
)
display(Markdown(response.text))
I am much less lettered in coding than everyone here, but I would love to understand at least where the problem is: in the bucket? in the dummy app? in the chat request?