Skip to main content

UIP — Universal Inference Platform Python SDK

Project description

UIP Python SDK

Universal Inference Platform 的 Python 客户端库。

安装

pip install uip-sdk

快速开始

from uip_sdk import UIPClient

# 方式 1: API Key
client = UIPClient(api_key="ggw-xxx...")

# 方式 2: JWT Token
client = UIPClient(token="eyJhbGciOiJIUzI1NiIs...")

# 方式 3: 环境变量 (UIP_API_KEY)
client = UIPClient()

使用示例

对话 (Chat Completions)

resp = client.chat(
    messages=[{"role": "user", "content": "你好"}],
    model="qwen2.5:7b",
)
print(resp.text)

流式生成

for chunk in client.generate("写一首关于春天的诗", stream=True):
    print(chunk.text, end="", flush=True)

Rerank (文档重排序)

results = client.rerank(
    query="CBA季后赛战术分析",
    documents=[
        "CBA联赛采用胜率决定排名",
        "篮球三分线距离为6.75米",
        "广东队采用全场紧逼战术",
    ],
    model="Qwen3-Reranker-0.6B",
    top_n=2,
)
for r in results.results:
    print(f"#{r.index}: {r.document[:30]}... score={r.relevance_score:.2f}")

批量推理

batch = client.batch(
    prompts=["你好", "介绍你自己"],
    model="qwen2.5:7b",
)
for item in batch.results:
    print(f"[{item.index}] {item.response[:50]}")

指定调度策略

client.with_strategy("least_queue").generate("hi")

嵌入向量

resp = client.embed(input="需要向量化的文本", model="bge-m3:567m")
print(len(resp.embedding))  # 768

License

MIT License. Copyright (c) 2026 Zhu Wenbo (zwb.2002@tsinghua.org.cn).

UMR 通用推理(17 种模态)

训练管理

UMR 通用推理(17 种模态)

# SDXL 文生图
result = client.infer("sdxl:base", {"prompt": "a cat"})

# 目标检测
result = client.infer("yolov8:m", {"image": "photo.jpg"})

# ASR 语音识别
result = client.infer("whisper:large-v3", {"audio": "speech.wav"})

# BERT 编码
result = client.infer("bert-base:chinese", {"text": "hello world"})
print(result.modal_type)  # "llm"

训练管理

# 提交训练任务
job = client.submit_job(
    model="qwen2.5:7b",
    name="experiment-1",
    n_gpus=1,
    epochs=3,
)
print(job["job_id"])

# 任务列表
jobs = client.list_jobs(status="running")

# 任务详情
detail = client.get_job(job["job_id"])

# 取消任务
client.cancel_job(job["job_id"])

# 训练日志
logs = client.get_job_logs(job["job_id"], tail=50)

# 断点列表
ckpts = client.list_checkpoints(job["job_id"])

# 最新断点
latest = client.get_latest_checkpoint(job["job_id"])

# 数据集列表
datasets = client.list_datasets()

# 训练指标
metrics = client.get_training_metrics(job["job_id"])

# SSE 流式训练日志
for line in client.stream_job_logs(job["job_id"]):
    print(line, end="")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uip_sdk-0.2.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uip_sdk-0.2.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file uip_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: uip_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for uip_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5cd9931e23d656d77a968aae51e0b9176163e4b3f9c99a9444f09ea98dde414a
MD5 f691ffec51778c1331418800617604b8
BLAKE2b-256 71603bb5b7e783fd7bd0d3a6f50596e1825ce5d24dea943f54a067b017ca58dd

See more details on using hashes here.

File details

Details for the file uip_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: uip_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for uip_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e44b29bf67c71ac1b305cd2a83cbb378f4536321f329c16ac554edf8e67edcdf
MD5 8008cd68f63c4b5cf49fe802cba52f89
BLAKE2b-256 4f6a62a0c79fdc922832d0ffdb8fd36d06c6474b330062aa1e0749abc6504e73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page