-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
community[patch]: Upstash Vector Store Namespace Feature #5557
Changes from 2 commits
4d08d0e
d3468a3
c5eb148
c50eebf
c687250
b8e3f57
4faf733
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,7 +127,7 @@ | |
"@typescript-eslint/parser": "^5.58.0", | ||
"@upstash/ratelimit": "^1.1.3", | ||
"@upstash/redis": "^1.20.6", | ||
"@upstash/vector": "^1.0.7", | ||
"@upstash/vector": "^1.1.1", | ||
"@vercel/kv": "^0.2.3", | ||
"@vercel/postgres": "^0.5.0", | ||
"@writerai/writer-sdk": "^0.40.2", | ||
|
@@ -266,7 +266,7 @@ | |
"@tensorflow/tfjs-core": "*", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey there! 👋 I noticed the change in the "@upstash/vector" dependency version from "^1.0.7" to "^1.1.1". This comment is to flag the dependency change for maintainers to review, as it may impact peer/dev/hard dependencies. Great work on the PR! 🚀 |
||
"@upstash/ratelimit": "^1.1.3", | ||
"@upstash/redis": "^1.20.6", | ||
"@upstash/vector": "^1.0.7", | ||
"@upstash/vector": "^1.1.1", | ||
"@vercel/kv": "^0.2.3", | ||
"@vercel/postgres": "^0.5.0", | ||
"@writerai/writer-sdk": "^0.40.2", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,4 +172,89 @@ describe("UpstashVectorStore", () => { | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey there! 👋 I've reviewed the code changes and it looks like the added code explicitly accesses environment variables using |
||
expect(results3).toHaveLength(2); | ||
}); | ||
|
||
test("Should upsert the documents to target namespace", async () => { | ||
index = new Index({ | ||
url: process.env.UPSTASH_VECTOR_REST_URL, | ||
token: process.env.UPSTASH_VECTOR_REST_TOKEN, | ||
}); | ||
|
||
await index.reset(); | ||
|
||
embeddings = new SyntheticEmbeddings({ | ||
vectorSize: 384, | ||
}); | ||
|
||
const storeNamespace1 = new UpstashVectorStore(embeddings, { | ||
index, | ||
namespace: "namespace-1", | ||
}); | ||
const storeNamespace2 = new UpstashVectorStore(embeddings, { | ||
index, | ||
namespace: "namespace-2", | ||
}); | ||
|
||
|
||
await storeNamespace1.addDocuments([ | ||
{ pageContent: "namespace-test-original", metadata: { namespace: "namespace-1" } }, | ||
]); | ||
|
||
// Sleeping for a second to make sure that all the indexing operations are finished. | ||
await sleep(1000); | ||
|
||
const resultsNamespace2 = await storeNamespace2.similaritySearchWithScore("namespace-test-original", 1, "namespace = 'namespace-1'"); | ||
expect(resultsNamespace2).toHaveLength(0); | ||
|
||
const resultsNamespace1 = await storeNamespace1.similaritySearchWithScore("namespace-test-original", 1, "namespace = 'namespace-1'"); | ||
expect(resultsNamespace1).toHaveLength(1); | ||
|
||
expect([resultsNamespace1[0][0]]).toEqual([ | ||
new Document({ metadata: { namespace: "namespace-1" }, pageContent: "namespace-test-original" }), | ||
]); | ||
}) | ||
|
||
test("Should delete the documents from target namespace", async () => { | ||
index = new Index({ | ||
url: process.env.UPSTASH_VECTOR_REST_URL, | ||
token: process.env.UPSTASH_VECTOR_REST_TOKEN, | ||
}); | ||
|
||
await index.reset(); | ||
|
||
embeddings = new SyntheticEmbeddings({ | ||
vectorSize: 384, | ||
}); | ||
|
||
const storeNamespace1 = new UpstashVectorStore(embeddings, { | ||
index, | ||
namespace: "namespace-1", | ||
}); | ||
const storeNamespace2 = new UpstashVectorStore(embeddings, { | ||
index, | ||
namespace: "namespace-2", | ||
}); | ||
|
||
|
||
const idNamespace1 = await storeNamespace1.addDocuments([ | ||
{ pageContent: "namespace-test-original", metadata: { namespace: "namespace-test" } }, | ||
]); | ||
await storeNamespace2.addDocuments([ | ||
{ pageContent: "namespace-test-original", metadata: { namespace: "namespace-test" } }, | ||
]); | ||
|
||
// Sleeping for a second to make sure that all the indexing operations are finished. | ||
await sleep(1000); | ||
|
||
await storeNamespace1.delete({ ids: idNamespace1 }); | ||
|
||
const resultsNamespace1 = await storeNamespace1.similaritySearchWithScore("namespace-test-original", 1, "namespace = 'namespace-test'"); | ||
expect(resultsNamespace1).toHaveLength(0); | ||
|
||
const resultsNamespace2 = await storeNamespace2.similaritySearchWithScore("namespace-test-original", 1, "namespace = 'namespace-test'"); | ||
expect(resultsNamespace2).toHaveLength(1); | ||
|
||
expect([resultsNamespace2[0][0]]).toEqual([ | ||
new Document({ metadata: { namespace: "namespace-test" }, pageContent: "namespace-test-original" }), | ||
]); | ||
}) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there! I noticed the change in the "@upstash/vector" package version from "^1.0.7" to "^1.1.1" in the package.json file. This comment is to flag the dependency change for maintainers to review. Keep up the great work!