langchain-embedding_search

v1.0.0Created 7 months agoBy langchain

embedding_search

LangChain is a framework for developing applications powered by language models with a plugable architecture.

langchain-embedding_search uses a Supabase Postgres database as its vector store.

Installation

select dbdev.install('langchain-embedding_search');
create extension if not exists vector;
create extension "langchain-embedding_search"
    schema public
    version '1.0.0';

Note:

vector is a dependency of langchain-embedding_search. Dependency resolution is currently under development. In the near future it will not be necessary to manually create dependencies.

Once created, you can access the vector store for search using langchain as shown below:

import { SupabaseVectorStore } from "langchain/vectorstores/supabase";
import { OpenAIEmbeddings } from "langchain/embeddings/openai";
import { createClient } from "@supabase/supabase-js";

const privateKey = process.env.SUPABASE_PRIVATE_KEY;
if (!privateKey) throw new Error(`Expected env var SUPABASE_PRIVATE_KEY`);

const url = process.env.SUPABASE_URL;
if (!url) throw new Error(`Expected env var SUPABASE_URL`);

export const run = async () => {
  const client = createClient(url, privateKey);

  const vectorStore = await SupabaseVectorStore.fromTexts(
    ["Hello world", "Bye bye", "What's this?"],
    [{ id: 2 }, { id: 1 }, { id: 3 }],
    new OpenAIEmbeddings(),
    {
      client,
      tableName: "documents",
      queryName: "match_documents",
    }
  );

  const resultOne = await vectorStore.similaritySearch("Hello world", 1);

  console.log(resultOne);
};

For more details, checkout the LangChain Supabase integration docs: https://js.langchain.com/docs/modules/indexes/vector_stores/integrations/supabase

Install

  1. Install the dbdev package manager
  2. Install the package:
select dbdev.install('langchain-embedding_search');
create extension "langchain-embedding_search"
    version '1.0.0';

Downloads

  • 0 all time downloads
  • 0 downloads in the last 30 days
  • 0 downloads in the last 90 days
  • 0 downloads in the last 180 days