Aleksey Romanov
Aleksey Romanov

Reputation: 31

Langchain PGvector - How to find out how many documents have been indexed and added to the database

I used to use ChromaDB, now I switched to PGVector.

In ChromaDB there was an option to get the required amount of documents using a filter by metadata, but I can't find this in PGVector.

db = Chroma.from_documents(
    documents=documents,
    embedding=OpenAIEmbeddings(),
    collection_name='test',
    persist_directory=settings.PERSIST_DIR
)

doc = db.get(
    where={
        'file_id': file_id

    }
)

print(doc['documents'])
db = PGVector.from_documents(
    documents=documents,
    embedding=OpenAIEmbeddings(),
    collection_name='test',
    connection_string=PGVector.connection_string_from_db_params(
        driver='psycopg',
        host='***',
        port=1234,
        database='***',
        user='***',
        password='***'
    )
)

Any ideas?

I tried to get it this way, but I don't understand how to display the result, if this is possible. But it's also worth considering that there is a default limit of 4 documents.

retriever = db.as_retriever(
    search_kwargs={
        'filter': {
            'file_id': file_id
        }
    }
)

Upvotes: 2

Views: 607

Answers (0)

Related Questions