VirtualOffice Agent SDK — 透明拦截转发 + 平台 API 封装
Project description
vokit — VirtualOffice Agent SDK
一行 import vokit 完成拦截激活 + API 就绪。
安装
# 稳定版
pip install vokit
# 指定版本
pip install vokit==0.1.3
# 升级
pip install --upgrade vokit
快速开始
1. 拦截 LLM 请求
在 Agent 的入口文件最顶部 import 一次即可:
import vokit
- 只需 import 一次:patch 注册在进程级别的 HTTP 库入口,全局生效。
- 放在最顶部:确保在所有 LLM SDK 被 import 之前 patch 已注册好。
- 幂等安全:多次 import 不会重复注册。
2. 使用平台 API
import vokit
# 提交产出物
vokit.submit_output(
output_type="file",
content="base64编码的内容",
filename="report.pdf",
mime_type="application/pdf"
)
# 上报指标数据
vokit.report_metrics(metrics=[
{"metricType": "token_usage", "metricValue": 1500, "snapshotDate": "2026-04-14"},
])
# 上报费用记录
vokit.report_billing(
cost=150,
request_id="unique-request-id",
call_date="2026-04-14",
api_type="chat",
)
3. Token Override & Claims
import vokit
# Override token for a scope
with vokit.use_access_token("custom-token"):
vokit.submit_output("url", "https://...")
# Read JWT claims
claims = vokit.get_claims()
print(claims.enterprise_id, claims.agent_id)
运行模式
开发模式
不设置 VO_GATEWAY_URL 和 VO_ACCESS_TOKEN 时自动进入:
- LLM 请求直连 Provider,不被拦截
- 平台 API 返回 Mock 数据
export OPENAI_API_KEY="your-key"
python your_agent.py
生产模式
设置环境变量后自动进入:
export VO_GATEWAY_URL=http://localhost:8888
export VO_ACCESS_TOKEN=<your-jwt-token>
export OPENAI_API_KEY="your-key"
python your_agent.py
环境变量
| 变量 | 说明 |
|---|---|
VO_GATEWAY_URL |
内网网关地址,缺失则进入开发模式 |
VO_ACCESS_TOKEN |
网关 Bearer Token,缺失则进入开发模式 |
VO_DEV_MODE |
设为 1 强制进入开发模式 |
VO_RSA_PUBLIC_KEY_PATH |
RSA public key PEM path for get_claims() |
Python 版本
要求 Python 3.10+
License
MIT
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
vokit-0.1.8.tar.gz
(30.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
vokit-0.1.8-py3-none-any.whl
(18.3 kB
view details)
File details
Details for the file vokit-0.1.8.tar.gz.
File metadata
- Download URL: vokit-0.1.8.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df4e83023a82afc9fe966bb1e71739b9de7a2046798f2665c7b6cad568dc3f83
|
|
| MD5 |
523d5f8d570975c3d7ae3a4574f7e0ca
|
|
| BLAKE2b-256 |
fd2c9d1d6ded23e057584be9ed2199d083b8eecb47bda61a20cdaac934be707a
|
File details
Details for the file vokit-0.1.8-py3-none-any.whl.
File metadata
- Download URL: vokit-0.1.8-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1bcfb73fa339707b8d180dcfd1fafa37caa50701ae5424936bed3376efb4d49
|
|
| MD5 |
fb5e78247e96d7ac3e7820c7c72e3c90
|
|
| BLAKE2b-256 |
5eef28a65c6c47fe151bd70fe94c403b91be9ad73b832960cf4c9e4a6a2659d5
|