mirror of
https://github.com/qdrant/qdrant-client.git
synced 2026-07-23 11:11:01 -05:00
update async readme
This commit is contained in:
42
README.md
42
README.md
@@ -223,23 +223,47 @@ client = QdrantClient(host="localhost", grpc_port=6334, prefer_grpc=True)
|
||||
|
||||
## Async client
|
||||
|
||||
Async methods are available in raw autogenerated clients.
|
||||
Usually, you don't need to use them directly, but if you need extra performance, you can access them directly.
|
||||
Starting from version 1.6.1, all python client methods are available in async version.
|
||||
|
||||
### Async gRPC
|
||||
|
||||
Example of using raw async gRPC client:
|
||||
To use it, just import `AsyncQdrantClient` instead of `QdrantClient`:
|
||||
|
||||
```python
|
||||
from qdrant_client import QdrantClient, grpc
|
||||
from qdrant_client import AsyncQdrantClient, models
|
||||
import numpy as np
|
||||
import asyncio
|
||||
|
||||
client = QdrantClient(prefer_grpc=True, timeout=3.0)
|
||||
async def main():
|
||||
# Your async code using QdrantClient might be put here
|
||||
client = AsyncQdrantClient(url="http://localhost:6333")
|
||||
|
||||
grpc_collections = client.async_grpc_collections
|
||||
await client.create_collection(
|
||||
collection_name="my_collection",
|
||||
vectors_config=models.VectorParams(size=10, distance=models.Distance.COSINE),
|
||||
)
|
||||
|
||||
res = await grpc_collections.List(grpc.ListCollectionsRequest(), timeout=1.0)
|
||||
await client.upsert(
|
||||
collection_name="my_collection",
|
||||
points=[
|
||||
models.PointStruct(
|
||||
id=i,
|
||||
vector=np.random.rand(10).tolist(),
|
||||
)
|
||||
for i in range(100)
|
||||
],
|
||||
)
|
||||
|
||||
res = await client.search(
|
||||
collection_name="my_collection",
|
||||
query_vector=np.random.rand(10).tolist(), # type: ignore
|
||||
limit=10,
|
||||
)
|
||||
|
||||
print(res)
|
||||
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
Both, gRPC and REST API are supported in async mode.
|
||||
More examples can be found [here](./tests/test_async_qdrant_client.py).
|
||||
|
||||
### Development
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
from .async_qdrant_client import AsyncQdrantClient as AsyncQdrantClient
|
||||
from .qdrant_client import QdrantClient as QdrantClient
|
||||
|
||||
Reference in New Issue
Block a user