Skip to main content
Glama

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
NameRequiredDescriptionDefault
run_idYes
source_stageNofiltered
horizon_pathNo
config_pathNo

Implementation Reference

  • 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,
        }
  • 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,
            ),
        )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/henry-insomniac/Horizon-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server