如何通过Python SDK新建一个DashVector Client

本文介绍如何通过Python SDK新建一个DashVector Client。

说明

通过DashVector Client可连接DashVector服务端,进行Collection相关操作。

前提条件

接口定义

Python示例:

复制代码
dashvector.Client(
    api_key: str,
    endpoint: str,
    protocol: dashvector.DashVectorProtocol = dashvector.DashVectorProtocol.GRPC,
    timeout: float = 10.0
) -> Client

使用示例

说明

需要使用您的api-key替换示例中的YOUR_API_KEY、您的Cluster Endpoint替换示例中的YOUR_CLUSTER_ENDPOINT,代码才能正常运行。

Python示例:

复制代码
import dashvector

client = dashvector.Client(
    api_key='YOUR_API_KEY',
    endpoint='YOUR_CLUSTER_ENDPOINT'
)

# 判断client是否创建成功
if client:
    print('create client success!')

# 等同于下列代码
# from dashvector import DashVectorCode
# if client.code == DashVectorCode.Success:
#     print('create client success!')

入参描述

|--------------|--------------------|-------------------------|------------------------------------------------------|
| 参数 | 类型 | 默认值 | 说明 |
| api_key | str | - | api-key |
| endpoint | str | - | Cluster的Endpoint |
| protocol(可选) | DashVectorProtocol | DashVectorProtocol.GRPC | 通信协议,DashVectorProtocol.GRPC、DashVectorProtocol.HTTP |
| timeout(可选) | float | 10.0 | 超时时间(单位:秒),-1 代表不超时。 |

说明

1.endpoint参数,可在控制台Cluster详情中查看。

2.protocol参数,建议使用默认值DashVectorProtocol.GRPC,可获得更高的性能体验。

出参描述

说明

返回结果为Client对象,Client对象中可获取本次操作结果信息,如下表所示。

|------------|--------|---------------------------------------------------------------------------------|--------------------------------------|
| 字段 | 类型 | 描述 | 示例 |
| code | int | 返回值,参考返回状态码说明 | 0 |
| message | str | 返回消息 | success |
| request_id | str | 请求唯一id | 19215409-ea66-4db9-8764-26ce2eb5bb99 |

相关推荐
地瓜伯伯1 分钟前
从MESI缓存一致性协议讲透synchronized的底层
java·spring boot·spring·spring cloud·微服务·springcloud
杨云龙UP3 分钟前
Spotlight 接入 Oracle 数据库监控操作指南 2026-06-16
数据库·oracle·性能监控·预警·阈值·spotlight·瓶颈分析
三千花灯4 分钟前
【Playwright】 自动化测试之参数化登录(Excel/CSV 数据源)
人工智能·机器学习·excel
johnny2336 分钟前
Agent记忆框架:MemPalace、Cognee、Hindsight、memories.ai
人工智能
YOLO数据集集合7 分钟前
无人机风电设备智能巡检 风机叶片缺陷目标检测数据集实战 | 表面腐蚀漏油识别 工业视觉质检 深度学习模型训练落地10337期
人工智能·深度学习·目标检测·计算机视觉·无人机
zhenlai20128 分钟前
Vue3 + SpringBoot + AI:我做了一个股票分析工具(第1周复盘)
人工智能·spring boot·后端
装不满的克莱因瓶8 分钟前
【工业领域】了解目标检测基本流程——从数据到部署的完整工程化思路
人工智能·python·深度学习·机器学习·计算机视觉·目标跟踪·工业领域
叫我:松哥9 分钟前
基于Python flask的中学可控智能命题系统设计与实现,整合遗传算法、DeepSeek 大模型及数据库技术构建一体化应用
数据库·人工智能·python·算法·机器学习·flask·遗传算法
阿维的博客日记10 分钟前
Hippo4j 线程池监控接入方法
数据库·hippo4j
Devin~Y10 分钟前
大厂 Java 面试实录:从音视频内容社区到 AI RAG 的全链路技术设计
java·spring boot·redis·spring cloud·微服务·kafka·音视频