npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tigrisdata/vector

v1.1.0

Published

Tigris Vector Database client for TypeScript

Downloads

69

Readme

Tigris Vector Database Client Library for TypeScript

build codecov GitHub Discord Twitter Follow

Getting Started

Tigris makes it easy to build AI applications with vector embeddings. It is a fully managed cloud-native database that allows you store and index documents and vector embeddings for fast and scalable vector search.

1. Install the client library

npm install @tigrisdata/vector

2. Fetch Tigris API credentials

You can sign up for a free Tigris account here.

Once you have signed up for the Tigris account, create a new project called vectordemo. Next, make a note of the clientId and clientSecret, which you can get from the Application Keys section of the project.

3. Create the Vector Database client

import { VectorDocumentStore } from "@tigrisdata/vector";

const vectorDocStore = new VectorDocumentStore({
  connection: {
    serverUrl: "api.preview.tigrisdata.cloud",
    projectName: "vectordemo",
    clientId: "clientId_here",
    clientSecret: "clientSecret_here",
  },
  indexName: "my_index",
  numDimensions: 3,
});

Here, we have created a new VectorDocumentStore instance that connects to the Tigris Vector Database. The indexName is the name of the index that will store your embeddings, documents, and any additional metadata. You can use any name you like for the index. The numDimensions is the number of dimensions of the vector embeddings.

4. Add documents to the index

await vectorDocStore.addDocumentsWithVectors({
  ids: ["id1", "id2"],
  embeddings: [
    [1.2, 2.3, 4.5],
    [6.7, 8.2, 9.2],
  ],
  documents: [
    {
      content: "This is a document",
      metadata: {
        title: "Document 1",
      },
    },
    {
      content: "This is another document",
      metadata: {
        title: "Document 2",
      },
    },
  ],
});

Here, we have added two documents to the index. The ids are the unique identifiers for the documents. The embeddings are the vector embeddings for the documents. The documents are the actual documents that you want to store in the index. The content is the text content of the document. The metadata is any additional metadata that you want to store for the document.

5. Query the index

You can query the index for the top k most similar documents to a given vector. It's that simple!

const results = await vectorDocStore.similaritySearchVectorWithScore({
  query: [1.0, 2.1, 3.2],
  k: 10,
});
console.log(JSON.stringify(results, null, 2));

6. Enhance the query with attribute filtering

You can enhance the query with attribute filtering. For example, you can filter the results by a given metadata field.

const results2 = await vectorDocStore.similaritySearchVectorWithScore({
  query: [1.0, 2.1, 3.2],
  k: 10,
  filter: {
    "metadata.title": "Document 1",
  },
});
console.log(JSON.stringify(results2, null, 2));

Next Steps

Tigris Vector Database is simple enough to get started with, but powerful enough to build real-world applications.

Tigris provides the following features:

  • High performance: Tigris is built from the ground up to provide fast vector search. It is optimized for low-latency vector search and high throughput.
  • Real-time: Tigris provides real-time updates to the index. You can add, update, and delete documents and embeddings in real-time.
  • Hybrid search: Tigris supports hybrid search, which allows you to combine vector search with attribute filtering for more relevant search results.
  • Fully managed: Tigris is a fully managed cloud-native database. You can get started with Tigris in minutes and scale as needed with ease.

Contributing

Building


# clean the dev env

npm run clean

# build

npm run build

# test

npm run test

# lint

npm run lint

Code Quality

1. Linting

The coding style rules are defined by Prettier and enforced by Eslint

2. Git Hooks

We use pre-commit to automatically setup and run git hooks.

Install the pre-commit hooks as follows:

pre-commit install

On every git commit we check the code quality using prettier and eslint.

License

This software is licensed under the Apache 2.0.

Contributors

Thanks to all the people who contributed!