Skip to main content

Cota

Bot 开发与部署平台

把业务经验做成机器人,验证它的表现,再交付给自己或别人使用。

开始第一个 Bot · 项目主页 · 使用文档 · weather 示例

Cota 工作方式:用 Skill 和 Policy 定义业务,Bot 在对话中选择能力并调用工具,保留执行记录并评测,最后通过聊天入口或 Bot 文件夹交付。开发者根据记录人工修改业务案例,再验证效果。

原理示意动画,非实时运行或实际评测结果。查看静态图

为什么需要 Cota?

让模型回答一次问题之后,还需要把业务做法、执行过程和使用入口组织起来,机器人才能长期使用。

  • **把业务经验写下来。**什么时候先问一句,什么时候查数据,遇到异常怎么处理,用业务案例指导 Bot。
  • **让改进有依据。**看真实对话和工具记录,用同一份验证集对比修改前后的结果。
  • **把成果交付出去。**维护一个聊天服务,或把角色、能力、规则、配置和验证案例放进 Bot 文件夹交付。

Cota 面向懂业务、愿意编辑 YAML / Markdown 并维护运行环境的开发者。个人助手、客服和群聊助手是它的使用场景;完整的 Bot 是交付单位。

快速开始

1. 安装并初始化

需要 Python 3.12+。在准备好的 Python 环境中安装已发布版本:

python -m pip install -U cota
cota init
cd cota_projects/weather

cota init 创建官方示例目录,并保留已有的同名 Bot。使用飞书可安装 cota[feishu]。带内置运行时的平台 wheel 包含固定版本 Node/Pi;具体要求见 安装说明。

从源码开发或使用仓库最新代码

另外准备 Node.js 22.19+ 和 npm;固定 Node 版本见 .node-version。

git clone https://github.com/CotaAI/cota.git
cd cota
python -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[dev]'
npm ci --prefix cota/runtime/pi
cota init
cd cota_projects/weather

2. 配置模型

编辑 Bot 的 endpoints.yml,填写支持工具调用的模型服务,并保留模板中的 SQLite 配置:

llms:
  default:
    type: openai
    key: "填写模型服务密钥"
    apibase: "填写兼容 Chat Completions 的 API 地址"
    model: "填写支持工具调用的模型名称"

3. 开始对话,看清它怎么做

cota shell --debug

试着连续问两轮:

杭州,两大一小,今天想找室内亲子活动,门票总预算三百。

预算改成一百,其他条件不变。

终端会输出本地 Debug 页面地址,可以查看 Events、Skill 与工具目录、模型请求、DST 和投递状态。

输入 /stop 退出 Shell,再在 Bot 目录评测:

cota eval

weather 自带 30 个对话评测案例,覆盖多轮条件变更、预算约束、业务回复和异常处理。天气查询使用外部接口,活动查询使用随示例提供的活动目录,便于复现验证。详见 weather 示例。

想验证更长的制作流程,可以使用 绘本工坊:组合故事与分镜、图像生成/编辑、视觉审校和中文 PDF,并通过配套 Web 应用下载成品。它是 personal 示例,需要自行配置图像/视觉服务及可选排版依赖。

对话支持文件附件:Shell 用 /file "路径" 添加文件,Web 支持上传和授权下载;两者沿用统一的会话与历史链路。personal Bot 可交付工作区中的报告、图片或 PDF,文件内容独立于事件数据库保存。

需要浏览器聊天入口时,在 Bot 目录启动:

cota run --chat-app --host 127.0.0.1 --port 5005

打开 http://127.0.0.1:5005/chat/。对外提供服务前,按 部署指南 配置访问入口与授权。

Cota 如何把一个 Bot 做完整?

定义:能力与正确做法一起维护

my-bot/
├── agent.yml                 # 角色、行为、工具权限与 Policy 策略
├── endpoints.yml             # 模型、存储与 Channel 配置
├── skills/                   # 业务能力说明、SOP 与资源
└── policy/
    ├── data.yml              # 业务案例:教 Bot 怎样做
    └── eval/data.yml         # 验证案例:检查它是否做到

**Skill 描述“能做什么”,Policy 指导“这时候怎样做”。**模型结合当前对话和真实执行结果选择、组合能力。

例如,天气服务没有返回有效数据时,期望 Bot 说明情况。在 policy/data.yml 写下:

policies:
  - name: 天气查询失败时说明情况
    steps:
      - user: 北京现在多少度?
      - bot:
          - skills: [weather]
          - result: 主服务与备用服务都没有返回有效天气数据。
          - reply: 暂时没查到北京的气温,稍后再试一下吧。

result 描述案例适用的结果条件;运行时仍以本次实际数据为准。你可以直接编写案例,也可以用 cota annotate export 导出真实对话草稿,人工修改后通过 cota annotate import 校验。

案例较多时,可选择 BM25、Embedding 或模型策略,并按需用 cota train 准备索引等产物。运行时结合当前对话与执行事实,在每次模型请求前选取适用指导。使用方法见 业务标注 与 Policy 训练和推理。

验证:按业务要求逐项检查

在 policy/eval/data.yml 用相近的对话格式写要求:

policies:
  - name: 缺少查询城市
    steps:
      - user: 帮我查一下天气
      - bot:
          reply-review:
            - 询问用户要查询的城市。
            - 不擅自选择城市,也不编造天气数据。

cota eval 运行 Bot,再用 LLM 按回复要求逐项评判,输出进度、评分、报告和结构化执行证据。验证要求不会提供给被测 Bot;评委优先使用 llms.evaluator,未配置时使用默认模型。

改进流程是:

查看真实记录 → 人工修改 Skill / Policy → 按需训练 → 用同一验证集评测 → 比较版本

cota eval judge 可以重评已有执行记录,cota eval compare 可以比较多次评测。LLM 评委可能误判,关键业务结果仍需复核。完整用法见 对话评测 和 Debug。

交付:聊天入口,或 Bot 文件夹

交付方式 使用者得到什么 谁维护运行环境
分享已有服务 网页、IM 或已有应用中的聊天入口 服务维护者
分享 Bot 文件夹 配置、Skill、Policy、验证案例及所需资源 接收方安装 Cota、准备凭据与业务依赖,独立部署

业务规则和验证案例可以随 Bot 一起交付、持续更新。具体准备工作见 交付与分享。

选择你的使用方式

你要做什么 Cota 的支持 从这里开始
自己长期使用的助手 本机或自用云主机运行,保留对话与个人记忆,按配置使用部署环境工具 Agent 与部署模式
客服或业务助手 对接业务接口,按会话保存历史、去重和排队,跨会话有限并发 Application 接入
团队或社群助手 被 @ 时回应,也可启用主动参与判断,使用带说话者身份的群聊上下文 群聊模式
自有网页或小程序 HTTP/WebSocket 接入,可选聊天页面提供会话列表、历史分页和未读状态 Web 接入 · 配套聊天应用
飞书或公司内部 IM 内置飞书;其它平台以独立 Channel 包安装、配置,复用生命周期与投递机制 飞书 · 自定义 Channel

身份认证、会话归属和成员授权由外围应用或平台适配器完成。Cota 负责已验证输入的执行协调、记录和回复投递。

常见问题

Cota 提供托管平台或可视化搭建吗?

当前提供文件配置、命令行和自行部署的工作流。创作者分享聊天入口时维护服务,分享文件夹时由接收方独立部署。托管云平台与可视化拖拽搭建不在当前交付范围内。

自用助手和多人服务的工具权限怎么区分?

deploy: personal 用于自己的电脑或自用云主机;deploy: service 用于对外提供服务,默认不开放部署机器的原生文件与 Shell。工作目录不构成安全沙箱。权限与执行环境见 工具接入。

Cota 和 Pi 分别负责什么?

官方 TypeScript Pi Agent Core 驱动模型—工具循环。Cota 负责 Bot 定义、Policy 指导、应用接入、持久化、交付与验证。DST 根据事件恢复状态,Store 保存事件与快照,Trace 用于回溯执行证据。详见 模块地图 与 执行流程。

可以自动优化 Bot 吗?

当前支持记录、业务标注、Policy 训练、对话评测与版本比较,由开发者据此更新 Bot。自动生成优化版本并验证、应用的 RSI 流程仍是后续方向。

可以开多个进程共同执行同一个 Bot 吗?

当前执行协调以单进程为边界。同一 Bot 的数据库使用一个执行进程;SQL revision 不能替代跨进程执行租约,也不能撤销已发生的外部副作用。部署方式见 部署指南。

文档与开发

从源码开发时运行:

python scripts/check.py --coverage

检查语法、静态规则、Python/JavaScript 回归与覆盖率。框架测试使用可控模型响应;业务效果使用自己的验证集和模型服务评测。

MIT License

Metadata

Release files for cota 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cota 2.0.0
File Size Uploaded Provenance Actions
cota-2.0.0.tar.gz 363.2 kB With provenance Details for cota-2.0.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for cota 2.0.0
File Actions
cota-2.0.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for cota-2.0.0-py3-none-manylinux_2_28_x86_64.whl
cota-2.0.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for cota-2.0.0-py3-none-manylinux_2_28_aarch64.whl
cota-2.0.0-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details for cota-2.0.0-py3-none-macosx_11_0_x86_64.whl
cota-2.0.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for cota-2.0.0-py3-none-macosx_11_0_arm64.whl

Total release size: 294.9 MB

Release files / cota-2.0.0.tar.gz

Download URL cota-2.0.0.tar.gz
Size 363.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2711b5622c9f1113c95cf12fc92e6e8e3dea59af68ae80cff5e5d62a37bb69ca
BLAKE2b-256 checksum
How to use checksums
08d72422ee01758d7cc9617e3927bfb1d07509b93fcafdfcec55b0c41ea3abde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / cota-2.0.0-py3-none-manylinux_2_28_x86_64.whl

Download URL cota-2.0.0-py3-none-manylinux_2_28_x86_64.whl
Size 76.8 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
8164b6b13272d879a1596401afde300f4a516ffa1e17e9b0c888626cf61b9c13
BLAKE2b-256 checksum
How to use checksums
c30ec7d74108596a26bc599c8427571749e0f278898aabf63e79b1b40aac38fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / cota-2.0.0-py3-none-manylinux_2_28_aarch64.whl

Download URL cota-2.0.0-py3-none-manylinux_2_28_aarch64.whl
Size 76.7 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
6c68281c1a6e1ba56290f8d52628bb4db66709d8ea21687bf8a6c48a8357a9a2
BLAKE2b-256 checksum
How to use checksums
6f3c8d0e3bb349b8ede30261cb3f4712681e4d723cfd5b88d34e5df07dadb594
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / cota-2.0.0-py3-none-macosx_11_0_x86_64.whl

Download URL cota-2.0.0-py3-none-macosx_11_0_x86_64.whl
Size 71.1 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
cbf4bbcb72113ab41974aa01b35bf3d0693f9e79c6c4060fe39adf000bf4915e
BLAKE2b-256 checksum
How to use checksums
df2ceac69b3f1a5fcf64706a4f3e47ef6d900eb544b001ef71ae24cc458ed776
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / cota-2.0.0-py3-none-macosx_11_0_arm64.whl

Download URL cota-2.0.0-py3-none-macosx_11_0_arm64.whl
Size 69.9 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
07087747ad6c1d6ae7db84b47d7a65c8628b8228029d6423bd7371031c287ba0
BLAKE2b-256 checksum
How to use checksums
59771b854539624881887c32ab161e3e78e44ef9c5e07e789c4672038f82f21a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Security for cota 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for cota-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page