如何通过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 |

相关推荐
耿雨飞4 小时前
第三章:LangChain Classic vs. 新版 LangChain —— 架构演进与迁移指南
人工智能·架构·langchain
minebmw75 小时前
Oracle 19.29 中 ORA-00600 [4193] 错误完全解析与恢复指南
数据库·oracle
BizViewStudio5 小时前
甄选 2026:AI 重构新媒体代运营行业的三大核心变革与落地路径
大数据·人工智能·新媒体运营·媒体
俊哥V5 小时前
AI一周事件 · 2026年4月8日至4月14日
人工智能·ai
m0_377618235 小时前
Golang怎么连接MySQL数据库_Golang MySQL连接教程【总结】
jvm·数据库·python
GitCode官方5 小时前
G-Star Gathering Day 杭州站回顾
人工智能·开源·atomgit
LN花开富贵6 小时前
【ROS】鱼香ROS2学习笔记一
linux·笔记·python·学习·嵌入式·ros·agv
宇擎智脑科技6 小时前
开源 AI Agent 架构设计对比:Python 单体 vs TypeScript 插件化
人工智能·openclaw·hermes agent
weixin_586061466 小时前
C#怎么通过反射获取类属性_C#如何动态读取元数据【进阶】
jvm·数据库·python
Pluto_CSND6 小时前
PostgreSQL 聚合函数总览
数据库·postgresql