fix(market): 强化场景分类器解析兜底,避免合法 id 误判为 None
This commit is contained in:
1 parent
dc3077b5ae
commit
e2369b4915
1 file changed
+20
-16
@@ -211,20 +211,20 @@ def verify_agent_connectivity(platform: str, endpoint: str, api_key: str) -> dic
|
||||
# 注意:MarketApp.capability 列在此存放「业务场景 id」(见 MARKET_SCENES),不再是 text/vision 等模型能力。
|
||||
MARKET_SCENES: list = [
|
||||
# 元宝生成的「岗位 / 职能」分类(面向使用者视角,与后端模型路由能力解耦)
|
||||
{"id": "design", "label": "🎨 做设计", "color": "#EC4899", "desc": "页面、UI、视觉"},
|
||||
{"id": "frontend", "label": "💻 写前端", "color": "#3B82F6", "desc": "Web 页面、React、Next.js"},
|
||||
{"id": "mobile", "label": "📱 做移动端", "color": "#06B6D4", "desc": "React Native、Expo"},
|
||||
{"id": "backend", "label": "🧪 后端/全栈", "color": "#8B5CF6", "desc": "API、数据库、TypeScript"},
|
||||
{"id": "qa", "label": "🧪 测试质量", "color": "#6366F1", "desc": "TDD、Playwright、验证"},
|
||||
{"id": "search", "label": "🔍 搜索信息", "color": "#0EA5E9", "desc": "网页抓取、质疑、SEO"},
|
||||
{"id": "docs", "label": "✍️ 写文档", "color": "#F59E0B", "desc": "Word/PPT/PDF、文案、PRD"},
|
||||
{"id": "marketing", "label": "📢 推广获客", "color": "#F43F5E", "desc": "营销、社媒、邮件、定价"},
|
||||
{"id": "workflow", "label": "🔄 工作流", "color": "#14B8A6", "desc": "计划、调试、分级、原型"},
|
||||
{"id": "secops", "label": "🛡️ 安全运维", "color": "#EF4444", "desc": "安全审计、Azure、K8s"},
|
||||
{"id": "learning", "label": "🎓 学习教学", "color": "#10B981", "desc": "教学、提问、架构改进"},
|
||||
{"id": "video", "label": "🎬 视频多媒体", "color": "#D946EF", "desc": "AI视频、数字人"},
|
||||
{"id": "collab", "label": "🏢 办公协作", "color": "#64748B", "desc": "飞书全家桶"},
|
||||
{"id": "ai", "label": "🛠️ AI能力", "color": "#A855F7", "desc": "创建Skill、代码审查、统计"},
|
||||
{"id": "design", "label": "🎨 做设计", "color": "#EC4899", "desc": "页面、UI、视觉", "kw": "做设计"},
|
||||
{"id": "frontend", "label": "💻 写前端", "color": "#3B82F6", "desc": "Web 页面、React、Next.js", "kw": "写前端"},
|
||||
{"id": "mobile", "label": "📱 做移动端", "color": "#06B6D4", "desc": "React Native、Expo", "kw": "做移动端"},
|
||||
{"id": "backend", "label": "🧪 后端/全栈", "color": "#8B5CF6", "desc": "API、数据库、TypeScript", "kw": "后端"},
|
||||
{"id": "qa", "label": "🧪 测试质量", "color": "#6366F1", "desc": "TDD、Playwright、验证", "kw": "测试"},
|
||||
{"id": "search", "label": "🔍 搜索信息", "color": "#0EA5E9", "desc": "网页抓取、质疑、SEO", "kw": "搜索"},
|
||||
{"id": "docs", "label": "✍️ 写文档", "color": "#F59E0B", "desc": "Word/PPT/PDF、文案、PRD", "kw": "写文档"},
|
||||
{"id": "marketing", "label": "📢 推广获客", "color": "#F43F5E", "desc": "营销、社媒、邮件、定价", "kw": "推广"},
|
||||
{"id": "workflow", "label": "🔄 工作流", "color": "#14B8A6", "desc": "计划、调试、分级、原型", "kw": "工作流"},
|
||||
{"id": "secops", "label": "🛡️ 安全运维", "color": "#EF4444", "desc": "安全审计、Azure、K8s", "kw": "安全"},
|
||||
{"id": "learning", "label": "🎓 学习教学", "color": "#10B981", "desc": "教学、提问、架构改进", "kw": "学习"},
|
||||
{"id": "video", "label": "🎬 视频多媒体", "color": "#D946EF", "desc": "AI视频、数字人", "kw": "视频"},
|
||||
{"id": "collab", "label": "🏢 办公协作", "color": "#64748B", "desc": "飞书全家桶", "kw": "办公"},
|
||||
{"id": "ai", "label": "🛠️ AI能力", "color": "#A855F7", "desc": "创建Skill、代码审查、统计", "kw": "AI能力"},
|
||||
]
|
||||
_VALID_SCENE_IDS = {s["id"] for s in MARKET_SCENES}
|
||||
|
||||
@@ -277,10 +277,14 @@ def _classify_scene(name: str, description: Optional[str], content: Optional[str
|
||||
m = re.search(r'"capability"\s*:\s*"([a-z_]+)"', text_out)
|
||||
if m and m.group(1) in _VALID_SCENE_IDS:
|
||||
return m.group(1)
|
||||
# 兜底:在输出中扫描任一合法 id(容错标签/未加引号/多余文本等情况)
|
||||
for sid in _VALID_SCENE_IDS:
|
||||
# 兜底:在输出中扫描任一合法 id 或中文关键词(容错标签/未加引号/多余文本等情况)
|
||||
for s in MARKET_SCENES:
|
||||
sid = s["id"]
|
||||
if re.search(r'(?<![a-z])' + re.escape(sid) + r'(?![a-z])', text_out):
|
||||
return sid
|
||||
kw = s.get("kw", "")
|
||||
if kw and kw in text_out:
|
||||
return sid
|
||||
return None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
Reference in new issue
Block a user