Metadata-Version: 2.4
Name: uip-sdk
Version: 0.1.0
Summary: UIP — Universal Inference Platform Python SDK
Author-email: Zhu Wenbo <zwb.2002@tsinghua.org.cn>
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27

# UIP Python SDK

Universal Inference Platform 的 Python 客户端库。

## 安装

```bash
pip install uip-sdk
```

## 快速开始

```python
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)

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

### 流式生成

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

### Rerank (文档重排序)

```python
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}")
```

### 批量推理

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

### 指定调度策略

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

### 嵌入向量

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