@@ -346,7 +346,7 @@ You can pass a `psycopg_pool` [AsyncConnectionPool](https://www.psycopg.org/psyc
346
346
or use the ` PostgresSettings ` to create a connection pool from environment variables.
347
347
348
348
``` python
349
- from semantic_kernel.connectors.memory. postgres import PostgresStore, PostgresSettings
349
+ from semantic_kernel.connectors.postgres import PostgresStore, PostgresSettings
350
350
351
351
settings = PostgresSettings()
352
352
@@ -363,9 +363,9 @@ You can also create a collection directly. The Collection itself is a context ma
363
363
in a connection pool, the collection will create one using the ` PostgresSettings ` class.
364
364
365
365
``` python
366
- from semantic_kernel.connectors.memory. postgres import PostgresCollection
366
+ from semantic_kernel.connectors.postgres import PostgresCollection
367
367
368
- collection = PostgresCollection(collection_name = " skhotels" , data_model_type = Hotel)
368
+ collection = PostgresCollection(collection_name = " skhotels" , record_type = Hotel)
369
369
async with collection: # This will create a connection pool using PostgresSettings
370
370
...
371
371
```
@@ -381,33 +381,33 @@ into a `dict` that can be serialized to Postgres rows.
381
381
- The data model properties annotated as vectors will be mapped to a table column that has the pgvector ` VECTOR ` type in Postgres.
382
382
383
383
``` python
384
+ from typing import Annotated
384
385
from pydantic import BaseModel
385
386
386
- from semantic_kernel.connectors.memory. postgres import PostgresCollection
387
- from semantic_kernel.data import (
387
+ from semantic_kernel.connectors.postgres import PostgresCollection
388
+ from semantic_kernel.data.vector import (
388
389
DistanceFunction,
389
390
IndexKind,
390
- VectorStoreRecordDataField,
391
- VectorStoreRecordKeyField,
392
- VectorStoreRecordVectorField,
391
+ VectorStoreField,
393
392
vectorstoremodel,
394
393
)
395
394
396
395
@vectorstoremodel
397
396
class Hotel (BaseModel ):
398
- hotel_id: Annotated[int , VectorStoreRecordKeyField( )]
399
- hotel_name: Annotated[str , VectorStoreRecordDataField( )]
400
- hotel_description: Annotated[str , VectorStoreRecordDataField( has_embedding = True , embedding_property_name = " hotel_description_embedding " )]
397
+ hotel_id: Annotated[int , VectorStoreField( " key " )]
398
+ hotel_name: Annotated[str , VectorStoreField( " data " )]
399
+ hotel_description: Annotated[str , VectorStoreField( " data " )]
401
400
hotel_description_embedding: Annotated[
402
401
list[float ] | None ,
403
- VectorStoreRecordVectorField (
404
- index_kind = IndexKind. HNSW ,
402
+ VectorStoreField (
403
+ " vector " ,
405
404
dimensions = 4 ,
405
+ index_kind = IndexKind.HNSW ,
406
406
distance_function = DistanceFunction.COSINE_SIMILARITY ,
407
407
),
408
408
] = None
409
409
410
- collection = PostgresCollection(collection_name = " Hotels" , data_model_type = Hotel)
410
+ collection = PostgresCollection(collection_name = " Hotels" , record_type = Hotel)
411
411
412
412
async with collection:
413
413
await collection.create_collection_if_not_exists()
@@ -519,7 +519,7 @@ class AsyncEntraConnection(AsyncConnection):
519
519
You can use the custom connection class with the ` PostgresSettings.get_connection_pool ` method to create a connection pool.
520
520
521
521
``` python
522
- from semantic_kernel.connectors.memory. postgres import PostgresSettings, PostgresStore
522
+ from semantic_kernel.connectors.postgres import PostgresSettings, PostgresStore
523
523
524
524
525
525
pool = await PostgresSettings().create_connection_pool(connection_class = AsyncEntraConnection)
0 commit comments