Skip to main content

MyScale

Compatibility

Only available on Node.js.

MyScale is an emerging AI database that harmonizes the power of vector search and SQL analytics, providing a managed, efficient, and responsive experience.

Setup

  1. Launch a cluster through MyScale's Web Console. See MyScale's official documentation for more information.
  2. After launching a cluster, view your Connection Details from your cluster's Actions menu. You will need the host, port, username, and password.
  3. Install the required Node.js peer dependency in your workspace.
npm install -S @langchain/openai @clickhouse/client @langchain/community

Index and Query Docs

import { MyScaleStore } from "@langchain/community/vectorstores/myscale";
import { OpenAIEmbeddings } from "@langchain/openai";

const vectorStore = await MyScaleStore.fromTexts(
["Hello world", "Bye bye", "hello nice world"],
[
{ id: 2, name: "2" },
{ id: 1, name: "1" },
{ id: 3, name: "3" },
],
new OpenAIEmbeddings(),
{
host: process.env.MYSCALE_HOST || "localhost",
port: process.env.MYSCALE_PORT || "8443",
username: process.env.MYSCALE_USERNAME || "username",
password: process.env.MYSCALE_PASSWORD || "password",
database: "default", // defaults to "default"
table: "your_table", // defaults to "vector_table"
}
);

const results = await vectorStore.similaritySearch("hello world", 1);
console.log(results);

const filteredResults = await vectorStore.similaritySearch("hello world", 1, {
whereStr: "metadata.name = '1'",
});
console.log(filteredResults);

API Reference:

Query Docs From an Existing Collection

import { MyScaleStore } from "@langchain/community/vectorstores/myscale";
import { OpenAIEmbeddings } from "@langchain/openai";

const vectorStore = await MyScaleStore.fromExistingIndex(
new OpenAIEmbeddings(),
{
host: process.env.MYSCALE_HOST || "localhost",
port: process.env.MYSCALE_PORT || "8443",
username: process.env.MYSCALE_USERNAME || "username",
password: process.env.MYSCALE_PASSWORD || "password",
database: "default", // defaults to "default"
table: "your_table", // defaults to "vector_table"
}
);

const results = await vectorStore.similaritySearch("hello world", 1);
console.log(results);

const filteredResults = await vectorStore.similaritySearch("hello world", 1, {
whereStr: "metadata.name = '1'",
});
console.log(filteredResults);

API Reference:


Help us out by providing feedback on this documentation page: