Skip to main content

Javascript

NPM package is located here. Github repo is located here

Installation

You can install the package using npm:

npm i arcanelab-langchain

Initialize Client

To initialize the client, you need to provide your API key. You can find your API key on the settings page of your account. Additionally, you need to provide the workspace ID and the document store ID, which can you find on the associated pages of the workspace and document store respectively. You also need to provide your OpenAI API key, which you can find on the settings page of your OpenAI account. This is required to embed documents into vectors.

const vectorStore = new ArcaneLabVectorStore({
apiKey: "...",
workspaceId: "...",
documentStoreId: "...",
openaiAPIKey: "..."
});

Operations

Adding Documents

You can directly add any langchain document object using the addDocuments method of the vector store. We encourage that you set the title and source properties for document metadata.

await vectorStore.addDocuments(documents);

Adding Vectors

To directly add vectors, you need to first embed the vectors using the embedDocuments method of the vector store. You can then add the vectors using the addVectors method of the vector store.

const vectors = await vectorStore.embeddings.embedDocuments(
documents.map((doc) => doc.pageContent)
);
const response = await ArcaneLabVectorStore.addVectors(vectors, documents);

Examples

Building a QA Chain

const vectorStore = new ArcaneLabVectorStore({...});
await vectorStore.addDocuments(documents);
const chain = VectorDBQAChain.fromLLM(model, vectorStore, {
k: 1,
returnSourceDocuments: true,
});
const response = await chain.call({ query: "What is pinecone?" });