← 返回 Skills 市场
534422530

多模型路由器

作者 534422530 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
37
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install laosi-model-router
功能描述
多模型路由器 - 原创技能。根据任务特征自动选择最优AI模型,优化成本和性能。适用于大型项目、混合任务、成本优化等场景。
使用说明 (SKILL.md)

⚠️ 发布规则

所有发布到ClawHub的技能必须严格测试,确定没有问题再发布


技能测试验证清单

  • frontmatter格式正确
  • 模型选择逻辑完整
  • 成本优化策略明确
  • 任务分类清晰
  • 无语法错误

Multi-Model Router - 多模型路由器

原创技能 | 激活词: 选择模型 / 路由模型 / 成本优化

核心概念

不同任务需要不同模型:

  • 简单任务用小模型,省成本
  • 复杂任务用大模型,保质量
  • 特定任务用专用模型,提效率

模型能力矩阵

主流模型对比

模型 推理 编程 创意 成本 速度
GPT-4o ⭐⭐⭐ ⭐⭐⭐ ⭐⭐⭐
Claude 3.5 ⭐⭐⭐ ⭐⭐⭐ ⭐⭐⭐
GPT-4o-mini ⭐⭐ ⭐⭐ ⭐⭐
Claude 3-haiku ⭐⭐ ⭐⭐ ⭐⭐ 最低 最快
DeepSeek-V3 ⭐⭐⭐ ⭐⭐⭐ ⭐⭐

擅长领域

MODEL_STRENGTHS = {
    'claude-opus': {
        'best': ['复杂推理', '长文本分析', '代码审查'],
        'good': ['创意写作', '技术文档'],
        'avoid': ['简单问答', '批量处理'],
    },
    'claude-sonnet': {
        'best': ['编程', '数据分析', '快速迭代'],
        'good': ['日常对话', '文档生成'],
        'avoid': ['超长上下文'],
    },
    'gpt-4o': {
        'best': ['多模态', '实时信息', 'API集成'],
        'good': ['通用对话', '代码生成'],
        'avoid': ['超长输出'],
    },
    'deepseek': {
        'best': ['代码优化', '数学', '中文'],
        'good': ['低成本批量处理'],
        'avoid': ['英文创意写作'],
    },
}

任务分类

类型1: 简单任务 (Simple)

特征:
- 单一问题
- 答案明确
- 不需要推理

示例:
- "现在几点了"
- "把这段文字翻译成英文"
- "计算 2+2"

推荐模型: Claude-haiku / GPT-mini

类型2: 常规任务 (Normal)

特征:
- 需要一定推理
- 有明确答案
- 标准流程

示例:
- "写一个用户登录函数"
- "解释什么是闭包"
- "帮我总结这段文章"

推荐模型: Claude-sonnet / GPT-4o-mini

类型3: 复杂任务 (Complex)

特征:
- 多步推理
- 需要深度分析
- 可能有歧义

示例:
- "设计一个微服务架构"
- "分析并优化这段代码性能"
- "制定产品上线计划"

推荐模型: Claude-opus / GPT-4o

类型4: 专业任务 (Specialized)

特征:
- 需要专业知识
- 领域特定
- 高准���性要求

示例:
- "法律文件审查"
- "数学证明"
- "代码安全审计"

推荐模型: 专用模型 / Claude-opus

路由算法

主路由逻辑

def route_task(task: Task) -> Model:
    # 1. 分析任务特征
    complexity = analyze_complexity(task)
    domain = analyze_domain(task)
    urgency = analyze_urgency(task)
    
    # 2. 成本预算
    budget = get_budget()
    
    # 3. 选择模型
    if complexity == 'simple':
        if budget == 'low':
            return 'claude-haiku'
        else:
            return 'gpt-mini'
    
    elif complexity == 'normal':
        if domain == 'code' and urgency == 'high':
            return 'claude-sonnet'  # 编程优先
        else:
            return 'deepseek'  # 性价比
    
    elif complexity == 'complex':
        if domain == 'reasoning':
            return 'claude-opus'
        elif domain == 'creative':
            return 'gpt-4o'
        else:
            return 'claude-sonnet-max'
    
    else:  # specialized
        return 'claude-opus'

成本优化

def optimize_cost(task: Task, model: Model) -> Model:
    # 检查是否可以用更便宜的模型
    if can_use_cheaper(task):
        cheaper = find_cheaper_alternative(model)
        if test_quality(task, cheaper) >= 0.9:
            return cheaper
    
    return model

路由决策输出

## 路由决策

### 任务分析
- **复杂度**: Complex (多步推理)
- **领域**: Code (编程任务)
- **紧迫度**: Normal
- **预算**: 标准

### 模型选择
- **推荐**: claude-opus
- **备选**: gpt-4o
- **降级**: claude-sonnet

### 理由
1. 任务复杂度高,需要强推理能力
2. 编程任务,Claude编码能力强
3. 有足够预算

### 预估成本
- claude-opus: $0.015/1K tokens
- 预计消耗: 约 $0.05

模型切换策略

串行路由

def serial_route(task: Task) -> Response:
    # 用小模型先试
    response = call_model('haiku', task)
    
    if not satisfied(response):
        # 升级到大模型
        response = call_model('opus', task)
    
    return response

并行路由

async def parallel_route(task: Task) -> Response:
    # 并行调用多个模型
    results = await asyncio.gather(
        call_model('haiku', task),
        call_model('sonnet', task),
        call_model('opus', task),
    )
    
    # 选择最佳结果
    return select_best(results)

性能监控

监控指标

MONITOR = {
    'response_time': [],
    'quality_score': [],
    'cost_per_task': [],
    'model_usage': {},
}

路由优化

def optimize_routing():
    # 分析历史数据
    # 找出成本和质量最佳平衡点
    # 调整路由规则
    pass

集成建议

配合技能 效果
intent-classifier 先识别意图再路由
hallucination-detector 验证模型输出质量
context-optimizer 优化各模型的上下文

原创性声明

本技能为原创,融合了:

  • 模型能力评估
  • 任务复杂度分析
  • 成本效益优化
  • 动态路由算法

作者: laosi 创建日期: 2026-04-28

安全使用建议
This skill is a coherent design doc for routing tasks to different LLMs and is safe as-is (no installs or credential requests). Before using it in a live agent, ensure the concrete integration: (1) only supplies API keys for provider(s) you trust and scope those keys appropriately, (2) audits any code that implements call_model/test_quality to avoid sending sensitive data to external models, (3) considers cost impact of parallel calls or testing fallbacks, and (4) adds logging, rate limiting, and privacy controls. If you want a security review of an implementation (code that actually calls model APIs), provide that code or the integration plan so it can be evaluated for credential handling and network behavior.
功能分析
Type: OpenClaw Skill Name: laosi-model-router Version: 1.0.0 The skill bundle is a conceptual framework and set of instructions for an AI agent to perform multi-model routing based on task complexity and cost. It contains only documentation and pseudocode in SKILL.md, with no executable scripts, network calls, or sensitive data access. There are no indicators of malicious intent or prompt injection attacks.
能力评估
Purpose & Capability
The name/description (multi-model router to pick models by task characteristics) matches the content of SKILL.md: routing logic, model strengths, cost-optimization and switching strategies. The declared requirements (none) are proportionate to the provided instructions, which are high-level and platform-agnostic.
Instruction Scope
All runtime instructions are pseudocode and prose about task classification, routing, and monitoring. They do not tell the agent to read unrelated files, access environment variables, or exfiltrate data. The instructions are high-level and will require concrete integration code to actually call model APIs.
Install Mechanism
No install specification or code files are present; this is lowest-risk (instruction-only). Nothing will be written to disk by the skill as provided.
Credentials
The skill itself does not request any environment variables or credentials, which is appropriate for the documentation-level content. However, implementing the routing (call_model, test_quality, etc.) in a real system will require API keys/credentials for whichever model providers are used; those should be requested only at integration time and scoped narrowly.
Persistence & Privilege
Skill does not request always:true and makes no claims about modifying other skills or system settings. Autonomous invocation is allowed by platform default but the skill's content does not demand elevated persistence.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install laosi-model-router
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /laosi-model-router 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
原创技能 - 根据任务自动选择最优AI模型
元数据
Slug laosi-model-router
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

多模型路由器 是什么?

多模型路由器 - 原创技能。根据任务特征自动选择最优AI模型,优化成本和性能。适用于大型项目、混合任务、成本优化等场景。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 37 次。

如何安装 多模型路由器?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install laosi-model-router」即可一键安装,无需额外配置。

多模型路由器 是免费的吗?

是的,多模型路由器 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

多模型路由器 支持哪些平台?

多模型路由器 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 多模型路由器?

由 534422530(@534422530)开发并维护,当前版本 v1.0.0。

💬 留言讨论