Blog

Introducing the New Vecto TypeScript SDK and Docusaurus Search Plugin

Muhammad Fahreza Alghifari
3 Nov 2023

We’re excited to release two significant updates that will streamline how developers interact with our vector database: the release of our Vecto TypeScript Client and the Vecto Docusaurus Search plugin!

Vecto TypeScript Client: Simplifying API Integration

Our TypeScript SDK Client is here to streamline the way you use Vecto. With this release, TypeScript developers can now easily index and look up data in Vecto with a few lines of code.

Getting Started

Once you’ve received your vecto token, easily install the client with npm:

npm install @xpressai/vecto-client

Sample Code for Indexing and Lookup

import { Configuration, IndexApi, IndexDataRequest, LookupApi, LookupRequest } from '@xpressai/vecto-client';


const config = new Configuration({
    accessToken: 'your-vecto-token'
});

// Ingest

const indexApi = new IndexApi(config);
const textBlob = new Blob(["Hello Vecto"]);


const textDataParams: IndexDataRequest = {
    vectorSpaceId: your-vector-space-id,
    modality: 'TEXT',
    attributes: [JSON.stringify("sample metadata")],
    input: [textBlob];
};

await indexApi.indexData(textDataParams);

// Lookup

const lookupApi = new LookupApi(config);

const textParams: LookupRequest = {
    vectorSpaceId: your-vector-space-id,
    modality: 'TEXT',
    topK: 3,
    query: 'text query', 
};

const results = await lookupApi.lookup(textParams);

For full usage instructions, visit our official TypeScript documentation page.

Vecto Docusaurus Search: Enhance Your Docs

To complement our TypeScript Client, we’ve launched a search plugin for Docusaurus-powered sites. Get ready for an improved search experience with Vecto-powered results.

Installation and Configuration

  1. Install the Plugin
    Navigate to the root directory of your Docusaurus project and install the plugin:

    npm install @xpressai/docusaurus-vecto-search
  2. Update Docusaurus Configuration
    Modify your docusaurus.config.js by adding the plugin to the themes array:

    themes: [
      [
        "@xpressai/docusaurus-vecto-search",
        {
          vecto_public_token: "",
          vector_space_id: 123,
          top_k: 15,
          rankBy: "weightedAverage" // recommended
        },
      ],
    ]
  3. Set Environment Variable
    Define the VECTO_USER_TOKEN in your environment:

    • For CI/CD, use repository secrets.
    • For local development, export the variable or create a .env file at the project root with the line:
      VECTO_USER_TOKEN=your_token_value_here
  4. Build Your Site
    With the configuration in place, build your Docusaurus site:

    npm run build

Preview

You can also try out the Vecto search in action on the Vecto docs website and at Xircuits.io!

We’re here to support your journey, so join our Discord community for discussions and assistance, or reach out to Vecto support for more help.

Happy coding with our new Vecto tools - crafted to make your development smoother and smarter! 🎉