Skip to content

Commit

Permalink
Merge pull request langchain-ai#1099 from jacoblee93/pr_919
Browse files Browse the repository at this point in the history
Docs fixes, parameter shim for langchain-ai#919
  • Loading branch information
nfcampos authored May 4, 2023
2 parents 67e115e + ee7e1b6 commit e85d4dd
Show file tree
Hide file tree
Showing 13 changed files with 453 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/docs/modules/indexes/vector_stores/integrations/myscale.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
sidebar_class_name: node-only
---

import CodeBlock from "@theme/CodeBlock";

# MyScale

:::tip Compatibility
Only available on Node.js.
:::

[MyScale](https://myscale.com/) 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](https://console.myscale.com/). See [MyScale's official documentation](https://docs.myscale.com/en/quickstart/) 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.

```bash npm2yarn
npm install -S @clickhouse/client
```

## Index and Query Docs

import InsertExample from "@examples/indexes/vector_stores/myscale_fromTexts.ts";

<CodeBlock language="typescript">{InsertExample}</CodeBlock>

## Query Docs From an Existing Collection

import SearchExample from "@examples/indexes/vector_stores/myscale_search.ts";

<CodeBlock language="typescript">{SearchExample}</CodeBlock>
4 changes: 4 additions & 0 deletions examples/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ SUPABASE_URL=ADD_YOURS_HERE # # https://app.supabase.com/project/YOUR_PROJECT_ID
WEAVIATE_HOST=ADD_YOURS_HERE
WEAVIATE_SCHEME=ADD_YOURS_HERE
WEAVIATE_API_KEY=ADD_YOURS_HERE
MYSCALE_HOST=ADD_YOURS_HERE
MYSCALE_PORT=ADD_YOURS_HERE
MYSCALE_USERNAME=ADD_YOURS_HERE
MYSCALE_PASSWORD=ADD_YOURS_HERE
1 change: 1 addition & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"author": "LangChain",
"license": "MIT",
"dependencies": {
"@clickhouse/client": "^0.0.14",
"@getmetal/metal-sdk": "^2.0.1",
"@opensearch-project/opensearch": "^2.2.0",
"@pinecone-database/pinecone": "^0.0.14",
Expand Down
26 changes: 26 additions & 0 deletions examples/src/indexes/vector_stores/myscale_fromTexts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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);
22 changes: 22 additions & 0 deletions examples/src/indexes/vector_stores/myscale_search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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);
4 changes: 4 additions & 0 deletions langchain/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ MILVUS_URL=ADD_YOURS_HERE
WEAVIATE_HOST=ADD_YOURS_HERE
WEAVIATE_SCHEME=ADD_YOURS_HERE
WEAVIATE_API_KEY=ADD_YOURS_HERE
MYSCALE_HOST=ADD_YOURS_HERE
MYSCALE_PORT=ADD_YOURS_HERE
MYSCALE_USERNAME=ADD_YOURS_HERE
MYSCALE_PASSWORD=ADD_YOURS_HERE
3 changes: 3 additions & 0 deletions langchain/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ vectorstores/milvus.d.ts
vectorstores/prisma.cjs
vectorstores/prisma.js
vectorstores/prisma.d.ts
vectorstores/myscale.cjs
vectorstores/myscale.js
vectorstores/myscale.d.ts
text_splitter.cjs
text_splitter.js
text_splitter.d.ts
Expand Down
13 changes: 13 additions & 0 deletions langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
"vectorstores/prisma.cjs",
"vectorstores/prisma.js",
"vectorstores/prisma.d.ts",
"vectorstores/myscale.cjs",
"vectorstores/myscale.js",
"vectorstores/myscale.d.ts",
"text_splitter.cjs",
"text_splitter.js",
"text_splitter.d.ts",
Expand Down Expand Up @@ -305,6 +308,7 @@
"devDependencies": {
"@aws-sdk/client-lambda": "^3.310.0",
"@aws-sdk/client-s3": "^3.310.0",
"@clickhouse/client": "^0.0.14",
"@faker-js/faker": "^7.6.0",
"@getmetal/metal-sdk": "^2.0.1",
"@huggingface/inference": "^1.5.1",
Expand Down Expand Up @@ -363,6 +367,7 @@
"peerDependencies": {
"@aws-sdk/client-lambda": "^3.310.0",
"@aws-sdk/client-s3": "^3.310.0",
"@clickhouse/client": "^0.0.14",
"@getmetal/metal-sdk": "*",
"@huggingface/inference": "^1.5.1",
"@opensearch-project/opensearch": "*",
Expand Down Expand Up @@ -398,6 +403,9 @@
"@aws-sdk/client-s3": {
"optional": true
},
"@clickhouse/client": {
"optional": true
},
"@getmetal/metal-sdk": {
"optional": true
},
Expand Down Expand Up @@ -713,6 +721,11 @@
"import": "./vectorstores/prisma.js",
"require": "./vectorstores/prisma.cjs"
},
"./vectorstores/myscale": {
"types": "./vectorstores/myscale.d.ts",
"import": "./vectorstores/myscale.js",
"require": "./vectorstores/myscale.cjs"
},
"./text_splitter": {
"types": "./text_splitter.d.ts",
"import": "./text_splitter.js",
Expand Down
2 changes: 2 additions & 0 deletions langchain/scripts/create-entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const entrypoints = {
"vectorstores/opensearch": "vectorstores/opensearch",
"vectorstores/milvus": "vectorstores/milvus",
"vectorstores/prisma": "vectorstores/prisma",
"vectorstores/myscale": "vectorstores/myscale",
// text_splitter
text_splitter: "text_splitter",
// memory
Expand Down Expand Up @@ -157,6 +158,7 @@ const requiresOptionalDependency = [
"vectorstores/supabase",
"vectorstores/opensearch",
"vectorstores/milvus",
"vectorstores/myscale",
"document_loaders/web/cheerio",
"document_loaders/web/puppeteer",
"document_loaders/web/playwright",
Expand Down
Loading

0 comments on commit e85d4dd

Please sign in to comment.