Skip to content
File

Blob: src/cloudflare/internal/test/vectorize/vectorize-api-test.py

python24 lines
1# Copyright (c) 2023 Cloudflare, Inc.
2# Licensed under the Apache 2.0 license found in the LICENSE file or at:
3# https://opensource.org/licenses/Apache-2.0
4 
5from js import Float32Array
6 
7 
8async def test(context, env):
9 IDX = env.vectorSearch
10 
11 res_array = [0] * 5
12 results = await IDX.query(
13 Float32Array.new(res_array),
14 topK=3,
15 returnValues=True,
16 returnMetadata=True,
17 )
18 assert results.count > 0
19 assert results.matches[0].id == "b0daca4a-ffd8-4865-926b-e24800af2a2d"
20 assert (
21 results.matches[1].metadata.text
22 == "Peter Piper picked a peck of pickled peppers"
23 )