datastax / astra-db-ts Goto Github PK
View Code? Open in Web Editor NEWTypescript client for Astra DB Vector
Home Page: https://astra.datastax.com/register
License: Apache License 2.0
Typescript client for Astra DB Vector
Home Page: https://astra.datastax.com/register
License: Apache License 2.0
Add vector_find method with vector and limit as required parameters, optional filter and fields, and no options parameter.
The lines in the README sample code
// Create a collection
const collection = await astraDb.collection(COLLECTION_NAME);
seem to be incorrect, as that method does not create a collection rather returns a reference to an existing one.
Creating a collection, in my understanding, is done through createCollection with the (possible, but required for vector coll.s) addition of some parameters.
Allow unnamed parameters where applicable.
Given this code snippet:
I get this error:
My workaround is to actually make it idempotent and not raise an error by wrapping the call to createCollection
in a try/catch block and swallowing the error. When I do this, everything continues as normal.
Current status: calling createCollection
on an existing collection raises an error when the documentation says it does not.
Expected: no error if collection already exists.
There is no difference in configuration.
When implementing a create if does not exist
type of method the logs are bogged down w/ error logs and the error is not catchable.
This method should throw an appropriate error or we should have a create if does not exist method
error: Error: Command "createCollection" failed with the following errors: [{"message":"Server call failed, please retry!"}]
at handleIfErrorResponse (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/client/httpClient.js:226:15)
at HTTPClient.executeCommand (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/client/httpClient.js:206:43)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/collections/db.js:67:20
at async executeOperation (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/collections/utils.js:161:15)
at async AstraDB.createCollection (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/collections/client.js:73:16)
at async AstraDBVectorStore.initialize (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@langchain/community/dist/vectorstores/astradb.cjs:88:13)
at async AstraDBVectorStore.fromDocuments (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@langchain/community/dist/vectorstores/astradb.cjs:226:9)
Collection already exists, connecting to vector_test
While the readme is short and sweet and does a good job of showing example code immediately, users are not given much information on where to go next.
Linking to the client reference documentation seems like a sensible first step in resolving this issue.
There doesn't seem to be a way to point the api_endpoint to one of our dev/test servers for experimentation and testing. Can you add this please?
Rename projection to fields .
Work is in progress to add a feature to the Data API that allows users to specify a $vectorize
field in JSON documents that the API will then take and calculate an embedding for using a configured algorithm. We need to expose this functionality in the typescript client as well.
Work under this related issue for stargate-mongoose may help suggest syntax stargate/stargate-mongoose#188
I'm not positive whether the API was changed, but instead of having a field "projection" which is confusing, please change it to "fields" to match the python client
Api Endpoint is the preferred connection method moving forward so we should support the ability to use keyspaces along side the endpoint.
export class AstraDB extends Client {
constructor(...args: any[]) {
// token: string, path: string
if (args.length === 2) {
let endpoint = args[1];
endpoint += "/api/json/v1";
endpoint += "/default_keyspace";
super(endpoint, "default_keyspace", { isAstra: true, applicationToken: args[0] });
} else {
// token: string, dbId: string, region: string, keyspace?: string
const keyspaceName = args[3] || "default_keyspace";
const endpoint = createAstraUri(args[1], args[2], keyspaceName);
super(endpoint, keyspaceName, { isAstra: true, applicationToken: args[0] });
}
}
}
Hello,
We are using a metadata key to partition vectors in a collection for multi-tenancy.
In the delete operation we run the following code:
const astraClient = new AstraDB(
process.env.ASTRA_DB_APPLICATION_TOKEN,
process.env.ASTRA_DB_ENDPOINT
);
const collection: Collection = await astraClient.collection(collectionName);
return collection.deleteMany({ tenant: namespace });
Namespace is the string contained in the tenant field.
When running, I get the following error thrown by the package:
error: Error: Command "deleteMany" failed with the following error: More records found to be deleted even after deleting 20 records
What do I have to do when there are more than 20 records to delete in a single colllection? Is the approach of separating vectors by metadata key not optimal? If so what should I be doing?
Thanks
When running yarn install of an application that depends on it, it throws this warning
warning @datastax/[email protected]: Unable to read "bin" directory of module "@datastax/astra-db-ts"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.