Skip to content

Commit

Permalink
update the README.md with a new example of usage
Browse files Browse the repository at this point in the history
  • Loading branch information
my8bit committed Jan 30, 2025
1 parent f189e5b commit 9163038
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions libs/langchain-weaviate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@ export WEAVIATE_API_KEY=
```

```typescript
import weaviate, { ApiKey } from 'weaviate-ts-client';
import { OpenAIEmbeddings } from "@langchain/openai";
import weaviate, { ApiKey } from "weaviate-ts-client";
import { WeaviateStore } from "@langchain/weaviate";

// Weaviate SDK has a TypeScript issue so we must do this.
const client = (weaviate as any).client({
const client = weaviate.client({
scheme: process.env.WEAVIATE_SCHEME || "https",
host: process.env.WEAVIATE_HOST || "localhost",
apiKey: new ApiKey(
process.env.WEAVIATE_API_KEY || "default"
),
apiKey: new ApiKey(process.env.WEAVIATE_API_KEY || "default"),
});

// Create a store and fill it with some texts + metadata
await WeaviateStore.fromTexts(
const store = await WeaviateStore.fromTexts(
["hello world", "hi there", "how are you", "bye now"],
[{ foo: "bar" }, { foo: "baz" }, { foo: "qux" }, { foo: "bar" }],
new OpenAIEmbeddings(),
Expand All @@ -51,6 +50,8 @@ await WeaviateStore.fromTexts(
metadataKeys: ["foo"],
}
);

console.log(await store.similaritySearch("hello"));
```

## Development
Expand Down

0 comments on commit 9163038

Please sign in to comment.