hz_enrich_items
Enhance high-scoring content with background enrichment to prepare it for the enriched stage in the Horizon content pipeline.
Instructions
对高分内容执行背景富化,写入 enriched 阶段。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run_id | Yes | ||
| source_stage | No | filtered | |
| horizon_path | No | ||
| config_path | No |
Implementation Reference
- horizon_mcp/service.py:340-381 (handler)The actual logic for enrichment, implemented as a service method called by the MCP tool handler.
async def enrich_items( self, run_id: str, source_stage: str = "filtered", horizon_path: str | None = None, config_path: str | None = None, ) -> dict[str, Any]: items, ctx = self._load_stage_items( run_id=run_id, stage=source_stage, horizon_path=horizon_path, config_path=config_path, ) if not items: raise HorizonMcpError(code="HZ_EMPTY_INPUT", message="待富化内容为空。") ai_client = ctx.runtime.create_ai_client(ctx.config.ai) enricher = ctx.runtime.ContentEnricher(ai_client) await enricher.enrich_batch(items) self.run_store.save_items(run_id, "enriched", items_to_dicts(items)) citation_count = 0 for item in items: citation_count += len(item.metadata.get("sources", [])) meta = self.run_store.update_meta( run_id, { "enriched_count": len(items), "citation_count": citation_count, }, ) return { "run_id": run_id, "enriched": len(items), "citation_count": citation_count, "artifact": str((self.run_store.run_dir(run_id) / "enriched_items.json").resolve()), "meta": meta, } - horizon_mcp/server.py:218-234 (handler)MCP tool definition and registration for 'hz_enrich_items', which wraps the service method call.
async def hz_enrich_items( run_id: str, source_stage: str = "filtered", horizon_path: str | None = None, config_path: str | None = None, ) -> dict[str, Any]: """对高分内容执行背景富化,写入 enriched 阶段。""" return await _run_tool( "hz_enrich_items", lambda: service.enrich_items( run_id=run_id, source_stage=source_stage, horizon_path=horizon_path, config_path=config_path, ), )