Files
tw2/qingjian_cs/app/agent_tools.py
jimi a842f1861f
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
chore: initial import of standalone agentscope project
2026-03-02 18:21:40 +08:00

53 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
from .rules import (
detect_intent,
detect_order_status,
extract_image_urls,
extract_size_pairs_m,
has_map_or_political_risk,
has_porn_risk,
is_meaningless_short,
requests_external_contact,
)
def tool_detect_intent(msg: str) -> str:
"""识别客户当前意图: image/pricing/greeting/external_contact/finish_or_quote_trigger/nonsense/unknown。"""
return detect_intent(msg or "")
def tool_extract_image_urls(msg: str) -> list[str]:
"""提取消息中的图片 URL 列表。"""
return extract_image_urls(msg or "")
def tool_detect_order_status(goods_order: str) -> str:
"""识别订单状态: paid/pending_payment/refund/unknown。"""
return detect_order_status(goods_order or "")
def tool_extract_size_pairs(msg: str) -> list[tuple[float, float]]:
"""提取尺寸对,单位米。返回 [(w, h), ...]。"""
return extract_size_pairs_m(msg or "")
def tool_detect_risk(msg: str, goods_name: str = "") -> dict:
"""检测风险:地图政治、黄暴。"""
text = msg or ""
gname = goods_name or ""
return {
"map_or_political": has_map_or_political_risk(text, gname),
"porn": has_porn_risk(text),
}
def tool_detect_external_contact(msg: str) -> bool:
"""检测是否索要外部联系方式(微信/QQ/手机号等)。"""
return requests_external_contact(msg or "")
def tool_is_meaningless_short(msg: str) -> bool:
"""检测是否无意义短句(嗯/哦/ok等"""
return is_meaningless_short(msg or "")