langchain.vectorstores.timescalevector.TimescaleVector¶
class langchain.vectorstores.timescalevector.TimescaleVector(service_url: str, embedding: Embeddings, collection_name: str = 'langchain_store', num_dimensions: int = 1536, distance_strategy: DistanceStrategy = DistanceStrategy.COSINE, pre_delete_collection: bool = False, logger: Optional[Logger] = None, relevance_score_fn: Optional[Callable[[float], float]] = None, time_partition_interval: Optional[timedelta] = None)[source]¶
VectorStore implementation using the timescale vector client to store vectors
in Postgres.
To use, you should have the timescale_vector python package installed.
Parameters
service_url – Service url on timescale cloud.
embedding – Any embedding function implementing
langchain.embeddings.base.Embeddings interface.
collection_name – The name of the collection to use. (default: langchain_store)
This will become the table name used for the collection.
distance_strategy – The distance strategy to use. (default: COSINE)
pre_delete_collection – If True, will delete the collection if it exists.
(default: False). Useful for testing.
Example
from langchain.vectorstores import TimescaleVector
from langchain.embeddings.openai import OpenAIEmbeddings
SERVICE_URL = "postgres://tsdbadmin:<password>@<id>.tsdb.cloud.timescale.com:<port>/tsdb?sslmode=require"
COLLECTION_NAME = "state_of_the_union_test"
embeddings = OpenAIEmbeddings()
vectorestore = TimescaleVector.from_documents(
    embedding=embeddings,
    documents=docs,
    collection_name=COLLECTION_NAME,
    service_url=SERVICE_URL,
)
Attributes
DEFAULT_INDEX_TYPE
embeddings
Access the query embedding object if available.
Methods