From Model APIs to Smart Assistants: Building Multimodal Applications

    This article explores the evolution of large language model application development from simple API calls to comprehensive multimodal smart assistants. It covers the architecture, integration modes, engineering challenges, and optimization strategies needed to build robust AI applications, providing developers with a practical guide to orchestrating capabilities like web search, file parsing, and voice processing into a unified system.

    In recent years, the development of large language model (LLM) applications has been undergoing significant changes. In the past, developers often had to call a single text generation API and manually supplement it with external capabilities like search, file parsing, and voice processing. Today, an increasing number of model services are integrating these capabilities into a unified calling system. Developers no longer need to build complex retrieval, parsing, and multimodal processing pipelines from scratch. Instead, they can quickly build smart assistants with a complete interactive experience by enabling specific capabilities based on business needs or combining independent tools.

    From a technical perspective, this means the barrier to “developing a smart application” is shifting from low-level algorithm implementation to task orchestration, engineering architecture, and product design. As long as they master basic methods like API calling, context management, permission control, and result presentation, individual developers now have the opportunity to implement features that previously required multi-team collaboration.

    1. Smart Assistants Are Evolving from Single Dialogue to Capability Composition

    The core workflow of traditional chat applications is usually straightforward: the user inputs text, the system passes the text to the model, and the model’s generated content is returned to the user. While this pattern is suitable for Q&A, content generation, and simple text processing, its capabilities are significantly limited when dealing with real-time information, complex materials, and multimodal inputs.

    A more complete smart assistant typically requires the following capabilities:

    1. Web Search: Obtain real-time information to compensate for the model’s delayed knowledge updates.
    2. Deep Analysis: Summarize, compare, and reason across multiple sources, rather than just returning a simple answer.
    3. File Understanding: Process user materials such as documents, spreadsheets, presentations, and images.
    4. Webpage Reading: Scrape specific page content, extract the main text, and summarize it.
    5. Image OCR (Optical Character Recognition): Extract structured text from scanned documents, screenshots, and photos.
    6. Voice Input/Output: Allow users to ask questions via voice and receive voice feedback.
    7. Context Memory: Retain necessary information during continuous conversations to reduce repetitive descriptions by the user.

    These capabilities are not isolated. For example, a user might first upload a file, then ask the system to search the web for related information, and finally request a voice summary of the results. At this point, the system needs to perform file parsing, information retrieval, content generation, and speech synthesis simultaneously. The real technical challenge is not calling a specific API, but organizing multiple steps into a stable, traceable task flow.

    2. Two Primary Integration Modes

    Currently, developers building such applications can typically choose between two approaches.

    1. Unified API Mode

    The unified API mode consolidates capabilities like web search, file processing, and deep analysis into a single model calling endpoint. Developers declare task requirements via configuration items in the request, and the server automatically completes the corresponding processing based on the configuration.

    Its advantages include:

    • Shorter integration process, simpler frontend and backend code;
    • Relatively unified context management;
    • Suitable for rapid product idea validation;
    • Reduced data conversion between different modules.

    The schematic flow is as follows:

    1. User inputs question
    2. ↓
    3. App determines task type
    4. ↓
    5. Enables search, file, or analysis capabilities
    6. ↓
    7. Model processes input and external information
    8. ↓
    9. Returns answer, citations, or structured results
    10. ↓
    11. Frontend displays process and final conclusion

    This mode is suitable for scenarios such as general Q&A, material summarization, research assistance, and enterprise internal knowledge queries. Developers mainly focus on prompt design, result presentation, exception handling, and permission control, without needing to excessively interfere with the underlying tool calling process.

    2. Independent Tool Combination Mode

    The independent tool mode splits capabilities like search, web scraping, OCR, speech recognition, and speech synthesis into multiple services. Developers can use a single capability or freely combine them according to business workflows.

    For example, a contract review application can adopt the following pipeline:

    1. Upload contract image
    2. ↓
    3. Image OCR
    4. ↓
    5. Text cleaning and paragraph segmentation
    6. ↓
    7. Risk clause extraction
    8. ↓
    9. Knowledge base or external material retrieval
    10. ↓
    11. Model analysis and explanation
    12. ↓
    13. Generate text report or voice broadcast

    This approach offers higher flexibility. Developers can decide which steps are handled by the model and which by business code. They can also set up caching, retries, permissions, and audit rules for each step individually.

    However, its engineering complexity is also higher, requiring handling data format unification, context passing, task state maintenance, and failure recovery. Therefore, independent tools are more suitable for enterprise applications with clear workflows, high business requirements, and the need for fine-grained control.

    3. Basic Architecture for Building a Smart Assistant from Scratch

    A production-ready smart assistant can typically be divided into five layers.

    1. Interaction Layer

    The interaction layer is responsible for receiving inputs like text, files, images, and voice, and presenting the processing flow to the user. For complex tasks, instead of just showing a continuous loading spinner, it is better to provide real-time status feedback, such as:

    • Reading file;
    • Extracting webpage text;
    • Searching for related materials;
    • Organizing analysis results;
    • Generating final answer.

    Clear process indicators can reduce user misjudgments that the system is “stuck” or “unresponsive”.

    2. Task Orchestration Layer

    The task orchestration layer is the core of the entire system. It determines the user’s intent and decides which capabilities to call.
    For example:

    • General factual Q&A: directly call the model;
    • Involving real-time information: perform web search first;
    • After uploading a file: complete file parsing first;
    • When an image is input: perform text recognition first;
    • When the user requests a voice response: continue to call speech synthesis after text generation.

    The orchestration layer can use rule-based judgments or models for task classification. For scenarios requiring high stability, it is recommended to adopt a “rules first, model assisted” approach: clear tasks are handled directly by rules, while complex or ambiguous requests are handed over to the model for judgment.

    3. Capability Layer

    The capability layer contains modules such as search, webpage parsing, file processing, OCR, speech recognition, and speech synthesis. Each module should ideally have a unified input/output format to prevent upper-layer logic from depending on specific fields of a certain service.
    For example, search results can be uniformly abstracted as:

    1. {
    2. "query": "User's question",
    3. "items": [
    4. {
    5. "title": "Material title",
    6. "content": "Material summary",
    7. "source": "Source identifier"
    8. }
    9. ]
    10. }

    The fields here are just an example of the application’s internal data structure. In actual projects, information such as time, credibility, permissions, and content type should be added according to business needs.

    4. Context Management Layer

    Context management determines whether the system can complete continuous tasks. Developers need to distinguish three types of information:

    • Current question: what the user needs to solve right now;
    • Historical dialogue: necessary content to help the system understand the context;
    • External materials: search results, file contents, or webpage text.

    All historical content should not be crammed into every request indefinitely. This not only increases processing costs but may also distract the model’s attention. A more reasonable approach is to periodically compress historical conversations, retaining only user preferences, task goals, key conclusions, and unfinished items.

    For long documents, they should be segmented first, relevant content recalled, and finally the most relevant fragments passed to the model for analysis. This improves the accuracy and stability of the answers.

    5. Operations and Security Layer

    The production environment must record information such as request latency, failure reasons, tool call counts, input/output size, and user feedback. Through logging and monitoring, developers can pinpoint whether an issue lies in the model, retrieval, file parsing, or network.

    Additionally, the following security measures should be established:

    • Validate the type and size of uploaded files;
    • Prevent malicious files from triggering parsing vulnerabilities;
    • Isolate external webpage content;
    • Do not directly expose internal keys and sensitive configurations to the model;
    • Desensitize and control access to user privacy data;
    • Add manual confirmation for high-risk operations;
    • Retain necessary audit logs for generated content.

    4. Web Search Is Not Just Copying Web Pages

    After integrating retrieval capabilities, the application does not simply paste search results in front of the answer. A reliable retrieval-augmented generation (RAG) flow includes at least four steps.

    The first step is rewriting the user’s question. The user’s original query might be too colloquial, and the system needs to extract keywords, time ranges, and constraints.

    The second step is filtering results. Search results may contain duplicate content, low-quality pages, or information weakly related to the question. The system needs to deduplicate and rank them.

    The third step is extracting valid content. After scraping a webpage, navigation bars, ads, comment sections, and irrelevant scripts should be removed, retaining only the main text, title, time, and necessary context.

    The fourth step is generating verifiable answers. The response should distinguish between “content explicitly mentioned in the materials” and “inferences made by the model based on the materials,” displaying source summaries or citation locations when necessary.

    Doing so not only reduces errors but also helps users judge whether the answer is trustworthy.

    5. Engineering Challenges in File and Multimodal Input

    File input seems simple but often involves complex formats. Text-based files can usually have content extracted directly, but scanned documents, image-based materials, and spreadsheets require additional processing.

    The common workflow includes:

    1. File upload
    2. ↓
    3. Format identification
    4. ↓
    5. Virus and security check
    6. ↓
    7. Text, table, or image content extraction
    8. ↓
    9. Layout cleaning and structure restoration
    10. ↓
    11. Segmentation, indexing, and summarization
    12. ↓
    13. Handed to the model for task execution

    For spreadsheets, simply concatenating cell contents into text is not enough, as it easily loses row-column relationships. For reports and contracts, heading hierarchies, page numbers, and paragraph relationships must be preserved. For OCR results, low-confidence text should be flagged to prevent the system from treating recognition errors as established facts.

    Voice scenarios also need to account for noise, accents, pauses, and multi-speaker conversations. Speech recognition results are best processed through punctuation restoration, content correction, and sensitive word detection before entering the subsequent analysis flow.

    6. How to Reduce Costs and Improve Response Speed

    The richer the capabilities and the longer the call chain, the higher the system cost and latency. Optimization can focus on the following aspects:

    1. Distinguish Simple and Complex Tasks
      Simple questions do not need to trigger the full retrieval and deep analysis pipeline.

    2. Introduce Caching Mechanisms
      Cache identical questions, identical webpages, and stable file contents to reduce redundant processing.

    3. Use Streaming Output
      Return incremental results early so users see a response sooner, rather than waiting for all steps to complete.

    4. Execute Independent Tasks in Parallel
      If parsing, retrieval, or recognition of multiple materials are independent of each other, they can be processed concurrently.

    5. Limit Context Scale
      Summarize, segment, and filter by relevance for historical dialogues and external materials.

    6. Set Timeout and Degradation Strategies
      If an external tool is unavailable, degrade to standard Q&A or clearly prompt the user that real-time queries are temporarily unavailable.

    7. From Demo Prototype to Production System

    A working demo version does not equate to a product ready for large-scale use. Production systems also need to focus on:

    • Multi-user concurrency and rate limiting;
    • File storage and lifecycle management;
    • Task queues and asynchronous execution;
    • Permission isolation and tenant data isolation;
    • Result traceability and manual review;
    • Sensitive content filtering;
    • Automatic retries during service exceptions;
    • Cost tracking and API quotas.

    Furthermore, evaluating a smart application should not solely rely on the fluency of the answer. Attention should be paid to factual accuracy, citation completeness, task completion rate, average response time, and the number of user corrections. Only by establishing clear evaluation metrics can the system be continuously optimized, rather than adjusting prompts based on subjective feelings.

    Conclusion

    As model services open up capabilities like web search, file processing, webpage reading, image, and voice through unified APIs or independent tools, the development of smart assistants has shifted from “training a model” to “designing a reliable capability orchestration system.” Individual developers can quickly complete prototype validation, while enterprise teams can build production-grade applications around permissions, data, workflows, and monitoring.

    A truly valuable application is not just a simple concatenation of multiple APIs. It accurately understands user tasks, invokes the right capabilities at the right time, and delivers results in a clear, verifiable, and traceable manner. Mastering this architectural mindset enables developers to build multimodal smart applications for office work, education, customer service, knowledge management, and industry analysis more efficiently in general cloud service environments like Baidu AI Cloud.