How to Evaluate LLMs and Toolchains for Building a Chat Application: A Practical Engineering Guide

    This article presents a controlled, reproducible approach to evaluating how well a large language model and its surrounding toolchain work together when building a chat application. It covers a unified experiment design with fixed inputs, deliverables, environments, and acceptance criteria, then explains why verification depth—not just code generation—separates strong results from weak ones. You will find the five build stages, key engineering practices for streaming, security, and regression testing, a six-dimension scoring rubric, and common pitfalls to avoid. The method is vendor-neutral and can be applied to model and cloud service selection.

    1. Background and Problem Definition

    When an organization decides to build its own conversational AI product, the starting point is rarely “train a bigger model.” It is usually getting the product shell working: a usable chat interface, a stable backend session service, and a pipeline that can safely call model capabilities. A mature open-source ecosystem has lowered this barrier significantly, which creates a practical question for many teams—with so many models and AI coding tools available, which combination is best suited to quickly replicate a mature chat application?

    This article does not evaluate or recommend any specific vendor’s product. Instead, it abstracts the “multi-model comparison” from the source material into a general engineering problem: under unified constraints, how do you evaluate the combined output quality of a “model + toolchain (harness)”? Here, the harness refers to the orchestration layer wrapped around the model, including context management, tool invocation, file read/write, command execution, and test running. The same model paired with different harnesses can produce differences far larger than the differences between models.

    2. Unified Experiment Design: Control Variables for Comparability

    To make the comparison meaningful, you must lock down the variables first. A reusable design has four points:

    1. Unified input: All combinations receive exactly the same two-turn prompt. The first turn describes the requirement; the second adds the API key and integration instructions.
    2. Unified deliverables: Each group must produce three assets—a product feature document and structure diagram, a runnable web interface, and an enhanced version of the interface improved based on its own experience.
    3. Unified environment: The same directory structure, the same dependency versions, and the same available tool permissions.
    4. Unified acceptance: Hard criteria based on “can it start, can it complete a real conversation, and are exception paths handled.”

    The first-turn prompt can be written as follows. The key is to state the role, goal, reference object, and available tools clearly at once:

    1. You are a senior product manager and front-end engineer who needs to replicate a conversational AI web interface.
    2. Reference object: a publicly available conversational AI product interface (browse its information architecture and interaction details yourself).
    3. Reference material: the general API calling documentation for this type of product (used to understand the basic patterns of sessions, streaming output, and authentication).
    4. Available tools: browse web pages, read and write local files, execute commands.
    5. First-turn deliverables: feature list, information architecture diagram, page prototype code.

    The second-turn prompt only adds the API key and integration instructions, used to observe behavioral differences across combinations “after obtaining real credentials”:

    1. The key has been placed in an environment variable. Please complete the real integration and output the verification record.

    The clever part of this design is that the second turn adds almost no new requirements, yet it amplifies whether a combination has “engineering self-awareness.”

    3. Key Observed Differences: Verification Depth Determines Delivery Quality

    Under unified operation, different combinations show clear tiers. One type of combination performs only minimal connectivity verification after obtaining the key, for example sending a message to confirm a response; another type proactively constructs boundary scenarios, such as overly long input, empty messages, concurrent requests, stream interruptions, and authentication failures, thereby exposing defects during integration and fixing them.

    The takeaway is: when evaluating a model, do not only look at “whether it can generate,” but also at “whether it self-falsifies after generating.” A mature engineering agent should exhibit the following behaviors:

    • Proactively write and run tests rather than verbally claiming completion;
    • Classify and handle error codes and timeouts rather than using a single fallback;
    • Run regression verification after changes to avoid introducing new problems;
    • Output reproducible verification records for manual review.

    4. The Five Stages of Replication and Engineering Essentials

    1. Requirement Breakdown and Feature List

    First break the product into modules such as session management, message flow, input area, attachment upload, parameter settings, history, and authentication and quota prompts, and mark priorities. The feature document should include module responsibilities, state transitions, and exception-state descriptions, rather than only listing pages.

    2. Information Architecture and Structure Diagram

    Use a tree structure to express navigation hierarchy, and a state diagram to express the “empty—loading—streaming output—complete—failure retry” flow. The value of the structure diagram is to give subsequent coding clear boundaries and avoid writing and changing at the same time.

    3. Interface Restoration and Interaction Details

    The focus is on streaming rendering, auto-scroll, stop generation, resend and edit, message copy, and theme switching. Sample code:

    1. async function streamChat(payload, onDelta, signal) {
    2. const resp = await fetch('/api/chat', {
    3. method: 'POST',
    4. headers: { 'Content-Type': 'application/json' },
    5. body: JSON.stringify(payload),
    6. signal,
    7. });
    8. if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
    9. const reader = resp.body.getReader();
    10. const decoder = new TextDecoder();
    11. while (true) {
    12. const { done, value } = await reader.read();
    13. if (done) break;
    14. onDelta(decoder.decode(value, { stream: true }));
    15. }
    16. }

    4. API Integration and Security Boundaries

    Keys must be placed on the server side or in environment variables and must not be hard-coded in the front end; requests need timeouts, retry limits, and rate-limiting backoff; validate input length up front to avoid invalid requests consuming quota. A common practice is to enforce authentication, logging, and monitoring alerts at a gateway layer, building observability into the pipeline.

    5. Integration, Verification, and Iteration

    Build a minimal regression set: normal conversation, overly long input, empty input, authentication failure, network interruption, and concurrent sessions. Run it automatically after each round of changes to form a record. The enhanced interface should add “experience items” on top of the original, such as accessibility, keyboard operation, and readable error messages.

    5. Reusable Evaluation Dimensions

    Score across six dimensions, 1–5 points each:

    Dimension Observation Point
    Requirement coverage Whether the feature list is complete and priorities are reasonable
    Architecture quality Whether layering is clear and state is traceable
    Code runnability Whether it starts successfully on the first try and dependencies are clean
    Verification depth Whether it proactively constructs boundaries and fixes issues
    Security Key management, input validation, error handling
    Maintainability Naming, comments, directory structure, documentation sync

    6. Common Pitfalls and How to Avoid Them

    • Demo without verification: Require a verification record; otherwise treat it as incomplete.
    • Hard-coded keys: Explicitly prohibit this in the prompt and scan for it during review.
    • Missing streaming handling: Make streaming output a mandatory acceptance item.
    • Swallowed errors: Prohibit empty catch blocks; require distinguishing error types and prompting the user.
    • Context bloat: Long sessions need truncation or summarization strategies to control single-input length.

    7. Conclusion

    Replicating a chat application is essentially a combined assessment of “product understanding + engineering discipline.” Only by unifying variables, moving acceptance criteria forward, and writing verification into the process can you truly see the differences between models and toolchains. For a team, the most valuable output is not a ranking but a repeatable, auditable evaluation method—one that also applies to the selection and adoption of various model services and general cloud product capabilities on Baidu AI Cloud.