andrewyng / aisuite
andrewyng / aisuite
OpenCoworker An AI agent that lives on your desktop, built on aisuite. OpenCoworker is a desktop AI agent that can not only chat, but also do deep research and carry out tasks for you on your computer. It can read files (with permission) to gain context, read/send messages (slack, email, etc.), and create real deliverables like PDF reports, documents, spreadsheets. It also supports scheduled automations, such as providing you a daily news summary. Requires bringing your own API key (OpenAI, Anthropic, Google) or run fully local with Ollama. Your data stays on your machine. OpenCoworker 一个基于 aisuite 构建、驻留在桌面上的 AI 智能体。OpenCoworker 不仅仅能聊天,还能在你的电脑上进行深度研究并执行任务。它可以在获得许可的情况下读取文件以获取上下文,读取/发送消息(如 Slack、电子邮件等),并创建 PDF 报告、文档、电子表格等实际交付成果。它还支持定时自动化任务,例如为你提供每日新闻摘要。使用时需提供你自己的 API 密钥(OpenAI、Anthropic、Google),或通过 Ollama 完全本地运行。你的数据将保留在本地机器上。
⬇ Download for macOS macOS 13+ (Apple Silicon) ⬇ Download for Windows Windows 10/11 (x64) ⬇ 下载 macOS 版 (macOS 13+,Apple Silicon) ⬇ 下载 Windows 版 (Windows 10/11,x64)
· Quickstart: — install, connect a model, first tasks, automations. Its source lives in this repository under platform/ — a working reference for building your own agent harness on aisuite.
· 快速入门:安装、连接模型、执行首个任务、设置自动化。其源代码位于本仓库的 platform/ 目录下,是基于 aisuite 构建你自己的智能体框架的实用参考。
aisuite aisuite is a lightweight Python library for building with LLMs, in two layers: a unified Chat Completions API across providers, and an Agents API with tools and toolkits on top. This repo is also home to OpenCoworker, a desktop AI coworker built using aisuite: aisuite aisuite 是一个轻量级的 Python 库,用于构建大模型应用,包含两个层级:跨提供商的统一聊天补全 API(Chat Completions API),以及在其之上提供工具和工具包的智能体 API(Agents API)。本仓库也是 OpenCoworker 的所在地,这是一个使用 aisuite 构建的桌面 AI 同事:
┌───────────────────────────────────────────────┐
│ OpenCoworker │ agent harness for doing everyday tasks
├───────────────────────────────────────────────┤
│ Agents API · Toolkits · MCP │ build agents across multiple LLMs
├───────────────────────────────────────────────┤
│ Chat Completions API │ one API across multiple LLM providers
├────────┬───────────┬────────┬────────┬────────┤
│ OpenAI │ Anthropic │ Google │ Ollama │ Others │
└────────┴───────────┴────────┴────────┴────────┘
Chat Completions API — a unified, OpenAI-style interface for OpenAI, Anthropic, Google, Mistral, Hugging Face, AWS, Cohere, Ollama, OpenRouter, and more. Swap providers by changing one string. Chat Completions API — 为 OpenAI、Anthropic、Google、Mistral、Hugging Face、AWS、Cohere、Ollama、OpenRouter 等提供统一的、OpenAI 风格的接口。只需更改一个字符串即可切换提供商。
Agents API · Toolkits · MCP — give models real Python functions as tools, run multi-turn loops, attach ready-made toolkits (files, git, shell) or any MCP server, and govern it all with tool policies. Agents API · Toolkits · MCP — 为模型提供真实的 Python 函数作为工具,运行多轮对话循环,挂载现成的工具包(文件、git、shell)或任何 MCP 服务器,并通过工具策略管理这一切。
OpenCoworker — a desktop AI coworker built using aisuite, shipped as an app for everyday tasks. OpenCoworker — 一个使用 aisuite 构建的桌面 AI 同事,以应用程序形式发布,用于处理日常任务。
Installation
安装
The aisuite library (Python) Install the base package, or include the SDKs of the providers you plan to use: aisuite 库 (Python) 安装基础包,或包含你计划使用的提供商的 SDK:
pip install aisuite # base package, no provider SDKs
pip install 'aisuite[anthropic]' # with a specific provider's SDK
pip install 'aisuite[all]' # with all provider SDKs
You’ll also need API keys for the providers you call — the Chat Completions quickstart covers key setup and your first calls. 你还需要为你调用的提供商准备 API 密钥——“聊天补全快速入门”涵盖了密钥设置和首次调用。
The OpenCoworker app (desktop) Download the installer and bring your own API key (or run local models with Ollama): OpenCoworker 应用程序 (桌面端) 下载安装程序并提供你自己的 API 密钥(或使用 Ollama 运行本地模型):
⬇ macOS (Apple Silicon) · ⬇ Windows 10/11 (x64) ⬇ macOS (Apple Silicon) · ⬇ Windows 10/11 (x64)
OpenCoworker quickstart
OpenCoworker 快速入门
Chat Completions — one API across providers The chat API provides a high-level abstraction for model interactions. It supports all core parameters (temperature, max_tokens, tools, etc.) in a provider-agnostic way, and standardizes request and response structures so you can focus on logic rather than SDK differences. Chat Completions — 跨提供商的统一 API 聊天 API 为模型交互提供了高级抽象。它以与提供商无关的方式支持所有核心参数(temperature、max_tokens、tools 等),并标准化了请求和响应结构,让你能够专注于逻辑而非 SDK 差异。
Model names use the format <provider>:<model-name>; aisuite routes the call to the right provider with the right parameters:
模型名称使用 <provider>:<model-name> 格式;aisuite 会将调用路由到正确的提供商并使用正确的参数:
import aisuite as ai
client = ai.Client()
models = ["openai:gpt-4o", "anthropic:claude-3-5-sonnet-20240620"]
messages = [
{"role": "system", "content": "Respond in Pirate English."},
{"role": "user", "content": "Tell me a joke."},
]
for model in models:
response = client.chat.completions.create(
model=model,
messages=messages,
temperature=0.75
)
print(response.choices[0].message.content)
→ Quickstart: docs/chat-completions-quickstart.md — install, key setup, local models, and more examples. → 快速入门:docs/chat-completions-quickstart.md — 安装、密钥设置、本地模型及更多示例。
Agents — give models real tools
智能体 — 为模型提供真实工具
aisuite turns tool calling into a one-liner: pass plain Python functions and it generates the schemas, executes the calls, and feeds results back to the model. aisuite 将工具调用简化为一行代码:传入普通的 Python 函数,它会自动生成模式、执行调用并将结果反馈给模型。
[…代码示例略…]
With max_turns set, aisuite sends your message, executes any tool calls the model requests, returns the results to the model, and repeats until the conversation completes.
设置 max_turns 后,aisuite 会发送你的消息,执行模型请求的任何工具调用,将结果返回给模型,并重复此过程直到对话完成。
response.choices[0].intermediate_messages carries the full tool interaction history if you want to continue the conversation.
如果你想继续对话,response.choices[0].intermediate_messages 携带了完整的工具交互历史记录。
Prefer full manual control? Omit max_turns and pass OpenAI-format JSON tool specs — aisuite returns the model’s tool-call requests and you run the loop yourself. See examples/tool_calling_abstraction.ipynb for both styles.
更喜欢完全手动控制?省略 max_turns 并传入 OpenAI 格式的 JSON 工具规范——aisuite 会返回模型的工具调用请求,由你自行运行循环。两种风格请参考 examples/tool_calling_abstraction.ipynb。
The Agents API
智能体 API
For longer-running, structured work there is a first-class Agents API: declare an agent once, run it with a Runner, and attach toolkits — prebuilt, sandboxed tool families for files, git, and shell: 对于长期运行的结构化工作,可以使用一流的 Agents API:声明一次智能体,使用 Runner 运行它,并挂载工具包——即针对文件、git 和 shell 的预构建、沙盒化工具集:
[…代码示例略…]
The Agents API also gives you the pieces a production harness needs: Agents API 还为你提供了生产环境框架所需的组件:
- Tool policies — RequireApprovalPolicy, allow/deny lists, or your own callable deciding which tool calls run.
- State stores — persist and resume runs (in-memory, file, or Postgres) and continue conversations across processes.
- Artifacts & tracing — capture what an agent produced and every step it took along the way.
- 工具策略 — RequireApprovalPolicy、允许/拒绝列表,或由你自定义的可调用对象来决定哪些工具调用可以运行。
- 状态存储 — 持久化并恢复运行(内存、文件或 Postgres),并在不同进程间继续对话。
- 工件与追踪 — 捕获智能体的产出及其执行过程中的每一步。
MCP tools aisuite natively supports… MCP 工具 aisuite 原生支持…