Skip to content

Commit f6da527

Browse files
authored
Metadata values containing jsonb arrays are now supported. (#18)
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
1 parent babd036 commit f6da527

File tree

7 files changed

+205
-195
lines changed

7 files changed

+205
-195
lines changed

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ Now, you can query for similar items:
120120
vec.search([1.0, 9.0])
121121
```
122122

123-
[[UUID('73d05df0-84c1-11ee-98da-6ee10b77fd08'),
123+
[[UUID('45ecb666-0f15-11ef-8d89-e666703872d0'),
124124
{'action': 'jump', 'animal': 'fox'},
125125
'jumped over the',
126126
array([ 1. , 10.8], dtype=float32),
127127
0.00016793422934946456],
128-
[UUID('73d05d6e-84c1-11ee-98da-6ee10b77fd08'),
128+
[UUID('45ecb350-0f15-11ef-8d89-e666703872d0'),
129129
{'animal': 'fox'},
130130
'the brown fox',
131131
array([1. , 1.3], dtype=float32),
@@ -141,7 +141,7 @@ constrained by a metadata filter.
141141
vec.search([1.0, 9.0], limit=1, filter={"action": "jump"})
142142
```
143143

144-
[[UUID('73d05df0-84c1-11ee-98da-6ee10b77fd08'),
144+
[[UUID('45ecb666-0f15-11ef-8d89-e666703872d0'),
145145
{'action': 'jump', 'animal': 'fox'},
146146
'jumped over the',
147147
array([ 1. , 10.8], dtype=float32),
@@ -165,7 +165,7 @@ records = vec.search([1.0, 9.0], limit=1, filter={"action": "jump"})
165165
(records[0]["id"],records[0]["metadata"], records[0]["contents"], records[0]["embedding"], records[0]["distance"])
166166
```
167167

168-
(UUID('73d05df0-84c1-11ee-98da-6ee10b77fd08'),
168+
(UUID('45ecb666-0f15-11ef-8d89-e666703872d0'),
169169
{'action': 'jump', 'animal': 'fox'},
170170
'jumped over the',
171171
array([ 1. , 10.8], dtype=float32),
@@ -228,12 +228,12 @@ The basic query looks like:
228228
vec.search([1.0, 9.0])
229229
```
230230

231-
[[UUID('7487af96-84c1-11ee-98da-6ee10b77fd08'),
231+
[[UUID('4d629b54-0f15-11ef-8d89-e666703872d0'),
232232
{'times': 100, 'action': 'jump', 'animal': 'fox'},
233233
'jumped over the',
234234
array([ 1. , 10.8], dtype=float32),
235235
0.00016793422934946456],
236-
[UUID('7487af14-84c1-11ee-98da-6ee10b77fd08'),
236+
[UUID('4d629a50-0f15-11ef-8d89-e666703872d0'),
237237
{'times': 1, 'action': 'sit', 'animal': 'fox'},
238238
'the brown fox',
239239
array([1. , 1.3], dtype=float32),
@@ -245,7 +245,7 @@ You could provide a limit for the number of items returned:
245245
vec.search([1.0, 9.0], limit=1)
246246
```
247247

248-
[[UUID('7487af96-84c1-11ee-98da-6ee10b77fd08'),
248+
[[UUID('4d629b54-0f15-11ef-8d89-e666703872d0'),
249249
{'times': 100, 'action': 'jump', 'animal': 'fox'},
250250
'jumped over the',
251251
array([ 1. , 10.8], dtype=float32),
@@ -270,7 +270,7 @@ unconstrained):
270270
vec.search([1.0, 9.0], limit=1, filter={"action": "sit"})
271271
```
272272

273-
[[UUID('7487af14-84c1-11ee-98da-6ee10b77fd08'),
273+
[[UUID('4d629a50-0f15-11ef-8d89-e666703872d0'),
274274
{'times': 1, 'action': 'sit', 'animal': 'fox'},
275275
'the brown fox',
276276
array([1. , 1.3], dtype=float32),
@@ -283,12 +283,12 @@ returned if it matches any dict:
283283
vec.search([1.0, 9.0], limit=2, filter=[{"action": "jump"}, {"animal": "fox"}])
284284
```
285285

286-
[[UUID('7487af96-84c1-11ee-98da-6ee10b77fd08'),
286+
[[UUID('4d629b54-0f15-11ef-8d89-e666703872d0'),
287287
{'times': 100, 'action': 'jump', 'animal': 'fox'},
288288
'jumped over the',
289289
array([ 1. , 10.8], dtype=float32),
290290
0.00016793422934946456],
291-
[UUID('7487af14-84c1-11ee-98da-6ee10b77fd08'),
291+
[UUID('4d629a50-0f15-11ef-8d89-e666703872d0'),
292292
{'times': 1, 'action': 'sit', 'animal': 'fox'},
293293
'the brown fox',
294294
array([1. , 1.3], dtype=float32),
@@ -303,7 +303,7 @@ could use greater than and less than conditions on numeric values.
303303
vec.search([1.0, 9.0], limit=2, predicates=client.Predicates("times", ">", 1))
304304
```
305305

306-
[[UUID('7487af96-84c1-11ee-98da-6ee10b77fd08'),
306+
[[UUID('4d629b54-0f15-11ef-8d89-e666703872d0'),
307307
{'times': 100, 'action': 'jump', 'animal': 'fox'},
308308
'jumped over the',
309309
array([ 1. , 10.8], dtype=float32),
@@ -327,7 +327,7 @@ use the right type. Supported Python types are: `str`, `int`, and
327327
vec.search([1.0, 9.0], limit=2, predicates=client.Predicates("action", "==", "jump"))
328328
```
329329

330-
[[UUID('7487af96-84c1-11ee-98da-6ee10b77fd08'),
330+
[[UUID('4d629b54-0f15-11ef-8d89-e666703872d0'),
331331
{'times': 100, 'action': 'jump', 'animal': 'fox'},
332332
'jumped over the',
333333
array([ 1. , 10.8], dtype=float32),
@@ -341,7 +341,7 @@ combining using OR semantic). So you can do:
341341
vec.search([1.0, 9.0], limit=2, predicates=client.Predicates("action", "==", "jump") & client.Predicates("times", ">", 1))
342342
```
343343

344-
[[UUID('7487af96-84c1-11ee-98da-6ee10b77fd08'),
344+
[[UUID('4d629b54-0f15-11ef-8d89-e666703872d0'),
345345
{'times': 100, 'action': 'jump', 'animal': 'fox'},
346346
'jumped over the',
347347
array([ 1. , 10.8], dtype=float32),
@@ -364,7 +364,7 @@ my_predicates = client.Predicates("action", "==", "jump") & (client.Predicates("
364364
vec.search([1.0, 9.0], limit=2, predicates=my_predicates)
365365
```
366366

367-
[[UUID('7487af96-84c1-11ee-98da-6ee10b77fd08'),
367+
[[UUID('4d629b54-0f15-11ef-8d89-e666703872d0'),
368368
{'times': 100, 'action': 'jump', 'animal': 'fox'},
369369
'jumped over the',
370370
array([ 1. , 10.8], dtype=float32),
@@ -378,7 +378,7 @@ semantics. You can pass in multiple 3-tuples to
378378
vec.search([1.0, 9.0], limit=2, predicates=client.Predicates(("action", "==", "jump"), ("times", ">", 10)))
379379
```
380380

381-
[[UUID('7487af96-84c1-11ee-98da-6ee10b77fd08'),
381+
[[UUID('4d629b54-0f15-11ef-8d89-e666703872d0'),
382382
{'times': 100, 'action': 'jump', 'animal': 'fox'},
383383
'jumped over the',
384384
array([ 1. , 10.8], dtype=float32),
@@ -410,7 +410,7 @@ Then, you can filter using the timestamps by specifing a
410410
tpvec.search([1.0, 9.0], limit=4, uuid_time_filter=client.UUIDTimeRange(specific_datetime, specific_datetime+timedelta(days=1)))
411411
```
412412

413-
[[UUID('33c52800-ef15-11e7-be03-4f1f9a1bde5a'),
413+
[[UUID('95899000-ef1d-11e7-990e-7d2f7e013038'),
414414
{'times': 1, 'action': 'sit', 'animal': 'fox'},
415415
'the brown fox',
416416
array([1. , 1.3], dtype=float32),
@@ -426,12 +426,12 @@ unconstrained.
426426
tpvec.search([1.0, 9.0], limit=4, uuid_time_filter=client.UUIDTimeRange(start_date=specific_datetime))
427427
```
428428

429-
[[UUID('ac8be800-0de6-11e9-889a-5eec84ba8a7b'),
429+
[[UUID('0e505000-0def-11e9-8732-a154fea6fb50'),
430430
{'times': 100, 'action': 'jump', 'animal': 'fox'},
431431
'jumped over the',
432432
array([ 1. , 10.8], dtype=float32),
433433
0.00016793422934946456],
434-
[UUID('33c52800-ef15-11e7-be03-4f1f9a1bde5a'),
434+
[UUID('95899000-ef1d-11e7-990e-7d2f7e013038'),
435435
{'times': 1, 'action': 'sit', 'animal': 'fox'},
436436
'the brown fox',
437437
array([1. , 1.3], dtype=float32),
@@ -448,7 +448,7 @@ One example:
448448
tpvec.search([1.0, 9.0], limit=4, uuid_time_filter=client.UUIDTimeRange(start_date=specific_datetime, start_inclusive=False))
449449
```
450450

451-
[[UUID('ac8be800-0de6-11e9-889a-5eec84ba8a7b'),
451+
[[UUID('0e505000-0def-11e9-8732-a154fea6fb50'),
452452
{'times': 100, 'action': 'jump', 'animal': 'fox'},
453453
'jumped over the',
454454
array([ 1. , 10.8], dtype=float32),
@@ -470,7 +470,7 @@ filters and `__uuid_timestamp` for predicates. Some examples below:
470470
tpvec.search([1.0, 9.0], limit=4, filter={ "__start_date": specific_datetime, "__end_date": specific_datetime+timedelta(days=1)})
471471
```
472472

473-
[[UUID('33c52800-ef15-11e7-be03-4f1f9a1bde5a'),
473+
[[UUID('95899000-ef1d-11e7-990e-7d2f7e013038'),
474474
{'times': 1, 'action': 'sit', 'animal': 'fox'},
475475
'the brown fox',
476476
array([1. , 1.3], dtype=float32),
@@ -481,7 +481,7 @@ tpvec.search([1.0, 9.0], limit=4,
481481
predicates=client.Predicates("__uuid_timestamp", ">", specific_datetime) & client.Predicates("__uuid_timestamp", "<", specific_datetime+timedelta(days=1)))
482482
```
483483

484-
[[UUID('33c52800-ef15-11e7-be03-4f1f9a1bde5a'),
484+
[[UUID('95899000-ef1d-11e7-990e-7d2f7e013038'),
485485
{'times': 1, 'action': 'sit', 'animal': 'fox'},
486486
'the brown fox',
487487
array([1. , 1.3], dtype=float32),
@@ -850,7 +850,7 @@ import psycopg2
850850
from langchain.docstore.document import Document
851851
from langchain.text_splitter import CharacterTextSplitter
852852
from timescale_vector import client, pgvectorizer
853-
from langchain.embeddings.openai import OpenAIEmbeddings
853+
from langchain_openai import OpenAIEmbeddings
854854
from langchain.vectorstores.timescalevector import TimescaleVector
855855
from datetime import timedelta
856856
```
@@ -963,8 +963,8 @@ res = vector_store.similarity_search_with_score("Blogs about cats")
963963
res
964964
```
965965

966-
[(Document(page_content='Author Matvey Arye, title: First Post, contents:some super interesting content about cats.', metadata={'id': '4a784000-4bc4-11eb-855a-06302dbc8ce7', 'author': 'Matvey Arye', 'blog_id': 1, 'category': 'AI', 'published_time': '2021-01-01T00:00:00+00:00'}),
967-
0.12595687795193833)]
966+
[(Document(page_content='Author Matvey Arye, title: First Post, contents:some super interesting content about cats.', metadata={'id': '4a784000-4bc4-11eb-979c-e8748f6439f2', 'author': 'Matvey Arye', 'blog_id': 1, 'category': 'AI', 'published_time': '2021-01-01T00:00:00+00:00'}),
967+
0.12657619616729976)]
968968

969969
## Development
970970

0 commit comments

Comments
 (0)