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
- Launch a cluster through MyScale's Web Console. See MyScale's official documentation for more information.
- After launching a cluster, view your
Connection Details
from your cluster'sActions
menu. You will need the host, port, username, and password. - Install the required Node.js peer dependency in your workspace.
- npm
- Yarn
- pnpm
npm install -S @langchain/openai @clickhouse/client @langchain/community
yarn add @langchain/openai @clickhouse/client @langchain/community
pnpm add @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:
- MyScaleStore from
@langchain/community/vectorstores/myscale
- OpenAIEmbeddings from
@langchain/openai
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:
- MyScaleStore from
@langchain/community/vectorstores/myscale
- OpenAIEmbeddings from
@langchain/openai
Related
- Vector store conceptual guide
- Vector store how-to guides