Method and apparatus for processing streaming data, and electronic device
By introducing a streaming control data processing flow into the streaming generation process, the problems of erroneous rendering and data dumping in streaming data processing are solved, achieving high accuracy and security processing of streaming data.
Patent Information
- Application Number
- CN202611459322.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-18
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies cannot process the streaming fragments that make up the streaming data in real time during the streaming generation process, which leads to problems such as incorrect rendering, incorrect data storage, or disordered business logic.
Upon receiving a business request, a first processing request is sent to the business processing model to obtain streaming control data. After the preset conditions are met, a second processing request is sent to obtain streaming fragmented data. The fragmented data is then processed based on the streaming control data, including whitelist field matching, state machine management, and validator verification, to ensure the legality and integrity of the data.
It effectively improves the accuracy of streaming data processing, avoids erroneous rendering and incorrect data storage, ensures the security and robustness of the streaming generation process, and achieves high-quality processing of streaming data.
Smart Images

Figure CN123178459A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and more specifically, to a method and apparatus for processing streaming data, and an electronic device. Background Technology
[0002] With the development of artificial intelligence technology, large language models have been widely used in long text scenarios such as scriptwriting, contract generation, report writing, code generation, and multimedia asset generation.
[0003] In related technologies, when there are relevant business requirements, streaming data is output based on large language models (such as business processing models), and the streaming data is verified after output. If it fails, it is regenerated. This method cannot process the streaming fragments that make up the streaming data in real time during the streaming generation process, which makes it difficult to recover the streaming data once it is output, and it is easy to cause subsequent rendering misalignment, error data loss, and other problems.
[0004] Therefore, improving the accuracy of streaming data processing has become an urgent problem to be solved. Summary of the Invention
[0005] This application provides a method, apparatus, and electronic device for processing streaming data, which at least solves the problem in related technologies that the streaming fragment data constituting the streaming data cannot be processed in real time during the streaming generation process, which can easily lead to incorrect rendering, incorrect data storage, or business logic disorder.
[0006] According to one embodiment of this application, a method for processing streaming data is provided, comprising: upon receiving a business request from a target object, sending a first processing request to a business processing model, and receiving streaming control data fed back by the business processing model based on the first processing request; upon determining, based on the streaming control data, that preset control data conditions are met, sending a second processing request to the business processing model; receiving streaming fragmented data fed back by the business processing model based on the second processing request; and processing the streaming fragmented data based on the streaming control data to obtain a processing result.
[0007] According to another embodiment of this application, a streaming data processing apparatus is provided, comprising: a first processing module, configured to send a first processing request to a business processing model upon receiving a business request from a target object, and to receive streaming control data fed back by the business processing model based on the first processing request; a sending module, configured to send a second processing request to the business processing model upon determining, based on the streaming control data, that preset control data conditions are met; a receiving module, configured to receive streaming fragmented data fed back by the business processing model based on the second processing request; and a second processing module, configured to process the streaming fragmented data based on the streaming control data to obtain a processing result.
[0008] According to yet another embodiment of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and the computer program is configured to perform the steps in any of the above method embodiments when it is run.
[0009] According to yet another embodiment of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0010] According to yet another embodiment of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.
[0011] According to this application, by sending a first processing request to the business processing model before receiving streaming fragmented data to introduce streaming control data, a second processing request is sent to the business processing model only after determining that preset control data conditions are met based on the streaming control data. This allows the business processing model to process the streaming fragmented data fed back by the second processing request based on the streaming control data. In other words, processing of the fragmented data can begin immediately after obtaining it, avoiding the common problems in related technologies where processing is only performed after obtaining complete streaming data, such as incorrect rendering, incorrect data storage, or disordered business logic. This effectively improves the accuracy of streaming data processing. Attached Figure Description
[0012] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0013] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.
[0014] Figure 1 This is a hardware structure block diagram of a computer device for a streaming data processing method according to an embodiment of this application;
[0015] Figure 2 This is one of the flowcharts of a streaming data processing method according to an embodiment of this application;
[0016] Figure 3 This is an architecture diagram of a streaming data processing method according to an embodiment of this application;
[0017] Figure 4 This is a second flowchart of a streaming data processing method according to an embodiment of this application;
[0018] Figure 5 This is the third flowchart of a streaming data processing method according to an embodiment of this application;
[0019] Figure 6 This is one of the interaction diagrams of a streaming data processing method according to an embodiment of this application;
[0020] Figure 7 This is a flowchart of the streaming data processing method according to an embodiment of this application;
[0021] Figure 8 This is the second interaction diagram of a streaming data processing method according to an embodiment of this application;
[0022] Figure 9 This is a structural block diagram of a streaming data processing apparatus according to an embodiment of this application. Detailed Implementation
[0023] The embodiments of this application will be described in detail below with reference to the accompanying drawings and examples.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0025] The methods and embodiments provided in this application can be executed in a computer device or similar computing device. Taking running on a computer device as an example, Figure 1 This is a hardware structure block diagram of a computer device for a streaming data processing method according to an embodiment of this application. Figure 1As shown, a computer device may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor or programmable logic device) and a memory 104 for storing data are also shown. The computer device may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer device described above. For example, the computer device may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0026] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the streaming data processing method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thus implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to computer devices via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0027] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer equipment. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0028] This embodiment provides a method for processing streaming data, applied to the aforementioned computer device. Figure 2 This is a flowchart of a streaming data processing method according to an embodiment of this application, such as... Figure 2 As shown, the process includes the following steps:
[0029] Step S202: Upon receiving a business request from the target object, a first processing request is sent to the business processing model, and streaming control data is received from the business processing model based on the first processing request.
[0030] In this context, a business request refers to a raw input instruction initiated by a target object (such as a user or front-end application) through an interactive interface, aimed at generating business content (such as an interactive drama script, a draft contract, or code snippets). Business requests can carry specific creative requirements and contextual information from the target object. By parsing business requests, a first processing request can be constructed. Based on this first processing request, a processing mechanism based on streaming control data is initiated to ensure that subsequently generated streaming fragmented data can be correctly identified, verified, and persisted.
[0031] Specifically, upon receiving a business request from the target object, a first processing request can be constructed, including constraint prompts. These constraint prompts specify that the business processing model must follow the output order of declaration first, followed by the main content. Declaration first means the business processing model must prioritize outputting streaming control data. Main content second means the business processing model can only begin generating data related to specific business content after generating the streaming control data.
[0032] Optionally, receiving streaming control data from the business processing model based on the first processing request includes: receiving fragmented control data from the business processing model based on the first processing request; storing the fragmented control data in a predefined storage object when the predefined state machine is in a declared state; and accumulating the fragmented control data in the storage object to obtain streaming control data when the fragmented control data in the storage object meets the preset data integrity conditions.
[0033] It should be noted that streaming control data refers to the JSON-formatted semantic declarations (such as data types, validators, and repair strategies) output by meta-tools before the business processing model is generated, which are used to guide the subsequent processing of streaming sharded data.
[0034] Specifically, after receiving the first processing request, the business processing model generates streaming control data. Due to the characteristics of streaming transmission, the streaming control data is split into multiple control fragments and transmitted to the computer device. The computer device receives the fragmented control data returned by the business processing model. If the predefined state machine is in the declared state, the received fragmented control data is temporarily stored in a predefined storage object (such as a buffer) to prevent data loss. Further, the fragmented control data in the storage object is monitored to determine whether it meets preset data integrity conditions (such as JSON syntax closure and complete key fields). Once these conditions are met, the accumulated fragmented data is processed (concatenated and parsed) to reconstruct the complete streaming control data.
[0035] In the above embodiments, by combining state machines and storage objects, the integrity judgment of fragmented control data is carried out, which solves the problem of fragmentation in streaming transmission. This ensures that the server can accurately determine the streaming control data before processing streaming fragmented data, thereby providing a reliable basis for subsequent diversion, verification and repair, and avoiding incorrect processing of incomplete data.
[0036] Step S204: If the preset control data conditions are met based on the streaming control data, a second processing request is sent to the business processing model.
[0037] In an exemplary embodiment, when it is determined based on streaming control data that preset control data conditions are met, a second processing request is sent to the service processing model, including: obtaining a whitelist field corresponding to the service request; parsing the streaming control data and extracting the control field of the streaming control data; matching the control field with the whitelist field, and if the first matching result indicates that the control field meets the preset field conditions, constructing an execution confirmation signal based on the streaming control data; and sending a second processing request to the service processing model based on the execution confirmation signal to instruct the service processing model to provide streaming fragment data.
[0038] Optionally, the whitelist field refers to a predefined set of legal parameters based on actual business needs, including allowed data types (such as storyText), validators (such as interactive_script_markdown validator), repair strategies, and submission intent. The whitelist field can limit the behavioral boundaries of the business processing model, preventing it from declaring illegal or high-risk operations. The control field refers to the actual fields extracted from the streaming control data. The control fields are matched with the whitelist fields. If the first matching result indicates that the control fields meet the preset field conditions, it means that the currently declared streaming control data is legal and secure. A second processing request is then sent to the business processing model, authorizing the business processing model to continue generating subsequent formal text content (i.e., streaming fragmented data).
[0039] In some embodiments, when generating whitelist fields, a list of control fields allowed by the business requirements (such as scriptwriting) can be loaded from a configuration table based on the business requirements associated with the business request. For example, for scriptwriting, the data type is allowed to be story text (or script body), and the interactive drama validator is specified to perform structured validation after generation. Next, the control fields of the streaming control data are parsed and extracted, and whitelist matching validation is performed, comparing each extracted control field with a predefined whitelist field. It is checked whether all values in the control fields are within the allowed value range of the whitelist. For example, if a control field declares type=codeFile (data type = code file), but the whitelist only allows story text, the match fails. If all control fields are within the whitelist fields, the preset field conditions are met, i.e., the match is successful; if any control field exceeds the whitelist field range or contains a prohibited field, the match fails. When the first matching result indicates a successful match, an execution confirmation signal is constructed. The execution confirmation signal signifies that the streaming control data has passed security and compliance checks. Based on the execution confirmation signal, a second processing request is sent to the business processing model. The second processing request instructs the business processing model to begin generating formal streaming fragmented data (i.e., the main content).
[0040] In the above embodiments, by expanding the verification through predefined whitelist fields, illegal type declarations, high-risk operation requests, or policy conflicts caused by the business processing model are effectively prevented, ensuring that the streaming generation process is carried out within a controlled and secure scope, thereby improving the robustness and business security of the data processing process.
[0041] Step S206: Receive streaming fragmented data fed back by the service processing model based on the second processing request;
[0042] Understandably, each streaming data segment is a text block (token chunk) arriving in chronological order, collectively forming the complete business text (such as script text, code snippets, or contract terms). After confirming the execution signal, the state machine can switch from the declared state to the receiving state. The receiving state signifies that the data type and processing strategy for subsequent data segments are clear, and it is ready for targeted processing.
[0043] Step S208: Process the streaming fragment data based on the streaming control data to obtain the processing result.
[0044] In an exemplary embodiment, processing each streaming fragment data based on streaming control data to obtain a processing result includes: extracting a data type field from the streaming control data when the predefined state machine is in the receiving state; matching the target type identifier of the data type field with a preset type mapping table to determine the target output channel corresponding to the target type identifier; transmitting each streaming fragment data to the target output channel, and determining the rendering component corresponding to the target output channel; and previewing the streaming fragment data based on the rendering component.
[0045] For example, when the predefined state machine is in the receiving state (i.e., the streaming control data has been parsed and is ready to receive the main content), the data type field (such as type:storyText or type:codeFile) is precisely extracted from the streaming control data. This field defines the business semantics and processing strategy for subsequent streaming fragment data. Further, a pre-defined type mapping table is queried. This table includes multiple type identifiers and their corresponding output channels, establishing a one-to-one correspondence between the type identifiers and the output channels. For example, storyText maps to the script main content channel, and codeFile maps to the code file channel. Through matching, the target output channel for the streaming fragment data is determined, ensuring that streaming fragment data of different semantic types take different transmission paths, achieving logical isolation. Further, the received streaming fragment data is sent to the front end through the determined target output channel. Simultaneously, the corresponding rendering component is determined. For example, the script channel is bound to a structured script editor component, and the code channel is bound to a code highlighting editor component.
[0046] Optionally, streaming fragment data can be transmitted to the front end via the target output channel. Upon receiving the streaming fragment data, the front end automatically invokes the bound rendering component for real-time preview. This allows users to immediately see formatted content that conforms to business semantics (such as code with syntax highlighting and scripts with branch markers).
[0047] In an exemplary embodiment, after transmitting the streaming fragment data to the target output channel, the method further includes: determining a data buffer that matches the target type identifier based on the target type identifier of the data type field; transmitting the streaming fragment data to the data buffer to accumulate the streaming fragment data in the data buffer to obtain accumulated streaming fragment data.
[0048] It's important to note that while sending the streaming, sharded data to the front-end preview channel, a back-end data accumulation operation is also performed: based on the target type identifier of the data type field (e.g., storyText), the corresponding data buffer is matched from a predefined buffer pool. The received streaming, sharded data is then appended to this data buffer. This operation aims to build a complete copy of the business text for subsequent structured validation at the end of generation, execution of repair strategies, and final version persistence, ensuring consistency between the preview content and the back-end data awaiting review.
[0049] In an exemplary embodiment, processing streaming fragmented data based on target control data to obtain a processing result further includes: extracting a verification field from the streaming control data when the predefined state machine is in the reception completion state; searching for a verifier instance matching the verifier identifier in a preset verifier instance table based on the verifier identifier of the verification field; performing structural verification and semantic compliance verification on the accumulated streaming fragmented data in the data buffer based on the verifier instance to obtain a first verification result and a second verification result; and determining the verification result based on the first verification result and the second verification result.
[0050] It should be noted that when the business processing model finishes streaming output (e.g., upon receiving the finish_reason signal), the semantic state machine enters the receiving completion state. Validation fields (i.e., validator identifiers, such as interactive_script_markdown) are extracted from the previously parsed streaming control data. A pre-defined validator instance table is queried, and the corresponding specific validator instance (e.g., interactive script Markdown parser, code syntax analyzer, etc.) is found based on the extracted validator identifier. If no matching instance is found, it is considered an illegal declaration, directly triggering downgrade processing. The matched validator instance is called to concatenate the accumulated streaming fragments in the data buffer to obtain streaming data (e.g., complete text). Two further validations are performed on the complete text: structural validation (first validation result): checking the syntactic structural integrity of the text. For example, whether the script contains start / end markers, whether branch nodes are closed, and whether the code syntax is legal. Semantic compliance validation (second validation result): checking the correctness of the business logic. For example, whether the jump targets in the script exist, whether contract clauses are missing, and whether code references are consistent. Finally, the results of structural and semantic compliance validations are integrated to generate the final validation result. The verification result includes not only the pass / fail status, but also the specific failure type and detailed error information. This verification result will serve as the basis for triggering subsequent repair strategies (such as rewriting, retrying, or downgrading), ensuring that only structurally complete and semantically compliant content can enter the versioned saving process, effectively improving the accuracy of streaming data processing.
[0051] In some embodiments, downgrade processing means no longer treating the complete text as a structured asset for versioning, structured storage, or triggering downstream business stages. In other words, the complete text is converted to the default ordinary content type in normal mode, such as saving and displaying the complete text as an ordinary chat message or plain text, without performing special structured rendering or persistence.
[0052] Through the steps S202-S208 described above, a first processing request is sent to the business processing model before receiving the streaming fragmented data to introduce streaming control data. Thus, only when the preset control data conditions are met based on the streaming control data is a second processing request sent to the business processing model. Subsequently, based on the streaming control data, the streaming fragmented data fed back by the business processing model based on the second processing request can be processed. In other words, the processing of fragmented data can be started immediately after the streaming fragmented data is obtained, avoiding the common problems in related technologies that only process the complete streaming data, such as incorrect rendering, incorrect data storage, or business logic disorder. This effectively improves the accuracy of streaming data processing.
[0053] In an exemplary embodiment, after determining the verification result based on the first verification result and the second verification result, the method for processing streaming data further includes: updating the receiving completion status to the repair status if the verification result indicates that the verification has failed; extracting the repair field from the streaming control data in the repair status; matching the corresponding target repair strategy in the repair strategy mapping table associated with the repair field based on the verification result; and repairing the accumulated streaming fragment data in the data buffer based on the target repair strategy.
[0054] Specifically, when the verification result indicates verification failure, the semantic state machine is updated from the receive-complete state to the repair state, marking the entry into the automatic error correction process. Repair fields are extracted from the streaming control data, and these fields are associated with a repair strategy mapping table. This table includes multiple failure type identifiers and corresponding repair strategies. Based on the verification result, the corresponding target repair strategy is precisely matched in the repair strategy mapping table. Further, the accumulated streaming fragment data in the data buffer is repaired according to the matched target repair strategy. After repair, the semantic state machine can be updated back to the receive-complete state, and the data in the repaired data buffer is verified again until it passes or the maximum repair count threshold is reached.
[0055] Optionally, the repair strategy may include, but is not limited to: truncated continuation: truncating the end context and requesting the model to complete the missing content (append mode). Targeted retry: feeding back the validation error details to the model and requesting the regeneration of the complete content (replacement mode). Quick completion: For simple errors such as missing end markers, the server automatically completes the content directly without calling the model.
[0056] In the above embodiments, by determining the target repair strategy, problems such as truncation and format errors in the business processing model output can be effectively solved, ensuring that only high-quality, structurally compliant streaming data can enter persistent storage, thus guaranteeing the accuracy of streaming data.
[0057] In an exemplary embodiment, matching the corresponding target repair strategy in the repair strategy mapping table associated with the repair field based on the verification result includes: if the verification result includes a single failure type identifier, directly matching the failure type identifier with multiple failure type identifiers in the repair strategy mapping table to obtain a second matching result; if the second matching result indicates that there is a matching failure type identifier in the repair strategy mapping table, then the repair strategy corresponding to the matching failure type identifier is determined as the target repair strategy; if the second matching result indicates that there is no matching failure type identifier in the repair strategy mapping table, then a predefined downgrade repair strategy is obtained, and the downgrade repair strategy is determined as the corresponding target repair strategy.
[0058] It should be noted that when the validation result contains only one failure type (such as truncated), it is directly compared with multiple failure type identifiers in the repair strategy mapping table. If a corresponding failure type identifier exists in the repair strategy mapping table, the strategy associated with that failure type identifier is directly extracted as the target repair strategy, and targeted repair is performed. If no corresponding failure type identifier exists in the table, the predefined default degradation strategy is automatically invoked to downgrade the streaming sharded data to ordinary data, preventing process blockage or error handling due to missing strategies.
[0059] In the above embodiments, by matching the failure type identifier with multiple failure type identifiers in the repair strategy mapping table, the target repair strategy can be determined efficiently, reducing processing latency.
[0060] In an exemplary embodiment, matching the corresponding target repair strategy in the repair strategy mapping table based on the verification result further includes: if the failure type array in the verification result includes multiple failure type identifiers, obtaining a fused failure type identifier based on the multiple failure type identifiers; matching the fused failure type identifier with the multiple failure type identifiers in the repair strategy mapping table to obtain a third matching result; if the third matching result indicates that there is a matching failure type identifier in the repair strategy mapping table, then the repair strategy corresponding to the matching failure type identifier is determined as the target repair strategy; if the third matching result indicates that there is no matching failure type identifier in the repair strategy mapping table, then the target repair strategies corresponding to the multiple failure type identifiers are determined sequentially based on the priority of the multiple failure type identifiers.
[0061] Understandably, when multiple failure types exist, the system first attempts to find the corresponding fusion failure type identifier in the repair strategy mapping table to process all faults at once. If no fusion failure type identifier is found, the system searches for the first failure type with a corresponding repair strategy according to a preset priority. If no strategy is found after priority matching, the default degradation strategy is executed to ensure the process is not interrupted. Thus, prioritizing the use of fusion strategies avoids redundant calls caused by serial repairs, significantly improving processing speed. Prioritizing multiple fault conflicts ensures that high-severity errors are handled first, improving repair effectiveness.
[0062] In an exemplary embodiment, repairing the accumulated streaming fragment data in the data buffer based on the target repair strategy includes: if the target repair strategy includes a continuation strategy, generating a continuation request to the business processing model based on the accumulated streaming fragment data in the data buffer; the continuation request carries truncation position information; receiving subsequent fragment data generated by the business processing model based on the continuation request, and transmitting the subsequent fragment data to the data buffer; if the target repair strategy includes a replacement strategy, clearing the accumulated streaming fragment data in the data buffer, constructing a prompt word based on the verification result, generating a retry request based on the prompt word and sending it to the business processing model; receiving new streaming fragment data generated by the business processing model based on the retry request, and writing the new streaming fragment data into the data buffer; if the target repair strategy includes an end-padding strategy, adding an end marker to the data buffer.
[0063] In an exemplary embodiment, if the verification result indicates that the verification is successful, the state of the semantic state machine is updated from the receiving completion state to the verification success state; in the verification success state, the intent field is extracted from the streaming control data; based on the intent identifier of the verification intent field, it is matched in a preset submission policy mapping table to determine the submission policy corresponding to the intent identifier; and the accumulated streaming fragment data in the data buffer is submitted based on the submission policy.
[0064] Optionally, when the verification result is successful, the state machine transitions from the receiving completion state to the verification success state. Then, the intent field (such as `versioned_save` or `contract_draft_save`) is extracted from the streaming control data. The intent field represents the user's or business's expected data destination. The server queries a preset submission policy mapping table and matches the corresponding submission policy (such as `validate_before_versioned_persist`) based on the intent identifier. According to the determined submission policy, final processing is performed on the accumulated streaming fragment data in the data buffer, including writing the streaming fragment data to the target business database, creating version records, triggering downstream structured extraction tasks, or generating confirmation controls. After processing, the state machine enters the committed state, notifying the front end to remove the preview flag, completing the transition from temporary preview to formal asset.
[0065] To better understand the process of the above-described streaming data processing method, the implementation flow of the above-described streaming data processing method will be described below in conjunction with optional embodiments, but this is not intended to limit the technical solution of the embodiments of this application.
[0066] refer to Figure 3 As shown in the diagram, this application discloses a schematic diagram of the overall architecture of a streaming data processing method. The following is a detailed explanation... Figure 3 Detailed explanation: Figure 3 The system interacts with the front-end, the large model (i.e., the business processing model), and the server-side streaming session processing module (i.e., the server) to jointly process streaming data.
[0067] The front-end initiates user input, receives streaming responses, and renders them. The server-side streaming session processing module is the core control center, containing the following sub-modules: Constructing streaming requests: Initiating requests to the large model based on context and stage information. Tool call shard parser: Real-time parsing of the `tool_call_delta` and `textchunk` returned by the large model to extract semantic control frames (i.e., streaming control data). Semantic control frame validator: Verifying the legality of semantic control frames (e.g., whitelist checks). State machine: Managing the lifecycle states of the streaming session (e.g., Idle, Declared, Streaming, Validating, Repairing, Committed, etc.). SSE splitter: Distributing data to different front-end rendering channels based on semantic type. Semantic buffer (i.e., data buffer): Accumulating streaming shard data for subsequent validation. Validator registry: Storing validation logic for different text types (e.g., scripts, code, contracts). Repair strategy engine: Executing continuation, retry, or degradation strategies based on validation results. Submission strategy whitelist / persistence / version module: Responsible for the final versioning and storage of data.
[0068] Specifically, users can input business requests on the front end. Upon receiving the business request, the server-side streaming session processing module constructs a large model request based on the business request context and sends the large model request to the large model. The large model begins streaming generation, returning `tool_call_delta` (tool call fragment) and `textchunk` (text fragment). The server-side streaming session processing module calls the shard parser to parse `tool_call_delta` and extract semantic control frames. The semantic control frame validator checks the validity of the control frames. If valid, the state machine is updated to `Declared`.
[0069] The SSE splitter sends subsequent text chunks to the front end using different SSEevent types based on the type field in the semantic control frame. The front end then selects the corresponding rendering component (such as a script editor, code editor, etc.) based on the event type.
[0070] The server appends the received text fragments (i.e., streaming fragmented data) to the semantic buffer. When generation is complete (or a verification point is reached), the corresponding verifier in the verifier registry verifies the buffer content. If verification fails, a failureType (failure type identifier) is output. The repair strategy engine matches a repair strategy based on the failureType and the preset repairPolicy. If repair is needed (such as truncation continuation or structural retry), the state machine enters the Repairing state, generates a repair request (with context), and resends it to the large model. The large model returns the repaired content, and the process returns to the second stage to continue splitting and accumulating.
[0071] If verification is successful, the state machine enters the Previewing / Provisional state. The submission strategy whitelist module determines the final submission strategy (e.g., automatic saving or saving after manual confirmation) based on the intent in the control frame. The persistence / version module writes the verified complete text to the database, creates a version record, and completes versioned saving. Before generating the main text, the large model declares the semantic type and processing strategy of subsequent content through meta-tools, achieving declaration before processing. The system state dynamically switches during parsing, verification, and repair processes to ensure process controllability. After verification failure, a repair strategy (continue writing, retry, downgrade) is automatically triggered, forming a closed loop and improving the generation success rate. Submission behavior is controlled through whitelist mapping to prevent the model from forging high-privilege operations and ensure the security of data storage.
[0072] This architecture effectively solves the problems of misjudgment of semantic types of long text, error data retention, and lack of automatic repair capabilities in large-scale model streaming generation, thereby improving the quality of generated content and system reliability.
[0073] refer to Figure 4 The diagram shown is a general flowchart of the streaming data processing method. Figure 4 It covers the complete closed loop from request construction, streaming parsing, dynamic traffic splitting, verification and repair to final submission.
[0074] The following is a detailed explanation: Process Initiation and Request Construction: The user initiates a request on the front end. Constructing the Large Model Request: The server constructs a large model request containing semantic declarative meta-tooltips based on the session context / stage information. The large model request requires the large model to call the semantic declarative meta-tooltips to declare the type and processing strategy of subsequent content before outputting the main text.
[0075] Large Model Streaming Response: The large model begins generation, returning mixed streaming data: `tool_call_delta`: a fragment of a semantic declarative tool call. `text chunk`: a regular text fragment. Tool Call Fragment Parsing: `tool_call_delta` is parsed in real time, accumulating and parsing complete semantic control frames. Semantic Control Frame Validator: The semantic control frame performs a validity check on the control frame (e.g., whether the field is in the whitelist). If valid, the state machine enters the `Declared` state; if invalid or timed out, it enters the `Rejected` state and is downgraded to ordinary content processing.
[0076] After parsing out the valid semantic control frames, the SSE splitter switches the SSE event type based on the type field (such as storyText, contractText) in the control frame. The front end then renders the text to the corresponding component (such as a script editor, code editor, etc.) based on the SSE event type.
[0077] The server appends the received subsequent text chunks to the corresponding semantic buffer for later validation. Upon receiving the `finish_reason` signal, the current generation round is complete. The server then calls the corresponding validator in the validator registry (such as the interactive script Markdown validator, contract clause validator, etc.) to perform structural and semantic validation on the accumulated text in the semantic buffer. The validation result is output: validation passed or validation failed (including `failureType`, such as `truncated`, `invalid_structure`). If validation fails, the server enters the Repairing state and executes self-repair logic: matching the repair policy: the repair policy engine matches the corresponding repair policy from the preset `repairPolicy` mapping table based on `failureType`. Common policies include: `continue_if_truncated`: for truncation, executes continuation (append mode). `retry_if_invalid`: for structural errors, executes retry (replace mode, clears the buffer and regenerates). If repair is exhausted or there is no matching policy, a downgrade is performed. If it's continuation, the state returns to the streaming generation stage, appends content, and validates again. If it's a retry, the state returns to the streaming generation stage, clears the buffer, and regenerates. If the content is downgraded, the status will be changed to Downgraded, and the content will be treated as ordinary content and will no longer be saved in a structured manner.
[0078] If validation passes, proceed to the Previewing and Provisional states: Determine the submission strategy: Extract the intent field from the control frame. Combined with the whitelist mapping, the final submission strategy (e.g., validate_before_versioned_persist) is determined from the submission strategy whitelist. Generate a confirmation control and wait for user confirmation, or automatically submit according to the strategy. Once confirmed, the persistence / versioning module writes the text to the database, creating a version record. The state machine enters the Committed state. Send the Committed event, the frontend exits the preview state, and marks it as a production version.
[0079] If the control frame is illegal or exceeds the whitelist, it is rejected directly and downgraded to normal content. If the repair or verification fails and there is no effective repair strategy, it is downgraded to normal content and will not be included in the structured database.
[0080] refer to Figure 5 The diagram shown is a flowchart illustrating the lifecycle of the state machine provided in this embodiment of the application. Figure 5 It provides a detailed description of the complete lifecycle of the streaming session state machine driven by semantic control frames. It demonstrates the various states and their transition logic from the start of the session to the final commit or degradation process, including: the normal path, the repair path, and the abnormal path.
[0081] Initial Phase: Awaiting Declaration; Idle: Initial session state, no data received yet. AwaitingDeclaration: Triggering condition: Receiving the first non-tool call text chunk (e.g., a preface). Behavior: The server caches the text, waiting for the Semantic Declaration Tool to call it. Transition: Normal: If a valid control frame is received, enter Declared state. Abnormal: If a declaration is not received within a timeout period (TimedOut), or an illegal declaration / out-of-whitelist declaration is received (Rejected state), then enter the corresponding final state.
[0082] Declaration and Streaming Phase: Declared: Triggering condition: Parsing and validating the semantic control frame (including whitelist check). Behavior: Establishing the semantic type of the current stream (e.g., storyText), preparing to receive subsequent text. Transformation: When the large model begins outputting non-tool-invoked text chunks, it enters StreamingTargetContent.
[0083] During the streaming reception phase, StreamingTargetContent: Behavior: The server continuously receives text fragments output from the large model and writes them to the corresponding semantic buffer. The front-end displays them in streaming preview form, but the content has not yet been validated and cannot be written to the database. Transformation: Normal: Upon receiving finish_reason (generation complete), enter Validating. Exception: If a transmission exception occurs (network disconnection, model error, etc.), enter StreamError.
[0084] Validation Phase, Validating: Triggering condition: Generation complete, entering the validation process. Behavior: Using the corresponding validator to perform structural, syntactic, or business logic validation on the complete text in the semantic buffer. Transformation: Validation passed: Entering Previewing. Validation failed: Entering Repairing. Exception: If in a transmission exception state, attempt to salvage and validate the already output content.
[0085] Repairing Phase (Closed-Loop Mechanism): Triggering Condition: Verification fails, and a usable repair strategy exists. Behavior: Continue writing (continue_if_truncated): Appends content to truncated sections. Retry (retry_if_invalid): Clears the buffer and regenerates for structural errors. Transformation: Success: After repair, re-enters StreamingTargetContent to continue generation, then verifies again. Failure / Exhaustion: If the repair attempt reaches the maximum (maxRepairAttempts) or times out, enters Downgraded. Exception: A transmission exception occurs in the repair request itself, entering StreamError.
[0086] Previewing (Preview State): Triggering Condition: Validation passed. Behavior: Content has passed validation and can be safely displayed on the front end, but the final submission strategy has not yet been determined. Transition: Enters Provisional. Provisional (Temporary Submission State): Triggering Condition: Submission strategy determined based on intent and whitelist mapping. Behavior: Automatic Submission: Directly execute version writing. Manual Confirmation: Generate a confirmation control, waiting for the user to click to apply this version. Transition: After submission, enters Committed.
[0087] Final State, Committed: Behavior: Content has been versioned and saved; the state machine ends the normal process. A Committed event is sent to notify the frontend. Downgraded: Triggering Conditions: Validation fails and repair is exhausted, or there is insufficient streaming content. Behavior: The content is downgraded to plain text, not included in structured database storage or version saving. StreamError: Triggering Conditions: An exception occurs during transmission. Behavior: Attempts to salvage the already output content (entering Validating) or directly downgrades (if content is insufficient).
[0088] TimedOut: Trigger condition: No declaration is received within the AwaitingDeclaration state. Behavior: Degraded to normal content processing. Rejected: Trigger condition: Control frame is illegal or exceeds the whitelist. Behavior: Declaration is rejected, downgraded to normal content processing.
[0089] Further, refer to Figure 6The diagram illustrates the interaction of the streaming data processing method provided in this application embodiment: The server parses the tool_call_delta returned by the large model and extracts the key semantic control fields: type: semantic type identifier (e.g., content, storyText, shotPreview, codeFile); validator: validator identifier; repairPolicy: repair policy; intent: submission intent.
[0090] The server checks if fields such as `type` are within the whitelist. Only valid `type` values will trigger subsequent traffic splitting logic. Based on the parsed `type` field, the server executes the following parallel processing flow: Scenario A: Normal content (Type: content); SSE event type: SSE event: content; Data transmission: Send the text chunk (normal content) to the front end. Buffer writing: Write to the content buffer. Front end rendering: The front end selects the chat message component to display based on the event type.
[0091] Scenario B: Script text (Type: storyText); SSE event type: SSE event: storyText; Data transmission: Send the text chunk (script text) to the front end. Buffer writing: Write to the storyText buffer. Front end rendering: The front end selects the script editor component for structured display.
[0092] Scene C: Shot Preview (Type: shotPreview); SSE Event Type: SSE event:shotPreview; Data Transmission: Send the text chunk (shot preview description) to the front end. Buffer Writing: Write to the shotPreview buffer. Front End Rendering: The front end selects the shot card component for display.
[0093] Scenario D: Code file (Type: codeFile); SSE event type: SSE event: codeFile; Data transmission: Send the text chunk (code file content) to the front end. Buffer writing: Write to the codeFile buffer. Front end rendering: The front end selects the code editor component for display.
[0094] Front-end adaptive rendering and component selection: The front-end listens for different SSE event types. Differentiated display: content - a plain text list; storyText - a structured script interface; shotPreview - a visual card; codeFile - highlighted code blocks. This mechanism ensures that different semantic content generated by the large model can be accurately distributed to the corresponding processing channels and display interfaces, laying the data structure foundation for subsequent structure verification and version saving.
[0095] refer to Figure 7 The diagram shown is a flowchart illustrating a streaming data processing method according to another embodiment of this application:
[0096] The validator instance performs structural validation on the text in the semantic buffer. Fault output: determined by entering the Previewing state and executing the submission strategy. Failure: enters the Repairing state and outputs the specific failureType. Common fault types: truncated; invalid_structure; broken_branch; duplicate_node; missing_end_marker.
[0097] Repair strategies are matched based on the number of faults: Scenario A: Single fault; Direct matching: Directly search for the corresponding strategy in the repairPolicy mapping table using faultType. Fallback mechanism: If no matching key is found, use the _default fallback strategy. Scenario B: Multi-fault priority mixed strategy: Check if the mixed key exists in the repairPolicy. If mixed exists: Execute the comprehensive repair strategy to handle all faults at once. If not mixed: Proceed to the priority matching process.
[0098] Priority matching: Based on the order defined in the repairPriority array, the fault type with the highest priority is selected. The corresponding repair strategy for that priority fault is then matched. If no match is found, the _default degradation strategy is executed.
[0099] Repair strategy execution modes, based on the matched strategy, perform different buffer operations: Append mode: Applicable scenario: truncated. Action: Append new content to the end of the existing buffer. Representative strategy: continue_if_truncated. Retry mode: Replace mode: Applicable scenario: structural errors such as invalid_structure, broken_branch, and duplicate_node. Action: Clear the current target semantic buffer and replace it with the complete version of the new output. Identifier transmission: Carry the attemptId to the front end to notify the front end to replace the preview area. Representative strategy: retry_if_invalid. Zero-cost repair: Applicable scenario: missing_end_marker (only the end marker is missing). Action: The server directly appends the end marker without calling the large model. Advantages: Fast and low cost.
[0100] Loop boundaries and exception handling: To prevent infinite loops, strict boundary control is introduced.
[0101] Loop counter: `repairAttemptCount` records the number of attempts in the current repair session. Maximum number of attempts: `maxRepairAttempts` (e.g., 3 times). Judgment: If `repairAttemptCount` >= `maxRepairAttempts`, stop repairing. Timeout control: `repairTimeout`. Judgment: If a repair request times out, it is treated as a `StreamError`. Exception handling: If a `StreamError` (transmission exception) occurs during a repair request, it determines whether to enter Validating (rescue) or Downgraded (degradation) based on whether the content is sufficient. Final degradation: If repairs are exhausted, timeouts, or exceptions cause validation to fail, the status enters Downgraded. Result: The content is downgraded to plain text and is no longer saved in a structured format.
[0102] refer to Figure 8 As shown, another embodiment of this application provides an interactive diagram of a streaming data processing method: Scenario 1: Normal declaration (control frame arrives first); Temporal characteristics: The large model outputs tool_call_delta (semantic control frame) first, followed by the main text chunk. Processing flow: The server parses tool_call_delta and verifies its validity. Channel switching: Based on the type field in the control frame, the SSE output type is immediately switched. Subsequent text chunks (GB / T main text) are directly written to the corresponding target buffer. Result: The text is accurately identified and enters the structured processing flow.
[0103] Scenario 2: Late Declaration (Control Frame Arrives Later, Default Isolation); Timing Characteristics: The large model outputs partial text chunks A and B (usually background / introduction) first, and then outputs tool_call_delta. Processing Flow: When the server receives A and B, since no control frame has been received, it stores them in the prelude (introduction) buffer. After receiving and parsing tool_call_delta, the state switches. Streaming Processing: The cached A+B does not enter the target buffer, but remains in the prelude (as a normal dialogue or context). The text chunk C that arrives later is written to the target buffer. Result: The introduction is physically isolated from the main text, preventing the introduction from being incorrectly treated as a structured asset for validation or data storage.
[0104] Scenario 3: Late Declaration (Merged Buffer); Timing Characteristics: Same as Scenario 2, but the control frame contains the `includeBufferedText:true` field. Processing Flow: After receiving the control frame, the server checks whether the whitelist authorizes the `includeBufferedText` behavior. Prefix Validation: Lightweight validation is performed on cached text chunks A and B (e.g., checking for correct start markers, header metadata, etc.). Branch Decision: Validation Passes: A+B is merged and written to the target buffer, and then C is also written to the target buffer. The entire text is treated as having the same semantic type. Validation Failes: The behavior is the same as in Scenario 2; A+B is assigned to the prelude, and C is assigned to the target buffer. Under the premise of server-side control, the coherence of long text generation is optimized, allowing the incorporation of prior context into structured processing.
[0105] Scenario 4: Declaration Timeout; Timing Characteristics: After receiving the first text chunk, the server does not receive any tool_call_delta within the declarationTimeout period (e.g., 5 seconds). Processing Flow: The server determines that a timeout has occurred, and the status enters TimedOut. Degradation Processing: All output text chunks (A, B, C...) are processed as the default content type. Subsequent validation, repair, and version saving processes are not triggered. Result: Prevents server resource waste or state suspension caused by model silence or response delay, ensuring system robustness.
[0106] Based on the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0107] This embodiment also provides a streaming data processing apparatus for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0108] Figure 9 This is a structural block diagram of a streaming data processing apparatus according to an embodiment of this application, such as... Figure 9 As shown, the device includes:
[0109] The first processing module 92 is used to send a first processing request to the business processing model when a business request from the target object is received, and to receive streaming control data fed back by the business processing model based on the first processing request.
[0110] Sending module 94 is used to send a second processing request to the service processing model when it is determined that the preset control data conditions are met based on the streaming control data;
[0111] Receiving module 96 is used to receive streaming fragmented data fed back by the service processing model based on the second processing request;
[0112] The second processing module 98 is used to process the streaming fragment data based on the streaming control data to obtain the processing result.
[0113] According to the above-mentioned device, by sending a first processing request to the business processing model before receiving streaming fragmented data to introduce streaming control data, a second processing request is sent to the business processing model only after it is determined from the streaming control data that the preset control data conditions are met. Then, based on the streaming control data, the streaming fragmented data fed back by the business processing model based on the second processing request can be processed. In other words, the processing of fragmented data can be started after the streaming fragmented data is obtained, avoiding the common problems caused by processing only after obtaining complete streaming data in related technologies, such as incorrect rendering, incorrect data storage, or business logic disorder, effectively improving the accuracy of streaming data processing.
[0114] In an exemplary embodiment, the first processing module 92 is further configured to receive fragmented control data fed back by the business processing model based on the first processing request; store the fragmented control data in a predefined storage object when the predefined state machine is in a declaration state; and, when the fragmented control data in the storage object meets the preset data integrity conditions, perform accumulation processing on the fragmented control data in the storage object to obtain streaming control data.
[0115] In an exemplary embodiment, the sending module 94 is further configured to: obtain a whitelist field corresponding to the service request; parse the streaming control data and extract the control field of the streaming control data; match the control field with the whitelist field; and, if the first matching result indicates that the control field meets a preset field condition, construct an execution confirmation signal based on the streaming control data; and send a second processing request to the service processing model based on the execution confirmation signal to instruct the service processing model to provide streaming fragment data.
[0116] In an exemplary embodiment, the second processing module 98 is further configured to: extract a data type field from the streaming control data when the predefined state machine is in the receiving state; match the target type identifier of the data type field with a preset type mapping table to determine the target output channel corresponding to the target type identifier; transmit the streaming fragmented data to the target output channel, determine the rendering component corresponding to the target output channel, and preview the streaming fragmented data based on the rendering component.
[0117] In an exemplary embodiment, the second processing module 98 is further configured to determine a data buffer that matches the target type identifier based on the target type identifier of the data type field; and to transfer the streaming fragment data to the data buffer to accumulate the streaming fragment data in the data buffer to obtain accumulated streaming fragment data.
[0118] In an exemplary embodiment, the second processing module 98 is further configured to: extract a verification field from the streaming control data when the predefined state machine is in the receiving completion state; search for a verifier instance matching the verifier identifier in a preset verifier instance table based on the verifier identifier; perform structural verification and semantic compliance verification on the accumulated streaming fragment data in the data buffer based on the verifier instance to obtain a first verification result and a second verification result; and determine the verification result based on the first verification result and the second verification result.
[0119] In an exemplary embodiment, the second processing module 98 is further configured to update the receiving completion status to a repair status if the verification result indicates a verification failure; extract a repair field from the streaming control data in the repair status; match a corresponding target repair strategy in the repair strategy mapping table associated with the repair field based on the verification result; and repair the accumulated streaming fragment data in the data buffer based on the target repair strategy.
[0120] In an exemplary embodiment, the second processing module 98 is further configured to: generate a continuation request to the service processing model based on the accumulated streaming fragment data in the data buffer when the target repair strategy includes a continuation strategy; receive subsequent fragment data generated by the service processing model based on the continuation request and transmit the subsequent fragment data to the data buffer; clear the accumulated streaming fragment data in the data buffer when the target repair strategy includes a replacement strategy, construct a prompt word based on the verification result, generate a retry request based on the prompt word and send it to the service processing model; receive new streaming fragment data generated by the service processing model based on the retry request and write the new streaming fragment data into the data buffer; and add an end marker to the data buffer when the target repair strategy includes an end completion strategy.
[0121] In an exemplary embodiment, the second processing module 98 is further configured to, when the verification result indicates successful verification, update the state of the semantic state machine from the receiving completion state to the verification success state; in the verification success state, extract the intent field from the streaming control data; match the intent identifier of the intent field in a preset submission policy mapping table to determine the submission policy corresponding to the intent identifier; and perform submission processing on the accumulated streaming fragment data in the data buffer based on the submission policy.
[0122] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0123] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when run.
[0124] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0125] S1, upon receiving a business request from the target object, a first processing request is sent to the business processing model, and the streaming control data fed back by the business processing model based on the first processing request is received.
[0126] S2, if it is determined that the preset control data conditions are met based on the streaming control data, a second processing request is sent to the service processing model;
[0127] S3, Receive streaming fragmented data fed back by the service processing model based on the second processing request;
[0128] S4, The streaming segmented data is processed based on the streaming control data to obtain the processing result.
[0129] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0130] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0131] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0132] Optionally, in this embodiment, the processor may be configured to perform the following steps according to a computer program:
[0133] S1, upon receiving a business request from the target object, a first processing request is sent to the business processing model, and the streaming control data fed back by the business processing model based on the first processing request is received.
[0134] S2, if it is determined that the preset control data conditions are met based on the streaming control data, a second processing request is sent to the service processing model;
[0135] S3, Receive streaming fragmented data fed back by the service processing model based on the second processing request;
[0136] S4, The streaming segmented data is processed based on the streaming control data to obtain the processing result.
[0137] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.
[0138] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.
[0139] Embodiments of this application also provide a computer program that includes computer instructions stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps in any of the above method embodiments.
[0140] Optionally, in this embodiment, the processor may be configured to perform the following steps according to a computer program:
[0141] S1, upon receiving a business request from the target object, a first processing request is sent to the business processing model, and the streaming control data fed back by the business processing model based on the first processing request is received.
[0142] S2, if it is determined that the preset control data conditions are met based on the streaming control data, a second processing request is sent to the service processing model;
[0143] S3, Receive streaming fragmented data fed back by the service processing model based on the second processing request;
[0144] S4, The streaming segmented data is processed based on the streaming control data to obtain the processing result.
[0145] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0146] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular hardware and software combination.
[0147] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.
Claims
1. A method for processing streaming data, characterized in that, include: Upon receiving a business request from the target object, a first processing request is sent to the business processing model, and streaming control data is received from the business processing model based on the first processing request. If the preset control data conditions are met based on the streaming control data, a second processing request is sent to the service processing model. Receive streaming fragmented data fed back by the business processing model based on the second processing request; The streaming control data is used to process the streaming fragmented data to obtain the processing result.
2. The method according to claim 1, characterized in that, Receiving streaming control data fed back by the service processing model based on the first processing request includes: Receive the fragmentation control data fed back by the service processing model based on the first processing request; When the predefined state machine is in the declaration state, the fragmented control data is stored in a predefined storage object; If the fragmented control data in the storage object meets the preset data integrity conditions, the fragmented control data in the storage object is accumulated to obtain streaming control data.
3. The method according to claim 1, characterized in that, If, based on the streaming control data, it is determined that preset control data conditions are met, a second processing request is sent to the service processing model, including: Obtain the whitelist field corresponding to the business request; Parse the streaming control data and extract the control fields from the streaming control data; The control field is matched with the whitelist field. If the first matching result indicates that the control field meets the preset field conditions, an execution confirmation signal is constructed based on the streaming control data. Based on the execution confirmation signal, a second processing request is sent to the business processing model to instruct the business processing model to return streaming fragmented data.
4. The method according to claim 1, characterized in that, Based on the streaming control data, each of the streaming data segments is processed to obtain the processing results, including: When the predefined state machine is in the receiving state, extract the data type field from the streaming control data; The target type identifier of the data type field is matched with a preset type mapping table to determine the target output channel corresponding to the target type identifier; The streaming fragment data is transmitted to the target output channel, and a rendering component corresponding to the target output channel is determined. The streaming fragment data is then previewed based on the rendering component.
5. The method according to claim 4, characterized in that, After transmitting the streaming fragmented data to the target output channel, the method further includes: Based on the target type identifier of the data type field, determine the data buffer that matches the target type identifier; The streaming fragment data is transmitted to the data buffer to accumulate the streaming fragment data in the data buffer, thereby obtaining the accumulated streaming fragment data.
6. The method according to claim 1, characterized in that, The processing of the streaming fragmented data based on the target control data to obtain the processing result also includes: When the predefined state machine is in the receive complete state, extract the verification field from the streaming control data; Based on the validator identifier of the verification field, a validator instance matching the validator identifier is searched in a preset validator instance table; Based on the verifier instance, structural verification and semantic compliance verification are performed on the accumulated streaming fragmented data in the data buffer to obtain the first verification result and the second verification result. The verification result is determined based on the first verification result and the second verification result.
7. The method according to claim 6, characterized in that, After determining the verification result based on the first verification result and the second verification result, the method further includes: If the verification result indicates that the verification failed, the receiving completion status will be updated to the repair status; In the repair state, the repair field is extracted from the streaming control data; Based on the verification result, the corresponding target repair strategy is matched in the repair strategy mapping table associated with the repair field; The accumulated streaming fragment data in the data buffer is repaired based on the target repair strategy.
8. The method according to claim 7, characterized in that, Repairing the accumulated streaming fragment data in the data buffer based on the target repair strategy includes: When the target repair strategy includes a rewrite strategy, a rewrite request is generated and sent to the business processing model based on the accumulated streaming fragmented data in the data buffer; subsequent fragmented data generated by the business processing model based on the rewrite request is received, and the subsequent fragmented data is transmitted to the data buffer. When the target repair strategy includes a replacement strategy, the accumulated streaming fragment data in the data buffer is cleared, and a prompt word is constructed based on the verification result. A retry request is generated based on the prompt word and sent to the business processing model. The new streaming fragment data generated by the business processing model based on the retry request is received, and the new streaming fragment data is written into the data buffer. If the target repair strategy includes an end-padding strategy, an end marker is added to the data buffer.
9. The method according to claim 6, characterized in that, The method further includes: If the verification result indicates that the verification was successful, the state of the semantic state machine is updated from the receiving completed state to the verification successful state. In the successful verification state, the intent field is extracted from the streaming control data; Based on the intent identifier of the intent field, a matching is performed in a preset submission strategy mapping table to determine the submission strategy corresponding to the intent identifier; The submitted data is processed by submitting the accumulated streaming fragments in the data buffer based on the submitted strategy.
10. A streaming data processing apparatus, characterized in that, include: The first processing module is used to send a first processing request to the business processing model when a business request from the target object is received, and to receive streaming control data fed back by the business processing model based on the first processing request. The sending module is used to send a second processing request to the service processing model when it is determined that the preset control data conditions are met based on the streaming control data; The receiving module is used to receive the streaming fragmented data fed back by the business processing model based on the second processing request; The second processing module is used to process the streaming fragment data based on the streaming control data to obtain the processing result.
11. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to perform the method according to any one of claims 1 to 9.
