Agent-based user interface rendering method
By constructing an ordered set of content fragments and rendering the agent's content based on time sequence and data type identifiers, the problem of discontinuous display of interleaved content by the agent is solved, and an interactive experience of logical sequential rendering and real-time feedback is achieved.
Patent Information
- Application Number
- CN202611385827.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-03
Smart Images

Figure CN123030263A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a user interface rendering method based on intelligent agents. Background Technology
[0002] With the widespread adoption of large language models in consumer applications, intelligent agents have emerged as a new form of interaction on mobile devices. Unlike the traditional request-response model, intelligent agents deliver content frame by frame through streaming interfaces, and the types of content delivered are heterogeneous and interleaved. For example, an address selection card might be pushed first, followed by a text reply word by word, interspersed with tool call descriptions or error messages.
[0003] In related technologies, the client renders and displays the content sent by the agent in the dialogue interface. However, the displayed content cannot express the multiple content types sent by the agent in an interleaved manner. The display order of multiple content types is disordered, and some content types of information cannot be displayed coherently, resulting in fragmented dialogue semantics and a poor dialogue interaction experience. Summary of the Invention
[0004] This application provides a user interface rendering method based on intelligent agents to alleviate or solve one or more technical problems existing in the prior art.
[0005] In a first aspect, embodiments of this application provide a user interface rendering method based on an intelligent agent, including: Receive the current dialogue frame sent by the intelligent agent server, wherein the current dialogue frame includes a timing identifier, message content, and a data type identifier corresponding to the message content; Based on the current dialogue frame, update the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the time sequence identifier included in each dialogue frame in the data stream. The current dialog interface is rendered based on the updated set of ordered content fragments.
[0006] In some embodiments of this application, the method includes: updating the ordered set of content segments corresponding to the data stream to which the current dialogue frame belongs, based on the current dialogue frame, including: The current dialogue frame is parsed to obtain the timing identifier, message content, and data type identifier included in the current dialogue frame; Based on the time sequence identifier and the data type identifier, determine the target storage location corresponding to the message content of the current dialogue frame in the ordered content fragment set; Update the message content of the current dialogue frame to the target storage location in the ordered set of content fragments.
[0007] In some embodiments of this application, determining the target storage location corresponding to the message content of the current dialogue frame in the ordered content fragment set based on the time sequence identifier and the data type identifier includes: When the data type identifier indicates that the message content of the current dialogue frame belongs to a service data type, based on the data type identifier, a target historical message fragment that matches the message content of the current dialogue frame is searched in the ordered content fragment set to obtain a search result; based on the time sequence identifier and the search result, the target storage location corresponding to the message content of the current dialogue frame is determined. When the data type identifier indicates that the message content of the current dialogue frame belongs to a non-service data type, the target storage location of the message content of the current dialogue frame in the ordered content fragment set is determined based on the timing identifier of the current dialogue frame and the timing identifiers of each message fragment already stored in the ordered content fragment set.
[0008] In some embodiments of this application, the step of searching for a target historical message fragment that matches the message content of the current dialogue frame in the ordered set of content fragments based on the data type identifier includes: Based on the data type identifier indicating that the message content of the current dialogue frame is text type, and based on the timing identifier, the reference insertion position of the message content of the current dialogue frame in the ordered content fragment set is determined; in response to the existence of a preceding message fragment adjacent to the reference insertion position in the ordered content fragment set, it is determined whether the data type of the preceding message fragment is text type. If the data type of the preceding message fragment is text, then the preceding message fragment is determined as the target historical message fragment; If the preceding message fragment does not exist, or if the data type of the preceding message fragment is not text, then it is determined that the target historical message fragment was not found.
[0009] In some embodiments of this application, the step of searching for a target historical message fragment that matches the message content of the current dialogue frame in the ordered set of content fragments based on the data type identifier includes: Based on the data type identifier indicating that the message content of the current dialogue frame is rich media type, the component identifier is obtained from the message content of the current dialogue frame; Determine whether the ordered set of content fragments contains a historical message fragment corresponding to the component identifier; If a historical message segment corresponding to the component identifier exists, then the historical message segment corresponding to the component identifier is determined as the target historical message segment; If no historical message segment corresponding to the component identifier exists, it is determined that the target historical message segment has not been found.
[0010] In some embodiments of this application, determining the target storage location corresponding to the message content of the current dialogue frame based on the time sequence identifier and the search result includes: Based on the search result indicating that the target historical message fragment has been found, the position of the target historical message fragment in the ordered content fragment set is determined as the target storage location; Based on the search result indicating that the target historical message segment was not found, and based on the time sequence identifier and the time sequence identifiers of each message segment already stored in the ordered content segment set, the reference insertion position of the message content of the current dialogue frame in the ordered content segment set is determined; and the reference insertion position is determined as the target storage position.
[0011] In some embodiments of this application, updating the message content of the current dialogue frame to the target storage location in the ordered content fragment set includes: In response to the absence of a stored message fragment at the target storage location in the ordered set of content fragments, an empty message fragment is created at the target storage location, and the message content of the current dialogue frame is written into the empty message fragment; In response to the existence of the target historical message fragment at the target storage location, the message content of the current dialogue frame is added to the target historical message fragment based on the data type identifier and the target historical message fragment.
[0012] In some embodiments of this application, adding the message content of the current dialogue frame to the target historical message segment based on the data type identifier and the target historical message segment includes: In response to the data type identifier indicating that the message content of the current dialogue frame is text type, the message content of the current dialogue frame is added to the end of the text information included in the target historical message segment; In response to the data type identifier indicating that the message content of the current dialogue frame is of rich media type, the component field information included in the target historical message segment is obtained, and the component field information is updated using the message content of the current dialogue frame.
[0013] In some embodiments of this application, rendering the current dialogue interface based on the updated set of ordered content fragments includes: Based on the updated set of ordered content fragments, an abstract syntax tree is generated; Based on the preset component mapping configuration, each syntax node of the abstract syntax tree is mapped to a component node supported by the current dialog interface to obtain the target component tree; Based on the target component tree, incremental rendering is performed on the current dialog interface.
[0014] In some embodiments of this application, generating an abstract syntax tree based on the updated set of ordered content fragments includes: Parse each message fragment in the updated ordered set of content fragments to generate an abstract syntax tree; or, Obtain the target message fragment for this update from the updated ordered set of content fragments; parse the target message fragment to generate an abstract syntax tree.
[0015] In some embodiments of this application, the step of mapping each syntax node of the abstract syntax tree to a component node supported by the current dialog interface based on a preset component mapping configuration to obtain a target component tree includes: Query the target component node corresponding to the target node type of the target syntax node from the component mapping configuration; In the abstract syntax tree, the target syntax node is replaced with the target component node; The component mapping configuration includes the mapping relationship between different node types and component nodes; the target syntax node is any syntax node on the abstract syntax tree; the target component node includes the basic view component and style attributes corresponding to the target node type.
[0016] In some embodiments of this application, the incremental rendering of the current dialog interface based on the target component tree includes: Obtain the first data reference identifier of the first component node in the previous rendering cycle, where the first component node is any component node in the target component tree; If the second data reference identifier of the first component node in the current rendering cycle is consistent with the first data reference identifier, then the rendering result of the first component node in the previous rendering cycle is reused. If the second data reference identifier is inconsistent with the first data reference identifier, then the update process of the first component node is performed according to the second data reference identifier.
[0017] In some embodiments of this application, the step of performing the update process of the first component node according to the second data reference identifier includes: Obtain the first data content pointed to by the first data reference identifier, and the second data content pointed to by the second data reference identifier; If the second data content is consistent with the first data content, then the rendering result of the first component node in the previous rendering cycle is reused; If the second data content is inconsistent with the first data content, then the first data that is the same as the first data content and the second data that is different from the first data content are determined from the second data content; the rendering result corresponding to the second data in the current rendering cycle is generated based on the second data, and the rendering result corresponding to the first data in the previous rendering cycle is reused.
[0018] In some embodiments of this application, generating the rendering result corresponding to the second data in the current rendering cycle based on the second data includes: Obtain the node type corresponding to the second data, and query the preset component injection mapping table to see if there is a custom component corresponding to the node type; If the custom component exists, the custom component is invoked to render the second data and generate the rendering result corresponding to the second data; If the custom component does not exist, the preset default basic component is called to render the second data and generate the rendering result corresponding to the second data.
[0019] In some embodiments of this application, the custom component includes a rich media component, and the step of calling the custom component to render the second data includes: In response to the data type identifier corresponding to the second data being a rich media type, the loader corresponding to the data type identifier is obtained from the preset static component registry; The loader loads the component code corresponding to the rich media component. The second data is rendered using the component code of the rich media component.
[0020] In some embodiments of this application, the method further includes: In response to the data type being identified as a preset rich media identifier, the component code corresponding to the preloaded preset rich media identifier is obtained; the second data is rendered using the component code corresponding to the preset rich media identifier; the preset rich media identifier is used to indicate that the usage frequency of the rich media component is greater than a preset threshold; the component code corresponding to the preset rich media identifier is preloaded when the client meets a preset idle condition; In response to the data type identifier not being the preset rich media identifier, the operation of retrieving the loader corresponding to the data type identifier from the preset static component registry is performed.
[0021] In some embodiments of this application, after generating the rendering result corresponding to the second data, the method further includes: If the node type corresponding to the second data belongs to a preset static streaming type, then the position index corresponding to the first component node in the ordered content fragment set is determined as the node identifier of the first component node. If the node type corresponding to the second data belongs to a preset dynamic update type, then the service data identifier included in the first component node is determined as the node identifier of the first component node.
[0022] Secondly, embodiments of this application provide a user interface rendering method based on an intelligent agent, including: Receive user requests sent by the client; Based on the user request, a current dialogue frame is generated, which includes a timing identifier, message content, and a data type identifier corresponding to the message content. The current dialogue frame is sent to the client so that the client updates the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs based on the current dialogue frame, and renders the current dialogue interface based on the updated ordered content fragment set; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the timing identifier included in each dialogue frame in the data stream.
[0023] In some embodiments of this application, generating the current dialogue frame based on the user request includes: Based on the user request, the intelligent agent is invoked to perform reasoning and generate a response message corresponding to the user request. A corresponding timing identifier is assigned to the response message, and the timing identifier is used to identify the generation order of the current dialogue frame in the data stream; The message content of the response message, the timing identifier, and the data type identifier of the message content are encapsulated into the current dialogue frame.
[0024] Thirdly, embodiments of this application provide a user interface rendering apparatus based on an intelligent agent, comprising: The first receiving module is used to receive the current dialogue frame sent by the intelligent agent server. The current dialogue frame includes a timing identifier, message content, and a data type identifier corresponding to the message content. The update module is used to update the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs based on the current dialogue frame; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the time sequence identifier included in each dialogue frame in the data stream. The rendering module is used to render the current dialog interface based on the updated set of ordered content fragments.
[0025] Fourthly, embodiments of this application provide a user interface rendering apparatus based on an intelligent agent, comprising: The second receiving module is used to receive user requests sent by the client. The generation module is used to generate a current dialogue frame based on the user request. The current dialogue frame includes a timing identifier, message content, and a data type identifier corresponding to the message content. The sending module is used to send the current dialogue frame to the client, so that the client updates the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs based on the current dialogue frame, and renders the current dialogue interface based on the updated ordered content fragment set; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the timing identifier included in each dialogue frame in the data stream.
[0026] Fifthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method described in the first aspect of embodiments of this application.
[0027] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing a computer program, which is executed by a processor to implement the method described in the first aspect of embodiments of this application.
[0028] In a seventh aspect, embodiments of this application provide a computer program product, including a computer program that is executed by a processor to implement the method described in the first aspect of embodiments of this application.
[0029] Based on the interface generation method described in the first aspect above, this application has at least the following beneficial effects or advantages: In the embodiments of this application, an ordered set of content fragments enables the client to reassemble message content according to the order in which dialogue frames are generated. Message content of various types can be accurately rendered into the dialogue interface in the expected logical order, reducing interface content jumps or logical breaks, and significantly improving the coherence of rendering long texts or multimodal content. The ordered set of content fragments is updated based on the current dialogue frame, triggering rendering, allowing for immediate feedback without waiting for the entire response to be generated. Combined with the caching mechanism of the ordered set of content fragments, even if subsequent frames arrive with a slight delay, the dialogue interface can maintain its current state based on the already arrived fragments without crashing or flickering, providing an instantly responsive and progressively improving interactive experience.
[0030] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application, it can be implemented according to the contents of the specification. In order to make the above and other objects, features and advantages of this application more obvious and understandable, specific embodiments of this application are given below. Attached Figure Description
[0031] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the various drawings denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments according to this application and should not be construed as limiting the scope of this application.
[0032] Figure 1 A flowchart of an agent-based user interface rendering method provided in an embodiment of this application is shown; Figure 2 This illustration shows a flowchart of updating a message fragment array for different types of message content, provided in an embodiment of this application. Figure 3 A flowchart illustrating the user interface rendering provided in an embodiment of this application is shown; Figure 4 This illustration shows a rendering process diagram of a text-type message fragment provided in an embodiment of this application; Figure 5 A flowchart illustrating a user interface rendering method based on an intelligent agent provided in an embodiment of this application is shown. Figure 6 This illustration shows a schematic diagram of the structure of a user interface rendering device based on an intelligent agent according to an embodiment of this application; Figure 7 This paper shows another structural schematic diagram of a user interface rendering device based on an intelligent agent provided in an embodiment of this application; Figure 8 A schematic diagram of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0033] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the concept or scope of this application. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.
[0034] To facilitate understanding of the technical solutions of the embodiments of this application, the relevant technologies of the embodiments of this application are described below. The following relevant technologies are optional solutions and can be combined with the technical solutions of the embodiments of this application in any way, and all of them fall within the protection scope of the embodiments of this application.
[0035] With the widespread adoption of large language models in consumer applications, intelligent agents have emerged as a new form of interaction on mobile devices. Unlike the traditional request-response model, intelligent agents deliver content frame by frame through streaming interfaces, and the types of content delivered are heterogeneous and interleaved. For example, an address selection card might be pushed first, followed by a text reply word by word, interspersed with tool call descriptions or error messages.
[0036] This multi-content-type interleaved streaming scenario presents several technical challenges for client-side interface rendering. For example, a traditional chat message is a complete text or a card, but a message from an agent consists of interleaved content segments of various types, which cannot be represented by simple text fields or independent arrays. Another example is that the agent returns data in Markdown (Lightweight Markup Language) format, but the client's primary rendering container, Weex (a dynamic cross-platform development framework), does not support HTML (HyperText Markup Language) semantic tags (e.g., it does not support...). <h1>~< / h1> <h6> / / / / <blockquote> / <code>For example, mainstream Markdown rendering libraries cannot run on Weex. Furthermore, for text frames with very small granularity (e.g., 1-2 characters / frame), dozens of rendering updates may be triggered per second, requiring a solution to the performance issues caused by full re-rendering without losing frames.
[0037] The solutions offered by related technologies are generally designed for plain text streaming scenarios. The displayed content cannot represent the multiple content types delivered by the agent in an interleaved manner. The display order of these content types is chaotic, and some content types are not displayed coherently, resulting in fragmented dialogue semantics and a poor interactive experience. Furthermore, these technologies lack a unified model for interleaved message flows of multiple content types and also lack Markdown rendering solutions for constrained rendering environments such as Weex.
[0038] Based on this, embodiments of this application provide a user interface rendering method based on an intelligent agent. In this method, a client receives a current dialogue frame sent by an intelligent agent server. The current dialogue frame includes a timing identifier, message content, and a data type identifier corresponding to the message content. Based on the current dialogue frame, the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs is updated. The ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the timing identifiers included in each dialogue frame in the data stream. Based on the updated ordered content fragment set, the current dialogue interface is rendered.
[0039] In this method, the dialogue frames sent by the agent server include timing identifiers. The client constructs an ordered set of content fragments based on these timing identifiers, enabling the client to strictly reassemble message content according to the order in which the dialogue frames were generated. This ensures that message content of various types is accurately rendered in the dialogue interface according to the expected logical order, reducing content jumps or logical breaks and significantly improving the coherence of rendering long texts or multimodal content. Furthermore, the dialogue frames include data type identifiers corresponding to the message content. Based on these identifiers, the client can accurately identify the content attributes of the current dialogue frame, allowing for subsequent invocation of the corresponding rendering logic or components. This mechanism decouples rendering logic from data transmission. When a new interaction method is needed, only the corresponding component needs to be pre-defined on the client, and the new data type identifier needs to be included in the dialogue frames sent by the agent server. This eliminates the need to reconstruct the entire rendering engine, greatly improving the client's response speed and scalability to new agent capabilities.
[0040] Furthermore, this solution supports real-time updates of the ordered content fragment set based on the current dialogue frame and triggers rendering, meaning that immediate feedback can be seen without waiting for the entire response to be generated. Combined with the caching mechanism of the ordered content fragment set, even if subsequent frames arrive with a slight delay, the dialogue interface can maintain its current state based on the arrived fragments without crashing or flickering, providing an interactive experience of "instant response and progressive improvement".
[0041] It should be noted that the application scenarios or examples provided in this application are for ease of understanding, and the embodiments of this application do not specifically limit the application of the technical solutions. Furthermore, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. The collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0042] The technical solution of this application and how it solves the aforementioned technical problems are described in detail below with specific embodiments. The listed specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0043] Figure 1 A flowchart illustrating an agent-based user interface rendering method provided in an embodiment of this application is shown. Figure 1 As shown, the method specifically includes steps 101-103.
[0044] Step 101: The client receives the current dialogue frame sent by the intelligent agent server. The current dialogue frame includes a timing identifier, message content, and a data type identifier corresponding to the message content.
[0045] Step 102: Based on the current dialogue frame, the client updates the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the timing identifiers included in each dialogue frame in the data stream.
[0046] Step 103: The client renders the current dialog interface based on the updated set of ordered content fragments.
[0047] The client can be an application installed on a mobile phone, computer, or other terminal. The client can be, but is not limited to, an app (APP), a web page, or a mini-program. The client can communicate with the intelligent agent server and also interact with the user.
[0048] The intelligent agent server is a backend system or service endpoint that provides specialized service capabilities. It is responsible for executing core service logic, invoking a large language model for reasoning and decision-making, and encapsulating the processed task results into a structured data stream, which is then sent to the client for rendering and display. In the embodiments of this application, a user can log in to the intelligent agent server through a client. The user can then input a user request (query) in the client's dialogue interface, and the client sends the user request to the intelligent agent server. Based on the user request, the intelligent agent server invokes the intelligent agent service and / or the large language model for reasoning, generates a response message corresponding to the user request, encapsulates the response message into a dialogue frame containing a timing identifier, a data type identifier, and message content, and sends the dialogue frame to the client, which then renders it in the dialogue interface.
[0049] In response to the same user request, the intelligent agent server continuously sends a series of dialogue frames, which constitute the data stream corresponding to that user request. The response message corresponding to the user request can be streamed and encapsulated into multiple dialogue frames in the order of content generation, and the data stream corresponding to the user request is the collection of these multiple dialogue frames. The multiple dialogue frames included in the data stream are stream-generated and can also be streamed and transmitted to the client. The client performs streaming rendering according to the rendering method provided in the embodiments of this application, thereby forming a progressive display effect in the dialogue interface.
[0050] The timing identifier included in the current dialogue frame indicates the generation order of the current dialogue frame in the data stream. The message content included in the current dialogue frame is the specific response generated by the agent server; the message content can be text, Markdown code, or image links, etc. The data type identifier corresponding to the message content describes the media type of the message content. The media type of the message content can include, but is not limited to, text, image, Markdown, JSON (JavaScript Object Notation) card types, etc.
[0051] The aforementioned set of ordered content fragments can be a data structure maintained in memory by the client, such as an array, linked list, or ordered mapping table. After receiving a dialogue frame sent by the agent server, the client stores the dialogue frame in the set of ordered content fragments corresponding to the data stream to which the dialogue frame belongs. Moreover, in this set of ordered content fragments, multiple dialogue frames are arranged sequentially based on the timing identifiers contained in each dialogue frame.
[0052] After receiving the current dialogue frame from the agent server, the client stores the message content of the current dialogue frame into an ordered set of content fragments. Then, it renders the current dialogue interface based on the updated ordered set of content fragments.
[0053] In this embodiment, the client constructs an ordered set of content fragments based on the temporal identifiers of each dialogue frame. This allows for the reorganization of message content strictly according to the order in which the dialogue frames were generated. The ordered set of content fragments satisfies the state management requirements of multiple types of interleaved messages, preserving temporal information while supporting differentiated update logic. This ensures that message content with various data type identifiers is accurately rendered into the dialogue interface according to the expected logical order, reducing interface content jumps or logical breaks, and significantly improving the coherence of rendering long texts or multimodal content. The ordered set of content fragments is updated in real-time based on the current dialogue frame, triggering rendering and providing immediate feedback without waiting for the entire response to be generated, thus achieving streaming rendering.
[0054] In some embodiments of this application, updating the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs based on the current dialogue frame includes: parsing the current dialogue frame to obtain the timing identifier, message content, and data type identifier included in the current dialogue frame; determining the target storage location corresponding to the message content of the current dialogue frame in the ordered content fragment set based on the timing identifier and data type identifier; and updating the message content of the current dialogue frame to the target storage location in the ordered content fragment set.
[0055] The client establishes a streaming session connection with the agent server, receiving dialogue frames sent by the agent server frame by frame. Each current dialogue frame can include two layers of encapsulation. The outer encapsulation can be information encapsulated by the client gateway, including but not limited to one or more fields such as API (Application Programming Interface) identifier, data fields, call result, and version number. The API identifier identifies the specific functional interface used by the agent server to respond to the client's current user request. Data fields may include, but are not limited to, timing identifiers and status description information. The call result indicates whether the call to the API corresponding to the API identifier was successful or failed. The status description information describes the specific call status information corresponding to the call result, such as the specific reason for the call failure. The version number indicates the version identifier of the API protocol or data structure.
[0056] The inner encapsulation information of the current dialogue frame may include, but is not limited to, one or more fields such as data type identifier, message content, and success flag. The success flag can be a judgment of the execution status of the current dialogue frame, used to indicate whether the service logic generated by the agent server for the current dialogue frame has encountered an error. The message content can be the specific data content carried by the current dialogue frame, which may include service data and / or non-service data. Service data may be one or more types of data such as text, images, and cards generated by the agent server based on the user request and the execution of service logic. Non-service data may include one or more types of error codes, error messages, and tool call descriptions. Error codes are numeric or character codes used to indicate the cause of an error. Error messages can be specific error descriptions. Tool call descriptions can refer to a descriptive text sent to the client when the agent server decides to use an external tool or internal function to complete a task.
[0057] The data type identifier may include, but is not limited to, TEXT (text), CARD_DATA_END (end of card data), TOOL_DES (tool call description), ERROR (error), and other type identifiers.
[0058] After receiving the current dialogue frame, the client parses it, extracting the aforementioned timing identifier from the outer encapsulation information. The outer encapsulation information is then removed, and the data type identifier and message content are extracted from the inner encapsulation information. If the inner encapsulation information includes error codes and error messages, these are also extracted. The extracted message content is serialized data, which is then deserialized. This deserialization process can be performed before storing the message content in the ordered content fragment set, or the serialized message content can be stored in the ordered content fragment set first, and then deserialized during UI rendering based on this message content.
[0059] Based on the extracted timing and data type identifiers, the target storage location within the ordered content fragment set for the current dialogue frame is determined. The message content corresponding to the current dialogue frame is then stored at that target storage location within the ordered content fragment set.
[0060] In some embodiments, before storing the message content in the ordered content fragment set, the message content can be deserialized, and then converted into a normalized event, which is then stored in the ordered content fragment set. The message content in a dialogue frame may be converted into one or more normalized events, depending on the data type identifier of the message content included in the current dialogue frame. If all the message content in the current dialogue frame belongs to the same data type identifier, then the message content is replaced with a normalized event corresponding to that data type identifier. If the current dialogue frame includes message content with different data type identifiers, then the message content with different data type identifiers needs to be converted into the normalized events corresponding to their respective data type identifiers.
[0061] When converting to multiple normalized events, the target storage location for each normalized event needs to be determined based on the time sequence identifier and its corresponding data type identifier, for each message content with different data type identifiers.
[0062] When the message content includes error codes and error messages, the error type can be normalized based on the error code, that is, the error type can be mapped to the corresponding text description based on the error code.
[0063] For the same user request, the client streams the dialogue frames sent by the agent server, and updates the ordered set of content fragments for each dialogue frame in the manner described above. When the dialogue frame received by the client includes an end frame event, it is determined that the data stream corresponding to that user request has ended.
[0064] In this embodiment, by parsing the current dialogue frame to obtain the timing identifier, message content, and data type identifier, and locating the target storage location within an ordered set of content fragments based on the timing identifier and data type identifier, the message content is updated to the corresponding location. This effectively solves the data rendering errors caused by network jitter, packet loss, or out-of-order arrival during streaming transmission. It enables the client to accurately locate and orderly reassemble heterogeneous data, facilitating the presentation of multimodal content (such as text, cards, tool call descriptions, etc.) on the dialogue interface strictly according to logical timing, significantly improving the coherence, completeness, and user experience of intelligent agent dialogue interaction. Differentiated storage and rendering scheduling based on data type identifiers improves the efficiency and scalability of front-end data processing, providing reliable technical support for streaming responses in complex service scenarios.
[0065] In some embodiments of this application, determining the target storage location corresponding to the message content of the current dialogue frame in an ordered content fragment set based on a time sequence identifier and a data type identifier includes: when the data type identifier indicates that the message content of the current dialogue frame belongs to a service data type, searching for a target historical message fragment matching the message content of the current dialogue frame in the ordered content fragment set based on the data type identifier, and obtaining a search result; determining the target storage location corresponding to the message content of the current dialogue frame based on the time sequence identifier and the search result; when the data type identifier indicates that the message content of the current dialogue frame belongs to a non-service data type, determining the target storage location of the message content of the current dialogue frame in the ordered content fragment set based on the time sequence identifier of the current dialogue frame and the time sequence identifiers of each message fragment already stored in the ordered content fragment set.
[0066] Service data types refer to the data types of message content generated by the agent server when executing service logic. For example, data types such as TEXT and CARD_DATA_END identify message content that falls under the service data type category. Non-service data types refer to the data types of message content generated by the agent server during task execution to assist the client in state management, flow control, or exception handling. For example, data types such as TOOL_DES and ERROR identify message content that falls under the non-service data type category.
[0067] If the message content belongs to a service data type, search the ordered set of content fragments for historical message fragments with the same data type identifier as the message content. If found, use the historical message fragment with the same data type identifier as the target historical message fragment. Based on the search result and the time sequence identifier corresponding to the message content, determine the target storage location for the message content. If the message content belongs to a non-service data type, determine the target storage location based on the time sequence identifier.
[0068] This embodiment achieves refined and efficient data processing by distinguishing between service data types and non-service data types and employing different target storage location determination strategies. For service data types (such as text and card data), the target storage location is determined by combining the matching and lookup of target historical message fragments with time sequence identifiers. This effectively handles the content splicing and update logic in the streaming generation process, ensuring the semantic and structural integrity and coherence of the service content. For non-service data types (such as tool call descriptions and error messages), the target storage location is directly located in the ordered set of content fragments based on time sequence identifiers. This allows for the rapid insertion of procedural states or exception information into the correct time sequence nodes without consuming additional computing resources for content matching. This differentiated processing mechanism not only significantly reduces the computational overhead of client-side parsing and reassembling of data streams and improves rendering efficiency, but also effectively reduces logical conflicts and visual interference when displaying different types of data. This provides a more stable, smooth, and logically rigorous presentation effect for streaming dialogues in complex interactive scenarios.
[0069] In some embodiments of this application, searching for a target historical message fragment that matches the message content of the current dialogue frame in an ordered set of content fragments based on a data type identifier includes: indicating that the message content of the current dialogue frame is text based on the data type identifier; determining the reference insertion position of the message content of the current dialogue frame in the ordered set of content fragments based on a time sequence identifier; determining whether the data type of the previous message fragment is text based on the existence of a preceding message fragment adjacent to the reference insertion position in the ordered set of content fragments; if the data type of the previous message fragment is text, then determining the previous message fragment as the target historical message fragment; if there is no preceding message fragment, or the data type of the previous message fragment is not text, then determining that no target historical message fragment was found.
[0070] The ordered content fragment set includes multiple stored message fragments. The message content in these fragments is the preceding dialogue frame of the current data stream received by the client. These message fragments are arranged in the ordered content fragment set according to their corresponding timing identifiers. The pivot insertion position can represent the theoretically correct location of the message content of the current dialogue frame within the already included message fragments of the ordered content fragment set. The pivot insertion position can also be represented as the theoretical sequence number of the message content of the current dialogue frame within the ordered content fragment set.
[0071] The preceding message segment can be a message segment that precedes and is adjacent to the reference insertion position. In other words, the preceding message segment can be the message segment that precedes the reference insertion position and is closest to it.
[0072] As an example, the current ordered set of content fragments A={a,c}, the message content of the current dialogue frame is b, and the baseline insertion position is determined by the timing identifier as sequence number 2, meaning that theoretically the message content should be placed between a and c. The preceding message fragment is a.
[0073] This embodiment achieves intelligent splicing and structured recombination of streaming text content by employing a strategy that locates the baseline insertion position for text-type data and then verifies and matches preceding message fragments. By using time sequence identifiers to accurately locate the baseline insertion position and further verifying the data type of adjacent preceding message fragments, a merging operation is performed only when both the preceding message fragment and the message content of the current dialogue frame are text-type. This effectively solves the text fragmentation problem caused by network jitter or fragmented transmission, ensuring the semantic and visual integrity and coherence of continuous dialogue content. Furthermore, it strictly distinguishes the boundaries between plain text streams and other multimodal data (such as cards, tool call descriptions, etc.), preventing erroneous concatenation or formatting errors of different data types during rendering. This significantly improves the client's parsing efficiency and display accuracy for complex heterogeneous message streams, providing users with a smoother and more natural reading experience.
[0074] In some embodiments of this application, searching for a target historical message fragment that matches the message content of the current dialogue frame in an ordered set of content fragments based on a data type identifier includes: obtaining a component identifier from the message content of the current dialogue frame based on the data type identifier indicating that the message content of the current dialogue frame is rich media; determining whether a historical message fragment corresponding to the component identifier exists in the ordered set of content fragments; if a historical message fragment corresponding to the component identifier exists, then the historical message fragment corresponding to the component identifier is determined as the target historical message fragment; if no historical message fragment corresponding to the component identifier exists, then it is determined that no target historical message fragment was found.
[0075] Rich media types refer to message content types that differ from plain text (TEXT) and possess complex structures or specific interactive functions. Rich media message content can include, but is not limited to, mixed text and images, card layouts, forms, charts, or interactive buttons. As an example, the message content corresponding to the data type identifier CARD_DATA_END belongs to the rich media type.
[0076] Component identifiers are used to uniquely identify message content belonging to a rich media type. As an example, if the message content is card data, the component identifier could be a card identifier, uniquely identifying a card. For rich media type message content, data from the same rich media type object may be distributed as multiple message contents, or previously rendered rich media type objects may be subsequently distributed with updated message content. Therefore, component identifiers can be used to locate message content belonging to the same rich media type, thus establishing a mapping relationship between the message content of the current dialogue frame and historical rendering instances.
[0077] This embodiment introduces component identifiers as unique association indexes for rich media message content, achieving precise positioning and state management of complex structured data during streaming transmission. Specifically, this method can extract component identifiers from rich media message content and quickly search for the existence of corresponding historical message segments in an ordered set of content fragments. If they exist, they are identified as target historical message segments to support incremental updates or content splicing; if they do not exist, it is determined that no target historical message segment was found, and it is then processed as a new component. This identity-based matching mechanism effectively solves problems such as duplicate rendering, data misalignment, and interface flickering that easily occur when complex objects such as rich media cards and charts are distributed in segments or dynamically refreshed. It ensures the logical consistency and visual coherence of the same rich media object in multi-frame transmission, reduces the computational overhead of the client traversing and comparing all historical data, significantly improves the parsing efficiency and rendering performance of heterogeneous message streams, and provides users with a smoother and more stable multimodal interactive experience.
[0078] In some embodiments of this application, when the data type identifier indicates that the message content of the current dialogue frame belongs to a service data type, the target storage location corresponding to the message content of the previous dialogue frame is determined based on the time sequence identifier and the search result. This includes: determining the position of the target historical message fragment in the ordered content fragment set as the target storage location based on the search result indicating that the target historical message fragment has been found; determining the reference insertion position of the message content of the current dialogue frame in the ordered content fragment set based on the time sequence identifier and the time sequence identifier of each message fragment already stored in the ordered content fragment set based on the search result indicating that the target historical message fragment has not been found; and determining the reference insertion position as the target storage location.
[0079] If the message content belongs to a service data type, and a target historical message fragment matching the message content is found, the location of that target historical message fragment is directly determined as the target storage location. If no target historical message fragment is found, the baseline insertion position is determined based on the time sequence identifier, and this baseline insertion position is used as the target storage location.
[0080] This embodiment attempts to reuse existing message fragments by searching for target historical message fragments. If found, the current message data is directly mapped to the position of the target historical message fragment, thereby achieving state updates and in-situ refreshes for the same service task or interaction flow, reducing interface redundancy and logical breaks caused by repeatedly creating message fragments. When no corresponding target historical message fragment is found, the baseline insertion position is determined based on the time sequence identifier, ensuring that the current message content can be accurately placed in strict linear chronological order. This solution helps maintain the contextual relevance of message content of service data types during rendering, maintains the temporal rigor of the dialogue flow, and significantly improves the flexibility and accuracy of managing ordered content fragment sets in complex interaction scenarios, providing users with a clearer and more orderly service feedback experience.
[0081] In some embodiments of this application, updating the message content of the current dialogue frame to the target storage location in the ordered content fragment set includes: in response to the absence of a stored message fragment at the target storage location in the ordered content fragment set, creating an empty message fragment at the target storage location and writing the message content of the current dialogue frame into the empty message fragment; in response to the presence of a target historical message fragment at the target storage location, adding the message content of the current dialogue frame into the target historical message fragment based on the data type identifier and the target historical message fragment.
[0082] In the preceding embodiments, the target storage location determined could be either the location of the target historical message fragment or the baseline insertion location. If no message fragment is stored at the target storage location, it means that the target storage location is the aforementioned baseline insertion location. An empty message fragment is created at the target storage location, and the message content of the current dialogue frame is written into this empty message fragment. If a message fragment is stored at the target storage location, this stored message fragment is the aforementioned target historical message fragment. By fusing the message content of the current dialogue frame with the data in the target historical message fragment, the update of the ordered content fragment set is achieved.
[0083] In this embodiment, a differentiated writing strategy is executed based on whether a message fragment already exists at the target storage location, achieving efficient construction and dynamic updating of streaming message content. When the target storage location is empty, a new message node is initialized by creating a new message fragment and writing content. When a target historical message fragment already exists at the target storage location, the current message content is directly appended or merged into the target historical message fragment. This effectively solves the content splicing problem when the same logical message is sent in multiple frames during streaming transmission, improves the integrity and continuity of various types of data such as text and cards on the client, reduces interface redundancy, resource waste, and visual flicker caused by repeatedly creating message nodes, significantly improves the efficiency and accuracy of message rendering, and provides users with a smoother and more natural dialogue interaction experience.
[0084] In some embodiments of this application, when a target historical message fragment exists at the target storage location, the message content of the current dialogue frame is added to the target historical message fragment based on the data type identifier and the target historical message fragment. This includes: in response to the data type identifier indicating that the message content of the current dialogue frame is text type, adding the message content of the current dialogue frame to the end of the text information included in the target historical message fragment; and in response to the data type identifier indicating that the message content of the current dialogue frame is rich media type, obtaining the component field information included in the target historical message fragment, and updating the component field information using the message content of the current dialogue frame.
[0085] Because text-type and rich media-type message content differ fundamentally in data structure, rendering method, and update semantics, the update methods for these two types of message content also differ when there are target historical message fragments at the target storage location.
[0086] Text-based messages are essentially linear sequences of characters. When an agent server streams text (e.g., a typewriter effect), subsequent data frames are usually a natural continuation of the preceding content. Therefore, new characters can be directly appended to the end of an existing string. From an update semantics perspective, the semantics of text are concatenation. As an example, for a text message, the first frame is "Hello," the second frame is "World," and the goal is to get "Hello World." A simple string concatenation operation is performed; the structure of the preceding content is irrelevant, only the appended text needs to be added. From a rendering perspective, when the client renders text, it is usually a continuous text box. When new data arrives, characters are simply drawn at the cursor position. Therefore, if a target historical message fragment exists, the message content of the current dialogue frame can be appended to the end of the target historical message fragment.
[0087] Rich media messages typically contain structured data objects, such as JSON-formatted cards and charts. These messages are not simple linear stacks but complex entities composed of multiple fields. Subsequent data frames often don't extend the object but rather populate or modify specific attributes within it. Therefore, the update semantics for rich media are state synchronization or field assignment. As an example, for a rich media component, the first frame might send an empty card frame (containing a title and an empty list), and the second frame might send the actual list item data. The corresponding "list field" in the first frame needs to be located, and the new data written into that field. When the client renders rich media, it needs to locate the specific component node and update its specific attribute values (e.g., updating the percentage of a progress bar, updating the number of rows in a table), rather than drawing a new component after the entire component. Therefore, when a target historical message fragment exists, the component's field information is updated using the message content of the current dialog frame.
[0088] This embodiment designs differentiated content merging strategies to address the characteristics of different data types in streaming scenarios, effectively improving the accuracy of message rendering and resource utilization. For text types, an append-only approach is used, conforming to the linear generation logic of natural language and ensuring the continuity and integrity of the dialogue content. For rich media types, targeted updates are performed by locating component field information, reducing formatting errors or duplicate rendering caused by incorrectly concatenating structured data as plain text. This dynamic processing mechanism based on data type identifiers not only achieves state synchronization and partial refresh of complex rich media message content during segmented delivery, significantly reducing client-side parsing overhead and interface redraw frequency, but also improves the consistency and smoothness of visual presentation during multimodal interaction, thereby greatly optimizing the user's real-time interactive experience.
[0089] In some embodiments of this application, the ordered set of content fragments can be a message fragment array, which may include one or more fragment elements for storing message content from a dialogue frame. When the message fragment array includes multiple fragment elements, the data type identifiers corresponding to these multiple fragment elements may be different. The data type identifier corresponding to a fragment element is the data type identifier of the message content stored in that fragment element. Each fragment element is arranged in the message fragment array according to the order indicated by its corresponding timing identifier.
[0090] The fragment elements can be of the following types, but are not limited to: TEXT segment, which contains a text field and stores the concatenated text content; CARD segment, which contains card identifier, card type, and result data fields and stores the card data; TOOL_DES segment, which contains a description field and stores the tool call description information; and ERROR segment, which contains an error code and error message fields and stores the error information.
[0091] Figure 2 This diagram illustrates the process of updating the message fragment array for different types of message content. For example... Figure 2 As shown, after receiving the current dialogue frame, the client determines the data type identifier of the message content in the current dialogue frame. If the data type identifier is TEXT, it checks whether the last element in the message fragment array is a TEXT segment. If it is, the message content of the current dialogue frame is appended to the end of the last TEXT segment. If not, a new TEXT segment is created at the end of the message fragment array, and the text content of the current dialogue frame is written into the newly created TEXT segment. If the data type identifier is CARD_DATA_END, the card identifier is extracted from the message content of the current dialogue frame. It checks whether a CARD segment containing that card identifier exists in the message fragment array. If it exists, the CARD segment containing that card identifier is updated in place based on the message content of the current dialogue frame. If not, a new CARD segment is created at the end of the message fragment array, and the message content of the current dialogue frame is added to the newly created CARD segment. If the data type identifier is TOOL_DES, a new TOOL_DES segment is created at the end of the message fragment array, and the message content of the current dialogue frame is added to the newly created TOOL_DES segment. If the data type is identified as ERROR, a new ERROR segment is created at the end of the message fragment array, and the error information in the current dialog frame is added to the newly created ERROR segment.
[0092] The ordered content fragment set uses the aforementioned message fragment array to arrange various types of content fragments in the same array according to the generation order of the agent server, faithfully restoring the output order of the agent server during rendering. Different semantic update strategies are adopted for different types of content: TEXT segments use an append-merge strategy, CARD_DATA_END segments use an upsert (update or insert) strategy, and TOOL_DES and ERROR segments use an append strategy. Each type has independent update semantics.
[0093] In other embodiments of this application, the ordered content fragment set can also be a collection that includes arrays corresponding to different data types. That is, the fragment elements stored in different arrays have different data types, while the fragment elements stored in the same array have the same data type. As an example, this collection may include arrays of type TEXT, CARD, TOOL_DES, and ERROR, etc. The fragment elements in the same array are sorted based on the time sequence identifier corresponding to each fragment element.
[0094] In this embodiment, when rendering the dialog interface based on an ordered set of content fragments, it is necessary to sort the fragment elements in each array according to the time sequence identifier of each fragment element in the array corresponding to each data type to obtain a fragment element sequence, and then perform the dialog interface rendering process based on the fragment element sequence.
[0095] In some other embodiments of this application, the ordered content fragment set may also directly include each fragment element. When each fragment element is stored in the ordered content fragment set, it may not be sorted based on the time sequence identifier. During the rendering process, the fragment elements may be sorted based on the time sequence identifier corresponding to each fragment element to obtain a fragment element sequence. Then, the rendering process of the dialog interface is performed based on the fragment element sequence.
[0096] In some embodiments of this application, rendering the current dialog interface based on the updated ordered set of content fragments includes: generating an abstract syntax tree based on the updated ordered set of content fragments; mapping each syntax node of the abstract syntax tree to a component node supported by the current dialog interface based on a preset component mapping configuration to obtain a target component tree; and performing incremental rendering of the current dialog interface based on the target component tree.
[0097] An Abstract Syntax Tree (ABS) is an intermediate representation generated after structured parsing of an updated set of ordered content fragments. ABS strips away redundant symbols and formatting details from the original data, preserving its logical structure and hierarchical relationships. For example, a rich media message containing a title, list, and buttons will be parsed into a tree structure with a root node containing child nodes such as title nodes, list nodes, and button nodes. This abstraction allows the subsequent rendering process to focus on semantic structure transformation independently of the original data format.
[0098] Because different client renderers may support different basic rendering tags, for example, some renderers support... 、 、 <text> 、 、 , <input> A small number of basic rendering tags are supported, but not... <h1>~< / h1> <h6>、 、 、 、 、 < / h6> < / text> < / code> < / blockquote> / <code> <blockquote> 、 <code>、 <pre>、 <hr> 、 <strong>、 <em>, HTML semantic tags, etc. To ensure that renderers on different clients can utilize the user interface rendering method provided in this application, a component mapping configuration can be pre-set in the client. This configuration includes the mapping relationship between node types of different syntax nodes and component nodes. The node type can be any node type that may exist in the abstract syntax tree, including but not limited to headings, paragraphs, lists, quotation blocks, code blocks, bold, italics, inline code, hyperlinks, etc. Component nodes can include, but are not limited to, basic view components and style attributes. As an example, the pre-set component mapping configuration can be shown in Table 1.
[0099] Table 1
[0100] In the target component data, each component node corresponds to a syntax node in the abstract syntax tree, and has been assigned a specific UI component type, attribute values, and child node relationships through a preset component mapping configuration. For example, a "title node" will become a "TextView" component node with a specific font size, color, and alignment after mapping. These component nodes are organized in a tree structure to form a complete target component tree that can be directly used for rendering.
[0101] By pre-setting the aforementioned component mapping configuration on the client side, parsing and rendering are decoupled, making the data structure transformation logic independent of the specific interface display format. When the underlying rendering framework is upgraded or needs to adapt to new UI specifications, only the correspondence between the node types of syntax nodes and component nodes in the component mapping configuration needs to be adjusted, without modifying the core parsing algorithm or reprocessing the original content fragments. This configurable approach not only significantly reduces code coupling and maintenance costs but also gives the system flexible cross-platform adaptability, ensuring that the same abstract syntax tree can dynamically generate matching target component trees according to different runtime environments, thereby efficiently completing the interface rendering.
[0102] In some embodiments of this application, generating an abstract syntax tree based on an updated ordered set of content fragments includes: parsing each message fragment in the updated ordered set of content fragments to generate an abstract syntax tree; or, obtaining the target message fragment updated in the updated ordered set of content fragments; parsing the target message fragment to generate an abstract syntax tree.
[0103] The system retrieves the target message fragment from the updated ordered set of content fragments and parses only that fragment. It avoids repeatedly processing previously parsed and unchanged message fragments, effectively reducing unnecessary computational overhead and memory usage, and lowering the time required to build the abstract syntax tree. This incremental processing approach is particularly suitable for frequent small-scale data updates in streaming scenarios, significantly shortening the time latency from data reception to interface response and improving the user's real-time interactive experience.
[0104] The system parses the entire updated set of ordered content fragments, ensuring that even in specific scenarios such as initial loading, data structure reorganization, or abnormal recovery, it can still generate a complete and logically consistent abstract syntax tree based on the global context, thus guaranteeing the accuracy and robustness of the rendering results.
[0105] In some embodiments of this application, based on a preset component mapping configuration, each syntax node of the abstract syntax tree is mapped to a component node supported by the current dialog interface to obtain a target component tree. This includes: querying the target component node corresponding to the target node type of the target syntax node from the component mapping configuration; replacing the target syntax node with the target component node in the abstract syntax tree; wherein, the component mapping configuration includes the mapping relationship between different node types and component nodes; the target syntax node is any syntax node on the abstract syntax tree; the target component node includes the basic view component and style attributes corresponding to the target node type.
[0106] This embodiment establishes a standardized mapping relationship between abstract syntax nodes and concrete basic view components by introducing component mapping configuration, realizing the automated conversion from logical semantic structure to specific interface rendering elements. In the abstract syntax tree, target syntax nodes are replaced with target component nodes carrying style attributes, ensuring that the generated component tree strictly adheres to the rendering specifications of the runtime environment, achieving synchronous adaptation of content and styles. This configuration-based node replacement mechanism effectively decouples the front-end parsing logic from the specific implementation of the underlying UI components. This allows for adaptation to different platforms or UI framework upgrades simply by adjusting the component mapping configuration, significantly improving code reusability, system scalability, and the accuracy and consistency of interface rendering.
[0107] In some embodiments of this application, incremental rendering of the current dialog interface is performed based on the target component tree, including: obtaining the first data reference identifier of the first component node in the previous rendering cycle, wherein the first component node is any component node in the target component tree; if the second data reference identifier of the first component node in the current rendering cycle is consistent with the first data reference identifier, then the rendering result of the first component node in the previous rendering cycle is reused; if the second data reference identifier is inconsistent with the first data reference identifier, then the update processing of the first component node is performed according to the second data reference identifier.
[0108] The client streams dialog frames, and each time a new dialog frame is received, a rendering cycle may be triggered. The previous rendering cycle can be the rendering cycle most recent before the current dialog frame was received. The current rendering cycle is the rendering cycle in which the current dialog frame is currently rendered.
[0109] The first data reference identifier identifies the data bound to the first component node in the previous rendering cycle. Specifically, it can be the storage address or index string of the data bound to the first component node in the previous rendering cycle. The second data reference identifier identifies the data bound to the first component node in the current rendering cycle.
[0110] In front-end and cross-platform development, the principle of data immutability is typically followed to ensure predictable state. When service logic needs to modify data, it doesn't directly modify the original memory address; instead, it creates a completely new object or array, generating a new memory address. If the second data reference identifier in the current rendering cycle matches the first data reference identifier in the previous rendering cycle, it means no new object has been created. Without creating a new object, according to the data immutability principle, this indicates that the storage address of the data bound to the first component node has not changed. Therefore, the rendering process for the first component node can be skipped, and the rendering result of the first component node from the previous rendering cycle can be directly reused. The rendering result can refer to the final product generated after the first component node has undergone parsing and layout calculations, which can be directly recognized and drawn by the display device (such as a mobile phone screen).
[0111] If the second data reference identifier is inconsistent with the first data reference identifier, the update process for the first component node is performed based on the second data reference identifier. Any component node in the target component tree can be processed in the same way as the first component node.
[0112] An efficient incremental rendering determination mechanism was established by comparing the data reference identifiers of component nodes in adjacent rendering cycles. This mechanism uses the consistency of data reference identifiers as the criterion for judging content stability. When the data reference identifiers are consistent, the rendering results from the previous rendering cycle are directly reused, avoiding repeated layout calculations and drawing instruction generation. When the data reference identifiers are inconsistent, an update process is triggered. This strategy based on data reference identifier comparison reduces rendering overhead from a full redraw to partial on-demand updates, significantly reducing computational load, effectively solving the performance bottleneck when complex interfaces are frequently refreshed, and improving the smoothness and responsiveness of application operation.
[0113] In some embodiments of this application, when the second data reference identifier is inconsistent with the first data reference identifier, the update process of the first component node is performed according to the second data reference identifier, including: obtaining the first data content pointed to by the first data reference identifier and the second data content pointed to by the second data reference identifier; if the second data content is consistent with the first data content, then the rendering result of the first component node in the previous rendering cycle is reused; if the second data content is inconsistent with the first data content, then the first data that is the same as the first data content and the second data that is different from the first data content are determined from the second data content; the rendering result corresponding to the second data in the current rendering cycle is generated according to the second data, and the rendering result corresponding to the first data in the previous rendering cycle is reused.
[0114] In the above embodiments, for incremental rendering of the dialog interface, it is first determined whether the data reference identifier corresponding to the first component node in the previous rendering cycle and the current rendering cycle are consistent. If they are consistent, the rendering process of the first component node is skipped, and the rendering result of the first component node in the previous rendering cycle is reused. If the data reference identifiers are inconsistent, it is further determined whether the data content bound to the first component node in the previous rendering cycle and the current rendering cycle are consistent. If they are consistent, the rendering result of the previous rendering cycle is reused. If they are inconsistent, the second data that has actually changed in the current rendering cycle compared with the data in the previous rendering cycle is further determined. Only the second data is rendered, and the rendering result of the previous rendering cycle is reused for the remaining unchanged first data.
[0115] As an example, the above incremental rendering measurement is referred to as a two-layer memory strategy, which includes an outer memory strategy and an inner memory strategy. For high-frequency appending scenarios with 1-2 characters per TEXT frame, the outer memory strategy is used first. The Markdown view component is wrapped with React.memo (memorized component), and the overall rendering is skipped when the input text citation identifiers are equal. If the input text citation identifiers are not equal, the inner memory strategy is used. Each content block after parsing the abstract syntax tree is encapsulated as an independent BlockSlot component. Each content block is re-rendered based on whether its original string is equal.
[0116] By adopting the above-mentioned dual-layer memory strategy, each time a new TEXT frame is received, only the last content block being appended will trigger re-parsing and rendering, while all previously stable content blocks will be hit in the memory cache, effectively avoiding full re-rendering.
[0117] By deeply comparing the specific data content pointed to by the data reference identifiers of the same component node in adjacent rendering cycles, fine-grained incremental updates based on content differences are achieved. When it is determined that the data content bound to the same component node in adjacent rendering cycles is inconsistent, the system can further parse out the unchanged first data and the changed second data. Therefore, the rendering result from the previous rendering cycle can be directly reused for the first data, while rendering generation is only performed on the second data. This finer-grained update strategy effectively reduces the resource waste caused by re-rendering the entire component node due to local data changes, and maximizes the preservation of the rendering cache of unchanged data. This not only significantly reduces computational redundancy in data processing and interface rendering, reducing memory usage and bandwidth consumption, but also greatly improves interface refresh efficiency and system response speed in complex data scenarios.
[0118] In some embodiments of this application, the performance degradation caused by frequent changes in data reference identifiers during streaming data transmission is effectively solved by optimizing the update strategy for message layer data storage. Specifically, the data reference identifier is only changed when a substantial change in a message fragment is detected (e.g., an insertion or update operation triggered based on a card identifier). This mechanism reduces the frequency of data reference identifier updates due to minor changes or non-substantial refreshes in data content during streaming updates, thereby ensuring that the data reference identifier passed to the component remains stable when the data attributes have not actually changed. By maintaining the stability of the data reference identifier, the failure of the memoization mechanism based on data reference identifier comparison in the front-end framework is effectively reduced, unnecessary re-rendering of rich media components and their sub-components is reduced, rendering overhead is significantly reduced, and page response speed and smoothness in streaming dialogue scenarios are improved.
[0119] In some embodiments of this application, the client provides a `componentsprops` interface, allowing the service provider to inject custom components based on node type. For each component node in the target component tree, it first checks `components.<node name>`. If a match is found, the custom component injected by the service provider is used; otherwise, a preset default base component is used. The children (child content) received by the injected component are already rendered view nodes, and the service component does not need to understand the structure of the content fragments.
[0120] In this embodiment, generating the rendering result corresponding to the second data in the current rendering cycle based on the second data includes: obtaining the node type corresponding to the second data and querying whether there is a custom component corresponding to the node type in the preset component injection mapping table; if there is a custom component, calling the custom component to render the second data and generating the rendering result corresponding to the second data; if there is no custom component, calling the preset default basic component to render the second data and generating the rendering result corresponding to the second data.
[0121] The node type corresponding to the second data can refer to the classification identifier of the data structure semantics of the second data. The node type determines which specific UI component should be called to display the second data. Node types can include, but are not limited to, headings, lists, code and references, media resources, and interactive elements. Among them, headings can include, but are not limited to, first-level headings and second-level headings. Lists can include, but are not limited to, ordered lists, unordered lists, and list items. Code and references can include, but are not limited to, code blocks, inline code, and reference blocks. Interactive elements can include, but are not limited to, hyperlinks and buttons.
[0122] The pre-defined component injection mapping table is stored in the client. This table includes the mapping relationship between custom components injected by the service provider and node types. For the second data, if a custom component corresponding to the node type of the second data exists in the component injection mapping table, that custom component will be used to render and display the second data. Otherwise, the pre-defined default basic component corresponding to the node type of the second data will be used to render and display the second data.
[0123] This embodiment provides a component injection mechanism for the service provider. A component injection mapping table stores the mapping relationship between injected custom components and node types. Based on the node type in the second data, the corresponding custom component is precisely matched in the preset component injection mapping table for differentiated rendering. This allows for dynamic configuration and personalized customization of functions for specific service scenarios without modifying the underlying rendering engine code, significantly improving the system's scalability. A default basic component is introduced as a fallback strategy. When a matching custom component is not found in the component injection mapping table, it automatically falls back to the general rendering logic. This effectively reduces rendering interruptions or program anomalies caused by missing custom components, thus ensuring both richness of the interface display and robustness and stability, reducing development and maintenance costs and improving the user experience.
[0124] In some embodiments of this application, the custom component includes a rich media component. Calling the custom component to render the second data includes: in response to the data type identifier of the second data being a rich media type, obtaining the loader corresponding to the data type identifier from a preset static component registry; loading the component code corresponding to the rich media component through the loader; and rendering the second data using the component code of the rich media component.
[0125] Rich media components are visual units used to display and interact with non-plain text content. They enhance the richness of information expression and user engagement. Rich media components can include, but are not limited to, image components, video and audio components, and interactive components. Image components can include, but are not limited to, static images, animated images, and image carousels. Video and audio components can include, but are not limited to, video players, audio players, and live streaming components. Interactive components can include, but are not limited to, form controls, voting devices, and embedded maps.
[0126] This embodiment maintains a static component registry on the client side, which includes a mapping relationship between data type identifiers of different rich media types and preset loaders. When the second data is a rich media type, based on the data type identifier of the second data, the loader corresponding to that data type identifier is retrieved from the static component registry, the corresponding component code is loaded using that loader, and the loaded component code is used to render and display the second data.
[0127] As an example, for each card type, the client maintains a card registry, which maps card types to lazy loaders. Each card is independently packaged into a code block that can be distributed and installed separately. When rendering the CARD_DATA_END section, the client looks up the corresponding lazy loader in the card registry based on the card type, loads the corresponding card's code block using the lazy loader, and uses this code block to render the CARD_DATA_END section. Once the code block corresponding to a card type is downloaded, subsequent occurrences of the same card type can reuse the previously downloaded code block for that card type.
[0128] This embodiment achieves efficient and flexible rendering of rich media content by establishing a dynamic mapping mechanism between data type identifiers and rich media component loaders. Based on the data type identifier of the second data, the corresponding loader is precisely matched from a preset static component registry, and the corresponding rich media component code is loaded on demand. This reduces the resource waste and first-screen performance degradation caused by the full loading of all component code in traditional solutions. This mechanism not only significantly reduces the initial loading size and improves page response speed, but also enhances the maintainability and scalability of the system through modular component organization. Adding or replacing rich media components does not require modifying the core rendering logic; only updating the static component registry and the corresponding component package is needed to complete the functional iteration, effectively supporting rapid service evolution and diverse display needs.
[0129] In some embodiments of this application, in response to the data type identifier being a preset rich media identifier, the component code corresponding to the preloaded preset rich media identifier is obtained; the second data is rendered using the component code corresponding to the preset rich media identifier; the preset rich media identifier is used to indicate that the usage frequency of the rich media component is greater than a preset threshold; the component code corresponding to the preset rich media identifier is preloaded when the client meets a preset idle condition; in response to the data type identifier not being a preset rich media identifier, the above-described operation of obtaining the loader corresponding to the data type identifier from the preset static component registry is performed.
[0130] Preset idle conditions may include at least one of the following: the main thread has no high-priority tasks being executed (such as responding to user clicks, processing complex animations or layout calculations, etc.), the current network status is good, and the system computing resource utilization rate is below a certain threshold.
[0131] This embodiment effectively balances system performance and user experience by differentiating the usage frequency of rich media components and employing a differentiated loading strategy. For rich media components with a usage frequency exceeding a preset threshold, their component code is preloaded when the client meets preset idle conditions. This allows the cached component code to be directly retrieved and rendered immediately when rendering corresponding data, significantly reducing loading latency for high-frequency components and improving response speed in the first screen and high-frequency interaction scenarios. For rich media components with a low usage frequency, the loader is dynamically obtained on demand through a static component registry, avoiding the invalid occupation of initial resources by low-frequency components. This mechanism not only optimizes resource scheduling efficiency and reduces network bandwidth and memory overhead but also enhances the system's adaptability, intelligently allocating loading priorities based on the actual usage of components. This ensures the smoothness of the core experience while supporting richer and more flexible rich media content display.
[0132] In some embodiments, if component code loading fails, a pre-defined fallback component can be automatically displayed to replace the original component as a placeholder, thereby reducing blank pages or layout errors and ensuring the integrity and usability of the user interface. A retry mechanism can also be provided to the user, triggering a pre-defined retry callback function to re-initiate the component code retrieval request and attempt to reload the component code. This not only improves robustness in weak network or resource-abnormal environments but also gives users the ability to recover their experience independently, effectively reducing the risk of interaction interruption due to a single loading failure.
[0133] When an internal error occurs during the rendering logic execution of a rich media component, a built-in error boundary mechanism is used to capture and isolate the exception in the rendering process. The error boundary accurately captures the exception and confines it within the scope of the current component, effectively preventing the error from propagating upwards and reducing pollution of the rendering state of the entire message bubble or other parent components. This mechanism ensures that even if a single rich media component experiences a rendering failure, the entire chat interface will not crash or display a blank screen, guaranteeing the normal display and interaction of other content in the message list, significantly improving the robustness and fault tolerance of the front-end application.
[0134] In some embodiments of this application, a non-blocking placeholder rendering strategy can be used to handle the loading state of rich media components. During the data acquisition or code loading of the rich media component, a preset placeholder skeleton screen is displayed. This skeleton screen adopts a layout structure matching the rich media component and a placeholder image with preset colors to visually pre-build the general structure of the page, thereby reducing page layout jitter and providing immediate visual feedback. This loading process adopts an asynchronous non-blocking mechanism, that is, the current loading state of the rich media component will not suspend or block the parsing and rendering process of other message fragments within the same message bubble. Through this parallel processing strategy, it can be ensured that even when some rich media content is not yet ready, the text or other lightweight content in the message can still be displayed on the screen in real time, significantly improving the visual smoothness and interactive experience of the user during the waiting process.
[0135] Some embodiments of this application also feature a silent fault-tolerance mechanism for unknown card types. Specifically, when the parsed data type identifier does not match a corresponding loader in the preset static component registry, the rendering operation of that data segment will be automatically skipped without triggering any abnormal errors or interrupting the current message stream processing. Through this silent degradation strategy, the potential rendering crash risk caused by newly added data types not yet synchronized to the client or compatibility issues with historical version data can be effectively shielded, thereby ensuring the stable display and smooth presentation of the overall message list and other normal message segments.
[0136] In some embodiments of this application, after generating the rendering result corresponding to the second data, the method further includes: if the node type corresponding to the second data belongs to a preset static streaming type, then the position index corresponding to the first component node in the ordered content fragment set is determined as the node identifier of the first component node; if the node type corresponding to the second data belongs to a preset dynamic update type, then the service data identifier included in the first component node is determined as the node identifier of the first component node.
[0137] The position index of the first component node in the ordered content fragment set indicates the sorting position of the message fragment corresponding to the first component node in the ordered content fragment set. The node identifier of the first component node is used to uniquely identify the first component node. The service data identifier is used to uniquely identify the message content corresponding to the first component node. As an example, if the first component node is a card node, then the service data identifier can be a card identifier.
[0138] Predefined static streaming types refer to message fragments whose content is fixed once generated and appended to the page, and will not be modified subsequently. Examples include plain text and fixed Markdown formatting. Predefined dynamic update types refer to data nodes whose content may change after the initial rendering due to asynchronous backend requests, user interaction, or environmental changes. Examples include chart components and card components.
[0139] This embodiment achieves precise control over the rendering and updating process of streaming content by employing an adaptive node identification strategy based on the differences in node types. For preset static streaming type nodes, their position index in the ordered content fragment set is used as the node identifier, ensuring the structural stability and sequential consistency of static streaming content during sequential rendering and incremental appending, effectively reducing node misalignment or duplicate rendering problems caused by segmented transmission of streaming data. For preset dynamic update type nodes, the service data identifier they contain is used as the node identifier, establishing a unique mapping relationship between the node and the underlying service data, ensuring accurate location of the target node for local updates when data changes or is refreshed. This differentiated node identification mechanism effectively reduces component state loss or rendering anomalies, significantly enhancing robustness and smoothness of interaction when handling mixed-type streaming data.
[0140] In this embodiment, the client uses a rendering entry component (MessageBubble) to achieve unified parsing and distribution of complex message structures. Specifically, this rendering entry component is configured to traverse an ordered set of content fragments and execute conditional branch dispatch logic based on the data type identifier carried by each message fragment. During the dispatch process, when the data type identifier is text (TEXT), a Markdown view component is triggered and rendered to support the parsing and display of rich text formats. When the data type identifier is CARD_DATA_END, a card component is lazy-loaded, enabling on-demand acquisition and rendering of rich media resources. When the data type identifier is tool description (TOOL_DES), a tool description slot component (ToolDescriptionSlot) is rendered to structurally present the tool parameters and status information called by the agent. When the data type identifier is error (ERROR), an error display slot component (ErrorSlot) is rendered to provide exception feedback and fallback placeholders. Through a dynamic routing mechanism based on data type identifiers, decoupled rendering of polymorphic content within a single message bubble is achieved, significantly improving the scalability and maintenance efficiency of the front-end interface.
[0141] To facilitate understanding of the user interface rendering process provided in the embodiments of this application, the following description is provided in conjunction with the accompanying drawings. Figure 3 A flowchart illustrating the user interface rendering process is shown. Figure 3 In this context, the client-side is divided into a network layer, a message layer, and a rendering layer. For example... Figure 3 As shown, the user enters a query in the client. The client sends the user request information to the agent server through the network layer. This user request information includes the query, the session identifier of the session connection between the client and the agent server, and the session identifier of the current dialogue between the user and the agent. The agent server returns response data for the user request information through a streaming interface. This response data includes streaming dialogue frames. After receiving the dialogue frames, the network layer unpacks the dialogue frames, deserializes the message content included in the dialogue frames, classifies the message content according to the data type identifier corresponding to the message content, converts the message content of each data type identifier into normalized events, and transmits them to the message layer.
[0142] The message layer updates the ordered content fragment set based on the normalized events corresponding to each data identifier. The message fragments in the ordered content fragment set are arranged according to the output order on the agent's server side. The rendering layer dispatches rendering based on the data type identifiers of the message fragments to be rendered in the ordered content fragment set. For text types, a Markdown view component is used for rendering. For CARD_DATA_END types, a card component is lazy-loaded based on the card type. For TOOL_DES types, a tool description slot component is used for rendering. For ERROR types, an error display slot component is used for rendering.
[0143] As an example, Figure 4 The diagram illustrates the rendering process of a text-type message fragment, such as... Figure 4 As shown, the client-side can be divided into a parsing layer, a type adaptation layer, and a rendering layer. The parsing layer inputs Markdown text into the lexical analyzer `marked.lexer()` and outputs an abstract syntax tree (AST). The type adaptation layer, based on a preset component mapping configuration, converts the syntax nodes on the AST into component nodes supported by the renderer, obtaining the target component tree. For each component node in the target component tree, it checks the preset component injection mapping table to see if a pre-injected custom component exists. If so, the custom component is used for rendering; otherwise, the preset default base component is used.
[0144] The following is a specific example of the user interface rendering method of this application embodiment, using a specific application scenario as an example. In this example, the user interacts with the intelligent agent server through a client. The user enters "Order me a milk tea" on the client's dialog page, and the intelligent agent server sends the following frame sequence through a streaming interface: Frame 1: CARD_DATA_END (cardType=ADDRESS_LIST), contains the user's historical shipping address list data; Frames 2-16: Text (text-by-text push: "Okay, where would you like it delivered? Please select a shipping address first"); Frame 17: TEXT (Tracking ID).
[0145] The client's message layer processes messages according to the rules. For frame 1, a CARD_DATA_END segment is created in the message fragment array. For frame 2, assuming the end of the message fragment array is not a TEXT segment, a new TEXT segment is created at the end. For frames 3-17, text is continuously appended to the TEXT segment. The final message fragment array is [CARD_DATA_END, TEXT].
[0146] After the client's rendering layer dispatches the rendering, the address selection card is first displayed on the dialog page, and the text reply appears word by word below, thus completely preserving the timing and interaction logic of each frame output by the agent server.
[0147] In the embodiments of this application, different types of message fragments are uniformly stored in the same ordered content fragment set, strictly arranged according to the output sequence of the agent server. Each type has independent update semantics, and all update operations can be fully expressed through the ordered content fragment set. This design preserves the temporal relationship between different types of content while supporting independent update logic for each type, solving the problem that traditional message models cannot express interleaved content. Based on this scheme, a single message can contain any number and any order of multiple types of content fragments, and the output sequence of the agent server can be faithfully reproduced during rendering, resulting in a smooth and natural user experience.
[0148] This solution generates an abstract syntax tree based on an ordered set of content fragments. Through a preset component mapping configuration, the syntax nodes in the abstract syntax tree are mapped to basic component tags and style attributes that are compatible with the renderer. It can be executed in any renderer, thus decoupling the parser from the renderer. It enables unified Markdown rendering across four platforms: Weex, H5 (Hypertext Markup Language 5), WeChat Mini Programs, and NPM (Node Package Manager). It covers common subsets of basic component tags such as headings, paragraphs, ordered / unordered lists, quotation blocks, code blocks, bold, italics, inline code, and hyperlinks, as well as the GFM (GitHub Flavored Markdown) list.
[0149] This solution directly constructs a React component tree based on an abstract syntax tree. It also provides a custom component injection mechanism, allowing service providers to inject custom components by node type. Injected custom components can receive pre-rendered child node content without needing to understand the underlying lexical structure. The rendering result is a standard React component tree, which can be easily integrated with the React ecosystem. Service providers can implement customized services such as hyperlink click handling and custom styles through component injection without modifying the container code.
[0150] This solution employs a two-layer memory strategy, refining rendering granularity to the content block level. The outer memory strategy intercepts cases where data reference identifiers remain unchanged, while the inner memory strategy checks the original string for equality for each content block. In scenarios with high-frequency appending of text frames, only the last content block being appended needs to be re-parsed and rendered, while all previously stable content blocks are fully cached. Rendering overhead is proportional to the size of the currently changing content block, not the length of the entire message, ensuring performance does not degrade as the conversation lengthens. In actual testing, even with messages accumulating to hundreds of characters, each frame rendering remains smooth.
[0151] The ordered content fragment set naturally preserves the generation sequence of all content types. In some embodiments, the rendering entry component can directly traverse the message fragments in the ordered content fragment set in order, without additional sorting or merging operations. Combined with rendering dispatch based on data type identifiers and differentiated node identifier determination strategies, time-series preservation with zero additional computational overhead is achieved. The order of content seen by the user is consistent with the actual output order of the agent server, resulting in a natural and smooth dialogue experience. Simultaneously, the CARD_DATA_END card identifier ensures that React reuses existing subtrees in upsert scenarios, avoiding unnecessary unloading and remounting of card components.
[0152] Corresponding to the methods provided in the foregoing embodiments, this application also provides a user interface rendering method based on intelligent agents, applied to an intelligent agent server. The embodiments of this application only describe the differences from the foregoing embodiments; all similarities can be found in the descriptions of the foregoing embodiments. See also... Figure 5 The diagram illustrates a user interface rendering method based on an intelligent agent, which specifically includes the following steps: Step 201: The agent server receives the user request sent by the client.
[0153] Step 202: The intelligent agent server generates the current dialogue frame based on the user request. The current dialogue frame includes a timing identifier, message content, and the data type identifier corresponding to the message content.
[0154] Step 203: The agent server sends the current dialogue frame to the client, so that the client updates the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs based on the current dialogue frame, and renders the current dialogue interface based on the updated ordered content fragment set; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the timing identifiers included in each dialogue frame in the data stream.
[0155] The client sends the user request to the agent server. Based on the user request, the agent server calls the agent service and / or the large language model to perform inference, generates a response message corresponding to the user request, encapsulates the response message into a dialogue frame containing a timing identifier, a data type identifier, and the message content, and sends the dialogue frame to the client, which then renders it in the dialogue interface.
[0156] Specifically, the agent server generates the current dialogue frame based on the user request in the following ways: based on the user request, it calls the agent to perform inference and generates a response message corresponding to the user request; it assigns a corresponding timing identifier to the response message, which is used to identify the generation order of the current dialogue frame in the data stream; and it encapsulates the message content, timing identifier, and data type identifier of the message content of the response message into the current dialogue frame.
[0157] The agent performs inference based on user requests and generates corresponding response messages. The content of the response message can be text, Markdown code, or image links, etc. A data type identifier corresponding to the message content describes the media type of the message content. The media type of the message content can include, but is not limited to, text, images, Markdown, JSON cards, etc.
[0158] The data stream corresponding to a user request is a collection of dialogue frames continuously sent by the agent server in response to the same user request. The agent server assigns a timing identifier to the response content within this data stream based on the order in which the response content is generated. Then, it encapsulates the message content, timing identifier, and data type identifier of the response message into the current dialogue frame.
[0159] In the embodiments of this application, the intelligent agent server sets a timing identifier for the current dialogue frame based on the generation order of the answer content corresponding to the user request in the data stream to which the user request belongs, and sends the current dialogue frame carrying the timing identifier to the client. This allows the client to construct an ordered set of content fragments based on the timing identifiers of each dialogue frame, enabling the message content to be reassembled strictly according to the generation order of the dialogue frames. The ordered set of content fragments satisfies the state management requirements of multiple types of interleaved messages, preserving timing information while supporting differentiated update logic. This ensures that message content with various data type identifiers can be accurately rendered into the dialogue interface according to the expected logical order, reducing interface content jumps or logical breaks, and significantly improving the coherence rendering of long texts or multimodal content. Real-time updates of the ordered set of content fragments based on the current dialogue frame trigger rendering, allowing for immediate feedback without waiting for the entire answer to be generated, thus achieving streaming rendering.
[0160] Corresponding to the methods provided in the foregoing embodiments, this application also provides an agent-based user interface rendering apparatus, applied to a client, see [link to relevant documentation]. Figure 6 The device includes: The first receiving module 301 is used to receive the current dialogue frame sent by the intelligent agent server. The current dialogue frame includes a timing identifier, message content, and a data type identifier corresponding to the message content. The update module 302 is used to update the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs based on the current dialogue frame; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the timing identifiers included in each dialogue frame in the data stream. Rendering module 303 is used to render the current dialog interface based on the updated set of ordered content fragments.
[0161] The specific implementation details of each module of the device can be found in the specific operation details of the client in the method embodiment above, and will not be repeated here.
[0162] The agent-based user interface rendering apparatus and the agent-based user interface rendering method provided in the above embodiments of this application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.
[0163] Corresponding to the methods provided in the foregoing embodiments, this application also provides a user interface rendering device based on an intelligent agent, applied to an intelligent agent server. See [link to relevant documentation]. Figure 7 The device includes: The second receiving module 401 is used to receive user requests sent by the client; The generation module 402 is used to generate the current dialogue frame based on the user request. The current dialogue frame includes a timing identifier, message content, and a data type identifier corresponding to the message content. The sending module 403 is used to send the current dialogue frame to the client so that the client updates the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs based on the current dialogue frame, and renders the current dialogue interface based on the updated ordered content fragment set; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the timing identifiers included in each dialogue frame in the data stream.
[0164] The specific implementation details of each module of the device can be found in the specific operation details of the server in the method embodiment above, and will not be repeated here.
[0165] The agent-based user interface rendering apparatus and the agent-based user interface rendering method provided in the above embodiments of this application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.
[0166] Figure 8 This is a block diagram of an electronic device used to implement embodiments of this application. Figure 8 As shown, the electronic device includes a memory 601 and a processor 602. The memory 601 stores a computer program that can run on the processor 602. When the processor 602 executes the computer program, it implements the method described in the above embodiments. The number of memories 601 and processors 602 can be one or more. In a specific implementation, the electronic device may also include a communication interface 603 for communicating with external devices and exchanging data.
[0167] In practical implementation, if the memory 601, processor 602, and communication interface 603 are implemented independently, they can be interconnected via a bus to communicate with each other. This bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0168] Optionally, in a specific implementation, if the memory 601, processor 602 and communication interface 603 are integrated on a single chip, the memory 601, processor 602 and communication interface 603 can communicate with each other through an internal interface.
[0169] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method provided in this application.
[0170] This application provides a computer program product, including a computer program that, when executed by a processor, implements the method provided in this application.
[0171] This application also provides a chip, which includes a processor for calling and executing instructions stored in a memory, causing a communication device equipped with the chip to perform the method provided in this application.
[0172] This application also provides a chip, including: an input interface, an output interface, a processor, and a memory. The input interface, output interface, processor, and memory are connected through an internal connection path. The processor is used to execute code in the memory. When the code is executed, the processor is used to execute the method provided in this application.
[0173] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting Advanced Reduced Instruction Set Machines (ARM) architecture.
[0174] Further, optionally, the aforementioned memory may include read-only memory and random access memory. The memory may be volatile memory or non-volatile memory, or may include both. Non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available. Examples include Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Sync Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
[0175] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.
[0176] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of those different embodiments or examples.
[0177] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.
[0178] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process. Furthermore, the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functionality involved.
[0179] The logic and / or steps described in the flowchart or otherwise herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution client, apparatus, or device (such as a computer-based client, a processor-included client, or other client that can fetch and execute instructions from the instruction execution client, apparatus, or device), or in conjunction with such instruction execution client, apparatus, or device.
[0180] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution client. All or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware, the program being stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiments.
[0181] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. This storage medium can be a read-only memory, a disk, or an optical disk, etc.
[0182] The above are merely exemplary embodiments of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various variations or substitutions within the technical scope described in this application, and these should all be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.< / em> < / strong> < / pre> < / code> < / blockquote> < / code> 、 < / h6>
Claims
1. A user interface rendering method based on intelligent agents, characterized in that, include: Receive the current dialogue frame sent by the intelligent agent server, wherein the current dialogue frame includes a timing identifier, message content, and a data type identifier corresponding to the message content; Based on the current dialogue frame, update the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the time sequence identifier included in each dialogue frame in the data stream. The current dialog interface is rendered based on the updated set of ordered content fragments.
2. The method according to claim 1, characterized in that, include: Based on the current dialogue frame, update the ordered set of content segments corresponding to the data stream to which the current dialogue frame belongs, including: The current dialogue frame is parsed to obtain the timing identifier, message content, and data type identifier included in the current dialogue frame; Based on the time sequence identifier and the data type identifier, determine the target storage location corresponding to the message content of the current dialogue frame in the ordered content fragment set; Update the message content of the current dialogue frame to the target storage location in the ordered set of content fragments.
3. The method according to claim 2, characterized in that, Determining the target storage location corresponding to the message content of the current dialogue frame in the ordered content fragment set based on the time sequence identifier and the data type identifier includes: When the data type identifier indicates that the message content of the current dialogue frame belongs to a service data type, based on the data type identifier, a target historical message fragment that matches the message content of the current dialogue frame is searched in the ordered content fragment set to obtain a search result; based on the time sequence identifier and the search result, the target storage location corresponding to the message content of the current dialogue frame is determined. When the data type identifier indicates that the message content of the current dialogue frame belongs to a non-service data type, the target storage location of the message content of the current dialogue frame in the ordered content fragment set is determined based on the timing identifier of the current dialogue frame and the timing identifiers of each message fragment already stored in the ordered content fragment set.
4. The method according to claim 3, characterized in that, The step of searching for a target historical message fragment that matches the message content of the current dialogue frame in the ordered set of content fragments based on the data type identifier includes: Based on the data type identifier indicating that the message content of the current dialogue frame is text type, and based on the timing identifier, the reference insertion position of the message content of the current dialogue frame in the ordered content fragment set is determined; in response to the existence of a preceding message fragment adjacent to the reference insertion position in the ordered content fragment set, it is determined whether the data type of the preceding message fragment is text type. If the data type of the preceding message fragment is text, then the preceding message fragment is determined as the target historical message fragment; If the preceding message fragment does not exist, or if the data type of the preceding message fragment is not text, then it is determined that the target historical message fragment was not found.
5. The method according to claim 3, characterized in that, The step of searching for a target historical message fragment that matches the message content of the current dialogue frame in the ordered set of content fragments based on the data type identifier includes: Based on the data type identifier indicating that the message content of the current dialogue frame is rich media type, the component identifier is obtained from the message content of the current dialogue frame; Determine whether the ordered set of content fragments contains a historical message fragment corresponding to the component identifier; If a historical message segment corresponding to the component identifier exists, then the historical message segment corresponding to the component identifier is determined as the target historical message segment; If no historical message segment corresponding to the component identifier exists, it is determined that the target historical message segment has not been found.
6. The method according to claim 3, characterized in that, Determining the target storage location corresponding to the message content of the current dialogue frame based on the time sequence identifier and the search result includes: Based on the search result indicating that the target historical message fragment has been found, the position of the target historical message fragment in the ordered content fragment set is determined as the target storage location; Based on the search result indicating that the target historical message segment was not found, and based on the time sequence identifier and the time sequence identifiers of each message segment already stored in the ordered content segment set, the reference insertion position of the message content of the current dialogue frame in the ordered content segment set is determined; and the reference insertion position is determined as the target storage position.
7. The method according to claim 3, characterized in that, The step of updating the message content of the current dialogue frame to the target storage location in the ordered content fragment set includes: In response to the absence of a stored message fragment at the target storage location in the ordered set of content fragments, an empty message fragment is created at the target storage location, and the message content of the current dialogue frame is written into the empty message fragment; In response to the existence of the target historical message fragment at the target storage location, the message content of the current dialogue frame is added to the target historical message fragment based on the data type identifier and the target historical message fragment.
8. The method according to claim 7, characterized in that, The step of adding the message content of the current dialogue frame to the target historical message segment based on the data type identifier and the target historical message segment includes: In response to the data type identifier indicating that the message content of the current dialogue frame is text type, the message content of the current dialogue frame is added to the end of the text information included in the target historical message segment; In response to the data type identifier indicating that the message content of the current dialogue frame is of rich media type, the component field information included in the target historical message segment is obtained, and the component field information is updated using the message content of the current dialogue frame.
9. The method according to any one of claims 1-8, characterized in that, The rendering of the current dialogue interface based on the updated set of ordered content fragments includes: Based on the updated set of ordered content fragments, an abstract syntax tree is generated; Based on the preset component mapping configuration, each syntax node of the abstract syntax tree is mapped to a component node supported by the current dialog interface to obtain the target component tree; Based on the target component tree, incremental rendering is performed on the current dialog interface.
10. A user interface rendering method based on intelligent agents, characterized in that, include: Receive user requests sent by the client; Based on the user request, a current dialogue frame is generated, which includes a timing identifier, message content, and a data type identifier corresponding to the message content. The current dialogue frame is sent to the client so that the client updates the ordered content fragment set corresponding to the data stream to which the current dialogue frame belongs based on the current dialogue frame, and renders the current dialogue interface based on the updated ordered content fragment set; the ordered content fragment set is used to store the message content of each dialogue frame in the order indicated by the timing identifier included in each dialogue frame in the data stream.
