Skip to content

Enable VertexAISearchTool for different regions (ex. EU) #3167

@nhellwig

Description

@nhellwig

At the moment when using the DiscoveryEngineSearchTool I could not find a way to specify client_options like api_endpoint.
When having a data store in EU region this leads to an error:

400 Incorrect API endpoint used. The current endpoint can only serve traffic from "global" region, but got "eu" region from the API request. Please follow https://cloud.google.com/generative-ai-app-builder/docs/locations to use the correct regional API endpoint.

My suggestions would be to implement client_options as parameter in DiscoveryEngineSearchTool like this:

class DiscoveryEngineSearchTool(FunctionTool):
  """Tool for searching the discovery engine."""

  def __init__(
      self,
      data_store_id: Optional[str] = None,
      data_store_specs: Optional[
          list[types.VertexAISearchDataStoreSpec]
      ] = None,
      search_engine_id: Optional[str] = None,
      filter: Optional[str] = None,
      max_results: Optional[int] = None,
      client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
  ):

...

     self._discovery_engine_client = discoveryengine.SearchServiceClient(
            client_options=client_options,
            credentials=credentials,
        )
...

I can try to create PR if needed.

Metadata

Metadata

Assignees

Labels

tools[Component] This issue is related to tools

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions