@@ -18,7 +18,9 @@ const generate_dummy_documents = (count: number) => {
1818docs . push ( {
1919id :i ,
2020text :`This is a test document:${ i } ` ,
21+ project :"a10" ,
2122uuid :i * 10 ,
23+ floating_uuid :i * 1.1 ,
2224name :`Test Document${ i } ` ,
2325} ) ;
2426}
@@ -36,7 +38,7 @@ it("can create collection", () => {
3638
3739it ( "can create model" , ( ) => {
3840let model = pgml . newModel ( "test" , "openai" , {
39- "tester" :"test 0123948712394871234987"
41+ some_example_parameter :"test 0123948712394871234987" ,
4042} ) ;
4143expect ( model ) . toBeTruthy ( ) ;
4244} ) ;
@@ -74,7 +76,7 @@ it("can vector search with local embeddings", async () => {
7476await collection . archive ( ) ;
7577} ) ;
7678
77- it ( "can vector search with remote embeddings" , async ( ) => {
79+ it ( "can vector search with remote embeddings" , async ( ) => {
7880let model = pgml . newModel ( "text-embedding-ada-002" , "openai" ) ;
7981let splitter = pgml . newSplitter ( ) ;
8082let pipeline = pgml . newPipeline ( "test_j_p_cvswre_0" , model , splitter ) ;
@@ -86,26 +88,34 @@ it("can vector search with remote embeddings", async() => {
8688await collection . archive ( ) ;
8789} ) ;
8890
89- it ( "can vector search with query builder" , async ( ) => {
91+ it ( "can vector search with query builder" , async ( ) => {
9092let model = pgml . newModel ( ) ;
9193let splitter = pgml . newSplitter ( ) ;
9294let pipeline = pgml . newPipeline ( "test_j_p_cvswqb_0" , model , splitter ) ;
9395let collection = pgml . newCollection ( "test_j_c_cvswqb_1" ) ;
9496await collection . upsert_documents ( generate_dummy_documents ( 3 ) ) ;
9597await 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 ( ) ;
97103expect ( results ) . toHaveLength ( 3 ) ;
98104await collection . archive ( ) ;
99105} ) ;
100106
101- it ( "can vector search with query builder with remote embeddings" , async ( ) => {
107+ it ( "can vector search with query builder with remote embeddings" , async ( ) => {
102108let model = pgml . newModel ( "text-embedding-ada-002" , "openai" ) ;
103109let splitter = pgml . newSplitter ( ) ;
104110let pipeline = pgml . newPipeline ( "test_j_p_cvswqbwre_0" , model , splitter ) ;
105111let collection = pgml . newCollection ( "test_j_c_cvswqbwre_1" ) ;
106112await collection . upsert_documents ( generate_dummy_documents ( 3 ) ) ;
107113await 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 ( ) ;
109119expect ( results ) . toHaveLength ( 3 ) ;
110120await collection . archive ( ) ;
111121} ) ;
@@ -122,10 +132,12 @@ it("can vector search with query builder and metadata filtering", async () => {
122132. vector_recall ( "Here is some query" , pipeline )
123133. filter ( {
124134metadata :{
125- $or :[ { uuid :{ $eq :0 } } , { uuid :{ $eq :20 } } ] ,
135+ $or :[ { uuid :{ $eq :0 } } , { floating_uuid :{ $lt :2 } } ] ,
136+ project :{ $eq :"a10" } ,
126137} ,
127138} )
128- . limit ( 10 ) . fetch_all ( ) ;
139+ . limit ( 10 )
140+ . fetch_all ( ) ;
129141expect ( results ) . toHaveLength ( 2 ) ;
130142await collection . archive ( ) ;
131143} ) ;
@@ -141,7 +153,6 @@ it("pipeline to dict", async () => {
141153let collection = pgml . newCollection ( "test_j_c_ptd_2" ) ;
142154await collection . add_pipeline ( pipeline ) ;
143155let pipeline_dict = await pipeline . to_dict ( ) ;
144- console . log ( JSON . stringify ( pipeline_dict ) )
145156expect ( pipeline_dict [ "name" ] ) . toBe ( "test_j_p_ptd_0" ) ;
146157await collection . archive ( ) ;
147158} ) ;