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_URL 时自动进入:

  • LLM 请求直连 Provider,不被拦截
  • 平台 API 返回 Mock 数据
export OPENAI_API_KEY="your-key"
python your_agent.py

生产模式

设置环境变量后自动进入:

export VO_GATEWAY_URL=http://localhost:8888
export OPENAI_API_KEY="your-key"
python your_agent.py

环境变量

变量 说明
VO_GATEWAY_URL 内网网关地址,缺失则进入开发模式
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.2.2.tar.gz (30.0 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.2.2-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for vokit-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0c1340f8b31d3d90a8fb350f43fb56e303c5426c6543254e96ffa570fb23038a
MD5 92e590850c979d49a22b451065ea57e5
BLAKE2b-256 b14cf8c26edeed0ed3f267f98e2526b3ef11b5072b5c93d65cfa50f08c663126

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vokit-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 17.6 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.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 860669f111840f27fe465e42b8d7fac5d9016d141cb9283769aff6d22b8ee3be
MD5 3e3ffd33faa5bdb364b974957dae4c02
BLAKE2b-256 4e2194298d40f6cca0c62d20f05c5b0e48afef12d120f6613eedad424b383551

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