Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for metadata values of type array #18

Merged
merged 1 commit into from
May 14, 2024
Merged

Conversation

jgpruitt
Copy link
Collaborator

@jgpruitt jgpruitt commented Apr 8, 2024

Metadata values containing jsonb arrays are now supported. Predicates can take a list as a value. A comparison operator of "@>" now tests for array containment. This is an indexed operation.

await vec.upsert([
    (uuid.uuid4(), '''{"key0": [1,2,3,4]}''', "the brown fox", [1.0, 1.8]),
    (uuid.uuid4(), '''{"key0": [5,6,7], "key3": 3}''', "the brown fox", [1.0, 1.8]),
])
rec = await vec.search([1.0, 2.0], limit=4, predicates=Predicates("key0", "@>", [1, 2]))
assert len(rec) == 1
rec = await vec.search([1.0, 2.0], limit=4, predicates=Predicates("key0", "@>", [3, 7]))
assert len(rec) == 0
rec = await vec.search([1.0, 2.0], limit=4, predicates=Predicates("key0", "@>", [9]))
assert len(rec) == 0
rec = await vec.search([1.0, 2.0], limit=4, predicates=Predicates("key0", "@>", [4]))
assert len(rec) == 1

rec = await vec.search([1.0, 2.0], limit=4, predicates=Predicates("key0", "@>", [6,7]) and Predicates("key3","==", 3))
assert len(rec) == 1
rec = await vec.search([1.0, 2.0], limit=4, predicates=Predicates("key0", "@>", [6,7]) and Predicates("key3","==", 6))
assert len(rec) == 0

@jgpruitt jgpruitt requested a review from cevian April 8, 2024 20:10
@jgpruitt jgpruitt self-assigned this Apr 8, 2024
Copy link
Collaborator

@cevian cevian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes requested

timescale_vector/client.py Show resolved Hide resolved
timescale_vector/client.py Outdated Show resolved Hide resolved
@jgpruitt jgpruitt requested a review from cevian April 9, 2024 18:19
timescale_vector/client.py Show resolved Hide resolved
Copy link
Collaborator

@cevian cevian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. will talk to you about how to run the nbdev commands

Predicates can take a list as a value. A comparison operator
of "@>" now tests for array containment. This is an indexed
operation. We allow for list/tuple PredicateValues with
elements of mixed type.

Fixes to upgrade to latest openai
@jgpruitt jgpruitt merged commit f6da527 into main May 14, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants