In this section, we’re going to quickly go over some important terms we will be using throughout this documentation, most of which will be related to storing and querying data in your vectorstore.

Although we’re going to draw analogies when explaining terminologies based on the assumption that your data is primarily stored in a SQL database, the same concepts can be applied to NoSQL databases, or even unstructured data like PDFs.

AI Services

AI Services is an unbrella term we use to encapsulate all the AI functionalities that Twilix offers out of the box, such as Question Answering on your data.

Vectorstore

The vectorstore refers to your Twilix vector database. (If you’re on the starter plan, your data will hosted be in a public, shared vector database instead.)

Your vectorstore is an important part of our API offerings because it allows us to offer AI services customized to your data, you do not need to know how it works under the hood to use Twilix.

Although you can use Twilix’s vectorstore as your primary database/datasource, it is ommon to use vectorstores as a layer on top of your primary datasource. For example, you might have a postgresQL database that implement hooks to keep the data in your Twilix vectorstore in sync with changes.

Schema

A schema refers to the data structure of your vectorstore (analogous to a database schema). A schema consists of collections, and each collection contains objects of the same type. These objects all have the same fields, and together, they form the schema.

Collections

A collection refers to a specific group of objects in your Twilix vectorstore (analogous to a table in SQL, and similar to a class in programming).

When you store objects in your vectorstore, you are required to specify which collection it belongs to by providing a collection name.

Collection names should be in camelCase and are case sensitive. Grouping objects into a collection, enables queries on the entire collection, which powers complex Question Answering uses cases.

To simplify the logic behind processing and transforming data when sending data to/from your vectorstore, we recommend a one to one mapping from your database table to a collection.

Objects

An object refers to a JSON object stored in your vectorstore as part of a collection (analogous to a row in SQL, and similar to an instance of a class in programming).

Similar to collections, we recommend a one to one mapping from the rows in your database to the objects you’re inserting.

Fields

A field refers to a property in an object (analogous to a column in SQL, or a class variable in programming). Each field has a type, and the type is inferred upon data insertion.

These are the field types that are currently supported:

  1. string
  2. int
  3. boolean
  4. float
  5. blob

You don’t have to map every column in your database table to fields in your object. Depending on your specific needs, you can leave out certain columns as you see fit, so that objects in your vectorstore contains a subsets of columns in your database.

Putting it all together

Here’s a quick example of how collections, objects, and fields work together to form your vectorstore schema (We will explain those in detail under the “Vectorstore” section).

example.ts
// send the request to store objects in your vectorstore
axios({
  url: "https://app.twilix.io/v1/collection/bulkInsert",
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer " + apiKey,
  },
  data: {
    // Your collection name
    collection: COLLECTIONS.EMAIL,
    objects: arrayOfObjects,
  },
})
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error(error);
  });

// print the schema
axios({
  url: "https://app.twilix.io/v1/schema",
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer " + apiKey,
  },
}); //...

/*
 Here's what the response looks like :
 {
    "collectionSchema": [
        {
            "type": "text",
            "field": "referenceTitle"
        },
        {
            "type": "text",
            "field": "content"
        }
    ]
}
*/

Notice how your schema is automatically generated based on the object you imported to your collection!

In the next section, we will talk about how Twilix uses data in your vectorstore to deliver you customized AI services, and how you can implement it using our APIs.