MyScale
兼容性
仅在Node.js上可用。
MyScale是一款新兴的人工智能数据库,将向量搜索和SQL分析的强大功能相结合,提供管理、高效、响应迅速的体验。
安装
- 通过MyScale Web控制台启动集群。更多信息请参见MyScale官方文档。
- 启动集群后,请从集群的“操作”菜单中查看您的“连接详细信息”。您需要主机名、端口、用户名和密码。
- 在您的工作区中安装所需的Node.js版本。
- npm
- Yarn
- pnpm
npm install -S @clickhouse/client
yarn add @clickhouse/client
pnpm add @clickhouse/client
索引与查询文档
import { MyScaleStore } from "langchain/vectorstores/myscale";
import { OpenAIEmbeddings } from "langchain/embeddings/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",
}
);
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);
从现有集合中查询文档
import { MyScaleStore } from "langchain/vectorstores/myscale";
import { OpenAIEmbeddings } from "langchain/embeddings/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: "your_database", // 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);