@@ -18,7 +18,9 @@ const generate_dummy_documents = (count: number) => {
18
18
docs . push ( {
19
19
id : i ,
20
20
text : `This is a test document: ${ i } ` ,
21
+ project : "a10" ,
21
22
uuid : i * 10 ,
23
+ floating_uuid : i * 1.1 ,
22
24
name : `Test Document ${ i } ` ,
23
25
} ) ;
24
26
}
@@ -36,7 +38,7 @@ it("can create collection", () => {
36
38
37
39
it ( "can create model" , ( ) => {
38
40
let model = pgml . newModel ( "test" , "openai" , {
39
- "tester" : "test 0123948712394871234987"
41
+ some_example_parameter : "test 0123948712394871234987" ,
40
42
} ) ;
41
43
expect ( model ) . toBeTruthy ( ) ;
42
44
} ) ;
@@ -74,7 +76,7 @@ it("can vector search with local embeddings", async () => {
74
76
await collection . archive ( ) ;
75
77
} ) ;
76
78
77
- it ( "can vector search with remote embeddings" , async ( ) => {
79
+ it ( "can vector search with remote embeddings" , async ( ) => {
78
80
let model = pgml . newModel ( "text-embedding-ada-002" , "openai" ) ;
79
81
let splitter = pgml . newSplitter ( ) ;
80
82
let pipeline = pgml . newPipeline ( "test_j_p_cvswre_0" , model , splitter ) ;
@@ -86,26 +88,34 @@ it("can vector search with remote embeddings", async() => {
86
88
await collection . archive ( ) ;
87
89
} ) ;
88
90
89
- it ( "can vector search with query builder" , async ( ) => {
91
+ it ( "can vector search with query builder" , async ( ) => {
90
92
let model = pgml . newModel ( ) ;
91
93
let splitter = pgml . newSplitter ( ) ;
92
94
let pipeline = pgml . newPipeline ( "test_j_p_cvswqb_0" , model , splitter ) ;
93
95
let collection = pgml . newCollection ( "test_j_c_cvswqb_1" ) ;
94
96
await collection . upsert_documents ( generate_dummy_documents ( 3 ) ) ;
95
97
await collection . add_pipeline ( pipeline ) ;
96
- let results = await collection . query ( ) . vector_recall ( "Here is some query" , pipeline ) . limit ( 10 ) . fetch_all ( ) ;
98
+ let results = await collection
99
+ . query ( )
100
+ . vector_recall ( "Here is some query" , pipeline )
101
+ . limit ( 10 )
102
+ . fetch_all ( ) ;
97
103
expect ( results ) . toHaveLength ( 3 ) ;
98
104
await collection . archive ( ) ;
99
105
} ) ;
100
106
101
- it ( "can vector search with query builder with remote embeddings" , async ( ) => {
107
+ it ( "can vector search with query builder with remote embeddings" , async ( ) => {
102
108
let model = pgml . newModel ( "text-embedding-ada-002" , "openai" ) ;
103
109
let splitter = pgml . newSplitter ( ) ;
104
110
let pipeline = pgml . newPipeline ( "test_j_p_cvswqbwre_0" , model , splitter ) ;
105
111
let collection = pgml . newCollection ( "test_j_c_cvswqbwre_1" ) ;
106
112
await collection . upsert_documents ( generate_dummy_documents ( 3 ) ) ;
107
113
await collection . add_pipeline ( pipeline ) ;
108
- let results = await collection . query ( ) . vector_recall ( "Here is some query" , pipeline ) . limit ( 10 ) . fetch_all ( ) ;
114
+ let results = await collection
115
+ . query ( )
116
+ . vector_recall ( "Here is some query" , pipeline )
117
+ . limit ( 10 )
118
+ . fetch_all ( ) ;
109
119
expect ( results ) . toHaveLength ( 3 ) ;
110
120
await collection . archive ( ) ;
111
121
} ) ;
@@ -122,10 +132,12 @@ it("can vector search with query builder and metadata filtering", async () => {
122
132
. vector_recall ( "Here is some query" , pipeline )
123
133
. filter ( {
124
134
metadata : {
125
- $or : [ { uuid : { $eq : 0 } } , { uuid : { $eq : 20 } } ] ,
135
+ $or : [ { uuid : { $eq : 0 } } , { floating_uuid : { $lt : 2 } } ] ,
136
+ project : { $eq : "a10" } ,
126
137
} ,
127
138
} )
128
- . limit ( 10 ) . fetch_all ( ) ;
139
+ . limit ( 10 )
140
+ . fetch_all ( ) ;
129
141
expect ( results ) . toHaveLength ( 2 ) ;
130
142
await collection . archive ( ) ;
131
143
} ) ;
@@ -141,7 +153,6 @@ it("pipeline to dict", async () => {
141
153
let collection = pgml . newCollection ( "test_j_c_ptd_2" ) ;
142
154
await collection . add_pipeline ( pipeline ) ;
143
155
let pipeline_dict = await pipeline . to_dict ( ) ;
144
- console . log ( JSON . stringify ( pipeline_dict ) )
145
156
expect ( pipeline_dict [ "name" ] ) . toBe ( "test_j_p_ptd_0" ) ;
146
157
await collection . archive ( ) ;
147
158
} ) ;
0 commit comments