Nodes/comfyui-dsocr-bbox/OCR Business LLM Review Prompt
ComfyUI Node

OCR Business LLM Review Prompt

A JSON-only prompt for your LLM, built from OCR detections

By maomaozi·Created 2 months ago·Updated 2 months ago· 0
OCR Business LLM Review Prompt
    • llm_prompt
    classified_json
    business_goalRemove brand, authorization, promotional and gift content; preserve product specifications and functional copy.

    LLMs in ComfyUI fail one way more than any other: they don't return clean, parseable output. Ask a chat model for JSON and you get a preamble, a markdown fence, maybe some bold text, and somewhere in there the actual answer. This node is the answer to that for the business-mask pipeline - it builds a strict, JSON-only prompt from your classified OCR detections, so whatever LLM you wire up after it has no room to free-wheel.

    It's the third stage in the pipeline, and it's a pure prompt-builder: nothing is sent anywhere, no model runs here. You give it the classified_json from the rule classifier plus your business_goal, and it hands back an llm_prompt string you connect to any LLM node - local Ollama, an API node, whatever you use.

    What the prompt asks for

    The generated prompt demands JSON with two sections:

    • decisions - one entry per detection ID, choosing an action (remove, preserve, ignore) and a region policy (text, box, top_banner, bottom_banner, group_box, gift_object, explicit_box, none), plus optional region and group.
    • additional_regions - a genuine superpower: visible logos, badges, gifts, or banners that have no OCR anchor at all (a stylized logo with no readable text). The LLM can list these as synthetic removal decisions with explicit pixel boxes.

    Every detection ID is embedded in the prompt and the LLM is told to keep them exactly. The business_goal input (default: remove brand/authorization/promotional/gift content, preserve specs and functional copy) is your control surface - edit it and the whole framing of the review changes.

    Using it well

    The README's advice is worth following: for banners, logos, badges, and gift objects, use a multimodal LLM and give it the original image alongside the prompt. Text-only judgments on "is this promotional?" work okay; geometric judgments on "how big is the banner around this text?" need to see the pixels. The explicit_box region policy is how the LLM tells the mask stage "the object next to this text also goes," and that only makes sense with vision.

    Installing

    Part of comfyui-dsocr-bbox. ComfyUI Manager (search "dsocr") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/maomaozi/comfyui-dsocr-bbox
    

    restart. This node adds zero dependencies - it's string formatting.

    Gotchas

    The output is a prompt, not a decision - don't wire llm_prompt into a mask node. And the "JSON only" instruction is a strong hint, not a hard guarantee; OCR Apply Business Decisions is written to tolerate markdown fences and surrounding prose precisely because models still slip. Also note this pipeline uses stable detection IDs (b0_d0, ...) - if you re-run the detector between classifier and review, the IDs change and the LLM's decisions won't line up. Keep the pipeline run in one pass.

    CategoryDeepSeek OCR

    Inputs (2)

    NameTypeDefaultDescription
    classified_jsonSTRING
    business_goalSTRINGRemove brand, authorization, promotional and gift content; preserve product specifications and functional copy.

    Outputs (1)

    NameTypeDescription
    llm_promptSTRING