Construct Qdrant wrapper from a list of texts.
afrom_texts(
cls: type[Qdrant],
texts: list[str],
embedding: Embeddings,
metadatas: list[dict] | None = None,
ids: Sequence[str] | None = None,
location: str | None = None,
url: str | None = None,
port: int | None = 6333,
grpc_port: int = 6334,
prefer_grpc: bool = False,
https: bool | None = None,
api_key: str | None = None,
prefix: str | None = None,
timeout: int | None = None,
host: str | None = None,
path: str | None = None,
collection_name: str | None = None,
distance_func: str = 'Cosine',
content_payload_key: str = CONTENT_KEY,
metadata_payload_key: str = METADATA_KEY,
vector_name: str | None = VECTOR_NAME,
batch_size: int = 64,
shard_number: int | None = None,
replication_factor: int | None = None,
write_consistency_factor: int | None = None,
on_disk_payload: bool | None = None,
hnsw_config: models.HnswConfigDiff | None = None,
optimizers_config: models.OptimizersConfigDiff | None = None,
wal_config: models.WalConfigDiff | None = None,
quantization_config: models.QuantizationConfig | None = None,
init_from: models.InitFrom | None = None,
on_disk: bool | None = None,
force_recreate: bool = False,
**kwargs: Any = {}
) -> QdrantThis is a user-friendly interface that:
This is intended to be a quick way to get started.
from langchain_qdrant import Qdrant
from langchain_openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
qdrant = await Qdrant.afrom_texts(texts, embeddings, "localhost")| Name | Type | Description |
|---|---|---|
texts* | list[str] | A list of texts to be indexed in Qdrant. |
embedding* | Embeddings | A subclass of |
metadatas | list[dict] | None | Default: NoneAn optional list of metadata. If provided it has to be of the same length as a list of texts. |
ids | Sequence[str] | None | Default: NoneOptional list of ids to associate with the texts. Ids have to be uuid-like strings. |
location | str | None | Default: NoneIf ':memory:' - use in-memory Qdrant instance.
If |
url | str | None | Default: Noneeither host or str of "scheme | None, host, port | None, prefix | None". |
port | int | None | Default: 6333Port of the REST API interface. Default: 6333 |
grpc_port | int | Default: 6334Port of the gRPC interface. Default: 6334 |
prefer_grpc | bool | Default: FalseIf true - use gPRC interface whenever possible in custom methods. Default: False |
https | bool | None | Default: NoneIf true - use HTTPS(SSL) protocol. Default: None |
api_key | str | None | Default: NoneAPI key for authentication in Qdrant Cloud. Default: None
Can also be set via environment variable |
prefix | str | None | Default: NoneIf not None - add prefix to the REST URL path. Example: service/v1 will result in http://localhost:6333/service/v1/{qdrant-endpoint} for REST API. Default: None |
timeout | int | None | Default: NoneTimeout for REST and gRPC API requests. Default: 5.0 seconds for REST and unlimited for gRPC |
host | str | None | Default: NoneHost name of Qdrant service. If url and host are None, set to 'localhost'. Default: None |
path | str | None | Default: NonePath in which the vectors will be stored while using local mode. Default: None |
collection_name | str | None | Default: NoneName of the Qdrant collection to be used. If not provided, it will be created randomly. Default: None |
distance_func | str | Default: 'Cosine'Distance function. One of: "Cosine" / "Euclid" / "Dot". Default: "Cosine" |
content_payload_key | str | Default: CONTENT_KEYA payload key used to store the content of the document. Default: "page_content" |
metadata_payload_key | str | Default: METADATA_KEYA payload key used to store the metadata of the document. Default: "metadata" |
vector_name | str | None | Default: VECTOR_NAMEName of the vector to be used internally in Qdrant. Default: None |
batch_size | int | Default: 64How many vectors upload per-request. Default: 64 |
shard_number | int | None | Default: NoneNumber of shards in collection. Default is 1, minimum is 1. |
replication_factor | int | None | Default: NoneReplication factor for collection. Default is 1, minimum is 1. Defines how many copies of each shard will be created. Have effect only in distributed mode. |
write_consistency_factor | int | None | Default: NoneWrite consistency factor for collection. Default is 1, minimum is 1. Defines how many replicas should apply the operation for us to consider it successful. Increasing this number will make the collection more resilient to inconsistencies, but will also make it fail if not enough replicas are available. Does not have any performance impact. Have effect only in distributed mode. |
on_disk_payload | bool | None | Default: NoneIf true - point`s payload will not be stored in memory. It will be read from the disk every time it is requested. This setting saves RAM by (slightly) increasing the response time. Note: those payload values that are involved in filtering and are indexed - remain in RAM. |
hnsw_config | models.HnswConfigDiff | None | Default: NoneParams for HNSW index |
optimizers_config | models.OptimizersConfigDiff | None | Default: NoneParams for optimizer |
wal_config | models.WalConfigDiff | None | Default: NoneParams for Write-Ahead-Log |
quantization_config | models.QuantizationConfig | None | Default: NoneParams for quantization, if None - quantization will be disabled |
init_from | models.InitFrom | None | Default: NoneUse data stored in another collection to initialize this collection |
on_disk | bool | None | Default: NoneIf true - point`s payload will not be stored in memory. It will be read from the disk every time it is requested. This setting saves RAM by (slightly) increasing the response time. Note: those payload values that are involved in filtering and are indexed - remain in RAM. |
force_recreate | bool | Default: FalseForce recreating the collection |
**kwargs | Any | Default: {}Additional arguments passed directly into REST client initialization |