Streaming data display method and related device

By using citation markers to define the boundaries of cited content in streaming data and displaying it after the truncation point, the problem of truncated cited content is solved, improving the integrity of streaming data display and user experience.

CN121880401APending Publication Date: 2026-04-17CHINA ECONOMIC INFORMATION SERVICE
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA ECONOMIC INFORMATION SERVICE
Filing Date
2026-01-06
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

During the display of streaming data, referenced content can easily be truncated, leading to display errors or unclickable content, affecting data integrity and user experience.

Method used

By acquiring and progressively displaying the target streaming data, the boundaries of the referenced content are determined using start and end reference markers, and the data is only displayed after the truncation point is located after the end reference marker, ensuring that the referenced content is presented only after it has arrived completely.

Benefits of technology

It reduces the probability of display errors or interaction failures caused by truncated referenced content, and improves the stability of streaming data display and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121880401A_ABST
    Figure CN121880401A_ABST
Patent Text Reader

Abstract

The invention discloses a streaming data display method and a related device, and the method comprises the steps: obtaining and gradually displaying currently accumulated target streaming data, and the target streaming data comprises a plurality of data blocks; reference content in the target streaming data is determined, and the starting position and the ending position of the reference content are determined through the starting reference mark and the ending reference mark respectively. And determining a truncation position of the target streaming data. And if the target streaming data comprises an initial reference mark of the target reference content and the truncation position is located between the initial reference mark in the target reference content and an end reference mark of the target reference content, displaying a data block in front of the initial reference mark. Therefore, the boundary of the reference content is determined through the reference mark, and the reference content is displayed only after the reference mark is ended at the cut-off position, so that the reference content is integrally presented only after the reference content completely arrives, and the probability of display abnormity or interaction failure caused by cut-off of the reference mark is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a streaming data display method and related apparatus. Background Technology

[0002] Streaming data is not generated and transmitted all at once, but is generated, transmitted and processed continuously over time. The receiving end can display the streaming data before all the data has arrived.

[0003] In related technologies, multiple data blocks in streaming data are typically displayed directly.

[0004] However, some data blocks are referenced content, which may be truncated during the display of the referenced content, resulting in display errors or inability to click, leading to low data integrity. Summary of the Invention

[0005] To address the aforementioned issues, this application provides a streaming data display method and related apparatus to reduce the probability of truncated content and improve data display integrity.

[0006] Based on this, the following technical solution is disclosed in this application:

[0007] In a first aspect, embodiments of this application provide a streaming data display method, the method comprising:

[0008] Acquire and progressively display the currently accumulated target streaming data, which includes multiple data blocks;

[0009] The referenced content in the target streaming data is determined, and the start and end positions of the referenced content are determined by a start reference marker and an end reference marker, respectively.

[0010] Determine the truncation point of the target streaming data;

[0011] If the target streaming data includes a start reference marker for the target reference content, and the truncation position is located between the start reference marker and the end reference marker in the target reference content, then the data block before the start reference marker is displayed.

[0012] Secondly, embodiments of this application provide a streaming data display device, the device comprising:

[0013] An acquisition unit is used to acquire and gradually display the currently accumulated target streaming data, which includes multiple data blocks;

[0014] A determining unit is used to determine the referenced content in the target streaming data, wherein the referenced content has its start and end positions determined by a start reference marker and an end reference marker, respectively.

[0015] The determining unit is further configured to determine the truncation position of the target streaming data;

[0016] The display unit is configured to display the data block before the starting reference mark if the target streaming data includes a start reference mark of the target reference content, and the truncation position is located between the start reference mark and the end reference mark of the target reference content.

[0017] Thirdly, embodiments of this application provide a computer device, the computer device including a processor and a memory:

[0018] The memory is used to store computer programs and to transfer the computer programs to the processor;

[0019] The processor is configured to execute the method described in the first aspect above according to the computer program.

[0020] Fourthly, embodiments of this application provide a computer-readable storage medium for storing a computer program for performing the method described in the first aspect above.

[0021] Fifthly, embodiments of this application provide a computer program product including a computer program, which, when run on a computer device, causes the computer device to perform the method described in the first aspect above.

[0022] As can be seen from the above technical solutions, this application has at least the following beneficial effects:

[0023] The system acquires and progressively displays the currently accumulated target streaming data, which includes multiple data blocks. It identifies referenced content within the target streaming data, with the start and end positions determined by start and end reference markers, respectively. It then determines the truncation point of the target streaming data. If the target streaming data includes a start reference marker for the target referenced content, and the truncation point lies between the start and end reference markers within the target referenced content, the data block before the start reference marker is displayed. This approach, by defining the boundaries of the referenced content through reference markers and displaying it only after the end reference marker at the truncation point, ensures that the referenced content is presented in its entirety only after it has fully arrived. This reduces the probability of display anomalies or interactive failures caused by truncation of reference markers, thereby improving the integrity and usability of the referenced content during streaming data display and enhancing the overall stability and user experience of the data display. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 A flowchart illustrating a streaming data display method provided in an embodiment of this application;

[0026] Figure 2 A system architecture diagram for streaming data display provided in this application embodiment;

[0027] Figure 3 This is a schematic diagram of the structure of a streaming data display device provided in an embodiment of this application;

[0028] Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application.

[0029] Specific implementation method

[0030] Embodiments of this application will now be described in more detail with reference to the accompanying drawings. While some embodiments of this application are shown in the drawings, it should be understood that this application can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this application. It should be understood that the drawings and embodiments of this application are for illustrative purposes only and are not intended to limit the scope of protection of this application.

[0031] In related technologies, the display of streaming data typically involves appending and displaying multiple received data blocks in chronological order. For example, in a streaming-based intelligent question-answering system, the server breaks down the generated answer into multiple data blocks and sends them sequentially. Upon receiving each data block, the client immediately appends it to the existing display content to create a continuous output effect.

[0032] However, in practical applications, some data blocks in streaming data may include referenced content, such as structured information like tags, numbers, or clickable links used to identify the source of the reference. Because the boundaries of data blocks and the logical boundaries of the referenced content are not consistent during streaming, the referenced content is often split into multiple adjacent data blocks. When the receiving end displays the referenced content before it has fully arrived, it is easy to see only a portion of the referenced content being displayed.

[0033] For example, if only the start marker of the referenced content is received at a certain moment, but the corresponding end marker has not yet been received, directly displaying the data block on the interface may result in incomplete display of the reference markers, abnormal formatting, or even issues such as being unclickable or unable to be parsed correctly. These situations not only affect the correct display of the referenced content itself but may also disrupt the overall display structure of the referenced content, thereby reducing the integrity of the data display and the user experience.

[0034] Based on this, embodiments of this application provide a streaming data display method and related apparatus. By defining the boundaries of the referenced content through reference markers, and displaying the content only at the truncation position after the end of the reference marker, the referenced content is presented as a whole only after it has been fully arrived. This reduces the probability of display abnormalities or interaction failures caused by the truncation of reference markers, thereby improving the integrity and usability of the referenced content during the streaming data display process, and enhancing the stability of the overall data display and user experience.

[0035] The streaming data display method provided in this application can be applied to computer devices with data display capabilities, such as terminal devices and servers. Specifically, terminal devices can be desktop computers, laptops, mobile phones, and tablets; servers can be independent physical servers, server clusters composed of multiple physical servers, or distributed systems. Terminal devices and servers can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions on this connection.

[0036] All data collected in this application (such as streaming data) is collected with the consent and authorization of the data subject (such as user, organization or enterprise), and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0037] See Figure 1 This figure is a schematic flowchart of the streaming data display method provided in an embodiment of this application. For ease of description, the following embodiments use a computer device as an example to illustrate the execution of this streaming data display method. Figure 1 As shown, the streaming data display method includes S101-S104.

[0038] S101: Retrieve and progressively display the currently accumulated target streaming data.

[0039] Streaming data is a form of data that is continuously generated by the sender and transmitted sequentially over time. At any given moment, some data blocks of streaming data may arrive at the receiver.

[0040] Target streaming data is a type of streaming data that is continuously updated and accumulated as data continues to arrive. The currently accumulated target streaming data is a phased data formed by aggregating the received target streaming data in the order of receipt. Target streaming data consists of multiple data blocks, and the data block is the basic unit for the transmission of streaming data.

[0041] Computer equipment can receive multiple data blocks arriving consecutively and accumulate them according to their arrival order to form the current target streaming data. Even before the target streaming data is fully received, the computer equipment can progressively display the data based on the currently accumulated target streaming data, allowing the displayed result to gradually expand as more data blocks arrive.

[0042] In order to achieve a progressive output effect during the streaming data display process, while taking into account rendering stability and performance control, this application provides a typewriter rendering engine for progressively displaying target streaming data.

[0043] In one possible implementation, the typewriter rendering engine includes at least the following state variables:

[0044] Content cache variable: Used to cache the target streaming data that has been received so far. The content cache variable is updated in real time as new data blocks arrive.

[0045] Display position index variable: Used to indicate the position of the currently displayed content in the content cache, in order to control the progress of gradual display.

[0046] Rendering status flag variable: Used to indicate whether the current rendering state is typewriter rendering, in order to control the start and termination of the rendering process.

[0047] Through the collaborative maintenance of the aforementioned state variables, the typewriter rendering engine can accurately perceive the current content status, display progress, and rendering running status.

[0048] In one possible implementation, the typewriter rendering engine performs a step-by-step display process in a loop, specifically including the following steps:

[0049] At the start of the rendering loop, a pre-state check is performed first. If it is detected that the current rendering loop is not in the typewriter rendering state or the step-by-step display parameters are not configured, the current rendering loop is terminated to avoid invalid calculations.

[0050] After passing the preliminary state check, it is determined whether the current content cache already contains displayable data blocks. When the content cache is empty, the rendering engine is controlled to enter a waiting state, and the rendering check is triggered again after a preset time interval to continuously wait for new streaming data to arrive.

[0051] When content to be displayed exists in the content cache, the display position index is updated. While retaining the previous display position, the display position is advanced forward by a preset step. After the index is updated, a content update event is triggered to notify the display module to refresh the interface.

[0052] In a question-and-answer system, if the dialogue is multi-turn, the target content to be displayed in the current turn is calculated based on the current display position index and the content cache length. The content cache is then truncated to generate the display content for the current turn. The truncation process is used to improve the structural integrity of the displayed content.

[0053] In one possible implementation, the typewriter rendering engine also includes a stuttering detection mechanism to avoid display progress stalling due to structured content or truncation rules.

[0054] Specifically, in each rendering round, the current display position index is compared with the previous index, and a judgment is made based on the length of the currently displayed content and the target content length. When it is detected that the display position index has not changed and the displayed content has not yet reached the target content length, the stutter count is accumulated. When it is detected that the display progress has resumed, the stutter count is reset.

[0055] When the stutter count reaches a preset threshold, the current rendering process is determined to be in an abnormal standstill state. The rendering engine is then controlled to directly complete the display of the remaining content to prevent the interface from remaining in an unupdated state for an extended period of time.

[0056] In one possible implementation, the typewriter rendering engine determines the rendering completion time through a combination of multiple conditions, specifically including at least one of the following:

[0057] Rendering is considered complete when the display position index has reached or exceeded the total length of the target content, and the target content is marked as having been fully received.

[0058] Rendering is considered complete when the length of the currently displayed content reaches or exceeds the total length of the target content, and the target content is marked as having been fully received.

[0059] When lag is detected in multiple consecutive rendering runs and the preset number of runs is reached, the rendering is considered complete.

[0060] When any of the above conditions are met, the rendering engine is controlled to perform rendering end processing and exit the rendering loop.

[0061] In one possible implementation, the typewriter rendering engine selects different scheduling methods based on preset time interval parameters.

[0062] When the time interval is less than or equal to a preset interval threshold, a frame scheduling mechanism synchronized with the interface redraw cycle is used to perform rendering updates to reduce invalid rendering operations. When the time interval is greater than the preset interval threshold, a timed trigger method is used to execute the next round of rendering to ensure the stability of the display rhythm and maintain the smoothness of the rendering process even in high-frequency update scenarios.

[0063] In one possible implementation, the typewriter rendering engine also includes a variety of performance optimization mechanisms.

[0064] In terms of content processing, processed display content is cached, and the cached results are only updated when the target content changes, reducing the overhead of repeated parsing. Content hash values ​​are maintained to determine whether the content has undergone substantial changes. Matching results for structured content are cached to avoid repeatedly performing matching operations in multiple rendering rounds.

[0065] In terms of state management, for large-scale text data, a lightweight reference method is used to store the content state, so as to reduce the overhead of the reactive system in monitoring large text variables, thereby reducing the overall memory and computing burden.

[0066] S102: Determine the referenced content in the target streaming data.

[0067] Referenced content refers to structured content within the target streaming data used to indicate other information. For example, referenced content typically carries identification information for location or interaction. The starting and ending positions of referenced content are determined by start and end reference markers, respectively. The start reference marker is an identifier indicating the beginning of the referenced content, indicating that subsequent content belongs to the same referenced content. The end reference marker is an identifier indicating the end of the referenced content, indicating its conclusion. Together, the start and end reference markers define the scope of a complete piece of referenced content within the target streaming data.

[0068] The cited content can be a portion of the cited content or its complete form. The cited content may include citation markers (such as start citation markers and end citation markers), but this application does not limit this.

[0069] In one possible implementation, when only a start reference marker is detected but no end reference marker is detected, the referenced content can be identified as incomplete reference content, and the corresponding starting position can be recorded. When both start and end reference markers are detected simultaneously, the executing entity determines the content between them as a complete reference. For example, the referenced content can be matched using regular expressions.

[0070] S103: Determine the truncation point of the target streaming data.

[0071] The truncation position is the boundary position used to limit the current display range when the target streaming data is displayed step by step. It can represent the very end position in the current display.

[0072] The truncation point of the target streaming data can be determined in a variety of ways.

[0073] For example, in response to a user-triggered stop generation operation, the trigger time corresponding to the stop generation operation is obtained, and based on the correspondence between the trigger time and the generation or reception time axis of the target streaming data, the target streaming data that has been accumulated before the trigger time is determined, thereby determining the corresponding end position as the truncation position of the target streaming data.

[0074] For example, during the gradual display of target streaming data, for each display cycle, based on the current display progress or a preset display step size, a candidate display position corresponding to the current cycle is calculated, and this candidate display position is determined as the truncation position of the target streaming data. The truncation position can gradually move forward as the gradual display process progresses.

[0075] S104: If the target streaming data includes the start reference marker of the target reference content, and the truncation position is located between the start reference marker and the end reference marker of the target reference content, then the data block before the start reference marker is displayed.

[0076] The target reference content is a reference content determined by the target streaming data. After identifying the target reference content in the target streaming data and determining the truncation position of the target streaming data, the relative positional relationship between the truncation position and the target reference content is further determined. When it is detected that the target streaming data already includes a start reference marker of the target reference content, but the currently determined truncation position is still located between the start reference marker and the corresponding end reference marker, it indicates that the target reference content may not have arrived completely. In this case, the target reference content is not displayed; instead, only the data block before the start reference marker is displayed, thus avoiding presenting incomplete reference content in the display interface.

[0077] As mentioned above, the truncation position can be actively determined or passively determined based on external operations. By executing S104, it is possible to restrict the complete referenced content whether the target streaming data is being displayed gradually or the display is being interrupted.

[0078] As can be seen from the above technical solution, the currently accumulated target streaming data is acquired and displayed step by step. The target streaming data includes multiple data blocks. The referenced content in the target streaming data is determined, with its start and end positions defined by start and end reference markers, respectively. The truncation position of the target streaming data is determined. If the target streaming data includes a start reference marker for the target referenced content, and the truncation position is located between the start and end reference markers within the target referenced content, then the data block before the start reference marker is displayed. Thus, by defining the boundaries of the referenced content through reference markers and only displaying it after the end reference marker at the truncation position, the referenced content is presented as a whole only after it has fully arrived. This reduces the probability of display anomalies or interactive failures caused by truncation of reference markers, thereby improving the integrity and usability of the referenced content during streaming data display, and enhancing the overall stability of data display and user experience.

[0079] In one possible implementation, if the target streaming data includes target reference content and the truncation position is after the end reference marker in the target reference content, then the target reference content and the data block preceding the target reference content are displayed.

[0080] In other words, if the target reference content is not fully received, i.e., the truncation point is between the start reference marker and the end reference marker, the target reference content can be temporarily not displayed. It can be displayed after the complete target reference content is received, such as when the end reference marker is detected.

[0081] Therefore, when the target reference content has been fully arrived and the truncation position is after the end reference mark corresponding to the target reference content, the reference content can be presented in a complete and continuous form by displaying the target reference content and the data blocks before it together in the current round. This avoids unnecessary delays in displaying the completed reference content and ensures that the reference content can be displayed in a timely manner and participate in subsequent interactions after the integrity condition is met.

[0082] In one possible approach, the target streaming data can be matched using reference content matching rules. If the target streaming data includes data blocks that match the reference content matching rules, the corresponding matching results are stored. If the target streaming data has not been updated, the reference content in the target streaming data is determined based on the stored matching results. If the target streaming data has been updated, the steps of matching the target streaming data using reference content matching rules and subsequent steps are re-executed.

[0083] The reference content matching rule is a data determination rule used to identify referenced content in the target streaming data. For example, it can be used to describe constraints on the referenced content in terms of data structure, tagging format, or syntactic features. The matching result is the referenced content identified in the target streaming data based on the reference content matching rule.

[0084] One implementation approach is to scan and match the currently accumulated target streaming data based on reference content matching rules. When a data block matching the reference content rules exists in the target streaming data, the corresponding matching result is stored. If the target streaming data remains unchanged within the current processing cycle, the reference content is directly determined based on the stored matching results, thus avoiding repeated matching operations on the same content. When an update to the target streaming data is detected, the matching process based on the reference content matching rules is re-executed on the updated target streaming data, and subsequent steps are executed after obtaining the new matching result.

[0085] Therefore, by reusing the stored matching results when the target streaming data has not been updated, and triggering the rematching process when the target streaming data has been updated, the computational overhead caused by repeated matching can be reduced while ensuring the accuracy of recognition, thereby improving the efficiency of recognizing and processing referenced content during the streaming data display process.

[0086] The above method embodiment is illustrated below by a program flow example, where text is the currently accumulated target streaming data (which may include multiple reference markers). maxLength is the character index position that the typewriter should currently display.

[0087] Step 1: Reference tag caching and matching

[0088] 1. If the text is different from the previously cached text:

[0089] a. Using regular expressions / <sup[^> ]*>[^<]*<\ / sup> / g matches all 标签

[0090] b. 将匹配结果数组存入supMatchesCache

[0091] c. 更新lastTextForMatches = text

[0092] 2. 否则:

[0093] a. 直接使用缓存的supMatchesCache,避免重复正则匹配

[0094] 第二步:检测截断位置是否在引用标记之间

[0095] 对于supMatchesCache中的每个match:

[0096] 1. 获取match的起始位置matchStart = match.index

[0097] 2. 计算match的结束位置matchEnd = matchStart + match[0].length

[0098] 3. 判断:

[0099] 若 maxLength > matchStart 且 maxLength < matchEnd:

[0100] 返回 text.slice(0, matchStart)

[0101] / / 策略:截断到引用开始前,等待下次迭代显示完整引用

[0102] 第三步:通用HTML标签保护

[0103] 1. 执行普通截断:truncated = text.slice(0, maxLength)

[0104] 2. 查找最后一个左尖括号位置:lastAngleBracket = truncated.lastIndexOf('<')

[0105] 3. 若lastAngleBracket不为-1:

[0106] a. 提取括号后的内容:afterBracket = truncated.slice(lastAngleBracket)

[0107] b. 检测是否为未闭合的HTML标签开始:

[0108] 若afterBracket匹配 / ^<[a-zA-Z] / 且不包含'>':

[0109] 返回truncated.slice(0, lastAngleBracket)

[0110] / / 防止显示不完整的任何HTML标签

[0111] 4. 返回truncated

[0112] 在一种可能的实现方式中,可以对引用内容进行格式转换,以使得用户可以对引用内容进行交互。

[0113] 在显示目标引用内容前,获取目标引用内容中携带的引用标识信息。基于引用标识信息确定用于显示的引用编号,并生成用于呈现目标引用内容的引用显示元素。在引用标识信息绑定至引用显示元素后,显示引用显示元素。

[0114] 其中,引用标识信息为引用内容中携带的、用于标识引用对象的标识信息,用于表征引用对应的数据来源、位置或索引关系。引用编号为基于引用标识信息确定的、用于在显示界面中直观呈现引用顺序或引用关系的编号信息。引用显示元素为用于在显示界面中呈现引用内容的可视化元素,可以用于承载引用编号并支持与引用标识信息相关联的交互操作。

[0115] 具体地,在对目标引用内容进行显示之前,可以从目标引用内容中获取其携带的引用标识信息。基于所获取的引用标识信息确定对应的引用编号,并生成与该引用编号相对应的引用显示元素。在生成引用显示元素后,将引用标识信息与所生成的引用显示元素进行绑定,使引用显示元素能够与对应的引用对象建立关联关系。在完成绑定处理后,将引用显示元素作为目标引用内容的显示形式进行呈现,从而使目标引用内容以结构化、可交互的方式显示在界面中。

[0116] 由此,通过对引用内容进行格式转换,并将引用标识信息绑定至引用显示元素,使引用内容能够以统一的引用编号形式进行展示,从而在保证引用内容完整显示的同时,实现对引用内容的交互支持,提升用户对引用内容进行定位、查看和使用的便利性,从而增强流式数据显示场景下引用内容的可用性与用户体验。

[0117] 在一种可能的实现方式中,可以使用以下正则表达式识别引用标记:

[0118] / <sup[^>]*(?:chunkid="([^"]+)")[^>]*>([^<]*)<\ / sup> / g

[0119] 正则表达式解析:

[0120] <sup[^>]*:匹配<sup标签开始及其任意属性(非贪婪匹配直到>)

[0121] (?:chunkid="([^"]+)"):非捕获组匹配chunkid属性,第一个捕获组([^"]+)提取chunkid的值

[0122] [^>]*>:匹配标签的其余属性和闭合的>

[0123] ([^<]*):第二个捕获组,提取标签内的文本内容(引用序号)

[0124] <\ / sup>:匹配闭合标签

[0125] 该正则表达式设计的关键点:

[0126] 使用[^>]*而非.*,避免跨标签匹配

[0127] 必须包含chunkid属性才被识别为有效引用

[0128] 支持属性顺序任意排列(chunkid可能在fileid之前或之后,chunkid和fileid为引用标识信息)

[0129] 在一种可能的实现方式中,格式转换流程可以如下所示:

[0130] 步骤1:Markdown解析

[0131] 使用markdown-it库将Markdown文本转换为HTML

[0132] 配置选项:html: true(允许内嵌HTML)、breaks: true(换行符转)

[0133] 步骤2:HTML中的标签替换使用正则表达式进行替换:

[0134] 正则模式: / <sup[^>]*(?:chunkid="([^"]+)")[^>]*>([^<]*)<\ / sup> / g

[0135] 匹配逻辑:

[0136] 1. <sup[^>]*:匹配<sup标签开始及任意属性

[0137] 2. (?:chunkid="([^"]+)"):非捕获组匹配chunkid属性,捕获其值到$1

[0138] 3. [^>]*>:匹配标签的其余属性和闭合>

[0139] 4. ([^<]*):捕获标签内的文本内容到$2

[0140] 5. <\ / sup>:匹配闭合标签

[0141] 替换逻辑:

[0142] 若捕获到chunkid($1不为空):

[0143] a. 分割chunkid:segments = $1.split('-')

[0144] b. 提取最后一段:lastSegment = segments[segments.length - 1]

[0145] c. 转换为数字并加1:display = Number(lastSegment) + 1

[0146] d. 若转换成功(!isNaN(display)):

[0147] 返回:display

[0148] 若未捕获到chunkid:

[0149] 检查是否有fileid属性:

[0150] 若有,从$2中提取数字作为display

[0151] 若无,保留原标签不变

[0152] 在一种可能的实现方式中,若目标流式数据不包括引用标记,或当截断位置大于或等于目标流式数据的当前长度时,直接显示目标流式数据包括的多个数据块。

[0153] 由此,在目标流式数据中不存在引用标记,或当前确定的截断位置大于或等于目标流式数据的当前长度时,通过直接显示目标流式数据中已累积的多个数据块,使流式数据显示过程无需额外执行引用相关的判断与处理,从而在保证显示结果正确性的前提下简化显示流程,降低不必要的处理开销。

[0154] 本申请实施例不具体限定数据块的数据类型,下面以数据块的数据类型包括思考类型和回答类型为例,对一种分类显示的方式进行说明。

[0155] 获取目标流式数据中各个数据块的数据类型,数据类型至少包括思考类型和回答类型。将数据类型为思考类型的数据块按照累积顺序存储在第一集合中。将数据类型为回答类型的数据块按照累积顺序存储在第二集合中。通过第一显示方式显示第一集合中的数据块,通过第二显示方式显示第二集合中的数据块,第一显示方式和第二显示方式为显示位置不同的显示方式。

[0156] 其中,第一集合用于存储思考类型的数据块,第二结合用于存储回答类型的数据块。

[0157] 在完成数据块的分类存储后,采用不同的显示方式对第一集合和第二集合中的数据块进行显示。其中,通过第一显示方式对第一集合中的数据块进行显示,通过第二显示方式对第二集合中的数据块进行显示,且第一显示方式与第二显示方式在显示位置上不同。

[0158] 例如,可以将思考类型的数据块显示在相对独立的显示区域中,而将回答类型的数据块显示在主要输出区域中,从而在界面布局上实现不同数据类型的数据块的区分。

[0159] 由此,能够在流式数据显示过程中,将不同数据类型的数据块进行分类处理并以不同显示位置进行呈现,使用户能够直观地区分思考过程与最终回答内容,在不影响流式逐步显示效果的前提下,提高数据显示的结构清晰度和整体可读性。

[0160] 在一种可能的实现方式中,当接收到的数据块的数据类型为思考类型时,可以判断是否存在正在处理的思考类型的数据块,若不存在则创建新的思考类型数据并记录对应的标识和内容,若已存在则将新的数据块追加至当前思考的数据块中,并将思考类型的数据块存储于用于显示思考类型的集合中。当接收到的数据块的数据类型为回答类型时,结束思考类型的数据块的处理,并将对应内容累积至显示回答类型的集合中,同时触发逐步显示处理。当接收到的数据块的数据类型为结束类型时,标识目标流式数据处理完成,结束思考类型的数据块的状态并停止逐步显示处理,同时对累积内容执行最终的格式化处理。当接收到的数据块的数据类型为知识类型时,对该数据块进行过滤而不进行显示处理。

[0161] 在一种可能的实现方式中,为提升流式数据显示过程中的渲染性能与界面稳定性,可以引入基于显示刷新周期的渲染优化机制。当逐步显示的时间间隔处于高频更新范围内时,结合界面重绘周期对显示更新进行调度,使内容更新与界面刷新过程保持同步,从而减少重复渲染带来的性能消耗,并避免无效的界面更新操作。

[0162] 在一种可能的实现方式中,还可以通过引入节流控制机制对与显示相关的滚动触发行为进行限制,在连续滚动或频繁更新场景下,通过控制相邻触发之间的最小时间间隔,使滚动事件在预设频率范围内触发,从而降低高频事件对渲染性能的影响,保证流式数据显示过程的平滑性和稳定性。

[0163] 在一种可能的实现方式中,为降低流式数据显示过程中对重复内容的处理开销,可以通过缓存策略对已处理的数据进行复用。具体地,对已经完成结构处理和格式转换的内容进行缓存,并为目标内容维护对应的内容标识,当检测到内容未发生变化时,直接复用缓存结果,从而避免对相同内容重复执行解析和匹配处理。同时,对引用内容的匹配结果进行缓存,使在目标流式数据未更新的情况下无需重复执行匹配操作,以提升整体处理效率。

[0164] 在一种可能的实现方式中,为减少大规模文本数据在状态管理过程中的性能消耗,针对用于存储目标流式数据和已处理显示内容的文本变量,采用浅层引用方式进行管理,从而降低响应式更新范围,减少不必要的状态监听开销,使流式数据显示在内容持续增长的情况下仍能保持较好的性能表现。

[0165] 参见图2,图2为本申请实施例提供的一种流式数据显示的系统架构图。

[0166] 用户输入模块用于接收用户的交互请求,并通过请求管理模块发起对应的流式数据请求。请求管理模块用于对流式请求的生命周期进行控制,例如支持中止生成操作,从而为后续基于用户操作确定目标流式数据的截断位置提供基础条件。

[0167] 请求管理模块通过流式请求接口获取连续返回的流式数据,并将接收到的原始流式数据传入解析模块进行处理。解析模块用于对流式数据进行解码与结构化解析,使连续到达的数据被拆分为多个数据块,从而形成当前累积的目标流式数据。

[0168] 作为一种实现方式,本模块使用Fetch API的ReadableStream接口接收服务器推送的SSE流式数据。关键实现步骤如下:

[0169] 步骤1:建立流式连接

[0170] 发送POST请求到智能问答接口,请求体包含问题文本(question)、业务ID(bus_id)、是否深度思考(deep_think)标志

[0171] 设置Content-Type为application / json

[0172] 附加AbortSignal用于支持请求中断

[0173] 步骤2:获取响应流

[0174] 检查响应状态码是否为200

[0175] 从response.body获取ReadableStream对象

[0176] 将二进制流传入XStream模块进行解析

[0177] 步骤3:流式数据转换 XStream模块的工作原理:

[0178] 使用TextDecoderStream将Uint8Array解码为UTF-8字符串

[0179] 通过splitStream转换器按双换行符(\n\n)分割SSE事件

[0180] 通过splitPart转换器解析每个事件的键值对(event、data等字段)

[0181] 返回AsyncIterable对象,支持for await...of循环迭代

[0182] 在XStream模块之后,系统设置数据分类器和缓冲区管理和类型识别器,用于对数据块进行数据类型的识别和阶段性缓存。其中,数据分类器用于识别数据块的数据类型,例如思考类型和回答类型,并将不同类型的数据块分别存储于不同的数据集合中,从而支持按照不同显示位置进行分类显示。

[0183] 缓冲区管理模块用于缓存当前累积的目标流式数据及相关处理结果,为后续引用内容匹配和显示控制提供数据基础。

[0184] 系统进一步设置智能截断与引用处理模块,用于对目标流式数据进行引用内容识别、引用边界确定以及截断位置判断。该模块通过起始引用标记和结束引用标记确定引用内容的起始位置和结束位置,并结合当前确定的截断位置,判断是否需要暂缓显示引用内容或仅显示起始引用标记前的数据块。

[0185] 在引用内容完整到达后,系统通过Markdown渲染引用转换模块对引用内容进行格式转换,将引用标识信息转换为可交互的引用显示元素,并在显示过程中绑定对应的引用标识信息,从而支持用户对引用内容进行交互操作。

[0186] 在显示阶段,系统通过打字机渲染引擎对目标流式数据进行逐步显示,使数据块按照预设节奏渐进式呈现。该引擎在显示过程中结合引用处理结果,仅在引用内容完整到达时才整体显示引用内容,从而保证显示结构的完整性。

[0187] 此外,系统还包括用户交互处理模块,用于响应用户对引用内容的点击操作,并基于引用标识信息执行相应的交互处理,例如定位引用来源位置,从而进一步增强引用内容在流式数据显示场景下的可用性。

[0188] 参见图3,图3为本申请实施例提供的一种流式数据显示装置,装置300包括:

[0189] 获取单元301,用于获取并逐步显示当前累积的目标流式数据,所述目标流式数据包括多个数据块;

[0190] 确定单元302,用于确定所述目标流式数据中的引用内容,所述引用内容通过起始引用标记和结束引用标记分别确定起始位置和结束位置;

[0191] 确定单元302,还用于确定所述目标流式数据的截断位置;

[0192] 显示单元303,用于若所述目标流式数据包括目标引用内容的起始引用标记,且所述截断位置位于所述目标引用内容中的起始引用标记和所述目标引用内容的结束引用标记之间,则显示所述起始引用标记前的数据块。

[0193] 可选地,所述装置还包括第二显示单元,用于:

[0194] 若所述目标流式数据包括所述目标引用内容,且所述截断位置位于所述目标引用内容中的结束引用标记之后,则显示所述目标引用内容及所述目标引用内容前的数据块。

[0195] 可选地,所述显示单元,具体用于:

[0196] 在显示所述目标引用内容前,获取所述目标引用内容中携带的引用标识信息;

[0197] 基于所述引用标识信息确定用于显示的引用编号,并生成用于呈现所述目标引用内容的引用显示元素;

[0198] 在所述引用标识信息绑定至所述引用显示元素后,显示所述引用显示元素。

[0199] 可选地,所述确定单元,具体用于:

[0200] 通过引用内容匹配规则对所述目标流式数据进行匹配,若所述目标流式数据中包括符合所述引用内容匹配规则的数据块,则存储对应的匹配结果;

[0201] 若所述目标流式数据未发生更新,则基于存储的所述匹配结果确定所述目标流式数据中的引用内容;

[0202] 若所述目标流式数据发生更新,则重新执行通过引用内容匹配规则对所述目标流式数据进行匹配的步骤及后续步骤。

[0203] 可选地,所述装置还包括:

[0204] 若所述目标流式数据不包括引用标记,或当所述截断位置大于或等于所述目标流式数据的当前长度时,直接显示所述目标流式数据包括的多个数据块。

[0205] 可选地,所述方法还包括分类显示单元,用于:

[0206] 获取所述目标流式数据中各个数据块的数据类型,所述数据类型至少包括思考类型和回答类型;

[0207] 将所述数据类型为所述思考类型的数据块按照累积顺序存储在第一集合中;

[0208] 将所述数据类型为所述回答类型的数据块按照累积顺序存储在第二集合中;

[0209] 通过第一显示方式显示所述第一集合中的数据块,通过第二显示方式显示所述第二集合中的数据块,所述第一显示方式和所述第二显示方式为显示位置不同的显示方式。

[0210] 参见图4,本申请实施例还提供一种计算机设备,所述计算机设备包括存储器401以及处理器402:

[0211] 所述存储器用于存储计算机程序,并将所述计算机程序传输给所述处理器;

[0212] 所述处理器用于根据所述计算机程序执行上述方法实施例的方法。

[0213] 本申请实施例还提供一种计算机可读存储介质,其特征在于,所述计算机可读存储介质用于存储计算机程序,所述计算机程序用于执行上述方法实施例的方法。

[0214] 本申请实施例还提供了一种包括计算机程序的计算机程序产品,当其在计算机设备上运行时,使得所述计算机设备执行上述方法实施例的方法。

[0215] 需要说明的是,本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的系统或装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。

[0216] 本文使用的术语"包括”及其变形是开放性包括,即"包括但不限于”。术语"基于”是"至少部分地基于”。术语"一个实施例”表示"至少一个实施例”;术语"另一实施例”表示"至少一个另外的实施例”;术语"一些实施例”表示"至少一些实施例”。其他术语的相关定义将在下文描述中给出。

[0217] 应当理解,在本申请中,"至少一个(项)”是指一个或者多个,"多个”是指两个或两个以上。"和 / 或”,用于描述关联对象的关联关系,表示可以存在三种关系,例如,"A和 / 或B”可以表示:只存在A,只存在B以及同时存在A和B三种情况,其中A,B可以是单数或者复数。字符" / ”一般表示前后关联对象是一种"或”的关系。"以下至少一项(个)”或其类似表达,是指这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b或c中的至少一项(个),可以表示:a,b,c,"a和b”,"a和c”,"b和c”,或"a和b和c”,其中a,b,c可以是单个,也可以是多个。

[0218] 还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语"包括”、"包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句"包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。

[0219] 结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。

[0220] 对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。

Claims

1. A method of displaying streaming data, characterized by, The method includes: Acquire and progressively display the currently accumulated target streaming data, which includes multiple data blocks; The referenced content in the target streaming data is determined, and the start and end positions of the referenced content are determined by a start reference marker and an end reference marker, respectively. Determine the truncation point of the target streaming data; If the target streaming data includes a start reference marker for the target reference content, and the truncation position is located between the start reference marker and the end reference marker in the target reference content, then the data block before the start reference marker is displayed.

2. The method of claim 1, wherein, The method further includes: If the target streaming data includes the target reference content, and the truncation position is located after the end reference marker in the target reference content, then the target reference content and the data block preceding the target reference content are displayed.

3. The method of claim 2, wherein, The display of the target reference content includes: Before displaying the target reference content, obtain the reference identification information carried in the target reference content; Based on the reference identification information, a reference number for display is determined, and a reference display element for presenting the target reference content is generated; After the reference identification information is bound to the reference display element, the reference display element is displayed.

4. The method of claim 1, wherein, Determining the referenced content in the target streaming data includes: The target streaming data is matched using reference content matching rules. If the target streaming data includes data blocks that match the reference content matching rules, the corresponding matching results are stored. If the target streaming data has not been updated, the referenced content in the target streaming data is determined based on the stored matching results; If the target streaming data is updated, the step of matching the target streaming data by reference content matching rules and subsequent steps are re-executed.

5. The method of claim 1, wherein, The method further includes: If the target streaming data does not include reference markers, or if the truncation position is greater than or equal to the current length of the target streaming data, the multiple data blocks included in the target streaming data are displayed directly.

6. The method of claim 1, wherein, The method further includes: Obtain the data type of each data block in the target streaming data, wherein the data type includes at least thinking type and answer type; The data blocks whose data type is the thinking type are stored in the first set in cumulative order; The data blocks of the data type of the answer type are stored in the second set in cumulative order; The data blocks in the first set are displayed using a first display method, and the data blocks in the second set are displayed using a second display method, wherein the first display method and the second display method are display methods with different display positions.

7. A streaming data display device, characterized in that, The device includes: An acquisition unit is used to acquire and gradually display the currently accumulated target streaming data, which includes multiple data blocks; A determining unit is used to determine the referenced content in the target streaming data, wherein the referenced content has its start and end positions determined by a start reference marker and an end reference marker, respectively. The determining unit is further configured to determine the truncation position of the target streaming data; The display unit is configured to display the data block before the starting reference mark if the target streaming data includes a start reference mark of the target reference content, and the truncation position is located between the start reference mark and the end reference mark of the target reference content.

8. A computer device, characterized in that, The computer device includes a processor and memory: The memory is used to store computer programs and to transfer the computer programs to the processor; The processor is configured to perform the method according to any one of claims 1-6 according to the computer program.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program for performing the method according to any one of claims 1-6.

10. A computer program product comprising a computer program, characterized in that, When it is run on a computer device, it causes the computer device to perform the method described in any one of claims 1-6.