VectoRex VectoRex
首页
  • 介绍
  • 嵌入

    • Spring嵌入使用
    • Solon嵌入使用
  • 服务端

    • 部署Server
    • API文档
  • 客户端

    • Java SDK
    • Golang SDK
    • Python SDK
  • 须知

    • 度量类型
    • 应用场景
    • 注解详解
快速开始
Source (opens new window)
首页
  • 介绍
  • 嵌入

    • Spring嵌入使用
    • Solon嵌入使用
  • 服务端

    • 部署Server
    • API文档
  • 客户端

    • Java SDK
    • Golang SDK
    • Python SDK
  • 须知

    • 度量类型
    • 应用场景
    • 注解详解
快速开始
Source (opens new window)
  • 介绍

    • 项目简介
  • 指南

    • 度量类型
    • 应用场景
    • 注解详解
  • 嵌入

    • spring内嵌使用
    • solon内嵌使用
  • 服务端

    • 独立部署服务
    • API文档
  • 客户端

    • java sdk
    • go sdk
    • python sdk
      • 快速开始
        • 1. 初始化客户端
目录

python sdk

# VectorRexClient Python SDK

VectoRex Python SDK 是一个用于与 VectorRex 服务进行交互的 Python 客户端 SDK。它提供了创建集合、添加数据、查询数据等功能,帮助开发者更便捷地在应用中集成 VectorRex 服务。

# 快速开始

# 1. 初始化客户端



import os
import sys

from client import VectorRexClient, CollectionRequest, VectorField, ScalarField

# 添加项目根目录到 Python 路径
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

def main():
    # 初始化客户端
    client = VectorRexClient(base_uri="https://vectorex.m78cloud.cn", username="admin", password="123456")

    # 创建集合
    collection_req = CollectionRequest(
        collectionName="test_collection",
        vectorFileds=[VectorField(name="vector", metricType="FLOAT_COSINE_DISTANCE", dimensions=128)],
        scalarFields=[ScalarField(name="id", isPrimaryKey=True)]
    )
    response = client.create_collection(collection_req)
    if response["status"] == 0:
        print("Collection created successfully!")
    else:
        print(f"Failed to create collection: {response['msg']}")

if __name__ == "__main__":
    main()

go sdk

← go sdk

Theme by Vdoing | Copyright © 2024-2025 xgc | Apache License
  • 跟随系统
  • 浅色模式
  • 阅读模式
  • 深色模式