Skip to main content

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_URLVO_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.6.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vokit-0.1.6-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file vokit-0.1.6.tar.gz.

File metadata

  • Download URL: vokit-0.1.6.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.1

File hashes

Hashes for vokit-0.1.6.tar.gz
Algorithm Hash digest
SHA256 5cb8f58ea9c956e028a443c38285ce6b73260f6925c0591e91de993fc2f9befc
MD5 30cf66a7f8b64a95ce425bb8e72500bd
BLAKE2b-256 fdc6992203e2136bbedf00cd75a6d276a36da85fd1e24b8cdc9cd25effe695af

See more details on using hashes here.

File details

Details for the file vokit-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: vokit-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.1

File hashes

Hashes for vokit-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d1ef7d4c17614f52862229f0b907cb9e99e8124bb8edd6d15c05d9c215c0611b
MD5 525d3c373cce911d5d3bc25d0563ec11
BLAKE2b-256 fc40c21dc12cdb4d0c824ec3a698c9525b07daac5a6bfa77eba8c424c3ffda32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page