Building a Conversational AI Web Interface with Multi-Model Collaboration: A Practical Approach

    This article describes a practical workflow for replicating a conversational AI web interface with several general-purpose reasoning models and coding agent frameworks. It covers how to define deliverables and acceptance criteria, split work across planning, documentation, coding, and verification roles, keep API keys out of prompts, structure the system architecture, and compare results with a shared test suite.

    Building a Conversational AI Web Interface with Multi-Model Collaboration

    Replicating a conversational AI web interface is often treated as a front-end exercise of copying a page. In practice, it is a systems engineering task. It spans product analysis, API orchestration, session state management, streaming interaction, voice integration, and quality assurance. The practice described here assigned this task to several combinations of general-purpose reasoning models and coding agent frameworks. The required outputs were a product feature document with a structure diagram, a high-fidelity replica of the target page, and an optimized version built on that understanding. The value of this approach is not in ranking which model performs better. It shows a reusable delivery method: break a vague product goal into verifiable artifacts, organize model capabilities into a pipeline with clear roles, and build the testing loop into the prompts and acceptance criteria from the start.

    1. Define Deliverables and Acceptance Criteria Before Replicating

    If a replication task only says “make it look identical,” the executor has to rely on subjective judgment. A more engineering-oriented approach is to define three deliverables and their acceptance criteria first:

    1. Product feature document and structure diagram: Describe the functional areas of the page, the core user paths, session states, file input, voice input and output, history, quota notices, error states, and empty states. The structure diagram can use indented text, for example:
      1. Conversational AI Web App
      2. ├─ Conversation Experience Layer
      3. │ ├─ New / History Sessions
      4. │ ├─ Message Stream / Streaming Output / Stop Generation
      5. │ └─ File Input / Voice Input and Output
      6. ├─ Capability Orchestration Layer
      7. │ ├─ Model Routing / Parameter Configuration
      8. │ ├─ Tool Calling / Retrieval Augmentation
      9. │ └─ Quotas and Rate Limiting
      10. └─ Platform Support Layer
      11. ├─ Key Management / Log Auditing
      12. ├─ Object Storage / Session Storage
      13. └─ Monitoring and Alerting / End-to-End Testing
    2. High-fidelity replica page: The goal is not just a similar look. The layout, component states, interaction feedback, exception handling, and responsive behavior should all closely match the target page. Acceptance should include visual difference checks, end-to-end tests for key paths, and error injection tests.
    3. Optimized page: Based on an understanding of the original product, add capabilities that make sense, such as conversation branching, citation tracing, prompt templates, a cost dashboard, and accessibility improvements. Each optimization needs a product reason. Adding features without justification is not enough.

    Writing acceptance criteria into the task contract reduces cases where a model considers its work finished when it is not. For example:

    1. {
    2. "task": "build_chat_web_replica",
    3. "deliverables": ["product_spec", "feature_tree", "replica_app", "optimized_app"],
    4. "constraints": {
    5. "ui": "high_fidelity",
    6. "secret_handling": "no_secret_in_prompt_history_or_logs",
    7. "responsive": true
    8. },
    9. "acceptance": ["feature_coverage", "e2e_pass", "visual_diff", "error_handling"]
    10. }

    2. Multi-Model Collaboration Depends on Role Separation, Not Simple Stacking

    When several model and agent framework combinations work on the same task, the differences often come from how the task is decomposed and how it is tested, not from a single model’s parameters. A stable collaboration pipeline usually includes four roles:

    • Planning role: Reads the target page and the public API documentation, then breaks the work into a feature list, page routes, and data flows.
    • Documentation role: Turns the plan into a product report, state machines, a feature structure diagram, and an acceptance checklist.
    • Coding role: Builds front-end components, the API layer, session state management, and styles module by module.
    • Verification role: Runs end-to-end tests, boundary tests, error injection, and visual comparison, then sends issues back to the coding role for repair.

    The pipeline can be abstracted as the following pseudocode:

    1. pipeline(spec):
    2. plan = planner(spec)
    3. doc = doc_agent(plan)
    4. app = coding_agent(plan, doc)
    5. issues = tester(app, plan.acceptance)
    6. while issues not empty:
    7. app = coding_agent.repair(app, issues)
    8. issues = tester(app, plan.acceptance)
    9. return doc, app

    The key point is not to let the strongest model handle everything. The verification role needs independent judgment. In practice, some combinations ran only a minimal connectivity test after the key was injected. Others continued with empty inputs, oversized inputs, network failures, interrupted streams, and duplicate submissions, which exposed more defects. Engineering teams should use one shared acceptance script so that results remain comparable. Otherwise, differences in test depth can make the outcomes impossible to compare.

    3. Two-Round Prompting: Separate Requirements From Keys

    The practice used two rounds of prompts. The first round gave the requirements. The second round provided the API key. This separation has a security benefit: keys should not appear in early requirement descriptions, product documents, or code comments. A better approach is to inject keys through environment variables or a key management service, so the model sees only placeholders. The prompts can be abstracted as follows:

    1. Round 1:
    2. You are a senior product manager and full-stack engineer. The goal is a conversational AI web interface.
    3. Based on the public page and API documentation provided by the organizers, produce:
    4. 1. A product feature document and feature structure diagram;
    5. 2. A high-fidelity replica page;
    6. 3. An optimized page with clear reasons for each change.
    7. First output the implementation plan, module boundaries, and acceptance checklist. Do not request or output any real keys.
    8. Round 2:
    9. The API base URL and key required for running the app have been injected through environment variables named CHAT_API_BASE and CHAT_API_KEY.
    10. Complete integration, then run the end-to-end tests, error injection tests, and visual checks in the acceptance checklist.
    11. Do not write the key into code, logs, session history, or commit records.

    Separating the two rounds also reduces context pollution. The first round focuses on understanding the product. The second round focuses on integration and fixes. For agent frameworks, the prompt should require the agent to read the contract before changing code, and to provide test evidence instead of only saying the work is done.

    4. Reference Architecture: A Observable Pipeline for Conversational Capabilities

    A practical conversational AI web app usually includes a front-end conversation layer, a BFF (backend for frontend) or API aggregation layer, a model gateway, session and file storage, voice services, and logging and monitoring. The model gateway handles unified authentication, quotas, timeouts, retries, and streaming forwarding. The BFF converts front-end events into backend calls. Session storage keeps messages, attachment metadata, and state. Logging and monitoring record latency, error codes, and call chains.

    On the deployment side, the original practice used Baidu AI Cloud service categories, including a general-purpose container platform, object storage, log service, and monitoring and alerting. These were used to host the web service, static assets, runtime logs, and metrics, respectively.

    Several engineering points matter most:

    • Streaming output must support interruption and reconnection.
    • File input needs checks for type, size, and malware scanning.
    • The voice pipeline should track recording, transcription, and synthesis as three separate states.
    • Error messages should distinguish authentication failures, quota exhaustion, timeouts, and content blocking.
    • The front end must never expose keys.

    Session state is best described with an explicit state machine. This prevents states such as “loading,” “sent,” and “failed” from overwriting each other.

    5. From High-Fidelity Replication to Experience Optimization

    High-fidelity replication should first cover the core paths: starting a new session, sending a message, receiving a streamed response, stopping generation, switching history, uploading files, and recovering from errors. Visual checks should cover spacing, font sizes, colors, dark mode, mobile breakpoints, and keyboard accessibility.

    Optimization should focus on real pain points. Examples include conversation branching and retry, citation tracing, prompt templates, a cost and latency dashboard, redaction of sensitive information, and audit export. Each optimization needs an acceptance metric, such as “errors can be recovered from,” “key actions can be completed with the keyboard,” or “abnormal states show clear messages.”

    6. Testing Strategy and Evaluation: A Shared Script Is More Reliable Than Informal Comparison

    When evaluating the results of multi-model collaboration, use one acceptance checklist that covers feature coverage, end-to-end pass rate, visual differences, error handling, code maintainability, and security compliance. Tests should include at least empty input, oversized input, concurrent submissions, network interruption, stream interruption, authentication failure, quota exhaustion, and abnormal file handling.

    The conclusion should be stated narrowly. In this abstracted task, the combination of a strong reasoning model for planning and an independent verification loop produced more reliable documentation completeness and interface fidelity. The result should not be attributed to a single model. Replication is not the end goal. The practical engineering benefit lies in a reusable, observable, and verifiable build pipeline.