Building LLM Application Workflows: A Practical Guide to Creating Intelligent Assistants

    This article explains why LLM applications need structured workflows instead of a single chat box, and walks through four practical scenarios: content production pipelines, fine-tuning dataset construction, trending news aggregation, and multimodal invoice recognition. You will learn the common node types used in workflow design, along with an engineering checklist covering variable contracts, fallback handling, cost control, observability, regression evaluation, and security compliance before going live.

    1. Why Workflows Matter More Than a Chat Box

    When teams first start building LLM applications on a development platform, they often cram all the logic into a single system prompt. This works for a demo, but it breaks down in real business use and exposes three problems: the process becomes uncontrollable and the model may skip required steps to jump straight to a conclusion; logic is hard to reuse, so similar prompts get rewritten across scenarios; and failures are hard to diagnose, because when the output goes wrong you cannot tell which step caused it.

    The value of a workflow is that it turns “uncontrollable generation” into “controllable orchestration.” It breaks a task into several nodes that pass data to each other through variables, and the input and output of every node are observable and replayable. In engineering practice, workflows typically include these node types:

    • Start node: defines input parameters (text, files, numbers, booleans, and so on) and validation rules.
    • LLM node: selects a capability such as text generation or multimodal understanding, and binds a prompt with model parameters.
    • Code or conditional branch node: handles format cleanup, field extraction, and threshold checks.
    • Loop and iteration nodes: process list data item by item to enable batching and aggregation.
    • Knowledge retrieval node: connects to a vector store for retrieval augmentation to reduce hallucinations.
    • End node: defines the output structure so downstream systems can consume it.

    Note that node capabilities are a general industry abstraction. Naming varies slightly across platforms, but the design principles are the same: each node does one thing only, and data contracts are declared explicitly.

    2. Scenario 1: A Content Production Pipeline for Creators

    The pain point in content creation is not a lack of ideas but the volume of repetitive work: topic selection, scripts, headlines, cover copy, rewriting for multiple platforms, and comment replies. This can be modeled as a five-stage pipeline.

    1. Topic input and cleanup: the input is raw material text or the body of a link. A code node first strips noise such as ads and navigation, then outputs a unified structure {title, body, tags}.
    2. Structured extraction: an LLM node outputs fixed JSON containing the core viewpoint, target audience, emotional tone, and three expandable subheadings. The prompt must include field descriptions and an example, and state clearly that no extra explanation should be output.
    3. Script and headline generation: split into two nodes rather than one, so each can be tuned and A/B tested independently.
    4. Multi-platform rewriting: an iteration node loops over the platform list, injecting that platform’s style constraints (word count, tone, hashtag conventions) on each pass.
    5. Quality self-check: another model node acts as a reviewer and scores the draft against a checklist (factual consistency, readability, compliance risk). If the score falls below the threshold, the draft loops back for rewriting, closing the loop.

    Example prompt structure:

    1. You are a content editor. Output JSON only, with no prefix or suffix.
    2. Input: {{source body}}
    3. Requirements:
    4. 1. summary must not exceed 60 characters;
    5. 2. points must contain 3 items, each no more than 30 characters;
    6. 3. audience identifies the best-matching group;
    7. 4. do not fabricate data that is absent from the input.
    8. Output fields: {"summary":"","points":[],"audience":""}

    3. Scenario 2: A Fine-Tuning Dataset Construction Pipeline

    The quality of fine-tuning depends heavily on the dataset, yet manual construction is expensive. A workflow can handle the conversion from raw documents to training samples.

    • Collection and normalization: convert documents from multiple sources into plain text, keeping the chapter hierarchy as metadata.
    • Chunking strategy: split on semantic boundaries rather than a fixed character count, keep chunk length within what the model’s context can hold, and retain 10%–15% overlap to avoid cutting semantics short.
    • Instruction rewriting: use a model to rewrite “knowledge fragments” into instruction–answer pairs, requiring answers to rely only on the fragment content so the dataset is less polluted by hallucinations.
    • Deduplication and difficulty tiering: use text similarity for near-duplicate removal; tag samples by question type (factual, reasoning, summarization) to keep the distribution balanced.
    • Quality check and export: manually review a sample, export to a common training format (such as the three-part instruction/input/output structure), and keep a separate validation set.

    Engineering tip: always keep a “source traceable” field in the dataset so that when quality regresses you can quickly locate the dirty data.

    The core of a news aggregation app is a scheduled loop of “fetch, filter, summarize, push.”

    1. Trigger: a scheduled task starts the flow periodically.
    2. Fetch: a generic HTTP request node calls public endpoints; a code node then extracts the title, link, and popularity score from the returned list.
    3. Filter: apply a popularity threshold and a keyword whitelist, deduplicate, and take the top N.
    4. Summarize and classify: an iteration node generates a one-sentence summary for each item and assigns a category, avoiding output truncation caused by stuffing too much content in at once.
    5. Aggregate output: group items by category into a structured report, write it to object storage, or push it to a messaging channel.

    One caveat: the fetch step needs timeouts and retries, and on failure it should take a fallback branch that returns cached data so a single point of failure does not break the whole flow.

    5. Scenario 4: Multimodal Invoice Recognition and Comparison

    Pure optical character recognition loses accuracy when layouts are complex, stamps obscure the text, or lighting is uneven and skewed. Multimodal understanding models can parse images semantically, but they carry a risk of numerical hallucination, so a “dual channel plus cross-validation” design is recommended:

    • Channel A: a multimodal model extracts fields and outputs structured amounts, dates, buyer and seller, and tax.
    • Channel B: traditional character recognition produces text, and a code node applies regex and key-field location.
    • Validation layer: compare the two channels’ results and run arithmetic checks on amounts and tax (amount + tax ≈ total with tax); flag mismatches for manual review.
    • Batch scenarios: an outer iteration node loops over multiple invoices, the inner flow is reused for each one, and the results are aggregated into a summary table.

    The point of this design is to decouple “model capability” from “business rules”: when rules change, you only modify the code node and leave the prompt untouched.

    6. Pre-Launch Engineering Checklist

    • Variable contracts: explicitly declare the type of each node’s input and output to avoid dirty data from implicit conversion.
    • Exception fallbacks: set failure retries and default return values for model nodes; critical paths must have a degradation plan.
    • Cost control: limit context length, cache repeated request results, and use lightweight models for non-critical steps.
    • Observability: log node latency, token consumption, and output summaries for each run, and connect to a logging service with monitoring and alerts.
    • Evaluation set: prepare 30–50 regression samples per scenario and rerun them after prompt changes to prevent “fix one, break several.”
    • Security and compliance: mask sensitive information in inputs, add compliance filtering on outputs, and encrypt invoice data containing personal information with restricted access permissions.

    7. Conclusion

    What separates LLM applications that ship from those that stall is not whether they use the newest model, but whether the team has the engineering habit of breaking business logic into nodes and turning nodes into observable units. From content production to dataset construction, from news aggregation to multimodal recognition, the methodological skeleton is the same: define input contracts, split responsibilities, cross-validate, and close the loop with evaluation. Once you have this skeleton, swapping the underlying model or migrating to a cloud environment such as Baidu AI Cloud, with its complete model services, object storage, container platform, and monitoring and alerting capabilities, requires almost no rewrite of business logic.