Skip to content

Commit

Permalink
bump version (langchain-ai#177)
Browse files Browse the repository at this point in the history
* bump version

* cr
  • Loading branch information
hwchase17 authored Mar 1, 2023
1 parent e0a3347 commit 67422c9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 50 additions & 0 deletions docs/docs/modules/agents/agent_toolkits/vectorstore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# VectorStore Agent Toolkit

This example shows how to load and use an agent with a vectorstore toolkit.

```typescript
import { OpenAI } from "langchain";
import { HNSWLib } from "langchain/vectorstores";
import { OpenAIEmbeddings } from "langchain/embeddings";
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
import * as fs from "fs";
import {
VectorStoreToolkit,
createVectorStoreAgent,
VectorStoreInfo,
} from "langchain/agents";

export const run = async () => {
const model = new OpenAI({ temperature: 0 });
/* Load in the file we want to do question answering over */
const text = fs.readFileSync("state_of_the_union.txt", "utf8");
/* Split the text into chunks */
const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });
const docs = await textSplitter.createDocuments([text]);
/* Create the vectorstore */
const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());

/* Create the agent */
const vectorStoreInfo: VectorStoreInfo = {
name: "state_of_union_address",
description: "the most recent state of the Union address",
vectorStore,
};

const toolkit = new VectorStoreToolkit(vectorStoreInfo, model);
const agent = createVectorStoreAgent(model, toolkit);

const input =
"What did biden say about Ketanji Brown Jackson is the state of the union address?";
console.log(`Executing: ${input}`);
const result = await agent.call({ input });
console.log(`Got output ${result.output}`);
console.log(
`Got intermediate steps ${JSON.stringify(
result.intermediateSteps,
null,
2
)}`
);
};
```
2 changes: 1 addition & 1 deletion langchain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langchain",
"version": "0.0.16",
"version": "0.0.17",
"description": "Typescript bindings for langchain",
"type": "module",
"main": "./index.js",
Expand Down

0 comments on commit 67422c9

Please sign in to comment.