Compare commits

...

23 Commits

Author SHA1 Message Date
sweep-ai[bot] 53bf6b2c5b Merge main into sweep/add-test-cases-vectorstoreindex 2023-07-28 03:45:48 +00:00
sweep-ai[bot] 705675c06a Merge main into sweep/add-test-cases-vectorstoreindex 2023-07-27 23:46:24 +00:00
sweep-ai[bot] 474c3eb5da Merge main into sweep/add-test-cases-vectorstoreindex 2023-07-27 15:25:51 +00:00
sweep-ai[bot] 8184af23b3 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-27 08:24:20 +00:00
sweep-ai[bot] 6b25eddd97 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-27 08:17:50 +00:00
sweep-ai[bot] ecdad23086 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-27 08:11:32 +00:00
sweep-ai[bot] 2df11d43ed Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-27 07:52:39 +00:00
sweep-ai[bot] bb91bedf8c Merge main into sweep/add-test-cases-vectorstoreindex 2023-07-27 07:50:17 +00:00
sweep-ai[bot] 03ccc6a137 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-27 07:48:42 +00:00
sweep-ai[bot] 9d156d86e3 Merge main into sweep/add-test-cases-vectorstoreindex 2023-07-27 07:42:26 +00:00
sweep-ai[bot] ef6fc95e33 Merge main into sweep/add-test-cases-vectorstoreindex 2023-07-27 07:39:26 +00:00
sweep-ai[bot] 50b15f67ae Merge main into sweep/add-test-cases-vectorstoreindex 2023-07-27 07:38:44 +00:00
sweep-ai[bot] 958547c04d Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-27 00:22:37 +00:00
sweep-ai[bot] 0b8bd31078 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-27 00:06:00 +00:00
sweep-ai[bot] 9e0cbad9d5 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-27 00:04:37 +00:00
sweep-ai[bot] ebfd95a94e Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-26 23:55:39 +00:00
sweep-ai[bot] 50be882ccf Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-26 23:36:34 +00:00
sweep-ai[bot] 96fdd8b5e7 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-26 23:34:37 +00:00
sweep-ai[bot] ab7141d337 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-26 23:33:08 +00:00
sweep-ai[bot] dd88235b32 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-26 23:32:50 +00:00
sweep-ai[bot] 4fb1b2dc98 Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-26 23:31:13 +00:00
sweep-ai[bot] a041d4b13f Update packages/core/src/tests/VectorStoreIndex.test.ts 2023-07-26 23:29:35 +00:00
sweep-ai[bot] f3829d86da sweep: Create packages/core/src/tests/VectorStoreIndex.te 2023-07-26 23:27:30 +00:00
@@ -0,0 +1,134 @@
import { VectorStoreIndex } from '../indices/vectorStore/VectorStoreIndex';
import { TextNode, Document } from '../Node';
import { BaseRetriever } from '../Retriever';
import { BaseQueryEngine } from '../QueryEngine';
import { mockEmbeddingModel } from './utility/mockOpenAI'; // import the mockEmbeddingModel
describe('VectorStoreIndex', () => {
test('init', async () => {
// Prepare inputs
const options = {
storageContext: new StorageContext(),
serviceContext: new ServiceContext(),
docStore: new BaseDocumentStore(),
vectorStore: new VectorStore(),
indexStruct: new IndexStruct(),
}; // fill with appropriate data
// Call the method
const result = await VectorStoreIndex.init(options);
// Assert the result
expect(result).toBeInstanceOf(VectorStoreIndex);
// Add more assertions as necessary
// Handle edge cases and errors
// Add code to handle edge cases and errors
});
// Write similar test blocks for the other methods: getNodeEmbeddingResults, buildIndexFromNodes, fromDocuments, asRetriever, asQueryEngine
test('getNodeEmbeddingResults', async () => {
// Prepare inputs
const nodes = [
new TextNode({text: 'Apple'}),
new TextNode({text: 'Banana'}),
new TextNode({text: 'Cherry'}),
new TextNode({text: 'Date'}),
new TextNode({text: 'Elderberry'}),
new TextNode({text: 'Fig'}),
new TextNode({text: 'Grape'}),
new TextNode({text: 'Honeydew'}),
new TextNode({text: 'Iced Apple'}),
new TextNode({text: 'Jackfruit'})
];
// Use the mockEmbeddingModel instead of the ServiceContext
const serviceContext = new ServiceContext();
serviceContext.embedModel = mockEmbeddingModel;
// Call the method
const result = await VectorStoreIndex.getNodeEmbeddingResults(nodes, serviceContext);
// Assert the result
expect(result).toBeInstanceOf(Array);
// Assuming the getNodeEmbeddingResults method returns an array of embeddings for the input nodes
expect(result).toHaveLength(nodes.length);
result.forEach(embedding => {
expect(embedding).toBeInstanceOf(Float32Array); // Assuming each embedding is a Float32Array
});
// Add more assertions as necessary
});
// Add similar test blocks for the other methods: buildIndexFromNodes, fromDocuments, asRetriever, asQueryEngine
test('buildIndexFromNodes', async () => {
// Prepare inputs
const nodes = [
new TextNode({text: 'Apple'}),
new TextNode({text: 'Banana'}),
new TextNode({text: 'Cherry'}),
new TextNode({text: 'Date'}),
new TextNode({text: 'Elderberry'}),
new TextNode({text: 'Fig'}),
new TextNode({text: 'Grape'}),
new TextNode({text: 'Honeydew'}),
new TextNode({text: 'Iced Apple'}),
new TextNode({text: 'Jackfruit'})
];
const serviceContext = new ServiceContext();
serviceContext.embedModel = mockEmbeddingModel;
// Call the method
const result = await VectorStoreIndex.buildIndexFromNodes(nodes, serviceContext);
// Assert the result
expect(result).toBeInstanceOf(VectorStoreIndex);
});
test('fromDocuments', async () => {
// Prepare inputs
const documents = [
new Document({text: 'Apple'}),
new Document({text: 'Banana'}),
new Document({text: 'Cherry'}),
new Document({text: 'Date'}),
new Document({text: 'Elderberry'}),
new Document({text: 'Fig'}),
new Document({text: 'Grape'}),
new Document({text: 'Honeydew'}),
new Document({text: 'Iced Apple'}),
new Document({text: 'Jackfruit'})
];
const serviceContext = new ServiceContext();
// Call the method
const result = await VectorStoreIndex.fromDocuments(documents, serviceContext);
// Assert the result
expect(result).toBeInstanceOf(VectorStoreIndex);
});
test('asRetriever', async () => {
// Prepare inputs
const vectorStoreIndex = new VectorStoreIndex();
// Call the method
const result = vectorStoreIndex.asRetriever();
// Assert the result
expect(result).toBeInstanceOf(BaseRetriever);
});
test('asQueryEngine', async () => {
// Prepare inputs
const vectorStoreIndex = new VectorStoreIndex();
// Call the method
const result = vectorStoreIndex.asQueryEngine();
// Assert the result
expect(result).toBeInstanceOf(BaseQueryEngine);
});
// Remember to handle edge cases and errors in the test cases
}) // Add a closing parenthesis at the end of the file to correctly close the `describe` function call.