现在很多厂商都有免费的token可以领,但是都零散的分布在各个Agent或者 token plan 里面,把这些羊毛集中管理起来是我一直苦恼的问题。
最近在推特上 magpie 这个工具比较火,起初第一眼我不以为然,不就是本地其服务转发嘛,我自己写的配置文件完全没有用的必要。
但是随着热度越来越高,我的逆反心理就上来了。“我倒要看看你有什么本事。”抱着这个心态我越用越上头,因为是真好用。核心确实是把这些模型接到 Agent 上。供应商出模型,magpie 在中间收请求、再转发出去。
但是做到了两点特别好用:1. 把多个模型或账号并成路由组,一个用完就换一个不中断。2. 按任务分工,加意图规则,让不同的活找不同的模型。
本来东鳞西爪薅的羊毛都能及时用掉了!
言归正传我们来看看具体怎么用:
先把供应商加进来
去供应商页,把准备用的服务加上。这一步配的是模型从哪里来;哪个 Agent 用它,下一步再定。
给 Agent 选个模型
Agent 页里,本机装了或配置过的 Agent 各占一行,显示它当前用的模型。
一个组管几个模型
给 Agent 选定一个模型,接入就算完成。想用上其他账号的额度,或者希望当前模型答不了时有后备,才需要路由组。
路由组把多个模型或账号并成一个名字,Agent 像选单个模型一样选它,名字写成 group/<id>。其中一个答不了,就换下一个。
先建一个主力组
我的建议是先建一个主力编程组,配几条关键规则就够了。不必一上来就把所有组和规则配齐。
路由方式先选 smart 或 order:混用多个订阅、想少浪费额度,用前者;已经有明确的主力和备用顺序,用后者。
会话保持选 auto 或 session,长代码会话靠它留在同一个账号上,再考虑提示词缓存能不能复用。
主力组稳定之后,再按用途拆。
按规则把某类对话交给指定模型
一条规则能按对话长度、图片或推理要求来筛,也能限定来源 Agent、意图、压缩上下文或所在文件夹。条件可以叠加,所以「在 ~/work/acme 里,并且够长」这样的规则写得出来。
每来一条新消息,magpie 都从上往下检查规则。第一条命中的决定谁排在最前,其余成员做故障转移。一条都没命中,就按组本来的方式路由,并留在原来的账号上。
让不同的活找不同的模型
怎么看懂那条记录
路由页会显示每个组最近一次请求由谁回答,原因写在记录下面。
图中是一条要求写测试的消息。判断模型 964 毫秒后说是“writing or fixing tests”,规则 2 就把 live/aihubmix/glm-5.3 排到第一。这条记录和上面的配置截图来自不同示例,模型和规则编号以各自的截图为准。
判断模型的调用记在用量页的 Agent magpie 名下,带 token 数和费用。想知道意图判断的开销,看这里。
几个常被问到的问题
magpie 要一直开着吗?
通过 magpie 用的模型,需要网关跟着应用一起跑。窗口关掉,magpie 还在菜单栏或托盘里。
怎么恢复原样?
在选择列表里选 Agent 自带的模型,或者运行 magpie <agent> default。magpie 会删掉自己写进去的东西,把你原来的值还回来,比如 ANTHROPIC_BASE_URL。
换了模型,Agent 还在用旧的?
已经在跑的会话,模型是启动时定下的。开个新会话。如果是 Codex,还要重启 Codex 应用。
从一个能用的组开始
先接入常用供应商,给一个 Agent 配好主力组,再按需要加备用模型。确认请求能正常完成、路由记录能看懂,再考虑拆快速组、审查组,或者加意图规则。
意图判断本身有开销。用量页能看到它值不值得留。常用任务先跑顺,再按实际使用调整分工。哪项配置真有用,这时候才看得清。
本文由 AI图鉴自动抓取并翻译,版权归原作者所有;如需查看原文请点下方链接。
Many manufacturers now have free tokens, but they're scattered in different Agents or token plans, and it's been a problem for me to centralize the wool.
More recently on Twitter, magpie, this tool is hot, and at first I didn't think it was a local service relay, but my own profile was completely unnecessary.
But as the heat gets hotter, my backslides come up. "I'll see what you can do." The more I use it, the better it is. The core is actually putting these models on Agent. Vendor out of the model, magpie in the middle, retransmitted.
But two things were particularly useful: 1. Combining multiple models or account numbers into route groups, and replacing one without interruption. 2. A division of tasks, with rules of intent, allows different jobs to find different models.
We could have used the wool in time!
Let's see what we can do:
Add the supplier first.
Go to the supplier's page and add the services to be used. This step goes with where the model comes from; which Agent uses it, reset by next step.
Select a model for Agent
On the Agent page, this machine has installed or configured Agent in one line each, showing its current model.
A group of models.
Select a model for Agent, access is complete. Route groups are needed to use quota for other accounts, or to have backup if the current model fails to answer.
The router group combines multiple models or account numbers into a name, and Agent selects it like a single model, and the name is a group/ <id>. One of them can't answer, but the next one.
Let's start with a main team.
My proposal is to start with a major programming group, with a few key rules. There is no need to fit all the groups and rules at once.
The route method is first smart or order: multiple subscriptions are mixed and quota is wasted; there is already a clear master and backup sequence, and the latter is used.
The session keeps the auto or session, with long code sessions on the same account, and then considers whether promptcache can be reused.
After the main force group is stabilized, it is removed by use.
Hand over certain types of conversations to specified models according to the rules
A rule can be sifted according to the length of the conversation, the picture or the reasoning requirements, and can also limit the source, the intent, the compression of context or the folder in which it is located. The conditions can be superimposed, so the rule "in ~/work/acme long enough" can be written.
Every new message, magpie checks the rules from top to bottom. The first hit decided who was at the top of the line and the rest of the members made a failure transfer. None of them were hit, and the route was the same as in the group, and it remained on the original account number.
Let's find different models.
How can you read that record?
The route page shows who responded to each group ' s most recent request, for the reasons stated below.
The figure is a message requesting a test. Model 964 ms says "writing or fixing tests", rule 2 puts live/aihubmix/glm-5.3 in first place. This record and the configuration screenshot above are taken from different examples, and the model and rule number are based on the respective screenshot.
The call to judge the model is in the name of Agent Magpie on the volume page, with token numbers and costs. You want to know the cost of the judgment, look here.
A couple of questions I've been asked.
Magpie, do you want to keep it on?
Through the model used by magpie, the gateway is required to follow the application. The window is off, Magpie is still in the menu bar or tray.
How?
Select the model of Agent's belt in the selection list, or run the Magpie <agent> default. Magpie would delete what she wrote and return your original value, like ANTHRAPIC BASE URL.
Changed the model, Agent. Still using the old one?
It's already running a session, and the model is set at startup. Have a new session. In the case of Codex, restart the Codex application.
Start with a working group.
Access to a common supplier, a major force group for Agent, and a back-up model as required. Confirm that the request is properly completed, that the route log is understandable, and that consideration is given to dismantling the fast-track, review or intent rules.
The intention is to make its own cost. The page can see if it is worth keeping. Regularly used tasks run smoothly before the division of labour is adjusted for actual usage. It's only then that you can see which configuration is useful.
Auto-fetched and translated by AI Atlas. All rights belong to the original author.