Git Product home page Git Product logo

Comments (7)

eddie-scio avatar eddie-scio commented on July 21, 2024 1

It would be great to have this! It'll unblock some of our use cases that require item lookups (with Python API, on VPC)

from python-aiplatform.

thundercat1 avatar thundercat1 commented on July 21, 2024

+1 - the docs include an example of querying by document ID with the grpc cli, but the python client seems like it might be missing this.

from python-aiplatform.

sshcherbakov avatar sshcherbakov commented on July 21, 2024

Getting the same error just following the default Python example at https://cloud.google.com/vertex-ai/docs/vector-search/quickstart :

PROJECT_ID="my_project_id"
PROJECT_NUMBER="811111111111"
LOCATION="europe-west3"
INDEX_ENDPOINT_NAME="test-index-endpoint"
INDEX_ENDPOINT_ID="4444444444444444444"
DEPLOYED_INDEX_ID="my_deployed_test_index"

aiplatform.init(project=PROJECT_ID, location=LOCATION)

my_index_endpoint = aiplatform.MatchingEngineIndexEndpoint(
    index_endpoint_name = INDEX_ENDPOINT_ID,
    project = PROJECT_NUMBER,
    location = LOCATION
)


product_names = {}
product_embs = {}
with open('product-embs.json') as f:
    for l in f.readlines():
        p = json.loads(l)
        id = p['id']
        product_names[id] = p['name']
        product_embs[id] = p['embedding']

query_emb = product_embs['6523']

response = my_index_endpoint.find_neighbors(
    deployed_index_id = DEPLOYED_INDEX_ID,
    queries = [query_emb],
    num_neighbors = 10
)

for idx, neighbor in enumerate(response[0]):
    print(f"{neighbor.distance:.2f} {product_names[neighbor.id]}")

from python-aiplatform.

tottenjordan avatar tottenjordan commented on July 21, 2024

@matthewsparr is your workbench instance also within the same VPC?

from python-aiplatform.

kazunori279 avatar kazunori279 commented on July 21, 2024

@sshcherbakov The example works with a public endpoint, not with a VPC. We will add a note to the sample code.

from python-aiplatform.

Ludovic-Emo-Pyl-Tech avatar Ludovic-Emo-Pyl-Tech commented on July 21, 2024

+1

The query example page provided for a VPC endpoint context are using low level grpc calls: https://cloud.google.com/vertex-ai/docs/vector-search/query-index-vpc

The query example page for a public endpoint is using python:
https://cloud.google.com/vertex-ai/docs/vector-search/query-index-public-endpoint

Would someone have a working example in a VPC context in python in Cloud Run ?
We have tried to do it but could not achieve it so far.

from python-aiplatform.

lingyinw avatar lingyinw commented on July 21, 2024

read_index_datapoints() now support private service access endpoints, please update to or later https://pypi.org/project/google-cloud-aiplatform/1.38.0/.

from python-aiplatform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.