MT

mattbusel/tokio-prompt-orchestrator

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

62 stars 4 forks 质量 70 趋势 20MIT

Tokio 用于处理大型语言模型请求的流水线:有界五级流程,包含去源、断路器、重试、速率限制,以及在 Anthropic、OpenAI、llama.cpp 或 vLLM 前的死字母队列。

概览

对于那些从应用、代理或脚本调用LLM API,并且希望它在负载和宕机时保持快速和可预测性的开发者。可以将其用作现成的服务器(编排器)或Rust库。 真实的录音,只有在等待时才加速。网站一步步重播同样的过程。 (x86_64,Ubuntu 20.04+ / Debian 11+)。一行,无依赖,安装到 ~/.local/bin: 每个方法都安装同一个编排器命令。每个版本,带有 SHA-256 校验和:释放。 任何已经使用 OpenAI 客户端的应用都会得到重复删除、断路器、超时、支出上限和死字母队列,且代码不变:启动编排器并指向客户端的基础 URL。

概述(AI 翻译)

同时运行多个LLM代理,避免超出速率限制或账单:24个Claude Code代理运行在一台RTX 4070上,重复去重使API使用率降至预期的26%。

为什么选择这个而不是其他选择: 一个普通的请求队列会把所有重复的上下文发送到API。这会把重复的合并成一个调用,内置了背压和断路器。

保证: 如果不符合这个 README 的说法,请打开一个问题,我会修复。

英文 |简体中文 |日本語 |한국어

一个Rust大型语言模型请求编排器:它位于你的应用和AI模型(Anthropic、OpenAI、llama.cpp、vLLM)之间,所以同一个提示请求重复需要一次模型调用,当服务提供者宕机时,你的请求会快速失败,且有明确原因,而不是堆积起来。

对于那些从应用、代理或脚本调用LLM API,并且希望它在负载和宕机时保持快速且可预测的开发者。可以将其用作现成服务器(orchestrator)或Rust库。

真实的录音,只有在等待时才加速。网站一步步重播同样的过程。

安装

Linux(x86_64,Ubuntu 20.04+ / Debian 11+)。一行,无依赖,安装到 ~/.local/bin:

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

tokio-prompt-orchestrator: the proxy in front of your LLM should not be the slow part

English | 简体中文 | 日本語 | 한국어

Python made the LLM gateway easy to write. It did not make it cheap to run. On the same 4 CPUs and the same mock upstream, the LiteLLM proxy added 7.8 ms per request, idled at 347 MB and topped out at 162 req/s; this one added 0.5 ms, idled at 55 MB and ran at 1,217 req/s, the upstream’s own ceiling (method and caveats). It also sends a repeated prompt upstream once by default: 2,000 requests over 50 distinct prompts became 50 calls.

Ran 24 Claude Code agents on one RTX 4070. Cut API use to 26% of expected.

  • Sends the same prompt once. Since 3.0 that includes sampled requests: an identical request inside the 5-minute window is a duplicate, not a new question. Want a fresh sample? Send x-orchestrator-fresh: 1.
  • Caps retries in dollars, not attempts. A retry count says nothing about money: three retries of a 200K-token agent context are dollars. --retry-budget (default $0.50 an hour plus 10% of real spend) refuses the retry that does not fit, and a 4xx is never retried.
  • Reserves the spend cap before the call. A budget checked after the call is a receipt.
  • Fails fast when the provider is down
  • Works with Anthropic, OpenAI, llama.cpp, vLLM

How much are you paying twice?

cargo install --locked tokio-prompt-orchestrator --features cli --bin burn
burn your_request_log.jsonl          # OpenAI-style logs, LiteLLM spend logs, Helicone/Langfuse exports
burn audit path/to/your/agent        # retry code with no stop, no dollar cap, or retries on a 4xx

What it found in public data (method and numbers):

  • SWE-agent trajectories (nebius/SWE-agent-trajectories, 6,669 runs, 174,815 model calls): 12,533 calls (7.2%) repeated the previous action and got the identical result back, half of them the same rejected edit re-sent after the same syntax error. They used 10.9% of the tokens, because they happen late, in long contexts. 1,176 of the 6,669 runs (18%) did it at least once.
  • WildChat-1M (2 of 14 shards, 334,731 real gpt-3.5 and gpt-4 calls from one public app): 5,097 exact repeats within 5 minutes of the same answer, 1.5% of spend at the 2023 list prices; 8,380 (2.3%) within an hour.

Install

docker run --rm -p 8080:8080 ghcr.io/mattbusel/tokio-prompt-orchestrator

Kubernetes:

在 GitHub 查看完整 README

安装

docker run --rm -p 8080:8080 ghcr.io/mattbusel/tokio-prompt-orchestrator
新手?先看 mcpskill.org 教程 →