Skip to content

langchain Vector Store implementation based for PostgreSQL pgvector

Notifications You must be signed in to change notification settings

abhirockzz/langchain-go-postgresql-vectorstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL Vector Database implementation for LangChain Go

langchaingo extension to use pgvector as a vector database for your Go applications. It uses the pgvector-go library along with pgx driver.

You can use this in your LangChain applications as a standalone vector database or more likely, as part of a chain. For example, in a RAG implementation:

    import(
        "github.com/abhirockzz/langchain-go-postgresql-vectorstore/pgvector"
         //...
    )
    func ragToRiches(){
        
        bedrockClaudeLLM, err := claude.New("us-east-1")

        tableName := "test_table"
        textColumnName := "text_data"
        embeddingStoreColumnName := "embedding_data"

        amazonTitanEmbedder, err := titan_embedding.New("us-east-1")

        pgVectorStore, err := pgvector.New(pgConnString, 
                                        tableName, 
                                        embeddingStoreColumnName, 
                                        textColumnName, 
                                        false, 
                                        amazonTitanEmbedder)

        result, err := chains.Run(
            context.Background(),
            chains.NewRetrievalQAFromLLM(
                bedrockClaudeLLM,
                vectorstores.ToRetriever(pgVectorStore, numOfResults),
            ),
            question,
            chains.WithMaxTokens(8091),
        )
    }

About

langchain Vector Store implementation based for PostgreSQL pgvector

Topics

Resources

Stars

Watchers

Forks

Languages