新应用如何发现专家能力

📋 问题

新设计的应用如何发现专家的能力?


🎯 核心答案

新应用可以通过多种方式发现专家能力:API搜索、SDK查询、MCP工具、推荐系统等。


🔍 专家发现机制总览

发现方式对比

方式 适用场景 优势 实现
API搜索 应用后端集成 灵活、可定制 REST API
SDK查询 应用快速集成 简单、易用 Python/JS SDK
MCP工具 AI IDE集成 智能、交互式 MCP Server
推荐系统 个性化推荐 智能匹配 推荐引擎
专家注册表 直接查询 完整信息 ExpertRegistry

1. 通过API搜索专家

1.1 搜索API端点

端点: GET /api/v1/experts

功能: 按关键词、类别、能力等条件搜索专家

请求示例:

import requests

# 搜索设计相关专家
response = requests.get(
    "https://api.mbe.hi-maker.com/api/v1/experts",
    params={
        "query": "设计",
        "category": "design",
        "capabilities": ["design_advice", "color_palette"],
        "min_rating": 4.0,
        "limit": 10
    },
    headers={
        "Authorization": "Bearer YOUR_API_KEY"
    }
)

experts = response.json()["experts"]

响应示例:

{
  "experts": [
    {
      "id": "dynamic_graphic_designer",
      "name": "平面设计专家",
      "description": "资深平面设计专家,精通视觉设计、品牌设计...",
      "category": "design",
      "tags": ["平面设计", "视觉设计", "品牌设计"],
      "capabilities": [
        {
          "name": "design_advice",
          "description": "提供设计建议",
          "input_schema": {...},
          "output_schema": {...}
        },
        {
          "name": "color_palette",
          "description": "生成配色方案",
          "input_schema": {...},
          "output_schema": {...}
        }
      ],
      "metrics": {
        "rating": 4.7,
        "call_count": 12500,
        "avg_latency_ms": 45
      },
      "pricing": {
        "model": "free",
        "price_per_1k_tokens": 0.0
      }
    }
  ],
  "total": 15,
  "page": 1
}

1.2 获取专家详情

端点: GET /api/v1/experts/{expert_id}

功能: 获取专家的完整信息,包括所有能力接口

请求示例:

# 获取平面设计专家的详细信息
response = requests.get(
    "https://api.mbe.hi-maker.com/api/v1/experts/dynamic_graphic_designer",
    headers={
        "Authorization": "Bearer YOUR_API_KEY"
    }
)

expert = response.json()
capabilities = expert["capabilities"]  # 所有能力接口

响应示例:

{
  "id": "dynamic_graphic_designer",
  "name": "平面设计专家",
  "description": "...",
  "capabilities": [
    {
      "name": "design_advice",
      "description": "提供设计建议",
      "input_schema": {
        "type": "object",
        "properties": {
          "task": {"type": "string"},
          "requirements": {"type": "object"},
          "style": {"type": "string"}
        },
        "required": ["task"]
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "design_advice": {"type": "string"},
          "color_palette": {"type": "array"},
          "layout_suggestions": {"type": "array"}
        }
      }
    },
    {
      "name": "color_palette",
      "description": "生成配色方案",
      "input_schema": {...},
      "output_schema": {...}
    }
  ],
  "examples": [
    {
      "capability": "design_advice",
      "input": {
        "task": "设计课程海报",
        "requirements": {
          "title": "Python编程入门",
          "style": "现代简约"
        }
      },
      "output": {...}
    }
  ]
}

2. 通过SDK查询专家

2.1 Python SDK

安装:

pip install mbe-sdk-python

使用示例:

from mbe_sdk import MBEClient

# 初始化客户端
client = MBEClient(api_key="YOUR_API_KEY")

# 搜索专家
experts = await client.experts.search(
    query="设计",
    category="design",
    capabilities=["design_advice"]
)

# 获取专家详情(包括能力)
expert = await client.experts.get("dynamic_graphic_designer")
capabilities = expert.capabilities

# 查看能力接口定义
for capability in capabilities:
    print(f"能力: {capability.name}")
    print(f"描述: {capability.description}")
    print(f"输入: {capability.input_schema}")
    print(f"输出: {capability.output_schema}")

2.2 JavaScript/TypeScript SDK

安装:

npm install @mbe/sdk

使用示例:

import { MBEClient } from '@mbe/sdk';

// 初始化客户端
const client = new MBEClient({
  apiKey: 'YOUR_API_KEY'
});

// 搜索专家
const experts = await client.experts.search({
  query: '设计',
  category: 'design',
  capabilities: ['design_advice']
});

// 获取专家详情
const expert = await client.experts.get('dynamic_graphic_designer');
const capabilities = expert.capabilities;

// 查看能力接口
capabilities.forEach(capability => {
  console.log(`能力: ${capability.name}`);
  console.log(`描述: ${capability.description}`);
  console.log(`输入:`, capability.input_schema);
  console.log(`输出:`, capability.output_schema);
});

3. 通过MCP工具发现专家

3.1 MCP Server工具

工具列表:

  • expert_search - 搜索专家
  • expert_info - 获取专家详情
  • expert_recommend - 推荐专家
  • expert_list - 列出所有专家

使用示例 (在Cursor等AI IDE中):

expert_search: 查找设计相关专家
  - query: "设计"
  - category: "design"
  - capabilities: ["design_advice", "color_palette"]

响应:

{
  "experts": [
    {
      "id": "dynamic_graphic_designer",
      "name": "平面设计专家",
      "capabilities": [
        "design_advice",
        "color_palette",
        "layout",
        "typography"
      ]
    },
    {
      "id": "dynamic_web_designer",
      "name": "网页设计专家",
      "capabilities": [
        "web_layout",
        "responsive_design",
        "ui_components"
      ]
    }
  ]
}

4. 通过推荐系统发现专家

4.1 基于任务的推荐

端点: POST /api/v1/market/recommendations/for-task

功能: 根据任务描述推荐合适的专家

请求示例:

response = requests.post(
    "https://api.mbe.hi-maker.com/api/v1/market/recommendations/for-task",
    json={
        "task_description": "我需要为我的教育应用设计课程海报",
        "requirements": {
            "style": "现代简约",
            "target_audience": "学生"
        }
    },
    headers={
        "Authorization": "Bearer YOUR_API_KEY"
    }
)

recommendations = response.json()["recommendations"]

响应示例:

{
  "recommendations": [
    {
      "expert_id": "dynamic_graphic_designer",
      "expert_name": "平面设计专家",
      "score": 0.92,
      "reason": "擅长课程海报设计,符合现代简约风格",
      "matched_capabilities": [
        "design_advice",
        "color_palette",
        "layout"
      ]
    },
    {
      "expert_id": "dynamic_web_designer",
      "expert_name": "网页设计专家",
      "score": 0.75,
      "reason": "可以优化海报的网页展示效果",
      "matched_capabilities": [
        "web_layout",
        "responsive_design"
      ]
    }
  ]
}

4.2 基于用户历史的推荐

端点: GET /api/v1/market/recommendations/for-user/{user_id}

功能: 根据用户历史使用记录推荐专家

请求示例:

response = requests.get(
    "https://api.mbe.hi-maker.com/api/v1/market/recommendations/for-user/user_123",
    params={
        "limit": 10,
        "exclude_experts": ["expert_1", "expert_2"]  # 排除已使用的专家
    },
    headers={
        "Authorization": "Bearer YOUR_API_KEY"
    }
)

recommendations = response.json()["recommendations"]

5. 专家能力接口定义

5.1 能力接口结构

每个专家都定义了标准的能力接口:

{
  "capability": {
    "name": "design_advice",
    "description": "提供设计建议",
    "version": "1.0.0",
    "input_schema": {
      "type": "object",
      "properties": {
        "task": {
          "type": "string",
          "description": "设计任务描述"
        },
        "requirements": {
          "type": "object",
          "description": "设计要求"
        },
        "style": {
          "type": "string",
          "enum": ["现代简约", "极简主义", "新拟态", "玻璃态"],
          "description": "设计风格"
        }
      },
      "required": ["task"]
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "design_advice": {
          "type": "string",
          "description": "设计建议文本"
        },
        "color_palette": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "color": {"type": "string"},
              "usage": {"type": "string"}
            }
          }
        },
        "layout_suggestions": {
          "type": "array",
          "items": {"type": "string"}
        }
      }
    },
    "examples": [
      {
        "input": {
          "task": "设计课程海报",
          "requirements": {
            "title": "Python编程入门"
          }
        },
        "output": {
          "design_advice": "建议使用现代简约风格...",
          "color_palette": [...]
        }
      }
    ]
  }
}

5.2 能力分类

设计类能力:

  • design_advice - 设计建议
  • color_palette - 配色方案
  • layout - 布局设计
  • typography - 排版建议

教育类能力:

  • course_design - 课程设计
  • learning_path - 学习路径
  • assessment - 评估建议

法律类能力:

  • legal_consultation - 法律咨询
  • case_analysis - 案例分析
  • document_review - 文档审查

6. 完整发现流程示例

场景:新应用需要设计能力

步骤1: 搜索设计专家

from mbe_sdk import MBEClient

client = MBEClient(api_key="YOUR_API_KEY")

# 搜索设计相关专家
experts = await client.experts.search(
    query="设计",
    category="design"
)

步骤2: 查看专家能力

# 获取专家详情
expert = await client.experts.get(experts[0]["id"])

# 查看所有能力
for capability in expert.capabilities:
    print(f"能力: {capability.name}")
    print(f"描述: {capability.description}")
    print(f"输入: {capability.input_schema}")
    print(f"输出: {capability.output_schema}")

步骤3: 测试能力接口

# 测试设计建议能力
result = await client.experts.invoke(
    expert_id=expert.id,
    capability="design_advice",
    input={
        "task": "设计课程海报",
        "requirements": {
            "title": "Python编程入门",
            "style": "现代简约"
        }
    }
)

print(result["design_advice"])
print(result["color_palette"])

步骤4: 集成到应用

# 在应用中使用设计专家
class MyApp:
    def __init__(self):
        self.mbe_client = MBEClient(api_key="YOUR_API_KEY")
        self.design_expert = None
    
    async def initialize(self):
        # 发现设计专家
        experts = await self.mbe_client.experts.search(
            query="设计",
            category="design"
        )
        self.design_expert = experts[0]
    
    async def design_poster(self, title: str, style: str):
        # 使用设计专家
        result = await self.mbe_client.experts.invoke(
            expert_id=self.design_expert["id"],
            capability="design_advice",
            input={
                "task": "设计海报",
                "requirements": {
                    "title": title,
                    "style": style
                }
            }
        )
        return result

7. 专家发现最佳实践

7.1 应用启动时发现

推荐: 在应用启动时发现并缓存专家信息

class MyApp:
    def __init__(self):
        self.mbe_client = MBEClient(api_key="YOUR_API_KEY")
        self.expert_cache = {}
    
    async def startup(self):
        # 发现需要的专家
        design_experts = await self.mbe_client.experts.search(
            category="design"
        )
        education_experts = await self.mbe_client.experts.search(
            category="education"
        )
        
        # 缓存专家信息
        for expert in design_experts + education_experts:
            self.expert_cache[expert["id"]] = expert

7.2 按需发现

推荐: 根据用户需求动态发现专家

async def find_expert_for_task(self, task_description: str):
    # 使用推荐系统
    recommendations = await self.mbe_client.experts.recommend(
        task_description=task_description
    )
    
    # 返回最匹配的专家
    return recommendations[0]

7.3 能力验证

推荐: 在使用前验证专家能力

async def verify_expert_capability(self, expert_id: str, capability: str):
    expert = await self.mbe_client.experts.get(expert_id)
    
    # 检查能力是否存在
    if not any(c.name == capability for c in expert.capabilities):
        raise ValueError(f"专家 {expert_id} 不支持能力 {capability}")
    
    # 验证输入输出schema
    capability_def = next(c for c in expert.capabilities if c.name == capability)
    return capability_def

8. 专家发现API完整列表

8.1 搜索和查询

端点 方法 功能
/api/v1/experts GET 搜索专家
/api/v1/experts/{expert_id} GET 获取专家详情
/api/v1/experts/{expert_id}/capabilities GET 获取专家能力列表
/api/v1/experts/{expert_id}/capabilities/{capability} GET 获取能力详情

8.2 推荐

端点 方法 功能
/api/v1/market/recommendations/for-task POST 基于任务推荐
/api/v1/market/recommendations/for-user/{user_id} GET 基于用户推荐
/api/v1/market/recommendations/similar/{expert_id} GET 相似专家推荐

8.3 分类和标签

端点 方法 功能
/api/v1/experts/categories GET 获取所有类别
/api/v1/experts/tags GET 获取所有标签
/api/v1/experts/capabilities GET 获取所有能力类型

9. SDK完整示例

9.1 Python SDK完整示例

from mbe_sdk import MBEClient

async def discover_and_use_experts():
    # 1. 初始化客户端
    client = MBEClient(api_key="YOUR_API_KEY")
    
    # 2. 搜索专家
    experts = await client.experts.search(
        query="设计",
        category="design",
        capabilities=["design_advice"]
    )
    
    # 3. 获取专家详情
    expert = await client.experts.get(experts[0]["id"])
    
    # 4. 查看能力
    print("专家能力:")
    for capability in expert.capabilities:
        print(f"  - {capability.name}: {capability.description}")
    
    # 5. 调用能力
    result = await client.experts.invoke(
        expert_id=expert.id,
        capability="design_advice",
        input={
            "task": "设计课程海报",
            "requirements": {
                "title": "Python编程入门",
                "style": "现代简约"
            }
        }
    )
    
    return result

✅ 总结

核心发现方式

  1. API搜索: 灵活、可定制,适合后端集成
  2. SDK查询: 简单、易用,适合快速集成
  3. MCP工具: 智能、交互式,适合AI IDE
  4. 推荐系统: 智能匹配,适合个性化需求

关键步骤

  1. 搜索专家: 使用关键词、类别、能力等条件
  2. 查看能力: 获取专家的能力接口定义
  3. 验证能力: 检查能力是否符合需求
  4. 测试调用: 测试能力接口是否可用
  5. 集成应用: 将专家能力集成到应用中

最佳实践

  • ✅ 应用启动时发现并缓存专家
  • ✅ 按需动态发现专家
  • ✅ 验证专家能力后再使用
  • ✅ 使用推荐系统发现新专家
  • ✅ 定期更新专家信息

🔗 相关文档


文档创建日期:2026-02-06
最后更新:2026-02-06