Metadata-Version: 2.4
Name: airoles
Version: 0.5.7
Summary: AI Role 树 — 约束 LLM 防致幻（Role / Policy 唯一源码）
License-Expression: MIT
Project-URL: Homepage, https://gitee.com/wangguoran/airoles
Project-URL: Repository, https://gitee.com/wangguoran/airoles.git
Keywords: ai,llm,prompt,rag,anti-hallucination,dify
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.25; extra == "anthropic"

# airoles

**Model-Agnostic Agent Role Framework** — 防致幻规则 + PromptBuilder + Runtime。

```bash
pip install airoles
export AIROLES_API_KEY=sk-...
export AIROLES_BASE_URL=https://api.deepseek.com/v1
export AIROLES_MODEL=deepseek-chat
```

```python
from airoles import Planner

result = Planner.from_env().run(
    "帮我规划一套 ERP 系统",
    policy_mode="planning",
)
print(result["need_confirmation"], result["plan"]["summary"])
```

**无 API Key 测试**（Mock Provider）:

```python
from airoles import Agent, CallableProvider

agent = Agent(CallableProvider(your_mock_fn))
out = agent.plan("...", skip_clarify=True)
```

## 三层

| 层 | API | 版本 |
|----|-----|------|
| Prompt | `ROLE_*`, `POLICY_*`, `templates` | v0.1+ |
| 组装 | `PromptBuilder` + `PolicySelector` + `compiled/` | v0.5 |
| Runtime | `Planner.from_env().run()` + Provider + Adapters | v0.3+ |

- [ARCHITECTURE.md](./ARCHITECTURE.md) — 六层架构 + P4 路线图
- [OPERATION.md](./OPERATION.md) — 发版
