feat: 接入众包平台需求数据——opp_demands/opp_hot_demands工具(猪八戒/一品威客甲方需求)
This commit is contained in:
parent
d777f0ac33
commit
a53b81ffe6
@ -52,6 +52,12 @@ OPP_TOOLS = [
|
||||
ToolDefinition(name="opp_category_references", description="查某软件主题的全部分项明细(references 可查证:每条带公告原文URL+采集来源)。回答热点/排名类问题时用本工具取分项并附来源链接",
|
||||
parameters={"category": "软件主题名(须与热点排名中的category一致)",
|
||||
"days": "统计窗口天数(默认30)", "limit": "条数(默认200)"}, category="data"),
|
||||
ToolDefinition(name="opp_demands", description="查众包平台(猪八戒/一品威客)软件需求发布列表——甲方直接发布的开发需求,反映真实市场需求与预算分布。每条带详情页URL可查证",
|
||||
parameters={"keyword": "标题关键词(可选)", "days": "统计窗口天数(默认30)",
|
||||
"source": "来源(可选: zbj猪八戒/epwk一品威客,不传=全部)",
|
||||
"limit": "条数(默认50)"}, category="data"),
|
||||
ToolDefinition(name="opp_hot_demands", description="众包需求热点主题排名(需求侧热度,与招标侧的 opp_hot_software 互补)",
|
||||
parameters={"days": "统计窗口天数(默认30)", "top": "Top条数(默认10)"}, category="data"),
|
||||
|
||||
# ── 报告与审批(商机闭环)──
|
||||
ToolDefinition(name="opp_create_report", description="创建软件研发报告草稿。从热门软件中选定的方向写入报告,数据基础章节自动从爬取平台拉取",
|
||||
@ -122,6 +128,8 @@ opp_query_tenders / opp_tender_detail),**不要**自己去爬网站,
|
||||
并对推荐的主题调 opp_category_references 附 references。
|
||||
- 用户口述检索/统计条件 → opp_query_tenders 映射参数,返回明细或汇总并附样例链接。
|
||||
- 用户问「今天有什么AI招标」→ opp_daily_ai_tenders()。
|
||||
- 用户问「市场真实需求/甲方都在找什么开发」→ opp_hot_demands 或 opp_demands
|
||||
(猪八戒/一品威客等众包平台的甲方需求发布,与招标互补,同样带 references)。
|
||||
- 用户说「给XX写个研发报告」→ 先确认调研充分(1-3步),再
|
||||
opp_create_report → 拉数据补写 → opp_submit_report。
|
||||
- 用户问进展 → opp_diagnose(报告/审批分布 + 待办人工任务)。"""
|
||||
@ -260,6 +268,33 @@ async def _h_category_references(sor, p, ctx):
|
||||
}, ensure_ascii=False, default=str)
|
||||
|
||||
|
||||
async def _h_demands(sor, p, ctx):
|
||||
from .opp_data_capability import demands
|
||||
ok, res = await demands(
|
||||
sor, keyword=(p.get("keyword") or "").strip(),
|
||||
days=int(p.get("days") or 30),
|
||||
source=(p.get("source") or "").strip(),
|
||||
limit=min(int(p.get("limit") or 50), 200))
|
||||
if not ok:
|
||||
return _fmt(False, res)
|
||||
return json.dumps({
|
||||
"需求总数": res.get("matched"),
|
||||
"返回条数": res.get("count"),
|
||||
"需求": res.get("items"),
|
||||
"说明": "每条需求的 url 为众包平台详情页,可点击查证;source: zbj=猪八戒, epwk=一品威客",
|
||||
}, ensure_ascii=False, default=str)
|
||||
|
||||
|
||||
async def _h_hot_demands(sor, p, ctx):
|
||||
from .opp_data_capability import hot_demands
|
||||
ok, res = await hot_demands(
|
||||
sor, days=int(p.get("days") or 30),
|
||||
top=min(int(p.get("top") or 10), 30))
|
||||
if not ok:
|
||||
return _fmt(False, res)
|
||||
return json.dumps(res, ensure_ascii=False, default=str)
|
||||
|
||||
|
||||
async def _h_create_report(sor, p, ctx):
|
||||
from .opp_report_capability import create_report
|
||||
ok, rid = await create_report(
|
||||
@ -336,6 +371,8 @@ OPP_HANDLERS = {
|
||||
"opp_tender_detail": _h_detail,
|
||||
"opp_crawler_stats": _h_crawler_stats,
|
||||
"opp_category_references": _h_category_references,
|
||||
"opp_demands": _h_demands,
|
||||
"opp_hot_demands": _h_hot_demands,
|
||||
"opp_create_report": _h_create_report,
|
||||
"opp_update_report": _h_update_report,
|
||||
"opp_list_reports": _h_list_reports,
|
||||
|
||||
@ -51,6 +51,26 @@ async def crawler_stats(sor):
|
||||
return await crawler_get(sor, "/api/stats")
|
||||
|
||||
|
||||
async def demands(sor, keyword="", days=30, source="", limit=50):
|
||||
"""众包平台软件需求发布列表(猪八戒/一品威客等)。
|
||||
|
||||
区别于招标:这些是甲方在众包平台直接发布的开发需求,
|
||||
反映市场真实需求热度与预算分布。每条带详情页 url(可查证)。
|
||||
"""
|
||||
params = {"days": days, "limit": limit}
|
||||
if keyword:
|
||||
params["keyword"] = keyword
|
||||
if source:
|
||||
params["source"] = source
|
||||
return await crawler_get(sor, "/api/demands", params)
|
||||
|
||||
|
||||
async def hot_demands(sor, days=30, top=10):
|
||||
"""众包需求热点主题排名(需求侧热度)。"""
|
||||
return await crawler_get(sor, "/api/hot_demands",
|
||||
{"days": days, "top": top})
|
||||
|
||||
|
||||
async def query_tenders(sor, keyword="", region="", buyer="", notice_type="",
|
||||
source="", min_budget="", max_budget="", min_ai="",
|
||||
days=90, group_by="", limit=50, only_it=True):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user