Skip to content

docs: refactor the readme #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feel free to use the abstraction as provided or else modify them / extend them a

## Requirements

The package currently only supports the [psycogp3](https://www.psycopg.org/psycopg3/) driver.
The package supports the [asyncpg](https://github.com/MagicStack/asyncpg) and [psycogp3](https://www.psycopg.org/psycopg3/) drivers.

## Installation

Expand All @@ -27,14 +27,12 @@ pip install -U langchain-postgres

### Vectorstore

> [!NOTE]
> See example for the [PGVector vectorstore here](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/vectorstore.ipynb)
`PGVector` is being deprecated. Please migrate to `PGVectorStore`.
`PGVectorStore` is used for improved performance and manageability.
See the [migration guide](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/migrate_pgvector_to_pgvectorstore.md) for details on how to migrate from `PGVector` to `PGVectorStore`.
> [!WARNING]
> In v0.0.14+, `PGVector` is deprecated. Please migrate to `PGVectorStore`
> for improved performance and manageability.
> See the [migration guide](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/migrate_pgvector_to_pgvectorstore.md) for details on how to migrate from `PGVector` to `PGVectorStore`.

> [!TIP]
> All synchronous functions have corresponding asynchronous functions
For a detailed example on `PGVectorStore` see [here](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/pg_vectorstore.ipynb).

```python
from langchain_postgres import PGEngine, PGVectorStore
Expand All @@ -58,11 +56,10 @@ store = PGVectorStore.create_sync(
embedding_service=embedding,
)

all_texts = ["Apples and oranges", "Cars and airplanes", "Pineapple", "Train", "Banana"]
metadatas = [{"len": len(t)} for t in all_texts]
ids = [str(uuid.uuid4()) for _ in all_texts]
docs = [
Document(id=ids[i], page_content=all_texts[i], metadata=metadatas[i]) for i in range(len(all_texts))
Document(page_content="Apples and oranges"),
Document(page_content="Cars and airplanes"),
Document(page_content="Train")
]

store.add_documents(docs)
Expand All @@ -72,7 +69,8 @@ docs = store.similarity_search(query)
print(docs)
```

For a detailed example on `PGVectorStore` see [here](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/pg_vectorstore.ipynb).
> [!TIP]
> All synchronous functions have corresponding asynchronous functions

### ChatMessageHistory

Expand Down Expand Up @@ -122,10 +120,6 @@ chat_history.add_messages([
print(chat_history.messages)
```

### Vectorstore

See example for the [PGVector vectorstore here](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/vectorstore.ipynb)

## Google Cloud Integrations

[Google Cloud](https://python.langchain.com/docs/integrations/providers/google/) provides Vector Store, Chat Message History, and Data Loader integrations for [AlloyDB](https://cloud.google.com/alloydb) and [Cloud SQL](https://cloud.google.com/sql) for PostgreSQL databases via the following PyPi packages:
Expand Down
4 changes: 1 addition & 3 deletions langchain_postgres/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ class EmbeddingStore(Base):

__tablename__ = "langchain_pg_embedding"

id = sqlalchemy.Column(
sqlalchemy.String, primary_key=True
)
id = sqlalchemy.Column(sqlalchemy.String, primary_key=True)

collection_id = sqlalchemy.Column(
UUID(as_uuid=True),
Expand Down