Large-model front-end dialogue interaction method, system and device and storage medium
By employing streaming POST requests and buffered queue parsing technology, the semantic coherence and real-time issues in large-scale model dialogue interactions are resolved, achieving efficient data transmission and a user-friendly interface experience, suitable for scenarios such as intelligent customer service and online education.
Patent Information
- Application Number
- CN202510684611.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-10-31
AI Technical Summary
Existing large-scale model dialogue interaction technologies suffer from semantic coherence loss, waiting delays, lag caused by data packet reassembly, and interface jitter, making it impossible to achieve real-time and natural human-like dialogue.
The system uses streaming POST requests to encapsulate prompts and historical dialogue text. Through a buffer queue and recursive parsing mechanism, combined with adaptive scrollbar adjustment, it achieves data processing that generates and transmits data simultaneously.
It achieves coherence and real-time response for large models, reduces first-word response time by more than 80%, provides stable output and improves the user reading experience, and is compatible with the HTTP/2 protocol without requiring modifications to the existing architecture.
Smart Images

Figure CN120873109A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence technology, specifically relating to a front-end dialogue interaction method, system, device, and storage medium for a large model. Background Technology
[0002] In existing large-scale dialogue interaction technologies, the front end typically adopts the following two mainstream solutions: one is to obtain the complete response by periodically refreshing the HTTP request based on short polling; the other is to use the SSE (Server-Sent Events) protocol to implement one-way data stream push.
[0003] These solutions suffer from three significant drawbacks: First, traditional EventSources only support GET requests and cannot carry dynamic historical session context, leading to a loss of semantic coherence in multi-turn conversations. Second, the full response transmission mode in JSON format introduces "waiting latency," requiring users to wait for all computations to complete before seeing the results when large models generate long texts. Finally, existing technologies lack dynamic rendering optimization mechanisms, easily resulting in user experience issues such as scroll bar jitter and cursor drift when outputting text word by word. Furthermore, when the response data volume exceeds the TCP window size, existing solutions experience stuttering due to packet reassembly, which significantly falls short of users' expectations for real-time "human-like dialogue." Summary of the Invention
[0004] In view of the above-mentioned shortcomings of the prior art, the present invention provides a front-end dialogue interaction method, system, device and storage medium for large models to solve the above-mentioned technical problems.
[0005] In a first aspect, the present invention provides a front-end dialogue interaction method for a large model, comprising: Obtain the prompt words and determine the historical dialogue text referenced by the prompt words; The prompt words and the historical dialogue text are encapsulated into a streaming POST request, and the streaming POST request is sent to the server, which is deployed with a large model; Obtain the response data generated by the large model returned by the server, and add the response data to the buffer queue; The response data in the buffer queue is recursively parsed to obtain the reply text; The reply text is rendered word by word in the dialog window, and the scroll bar of the dialog window is adaptively adjusted.
[0006] In one optional implementation, obtaining the prompt word and determining the historical dialogue text referenced by the prompt word includes: Get the suggestion word entered in the input box; Extract keywords from the prompts; The keywords are matched with historical dialogue content, and the matched historical dialogue content is output as the historical dialogue text referenced by the prompt words.
[0007] In one optional implementation, matching keywords with historical conversation content includes: A sliding window is used to divide the history of conversations into multiple text blocks; A keyword directory is created for historical dialogue content, which records the dialogue location where each important word appears; Calculate the number of times a keyword appears in a text block; Calculate the relevance score between the keywords of the prompt words and the text block:
[0008] Among them, inverse document frequency:
[0009] IDF(q i ) is the keyword q i The inverse document frequency, f(q) i D) is the keyword q i The number of occurrences in text block D; avgdl represents the average length of all text blocks; k1 represents the parameter controlling word frequency saturation; b represents the parameter controlling document length normalization; N represents the total number of text blocks; n(q i ) indicates that the keyword q is included. i The number of text blocks; The text block with the highest relevance score is output as the matching text block.
[0010] In an optional implementation, the response data in the buffer queue is recursively parsed to obtain the response text, including: Perform anomaly detection on the response data in the buffer queue; Concatenate the response data that passed the anomaly detection in the buffer queue into a string; Use JSON.parse() to verify if the string can be parsed. If the string can be parsed, then parse the string into a reply text. If the string cannot be parsed, a boundary detection algorithm is used to identify the break points of the string and fill in the break points.
[0011] In one optional implementation, anomaly detection is performed on the response data in the buffer queue, including: Use the try-catch command to capture abnormal data in the response data.
[0012] In an optional implementation, the reply text is rendered word by word in the dialog window, and the scroll bar of the dialog window is adaptively adjusted, including: Based on Vue's reactive mechanism, combined with setInterval or request Animation Frame, the reply text can be displayed word by word; By monitoring the visible area height of the scrolling container, the current scroll position, and the total height of the content in real time, it can be determined whether the user is within the bottom threshold range of the container. If so, the scroll position will be automatically positioned to the latest bottom after the content is updated; If not, the scroll position offset will be dynamically adjusted based on the height of the newly added content.
[0013] In an optional implementation, the method further includes: The AbortController captures user-initiated interruption signals and controls the interruption of streaming requests based on these signals via the signal parameter.
[0014] Secondly, the present invention provides a large-scale front-end dialogue interaction system, comprising: The first processing module is used to acquire prompt words and determine the historical dialogue text referenced by the prompt words; The second processing module is used to encapsulate the prompt words and the historical dialogue text into a streaming POST request, and send the streaming POST request to the server, which is deployed with a large model; The third processing module is used to obtain the response data generated by the large model returned by the server and add the response data to the buffer queue; The fourth processing module is used to recursively parse the response data in the buffer queue to obtain the reply text; The visualization module is used to render the reply text word by word in the dialog window and adaptively adjust the scroll bar of the dialog window.
[0015] Thirdly, a device is provided, comprising: Memory, used to store the front-end dialogue interaction program of a large model; The processor is configured to implement the steps of the front-end dialogue interaction method for the large model as provided in the first aspect when executing the front-end dialogue interaction program of the large model.
[0016] Fourthly, a computer-readable storage medium is provided, on which a large-scale front-end dialogue interaction program is stored, wherein when the large-scale front-end dialogue interaction program is executed by a processor, the steps of the large-scale front-end dialogue interaction method provided in the first aspect are implemented.
[0017] The beneficial effects of this invention are as follows: The large-scale model front-end dialogue interaction method, system, device, and storage medium provided by this invention encapsulate prompts and historical dialogues through streaming POST requests, solving the deficiency of traditional EventSource in not supporting dynamic context, and making the generation of responses by large models more coherent. Employing streaming processing with simultaneous generation and transmission, users can see the output word by word in real time, reducing the first-word response time by more than 80% and completely eliminating the latency problem of waiting for a complete response in traditional solutions. Data integrity is ensured through buffer queues and recursive parsing mechanisms, ensuring stable output even with network fluctuations. Adaptive scrollbar adjustment technology avoids interface jitter, providing a reading experience comparable to real-person dialogue. The chunked transmission design reduces the amount of data in a single request, improving server resource utilization, while being compatible with the HTTP / 2 protocol, allowing deployment without modifying the existing architecture. This solution significantly improves the naturalness of interaction and system response efficiency in scenarios such as intelligent customer service and online education.
[0018] Furthermore, the design principle of this invention is reliable, the structure is simple, and it has a very wide range of application prospects. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic flowchart of a method according to an embodiment of the present invention.
[0021] Figure 2 This is a schematic diagram illustrating the principle of a method according to an embodiment of the present invention.
[0022] Figure 3 This is a schematic block diagram of a system according to an embodiment of the present invention.
[0023] Figure 4 This is a schematic diagram of the structure of a device provided in an embodiment of the present invention. Detailed Implementation
[0024] To enable those skilled in the art to better understand the technical solutions of this invention, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this invention.
[0025] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
[0026] The front-end dialogue interaction method for large models provided in this embodiment of the invention is executed by a computer device, and correspondingly, the front-end dialogue interaction system for large models runs on the computer device.
[0027] Figure 1 This is a schematic flowchart illustrating a method according to an embodiment of the present invention. Wherein, Figure 1 The executing entity can be a large-scale front-end dialogue interaction system. Depending on different needs, the order of the steps in this flowchart can be changed, and some can be omitted.
[0028] like Figure 1 As shown, the method includes: S1. Obtain the prompt word and determine the historical dialogue text referenced by the prompt word; S2. Encapsulate the prompt words and the historical dialogue text into a streaming POST request, and send the streaming POST request to the server, where a large model is deployed; S3. Obtain the response data generated by the large model returned by the server, and add the response data to the buffer queue; S4. Recursively parse the response data in the buffer queue to obtain the reply text; S5. Render the reply text word by word in the dialog window and adaptively adjust the scroll bar of the dialog window.
[0029] The following is combined with Figure 2 The technical solution of the present invention will be described.
[0030] In one embodiment of the present invention, based on step S1, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner.
[0031] S101. Get the prompt word entered in the input box.
[0032] Front-end implementation: Create input box elements in HTML, and use JavaScript to listen for input events (such as input, change, or submit); retrieve the input value using document.getElementById('inputId').value; consider adding debouncing to avoid frequently triggering backend requests.
[0033] Backend implementation: Receive the input content sent by the front end through the API interface; perform basic verification on the input content (such as length limit, special character filtering, etc.); optionally record the original input log (pay attention to privacy compliance).
[0034] S102. Extract keywords from the prompt.
[0035] Use a word segmentation tool (such as NLTK, jieba, etc.) to segment the text; remove stop words, such as "的", "了", "and", "the", etc.; extract the core word classes such as nouns and verbs as keywords.
[0036] Extract high-frequency meaningful words in the text based on the TF-IDF algorithm; use algorithms such as TextRank to identify key phrases in the text; combine with a domain dictionary to identify professional terms.
[0037] S103. Match the keywords with the historical conversation content and output the matched historical conversation content as the historical conversation text cited by the prompt.
[0038] Use a sliding window to divide the historical conversation content into multiple text blocks; cut a long conversation into logical paragraphs (such as every 3 exchanges as a unit), just like dividing a long article into chapters.
[0039] Build a keyword directory for the historical conversation content, which is used to record the conversation positions where each important word appears.
[0040] Calculate the number of occurrences of keywords in the text blocks.
[0041] Calculate the correlation score between the keywords of the prompt and the text blocks: <00,00147>
[0042] Among them, the inverse document frequency:
[0043] IDF(q i ) is the inverse document frequency of keyword q i , f(q i , D) is the number of occurrences of keyword q i in text block D; avgdl represents the average length of all text blocks; k1 represents a parameter for controlling the saturation of word frequency; b represents a parameter for controlling the normalization of document length; N represents the total number of text blocks; n(q i ) represents the number of text blocks containing keyword q i ; Calculate the weighted sum of the relevance scores of multiple keywords to the text block to obtain the comprehensive relevance score. Output the text block with the highest comprehensive relevance score as the matched text block.
[0044] In one embodiment of the present invention, based on step S2, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner.
[0045] The prompt and the historical dialogue text are encapsulated into a streaming POST request, and the streaming POST request is sent to a server, which is deployed with a large model.
[0046] By using fetch-event-source, streaming communication via POST requests is achieved during the session request process. Authentication parameters or multimodal parameters can be defined in the processing fields of the request header. Authentication parameters are authentication information required in the request, such as the Authentication field to transmit the token of the currently logged-in user. Other multimodal parameters, such as userId and deviceType, can be dynamically injected into the request headers. This overcomes the limitation of traditional EventSource, which only supports GET requests. EventSource cannot flexibly inject multiple parameters for large and complex streaming requests, and multi-parameter GET requests inevitably result in excessively long URLs, which are verbose, unfriendly, and cause high latency and slow requests.
[0047] In one embodiment of the present invention, based on step S3, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner.
[0048] Define an initial queue, bufferQueue, to store the data returned by the streaming request interface. The returned data is the response data of the large model.
[0049] In one embodiment of the present invention, based on step S4, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner.
[0050] S401. Perform anomaly detection on the response data in the buffer queue; Use try-catch blocks to wrap data processing logic and catch exceptions such as network interruption and data format errors. Implement custom exception types (such as InvalidFormatError, IncompleteDataError); Record exception logs (error type, timestamp, partial data content); Configure a retry mechanism (such as the exponential backoff algorithm) to handle temporary exceptions.
[0051] S402. Concatenate the response data that passed the anomaly detection in the buffer queue into a string.
[0052] Use the array's join() method to efficiently concatenate strings; maintain a processing progress pointer to avoid repeatedly concatenating already processed data; consider adding data separators (such as \n, \0) for subsequent processing.
[0053] S403. Use JSON.parse() to verify if the string can be parsed. If the string can be parsed, then parse the string into a reply text.
[0054] Wrap JSON.parse() in try-catch to catch parsing exceptions; implement defensive parsing (such as limiting parsing depth and filtering malicious content); and perform structural validation on the parsed data (such as checking whether necessary fields exist).
[0055] S404. If the string cannot be parsed, a boundary detection algorithm is used to identify the break points of the string and to fill in the break points.
[0056] Break point detection: Locate break points based on JSON syntax features (such as unclosed parentheses and quotation marks); use regular expressions to match incomplete JSON structures; implement state machine parsing to identify syntax error locations.
[0057] Data repair strategy: trace back to complete historical JSON samples and extract possible structural templates; predict missing closing symbols (such as ] and}) based on context; implement heuristic repair (such as filling in the most likely missing quotation marks).
[0058] Specifically, a front-end buffer queue and boundary detection algorithm are used to process streaming JSON fragments (such as incomplete text blocks) returned by large models. The received message data is added to the buffer queue. An initial queue, bufferQueue, is defined to store the data returned by the streaming request interface. Then, the data in this buffer queue is parsed. Here, try-catch is used to catch data exceptions. First, in the try block, parseJSON() is used to recursively parse the data in the buffer queue. If the stringified data value is valid, the success callback is executed, and then the buffer queue is cleared. In the catch block, the exception data is caught and returned, while the data in the buffer queue is retained, waiting for the next fragment. Next, let's discuss how to recursively parse the data in the buffer queue to ensure data integrity. This also uses a try-catch block for recursive parsing. First, the try block parses the JSON using JSON.parse(). The catch block catches exceptions. If parsing fails, it checks if the data is incomplete. Based on the error message, if the data is incomplete and more data hasn't been loaded, it returns null; otherwise, it throws an exception due to other errors. This recursive parsing ensures data integrity and avoids semantic errors caused by truncation.
[0059] In one embodiment of the present invention, based on step S5, a possible embodiment will be given below, and its specific implementation will be described in a non-limiting manner.
[0060] S501. Based on Vue's reactive mechanism, combined with setInterval or request Animation Frame, the reply text is displayed word by word.
[0061] This implementation uses the reactive mechanism of the Vue front-end framework to display text character by character. Of course, if the React framework is used, text character by character can also be displayed. The following is a specific implementation scheme that uses Vue's reactive mechanism and setInterval or requestAnimationFrame to display text character by character. First, the data is defined to be displayed. The mounted hook function starts text character by character after the component is mounted. Define a method that recursively setsTimeout to output one character every 100 milliseconds until the complete text content is output.
[0062] S502. By monitoring the visible area height of the scrolling container, the current scroll position, and the total height of the content in real time, determine whether the user is within the bottom threshold range of the container: if yes, automatically position the scroll position to the latest bottom after the content is updated; if no, dynamically adjust the scroll position offset according to the height of the newly added content.
[0063] To maintain user focus through automatic scrolling and repositioning, this solution utilizes JavaScript to manipulate DOM elements and listen for relevant events. In the HTML, a vertically scrollable box element, `#content`, with a fixed height, is defined to display the content returned from the main model. A button is included; clicking it calls the `appendNewContent` function to simulate adding content. In the JavaScript, `appendNewContent` creates a new content paragraph and adds it to `#content`. By obtaining the current viewport height, the scroll position of the scroll container, and the content height, it determines if the user is near the bottom of the scroll container. If so, the scroll position is set to the bottom after new content is added; otherwise, the scroll position is adjusted based on the height of the newly added content to maintain the user's relative focus position. Of course, if using a front-end framework (Vue or React, etc.), adjustments need to be made according to the framework's syntax rules and the actual application scenario. Essentially, scrolling is performed after obtaining the current DOM element to maintain user focus.
[0064] S503. Capture the user-initiated interrupt signal through AbortController, and control the interruption of streaming requests based on the user-initiated interrupt signal through the signal parameter.
[0065] By capturing user-initiated interruption signals through AbortController, server-side computation tasks are synchronously terminated, reducing resource waste and supporting breakpoint resumption (e.g., resuming generation from a previous breakpoint when a user asks a new question). The specific implementation is as follows: The interruption of streaming requests is controlled via the `signal` parameter, which is an `AbortController` signal used to control the interruption of streaming requests. It allows developers to actively terminate ongoing streaming requests (e.g., when a user cancels an operation or when resources are cleaned up during component unloading), and is the core mechanism for managing interruption control in large-scale front-end model interactions. An interruption signal is passed to `fetchEventSource` via `AbortController.signal` to achieve active termination of the request. An `AbortError` is triggered upon interruption, which can be captured and handled in the `onerror` callback. This avoids the background continuously consuming server resources when the user switches pages or cancels an operation, and also prevents memory leaks caused by incomplete requests after React / Vue components are unloaded. This project is based on the Vue framework for developing a large model, so it uses the basic syntax of Vue. First, you need to import fetchEventSource, then create an AbortController instance, instantiate the controller, and then initiate a streaming request. Here, the POST request method is used, setting the method to POST and the signal value to the signal of the previously instantiated controller. The interrupt signal is bound, and then the connection is established to process the streaming data.For example, during a communication session with a large model, if a temporary pause is needed, a Controller can be used. The pause flag returned by the backend interface is used to determine whether to suspend the current session. Then, `controller.abort()` is called to pause the current data output, saving the content at the breakpoint. This allows for continued UI output to resume from where it left off when resuming. This is breakpoint resumption in large model sessions. Another use case is multi-request race condition control. In multi-request scenarios, this is also used. First, the current request variable `currentController` is initialized. Then, in the message sending definition method, `currentController.abort()` is used to terminate the previous request. A new controller is defined in the `fetch` parameter of the new request to continue executing the new request, achieving multi-request race condition control. However, a performance optimization issue must be considered here: avoid frequently creating `AbortController` instances, which can impact UI performance. Controllers should be reused as much as possible to optimize frontend performance. Furthermore, it can be combined with the `openWhenHidden:false` configuration to automatically pause the current streaming when the page switches to the background. The proper use of signals can enable fine-grained request control in large-scale session interactions, thereby improving the user experience and system robustness.
[0066] In some embodiments, the large-scale front-end dialogue interaction system may include multiple functional modules composed of computer program segments. The computer programs for each program segment in the large-scale front-end dialogue interaction system may be stored in the memory of a computer device and executed by at least one processor to perform (see details). Figure 1 (Description) The front-end dialogue interaction functionality of the large model.
[0067] In this embodiment, the front-end dialogue interaction system of the large model can be divided into multiple functional modules according to the functions it performs, such as... Figure 3 As shown. The module referred to in this invention is a series of computer program segments that can be executed by at least one processor and perform a fixed function, and is stored in memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0068] The first processing module is used to acquire prompt words and determine the historical dialogue text referenced by the prompt words; The second processing module is used to encapsulate the prompt words and the historical dialogue text into a streaming POST request, and send the streaming POST request to the server, which is deployed with a large model; The third processing module is used to obtain the response data generated by the large model returned by the server and add the response data to the buffer queue; The fourth processing module is used to recursively parse the response data in the buffer queue to obtain the reply text; The visualization module is used to render the reply text word by word in the dialog window and adaptively adjust the scroll bar of the dialog window.
[0069] Figure 4 The large-scale front-end dialogue interaction method provided in the embodiments of this application can be applied to devices. Those skilled in the art will understand that the device structures involved in the embodiments of this invention do not constitute a limitation on the device. A device may include more or fewer components than illustrated, or combine certain components, or have different component arrangements. In the embodiments of this invention, the device includes, but is not limited to, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of this application described and / or claimed herein.
[0070] The device 400 may include a processor 410, a memory 420, and a communication unit 430. These components communicate via one or more buses. Those skilled in the art will understand that the server structure shown in the figure does not constitute a limitation of the present invention. It may be a bus topology or a star topology, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0071] The memory 420 can be used to store execution instructions of the processor 410. The memory 420 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. When the execution instructions in the memory 420 are executed by the processor 410, the device 400 is able to perform some or all of the steps in the above method embodiments.
[0072] The processor 410 serves as the control center of the storage device, connecting various parts of the electronic device via various interfaces and lines. It executes software programs and / or modules stored in the memory 420, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of integrated circuits (ICs), such as a single packaged IC or multiple packaged ICs with the same or different functions connected together. For example, the processor 410 may consist only of a central processing unit (CPU). In this embodiment of the invention, the CPU may have a single processing core or include multiple processing cores.
[0073] The communication unit 430 is used to establish a communication channel, enabling the storage device to communicate with other devices. It can receive user data sent by other devices or send user data to other devices.
[0074] The present invention also provides a computer storage medium, wherein the computer storage medium may store a program, which, when executed, may include some or all of the steps provided in the embodiments of the present invention. The storage medium may be a magnetic disk, an optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0075] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or any other medium capable of storing program code. It includes several instructions to cause a computer device (which may be a personal computer, a server, or a second device, network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0076] The same or similar parts between the various embodiments in this specification can be referred to mutually. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple, and the relevant parts can be referred to the description in the method embodiments.
[0077] In the embodiments provided by this invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between systems or modules may be electrical, mechanical, or other forms.
[0078] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0079] In addition, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0080] Although the present invention has been described in detail with reference to the accompanying drawings and preferred embodiments, the present invention is not limited thereto. Various equivalent modifications or substitutions can be made to the embodiments of the present invention by those skilled in the art without departing from the spirit and essence of the invention, and such modifications or substitutions should all be within the scope of the present invention. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should also be covered within the protection scope of the present invention.
Claims
1. A front-end dialogue interaction method for a large model, characterized in that, include: Obtain the prompt words and determine the historical dialogue text referenced by the prompt words; The prompt words and the historical dialogue text are encapsulated into a streaming POST request, and the streaming POST request is sent to the server, which is deployed with a large model; Obtain the response data generated by the large model returned by the server, and add the response data to the buffer queue; The response data in the buffer queue is recursively parsed to obtain the reply text; The reply text is rendered word by word in the dialog window, and the scroll bar of the dialog window is adaptively adjusted.
2. The method according to claim 1, characterized in that, Obtain the prompt words and determine the historical dialogue text referenced by the prompt words, including: Get the suggestion word entered in the input box; Extract keywords from the prompts; The keywords are matched with historical dialogue content, and the matched historical dialogue content is output as the historical dialogue text referenced by the prompt words.
3. The method according to claim 2, characterized in that, Match keywords with historical conversation content, including: A sliding window is used to divide the history of conversations into multiple text blocks; A keyword directory is created for historical dialogue content, which records the dialogue location where each important word appears; Calculate the number of times a keyword appears in a text block; Calculate the relevance score between the keywords of the prompt words and the text block: Among them, inverse document frequency: IDF(q i ) is the keyword q i The inverse document frequency, f(q) i D) is the keyword q i The number of occurrences in text block D; avgdl represents the average length of all text blocks; k1 represents the parameter controlling word frequency saturation; b represents the parameter controlling document length normalization; N represents the total number of text blocks; n(q i ) indicates that the keyword q is included. i The number of text blocks; The text block with the highest relevance score is output as the matching text block.
4. The method according to claim 1, characterized in that, The response data in the buffer queue is recursively parsed to obtain the response text, including: Perform anomaly detection on the response data in the buffer queue; Concatenate the response data that passed the anomaly detection in the buffer queue into a string; Use a validation function to verify whether the string can be parsed. If the string can be parsed, then parse the string into a response text. If the string cannot be parsed, a boundary detection algorithm is used to identify the break points of the string and fill in the break points.
5. The method according to claim 4, characterized in that, Perform anomaly detection on the response data in the buffer queue, including: Use the try-catch command to capture abnormal data in the response data.
6. The method according to claim 1, characterized in that, The response text is rendered word by word in the dialog window, and the scroll bar of the dialog window is adaptively adjusted, including: Based on Vue's reactive mechanism, combined with setInterval or request Animation Frame, the reply text can be displayed word by word; By monitoring the visible area height of the scrolling container, the current scroll position, and the total height of the content in real time, it can be determined whether the user is within the bottom threshold range of the container. If so, the scroll position will be automatically positioned to the latest bottom after the content is updated; If not, the scroll position offset will be dynamically adjusted based on the height of the newly added content.
7. The method according to claim 1, characterized in that, The method further includes: The AbortController captures user-initiated interruption signals and controls the interruption of streaming requests based on these signals via the signal parameter.
8. A large-scale front-end dialogue interaction system, characterized in that, include: The first processing module is used to acquire prompt words and determine the historical dialogue text referenced by the prompt words; The second processing module is used to encapsulate the prompt words and the historical dialogue text into a streaming POST request, and send the streaming POST request to the server, which is deployed with a large model; The third processing module is used to obtain the response data generated by the large model returned by the server and add the response data to the buffer queue; The fourth processing module is used to recursively parse the response data in the buffer queue to obtain the reply text; The visualization module is used to render the reply text word by word in the dialog window and adaptively adjust the scroll bar of the dialog window.
9. A device, characterized in that, include: Memory, used to store the front-end dialogue interaction program of a large model; A processor, configured to implement the steps of the front-end dialogue interaction method for the large model as described in any one of claims 1-7 when executing the front-end dialogue interaction program of the large model.
10. A computer-readable storage medium storing a computer program, characterized in that, The readable storage medium stores a front-end dialogue interaction program for a large model, which, when executed by a processor, implements the steps of the front-end dialogue interaction method for a large model as described in any one of claims 1-7.
Citation Information
Cited By
Adaptive buffer management method, system and device for streaming response, medium and program product
CN121660095A
Front-end interaction method, system and device based on artificial intelligence, medium and product
CN121680696A
AI interactive element real-time rendering and back-end collaboration methods, systems, devices and program products
CN121704839A