Documentation Index
Fetch the complete documentation index at: https://docs.shannon.run/llms.txt
Use this file to discover all available pages before exploring further.
从源代码安装(开发):
git clone https://github.com/Kocoro-lab/Shannon.git
cd Shannon/clients/python
pip install -e .
可选(WebSocket 流支持):
快速验证
from shannon import ShannonClient
client = ShannonClient(base_url="http://localhost:8080")
print("✓ SDK ready")
from shannon import ShannonClient
client = ShannonClient(
base_url="http://localhost:8080",
api_key="sk_test_123"
)
通过环境变量驱动:
import os
from shannon import ShannonClient
client = ShannonClient(
base_url=os.getenv("SHANNON_BASE_URL", "http://localhost:8080"),
api_key=os.getenv("SHANNON_API_KEY"),
)
客户端选项
| 参数 | 类型 | 默认值 | 说明 |
base_url | str | http://localhost:8080 | 网关 HTTP URL |
api_key | str | None | 作为 X-API-Key 发送 |
bearer_token | str | None | 备选的 Authorization: Bearer |
default_timeout | float | 30.0 | 秒 |
异步客户端
import asyncio
from shannon import AsyncShannonClient
async def main():
async with AsyncShannonClient(base_url="http://localhost:8080") as client:
h = await client.submit_task("分析数据")
s = await client.wait(h.task_id)
print(s.result)
asyncio.run(main())
CLI
python -m shannon.cli --base-url http://localhost:8080 submit "2+2 等于多少?" --wait