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

VertexAISearch (grounding from data store). 400 Request contains an invalid argument.

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.

msdavid_0-1720856963870.png

I carefully double checked the path of the datastore and all other params. 

bug?

I'll appreciate any help or pointers.

Thank you. 

8 REPLIES 8

I'm not sure, but try removing or escaping the question mark in your prompt text see if that's what causing the problem.

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 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.

All working now!

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

 

def generate_grounded_content(data_store_path: str, generation_config: PartsType, safety_settings: SafetySettingsType,
model: generative_models.GenerativeModel, prompt: str):
tool = Tool.from_retrieval(
grounding.Retrieval(grounding.VertexAISearch(datastore=data_store_path))
)
logger.info(f"Tool created")
response = model.generate_content(
prompt,
tools=[tool],
generation_config=GenerationConfig(temperature=0.0, max_output_tokens=8192, top_p=0.95, top_k=40),
safety_settings=safety_settings
)
logger.info(f"Response received")
response_text = response.text
logger.info(f"Response text: {response_text}")
return response_text

have you been able to fix this? I am having the same issue too.

me too, having the same issue:

Failed to submit prompt
Error message: "Request contains an invalid argument."

Status: 400 Error code: 3

Request ID: 6924843284189509449

Any updates with this issue?
I am stuck on this issue for the last 2 months.

Hi:

I am having the same issue. I created a structured data store with the attached schema.

data_store_schema.png

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? 

It would be a good first step. 

Status 400 error code: 3