AsyncMilvusClient
AsyncMilvusClient 实例表示一个连接到特定 Zilliz Cloud 集群的异步 Python 客户端。它提供与 MilvusClient 相同的参数集和行为,唯一的区别在于调用它们的方式。
pymilvus.AsyncMilvusClient
构造函数
为常见用例构造一个客户端。
-
此接口仍处于早期阶段,未来版本中可能会有重大变化。建议您不要在生产环境中使用它。
-
要调用 AsyncMilvusClient,您需要从 asyncio 获取一个事件循环来管理请求处理。详情请参见 教程:结合 asyncio 使用 AsyncMilvusClient。
AsyncMilvusClient(
uri: str,
user: str,
password: str,
db_name: str,
token: str,
timeout=None,
**kwargs
)
参数:
-
uri (string) -
Zilliz Cloud 集群的 URI。例如:
-
集群 Endpoint
-
Free & Serverless
https://{cluster-id}.serverless.{region}.vectordb.zillizcloud.com -
Dedicated
https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530
-
-
项目 Endpoint(按需)
https://{project-id}.{region}.api.zillizcloud.com
-
-
user (string) -
用于连接指定 Zilliz Cloud 集群的有效用户名。
应与 password 一起使用。
-
password (string) -
用于连接指定 Zilliz Cloud 集群的有效密码。
应与 user 一起使用。
-
db_name (string) -
目标 Milvus 实例所属的 Database 名称。
-
token (string) -
用于访问指定 Zilliz Cloud 集群的有效访问令牌。
这可作为分别设置 user 和 password 的推荐替代方式。
设置此字段时,请注意:
有效 token 应为以下两者之一
-
timeout (float | None)
此操作的超时时长。
将其设置为 None 表示当收到任何响应或发生任何错误时,此操作即超时。
示例
import asyncio
from pymilvus import MilvusClient
# Get an event loop from asyncio
loop = asyncio.get_event_loop()
# Authentication enabled with a cluster user
client = AsyncMilvusClient(
uri="https://inxx-xxxxxxxxxxxx.api.gcp-us-west1.zillizcloud.com:19530",
token="user:password", # replace this with your token,
db_name="default"
)
将 uri 设置为您的集群 Endpoint。token 参数可以是具有足够权限的 Zilliz Cloud API key,也可以是格式为 username:p@ssw0rd 的集群用户凭据。