@@ -949,132 +949,132 @@ describe('Testing of the collection.query methods with a multi-tenancy collectio
949949 } ) ;
950950} ) ;
951951
952- const maybe = process . env . OPENAI_APIKEY ? describe : describe . skip ;
953-
954- maybe ( 'Testing of collection.query using rerank functionality' , ( ) => {
955- let client : WeaviateClient ;
956- let collection : Collection ;
957- const collectionName = 'TestCollectionRerank' ;
958- let id1 : string ;
959- let id2 : string ;
960-
961- afterAll ( ( ) => {
962- return client . collections . delete ( collectionName ) . catch ( ( err ) => {
963- console . error ( err ) ;
964- throw err ;
965- } ) ;
966- } ) ;
967-
968- beforeAll ( async ( ) => {
969- client = await weaviate . connectToLocal ( {
970- port : 8079 ,
971- grpcPort : 50050 ,
972- headers : {
973- 'X-OpenAI-Api-Key' : process . env . OPENAI_APIKEY as string ,
974- } ,
975- } ) ;
976- collection = client . collections . get ( collectionName ) ;
977- [ id1 , id2 ] = await client . collections
978- . create ( {
979- name : collectionName ,
980- properties : [
981- {
982- name : 'text' ,
983- dataType : 'text' ,
984- } ,
985- ] ,
986- reranker : weaviate . configure . reranker . transformers ( ) ,
987- vectorizers : weaviate . configure . vectorizer . text2VecOpenAI ( ) ,
988- } )
989- . then ( ( ) =>
990- Promise . all ( [
991- collection . data . insert ( {
992- properties : {
993- text : 'This is a test' ,
994- } ,
995- } ) ,
996- collection . data . insert ( {
997- properties : {
998- text : 'This is another test' ,
999- } ,
1000- } ) ,
1001- ] )
1002- ) ;
1003- } ) ;
1004-
1005- it ( 'should rerank the results in a bm25 query' , async ( ) => {
1006- const ret = await collection . query . bm25 ( 'test' , {
1007- rerank : {
1008- property : 'text' ,
1009- query : 'another' ,
1010- } ,
1011- } ) ;
1012- const objects = ret . objects ;
1013- expect ( objects . length ) . toEqual ( 2 ) ;
1014- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1015- expect ( objects [ 0 ] . properties . text ) . toEqual ( 'This is another test' ) ;
1016- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1017- expect ( objects [ 1 ] . properties . text ) . toEqual ( 'This is a test' ) ;
1018- } ) ;
1019-
1020- it ( 'should rerank the results in a hybrid query' , async ( ) => {
1021- const ret = await collection . query . hybrid ( 'test' , {
1022- rerank : {
1023- property : 'text' ,
1024- query : 'another' ,
1025- } ,
1026- } ) ;
1027- const objects = ret . objects ;
1028- expect ( objects . length ) . toEqual ( 2 ) ;
1029- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1030- expect ( objects [ 0 ] . properties . text ) . toEqual ( 'This is another test' ) ;
1031- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1032- expect ( objects [ 1 ] . properties . text ) . toEqual ( 'This is a test' ) ;
1033- } ) ;
1034-
1035- it . skip ( 'should rerank the results in a nearObject query' , async ( ) => {
1036- const ret = await collection . query . nearObject ( id1 , {
1037- rerank : {
1038- property : 'text' ,
1039- query : 'another' ,
1040- } ,
1041- } ) ;
1042- const objects = ret . objects ;
1043- expect ( objects . length ) . toEqual ( 2 ) ;
1044- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1045- expect ( objects [ 0 ] . properties . text ) . toEqual ( 'This is another test' ) ;
1046- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1047- expect ( objects [ 1 ] . properties . text ) . toEqual ( 'This is a test' ) ;
1048- } ) ;
1049-
1050- it ( 'should rerank the results in a nearText query' , async ( ) => {
1051- const ret = await collection . query . nearText ( 'text' , {
1052- rerank : {
1053- property : 'text' ,
1054- query : 'another' ,
1055- } ,
1056- } ) ;
1057- const objects = ret . objects ;
1058- expect ( objects . length ) . toEqual ( 2 ) ;
1059- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1060- expect ( objects [ 0 ] . properties . text ) . toEqual ( 'This is another test' ) ;
1061- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1062- expect ( objects [ 1 ] . properties . text ) . toEqual ( 'This is a test' ) ;
1063- } ) ;
1064-
1065- it . skip ( 'should rerank the results in a nearObject query' , async ( ) => {
1066- const obj = await collection . query . fetchObjectById ( id1 , { includeVector : true } ) ;
1067- const ret = await collection . query . nearVector ( obj ?. vectors . default ! , {
1068- rerank : {
1069- property : 'text' ,
1070- query : 'another' ,
1071- } ,
1072- } ) ;
1073- const objects = ret . objects ;
1074- expect ( objects . length ) . toEqual ( 2 ) ;
1075- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1076- expect ( objects [ 0 ] . properties . text ) . toEqual ( 'This is another test' ) ;
1077- expect ( objects [ 0 ] . metadata ?. rerankScore ) . toBeDefined ( ) ;
1078- expect ( objects [ 1 ] . properties . text ) . toEqual ( 'This is a test' ) ;
1079- } ) ;
1080- } ) ;
952+ // const maybe = process.env.OPENAI_APIKEY ? describe : describe.skip;
953+
954+ // maybe('Testing of collection.query using rerank functionality', () => {
955+ // let client: WeaviateClient;
956+ // let collection: Collection;
957+ // const collectionName = 'TestCollectionRerank';
958+ // let id1: string;
959+ // let id2: string;
960+
961+ // afterAll(() => {
962+ // return client.collections.delete(collectionName).catch((err) => {
963+ // console.error(err);
964+ // throw err;
965+ // });
966+ // });
967+
968+ // beforeAll(async () => {
969+ // client = await weaviate.connectToLocal({
970+ // port: 8079,
971+ // grpcPort: 50050,
972+ // headers: {
973+ // 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string,
974+ // },
975+ // });
976+ // collection = client.collections.get(collectionName);
977+ // [id1, id2] = await client.collections
978+ // .create({
979+ // name: collectionName,
980+ // properties: [
981+ // {
982+ // name: 'text',
983+ // dataType: 'text',
984+ // },
985+ // ],
986+ // reranker: weaviate.configure.reranker.transformers(),
987+ // vectorizers: weaviate.configure.vectorizer.text2VecOpenAI(),
988+ // })
989+ // .then(() =>
990+ // Promise.all([
991+ // collection.data.insert({
992+ // properties: {
993+ // text: 'This is a test',
994+ // },
995+ // }),
996+ // collection.data.insert({
997+ // properties: {
998+ // text: 'This is another test',
999+ // },
1000+ // }),
1001+ // ])
1002+ // );
1003+ // });
1004+
1005+ // it('should rerank the results in a bm25 query', async () => {
1006+ // const ret = await collection.query.bm25('test', {
1007+ // rerank: {
1008+ // property: 'text',
1009+ // query: 'another',
1010+ // },
1011+ // });
1012+ // const objects = ret.objects;
1013+ // expect(objects.length).toEqual(2);
1014+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1015+ // expect(objects[0].properties.text).toEqual('This is another test');
1016+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1017+ // expect(objects[1].properties.text).toEqual('This is a test');
1018+ // });
1019+
1020+ // it('should rerank the results in a hybrid query', async () => {
1021+ // const ret = await collection.query.hybrid('test', {
1022+ // rerank: {
1023+ // property: 'text',
1024+ // query: 'another',
1025+ // },
1026+ // });
1027+ // const objects = ret.objects;
1028+ // expect(objects.length).toEqual(2);
1029+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1030+ // expect(objects[0].properties.text).toEqual('This is another test');
1031+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1032+ // expect(objects[1].properties.text).toEqual('This is a test');
1033+ // });
1034+
1035+ // it.skip('should rerank the results in a nearObject query', async () => {
1036+ // const ret = await collection.query.nearObject(id1, {
1037+ // rerank: {
1038+ // property: 'text',
1039+ // query: 'another',
1040+ // },
1041+ // });
1042+ // const objects = ret.objects;
1043+ // expect(objects.length).toEqual(2);
1044+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1045+ // expect(objects[0].properties.text).toEqual('This is another test');
1046+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1047+ // expect(objects[1].properties.text).toEqual('This is a test');
1048+ // });
1049+
1050+ // it('should rerank the results in a nearText query', async () => {
1051+ // const ret = await collection.query.nearText('text', {
1052+ // rerank: {
1053+ // property: 'text',
1054+ // query: 'another',
1055+ // },
1056+ // });
1057+ // const objects = ret.objects;
1058+ // expect(objects.length).toEqual(2);
1059+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1060+ // expect(objects[0].properties.text).toEqual('This is another test');
1061+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1062+ // expect(objects[1].properties.text).toEqual('This is a test');
1063+ // });
1064+
1065+ // it.skip('should rerank the results in a nearObject query', async () => {
1066+ // const obj = await collection.query.fetchObjectById(id1, { includeVector: true });
1067+ // const ret = await collection.query.nearVector(obj?.vectors.default!, {
1068+ // rerank: {
1069+ // property: 'text',
1070+ // query: 'another',
1071+ // },
1072+ // });
1073+ // const objects = ret.objects;
1074+ // expect(objects.length).toEqual(2);
1075+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1076+ // expect(objects[0].properties.text).toEqual('This is another test');
1077+ // expect(objects[0].metadata?.rerankScore).toBeDefined();
1078+ // expect(objects[1].properties.text).toEqual('This is a test');
1079+ // });
1080+ // });
0 commit comments