20
20
import io
21
21
import json
22
22
import pathlib
23
+ import re
23
24
from typing import (
24
25
Any ,
25
26
AsyncIterable ,
@@ -2273,7 +2274,7 @@ def __init__(
2273
2274
source (VertexAISearch):
2274
2275
Set to use data source powered by Vertex AI Search.
2275
2276
disable_attribution (bool):
2276
- Optional . Disable using the result from this
2277
+ Deprecated . Disable using the result from this
2277
2278
tool in detecting grounding attribution. This
2278
2279
does not affect how the result is given to the
2279
2280
model for generation.
@@ -2284,22 +2285,38 @@ def __init__(
2284
2285
)
2285
2286
2286
2287
class VertexAISearch :
2287
- r"""Retrieve from Vertex AI Search datastore for grounding.
2288
- See https://cloud.google.com/vertex-ai-search-and-conversation
2288
+ r"""Retrieve from Vertex AI Search data store for grounding.
2289
+ See https://cloud.google.com/products/agent-builder
2289
2290
"""
2290
2291
2291
2292
def __init__ (
2292
2293
self ,
2293
2294
datastore : str ,
2295
+ * ,
2296
+ project : Optional [str ] = None ,
2297
+ location : Optional [str ] = None ,
2294
2298
):
2295
2299
"""Initializes a Vertex AI Search tool.
2296
2300
2297
2301
Args:
2298
2302
datastore (str):
2299
- Required. Fully-qualified Vertex AI Search's
2300
- datastore resource ID.
2301
- projects/<>/locations/<>/collections/<>/dataStores/<>
2303
+ Required. Vertex AI Search data store resource name. Format:
2304
+ ``projects/{project}/locations/{location}/collections/default_collection/dataStores/{data_store}``
2305
+ or ``{data_store}``.
2306
+ project (str):
2307
+ Optional. Project ID of the data store. Must provide either the full data store resource name or data store id, project ID, and location.
2308
+ location (str):
2309
+ Optional. Location of the data store. Must provide either the full data store resource name or data store id, project ID, and location.
2302
2310
"""
2311
+ if not re .fullmatch (
2312
+ r"^projects/[a-z0-9-]*/locations/[a-z0-9][a-z0-9-]*/collections/[a-z0-9][a-z0-9-_]*/dataStores/[a-z0-9][a-z0-9-_]*$" ,
2313
+ datastore ,
2314
+ ):
2315
+ if not project or not location :
2316
+ raise ValueError (
2317
+ "Must provide either the full data store resource name or data store id, project ID, and location."
2318
+ )
2319
+ datastore = f"projects/{ project } /locations/{ location } /collections/default_collection/dataStores/{ datastore } "
2303
2320
self ._raw_vertex_ai_search = gapic_tool_types .VertexAISearch (
2304
2321
datastore = datastore ,
2305
2322
)
0 commit comments