Metadata-Version: 2.4
Name: huace-aigc-prompt-client
Version: 0.1.6
Summary: 华策AIGC Prompt Client -- 提供提示词管理等功能
Author-email: Huace <support@huace.com>
License: MIT
Project-URL: Homepage, https://github.com/huace-aigc/huace-aigc-prompt-client
Project-URL: Documentation, https://github.com/huace-aigc/huace-aigc-prompt-client#readme
Project-URL: Repository, https://github.com/huace-aigc/huace-aigc-prompt-client
Project-URL: Issues, https://github.com/huace-aigc/huace-aigc-prompt-client/issues
Keywords: prompt,sdk,aigc,huace
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28.0
Requires-Dist: huace-aigc-auth-client>=1.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Dynamic: license-file

# Prompt SDK - 提示词管理 SDK

[![PyPI version](https://badge.fury.io/py/huace-aigc-prompt-client.svg)](https://badge.fury.io/py/huace-aigc-prompt-client)
[![Python](https://img.shields.io/pypi/pyversions/huace-aigc-prompt-client)](https://pypi.org/project/huace-aigc-prompt-client/)

## 核心特性

- `set` / `get` / `get_histories` / `delete` — 提示词 CRUD，自动版本管理
- 统一异常体系：`AuthenticationError` / `NotFoundError` / `RateLimitError` 等
- 自动链路追踪（`X-Trace-ID`）
- 幂等读操作自动重试

## 安装

```bash
pip install huace-aigc-prompt-client
```

## 快速开始

```python
from huace_aigc_prompt_client import PromptSDK
import os

# 必须配置：API_KEY + BASE_URL + ACCESS_TOKEN
sdk = PromptSDK(
    api_key=os.getenv("PROMPT_SDK_API_KEY"),
    base_url=os.getenv("PROMPT_SDK_BASE_URL", "http://localhost:7805"),
    access_token=os.getenv("AIGC_AUTH_ACCESS_TOKEN"),
)

# 新增提示词（operator 自动取自 token，无需显式传入）
result = sdk.set(
    prompt_type="system",
    key="chat_template",
    custom_prompt="You are a helpful AI assistant.",
)
print(f"prompt_id={result['prompt_id']}, version={result['version']}")

# 获取提示词
prompt = sdk.get(prompt_type="system", key="chat_template")
print(prompt["custom_prompt"])
```

## 环境变量

| 变量 | 必填 | 说明 |
|------|:---:|------|
| `PROMPT_SDK_API_KEY` | ✅ | 业务 API Key |
| `PROMPT_SDK_BASE_URL` | ✅ | 服务端地址 |
| `AIGC_AUTH_ACCESS_TOKEN` | ✅ | 用户访问令牌（JWT），用于注入 `Authorization` 头及解析用户名 |

## License

MIT License
