@vantage-discovery/vantage-node-sdk
v0.6.0-dev1
Published
<img src="assets/vantage_logo.png" title="Vantage Discovery Logo" width="300"/></br>
Downloads
8
Readme
Vantage Discovery Node SDK
The Vantage Discovery Node SDK provides an easy-to-use interface to interact with the Vantage vector database, enabling developers to seamlessly integrate vector search and collection management capabilities into their Node applications.
Installation
To install the Vantage Node SDK, run the following command:
npm i @vantage-discovery/vantage-node-sdk
Quickstart
To get started with the Vantage Node SDK, you'll need to set up your Vantage account and obtain your account ID and Vantage API key. Once you have your ID and key, you can initialize the VantageClient which you can then use to manage your account, collections and keys and perform searches.
import { VantageClient } from '@vantage-discovery/vantage-node-sdk';
const accountId = "ACCOUNT_ID"
const vantageApiKey = "API_KEY"
const configuration = {
vantageApiKey: vantageApiKey,
accountId: accountId
}
let client = new VantageClient(configuration)
Overview
The Vantage Discovery Node SDK is divided into several modules, allowing you to manage account, collections, and API keys, as well as perform various types of searches.
Key Features
- Collection Management: Easily create, update, list, and delete collections.
- Documents Upload: Upload your data easily to your collections.
- Search: Perform semantic, embedding and "more like this/these" searches within your collections.
- LLM Keys Management: Keep your LLM provider secrets safe and up-to-date.
🔍 Examples
Creating a Collection
To create a new collection for storing documents, specify the collection ID, the dimension of the embeddings, and the LLM (language learning model) details. Here, we use text-embedding-ada-002
from OpenAI with the necessary secret key.
📚 Visit management-api documentation for more details.
import { OpenAICollection } from '@vantage-discovery/vantage-node-sdk'
const newCollection: OpenAICollection = new OpenAICollection(
"openai-collection",
1536,
"text-embedding-ada-002",
"OPENAI_SECRET"
)
const response = client.createCollection({
collection: newCollection
})
Uploading Documents
To upload documents to your collection, provide a list of document IDs and corresponding text. Each document is wrapped in a VantageManagedEmbeddingsDocument
object. This example demonstrates uploading a batch of documents.
📚 Visit management-api documentation for more details.
const collectionId = "openai-collection"
const ids: string[] = [
"1",
"2",
"3",
"4",
];
const texts: string[] = [
"First text",
"Second text",
"Third text",
"Fourth text",
];
const documents: VantageManagedEmbeddingsDocument[] = ids.map(
(id, index) => new VantageManagedEmbeddingsDocument(texts[index], id)
);
client.upsertDocuments({
collectionId: collectionId,
documents: documents
});
Performing a Search
To perform a semantic search within your collection, specify the text you want to find similar documents for. This example retrieves documents similar to the provided text, printing out each document's ID and its similarity score.
📚 Visit search-api documentation for more details.
const collectionId = "openai-collection"
const queryText = "Find documents similar to this text"
const searchResults = client.semanticSearch(collectionId, queryText)
📚 Documentation
For detailed documentation on all methods and their parameters, please refer to the Vantage Discovery official documentation.