generative-ai
generative-ai copied to clipboard
How to query a public endpoint in matching engine.
**I have created a public endpoint to deploy the indexes.
Like this:**
my_index = aiplatform.MatchingEngineIndex.create_tree_ah_index(
display_name=DISPLAY_NAME,
contents_delta_uri=EMBED_URI, **//Path the embedding bucket**
dimensions=ME_DIMENSIONS,
approximate_neighbors_count=150,
distance_measure_type="DOT_PRODUCT_DISTANCE",
)
Then deployed the index to public endpoint
my_index_endpoint = aiplatform.MatchingEngineIndexEndpoint.create(
display_name=f"index_endpoint_for_demo_new",
public_endpoint_enabled= True
)
DEPLOYED_INDEX_ID = f"index_endpoint_for_demo_new"
my_index_endpoint = my_index_endpoint.deploy_index(
index=my_index, deployed_index_id=DEPLOYED_INDEX_ID
)
my_index_endpoint.deployed_indexes
Now I have created a vector store from the deployed endpoint and created index
vector_store = MatchingEngine.from_components(
project_id=PROJECT_ID,
region=REGION,
gcs_bucket_name=EMBED_URI,
index_id="#####",
endpoint_id="#####",
)
Now when I am don't similarity search like this:
vector_store.similarity_search("American Home Shield Corporation", k=2)
It's throwing error
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "DNS resolution failed for :10000: unparseable host:port"
debug_error_string = "UNKNOWN:DNS resolution failed for :10000: unparseable host:port {created_time:"2023-08-07T08:51:47.728727082+00:00", grpc_status:14}"
>
How to solve this issue?
Do you get any value from endpoint_address = self.endpoint.public_endpoint_domain_name?
You can also find the publish address from this code
from google.cloud import aiplatform_v1
ENDPOINT = f"{REGION}-aiplatform.googleapis.com"
index_endpoint_client = aiplatform_v1.IndexEndpointServiceClient(
client_options=dict(api_endpoint=ENDPOINT)
)
request = aiplatform_v1.GetIndexEndpointRequest(
name=f"projects/{PROJECT_ID}/locations/{REGION}/indexEndpoints/{INDEX_ENDPOIN_ID}"
)
result = index_endpoint_client.get_index_endpoint(
request=request
)
print(result)
No I didin't get any value from endpoint_address. Using above code its throwing this error.
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "DNS resolution failed for 7188510265376243712:443: C-ares status is not ARES_SUCCESS qtype=A name=7188510265376243712 is_balancer=0: Domain name not found"
debug_error_string = "UNKNOWN:DNS resolution failed for 7188510265376243712:443: C-ares status is not ARES_SUCCESS qtype=A name=7188510265376243712 is_balancer=0: Domain name not found {created_time:"2023-08-08T05:30:25.908008902+00:00", grpc_status:14}"
>
Here's an additional notebook in the vertex-ai-samples repository that shows how to create and query a Matching Engine (Vertex AI Vector Search) index.
https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/sdk_matching_engine_for_indexing.ipynb