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).

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.1.0.tar.gz (8.9 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.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for uip_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a15c89c06b878a735c0c8a6ae73850e46118aa547b546161050b33f88b243aba
MD5 e7b5c8f1bab9ccf3f0e53e3758cc2f58
BLAKE2b-256 dc8791a091c8affb6782ea97c44e1274187ddab0b12fcd5da9e33a2910bcd0cc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for uip_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c2819284901ff416ff58f175b4582d52c4852cc53fe2048551d96e607f7ff81
MD5 345351999aff71f5f9bd4f00dcfd1cb3
BLAKE2b-256 79609d31ba427a73a1507c95670526ef1023f54828261fd8633db41f3cd3511a

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