Streaming communication method and device based on long connection and computer equipment
By establishing a long SSE connection between the server and the big model and establishing a long WebSocket connection between the client and the server, two-way streaming communication between the client and the big model is realized, solving the problems of high latency and unstable connection in real-time conversations by traditional HTTP protocol, and improving communication efficiency and real-time performance.
Patent Information
- Application Number
- CN202411820808.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-18
AI Technical Summary
The traditional HTTP protocol has problems such as high latency and unstable connection when handling real-time conversations, which is difficult to meet the needs of streaming conversations.
The long connection-based streaming communication method is adopted, and a long SSE connection between the server and the big model is established, and a long WebSocket connection between the client and the server is established to realize bidirectional streaming communication between the client and the big model.
Improves communication efficiency and real-time between the client and the big model, providing a smoother conversation experience.
Smart Images

Figure CN119652952A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a streaming communication method, device and computer equipment based on a long connection. Background Art
[0002] With the rapid development of artificial intelligence technology, large models (such as the GPT series, BERT series, etc.) are increasingly used in the field of natural language processing, providing users with a more intelligent and smooth conversation experience. However, the traditional HTTP protocol has problems such as high latency and unstable connection when processing real-time conversations, making it difficult to meet the needs of streaming conversations. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a streaming communication method, device and computer equipment based on long connection, aiming to improve the interaction efficiency between the client and the large model.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is: a streaming communication method based on a long connection, comprising:
[0005] S10. When the server is started, an SSE long connection is established between the server and the large model;
[0006] S20, establishing a WebSocket persistent connection between the client and the server;
[0007] S30, the client sends the user dialogue text entered by the user with the big model to the server through the WebSocket persistent connection;
[0008] S40, the server receives the user conversation text from the client, processes the user conversation text, generates a corresponding data request, and sends the data request to the big model through the SSE long connection;
[0009] S50, the large model receives the data request, processes the data request, and transmits the model output information back to the server through the SSE long connection;
[0010] S60: The server receives the model output information, processes it, generates a corresponding response message, and sends the response message to the client through the WebSocket long connection.
[0011] Furthermore, in step S10, establishing an SSE long connection between the server and the large model includes:
[0012] S11. The server sends a request to the large model to create an SSE long connection thread;
[0013] S12. The large model establishes an SSE persistent connection with the server according to the request, and returns a message indicating that the SSE persistent connection has been successfully created to the server.
[0014] Furthermore, in step S10, establishing an SSE long connection between the server and the large model includes:
[0015] S13. Create an SSE heartbeat monitoring thread to monitor the SSE persistent connection heartbeat. If the SSE persistent connection heartbeat is not monitored for more than a preset number of times, the server resends a request to create an SSE persistent connection thread to the large model.
[0016] Furthermore, in step S20, establishing a WebSocket persistent connection between the client and the server includes:
[0017] S21, the client calls the server interface to obtain a token;
[0018] S22. The client sends a request to the server to create a WebSocket persistent connection and verify the binding token.
[0019] S23. The server establishes a WebSocket persistent connection with the client according to the request, and returns a message to the client indicating that the WebSocket persistent connection has been successfully established.
[0020] Furthermore, the streaming communication method based on the long connection also includes:
[0021] The large model temporarily stores each returned message, and the temporarily stored message uses sessionId+talkId as the key;
[0022] After the client determines that the WebSocket persistent connection is disconnected, it reconnects the WebSocket persistent connection, passes in the talkId, and checks whether the corresponding message exists in the cache. If it exists, it returns the message to the client.
[0023] Furthermore, the streaming communication method based on the long connection also includes:
[0024] If the server detects that the current server has a WebSocket persistent connection corresponding to the sessionID in the message, it returns it to the client through the WebSocket persistent connection;
[0025] If the server cannot detect a WebSocket persistent connection, it will cache messages using sessionId as the key;
[0026] When the client and the server reconnect to a WebSocket persistent connection, the server detects that the sessionId used to create the WebSocket persistent connection parameter is not empty and considers it as a reconnection. The server then searches the cache for the sessionId and, if found, broadcasts a message to all servers to find the server for the WebSocket persistent connection recreated by the client and returns it from the cache.
[0027] Furthermore, the streaming communication method based on the long connection also includes:
[0028] If the WebSocket persistent connection between the client and the server is disconnected, the large model has returned all the information to the server, and the server has temporarily stored it. When the client and the server reconnect through the WebSocket persistent connection, the client transmits talkId, and the server checks the cache based on sessionId+talkId to see if the message exists. If so, it is returned to the client.
[0029] If the WebSocket persistent connection between the client and the server is disconnected and the big model has not returned a message to the server, the WebSocket persistent connection is reconnected to the new server. The big model returns a message to the old server on the server side. The server broadcasts the message to all servers. When the new server finds that the current WebSocket persistent connection exists, it returns a message to the client.
[0030] If the WebSocket persistent connection between the client and the server is disconnected, the large model returns half of the message to the server. When the WebSocket persistent connection is reconnected, the client transmits talkId to retrieve cached data, and the large model returns the second half of the information for cache and broadcast.
[0031] The present invention also provides a streaming communication device based on a long connection, comprising:
[0032] The SSE long connection establishment module is used to establish an SSE long connection between the server and the large model when the server is started;
[0033] WebSocket persistent connection establishment module, used to establish a WebSocket persistent connection between the client and the server;
[0034] The dialogue text sending module is used by the client to send the user dialogue text entered by the user with the big model to the server through the WebSocket long connection;
[0035] The data request module is used for the server to receive the user conversation text from the client, process the user conversation text, generate the corresponding data request, and send the data request to the big model through the SSE long connection;
[0036] The model output module is used for the large model to receive data requests, process the data requests, and transmit the model output information back to the server through the SSE long connection;
[0037] The message return module is used for the server to receive the model output information for processing, generate the corresponding response message, and send the response message to the client through the WebSocket long connection.
[0038] The present invention also provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the streaming communication method based on long connection as described above is implemented.
[0039] The present invention also provides a storage medium storing a computer program, which can implement the above-mentioned streaming communication method based on long connection when executed by a processor.
[0040] The beneficial effects of the present invention are: combining the advantages of WebSocket and SSE, realizing two-way streaming communication between the client and the server, and between the server and the large model, and improving the communication efficiency and real-time performance between the client and the large model. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The specific structure of the present invention is described in detail below in conjunction with the accompanying drawings.
[0042] Figure 1 This is a flow chart of a streaming communication method based on a long connection according to an embodiment of the present invention;
[0043] Figure 2 A flowchart for establishing an SSE long connection according to an embodiment of the present invention;
[0044] Figure 3 A flowchart for establishing a WebSocket persistent connection according to an embodiment of the present invention;
[0045] Figure 4 A module block diagram of a streaming communication device based on a long connection according to an embodiment of the present invention;
[0046] Figure 5 A schematic block diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0049] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0050] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0051] Terminology explanation:
[0052] WebSocket: A protocol for full-duplex communication over a single TCP connection, suitable for scenarios that require two-way communication.
[0053] Server-Sent Events (SSE): A protocol that allows the server to push real-time updated data to the client, suitable for one-way communication scenarios.
[0054] Large model: refers to a deep learning model with a large number of parameters and complex structure, such as the GPT series, BERT series, etc., which is used to process complex tasks such as natural language.
[0055] Streaming dialogue: refers to the process of achieving continuous and dynamic dialogue between users and models through real-time data transmission.
[0056] The first embodiment of the present invention is: a streaming communication method based on a long connection, comprising the steps of:
[0057] S10. When the server is started, an SSE long connection is established between the server and the large model.
[0058] Among them, Figure 2 As shown, step S10 specifically includes:
[0059] S11. The server sends a request to the large model to create an SSE long connection thread;
[0060] S12. The large model establishes an SSE persistent connection with the server according to the request, and returns a message indicating that the SSE persistent connection has been successfully created to the server;
[0061] S13. Create an SSE heartbeat monitoring thread to monitor the SSE persistent connection heartbeat. If the SSE persistent connection heartbeat is not monitored for more than a preset number of times, the server resends a request to create an SSE persistent connection thread to the large model.
[0062] S20. Establish a WebSocket persistent connection between the client and the server.
[0063] Among them, Figure 3 As shown, step S20 specifically includes:
[0064] S21, the client calls the server interface to obtain a token;
[0065] S22. The client sends a request to the server to create a WebSocket persistent connection and verify the binding token.
[0066] S23. The server establishes a WebSocket persistent connection with the client according to the request, and returns a message to the client indicating that the WebSocket persistent connection has been successfully established.
[0067] S30. The client sends the user dialogue text entered by the user with the big model to the server through the WebSocket long connection.
[0068] S40: The server receives the user conversation text from the client, processes the user conversation text, generates a corresponding data request, and sends the data request to the large model through an SSE long connection.
[0069] S50: The large model receives the data request, processes the data request, and transmits the model output information back to the server through the SSE long connection.
[0070] S60: The server receives the model output information, processes it, generates a corresponding response message, and sends the response message to the client through the WebSocket long connection.
[0071] In this embodiment, the advantages of WebSocket and SSE are combined to achieve two-way streaming communication between the client and the server, and between the server and the big model, thereby improving the communication efficiency and real-time performance between the client and the big model.
[0072] In a specific embodiment, the streaming communication method based on a long connection further includes:
[0073] The large model temporarily stores each returned message, and the stored messages use sessionId+talkId as the key;
[0074] After the client determines that the WebSocket persistent connection is disconnected, it reconnects the WebSocket persistent connection, passes in the talkId, and checks whether the corresponding message exists in the cache. If it exists, it returns the message to the client.
[0075] In a specific embodiment, the streaming communication method based on a long connection further includes:
[0076] If the server detects that the current server has a WebSocket persistent connection corresponding to the sessionID in the message, it returns it to the client through the WebSocket persistent connection;
[0077] If the server cannot detect the WebSocket persistent connection, it will cache the message using sessionId as the key;
[0078] When the client and the server reconnect a WebSocket persistent connection, the server detects that the sessionId used to create the WebSocket persistent connection parameter is not empty and regards it as a reconnection. It then searches the cache for the sessionId and, if found, broadcasts a message to all servers to find the server for the WebSocket persistent connection recreated by the client and returns it from the cache.
[0079] In a specific embodiment, the streaming communication method based on a long connection further includes:
[0080] If the WebSocket persistent connection between the client and the server is disconnected, the large model has returned all the information to the server, and the server has temporarily stored it. When the client and the server reconnect through the WebSocket persistent connection, the client transmits talkId, and the server checks the cache based on sessionId+talkId to see if the message exists. If so, it returns it to the client.
[0081] If the WebSocket persistent connection between the client and the server is disconnected and the big model has not returned a message to the server, the WebSocket persistent connection is reconnected to the new server. The big model returns a message to the old server on the server side. The server broadcasts the message to all servers. When the new server finds that the current WebSocket persistent connection exists, it returns a message to the client.
[0082] If the WebSocket persistent connection between the client and the server is disconnected, the large model returns half of the message to the server. When the WebSocket persistent connection is reconnected, the client transmits talkId to retrieve cached data, and the large model returns the second half of the information for cache and broadcast.
[0083] In summary, the technical effects of the technical solution of this application are:
[0084] Improve communication efficiency and real-time performance: By optimizing the communication mechanisms of WebSocket and SSE, efficient two-way streaming communication is achieved, which improves communication efficiency and real-time performance, and provides users with a smoother conversation experience.
[0085] Enhanced data synchronization and consistency: By introducing intelligent data synchronization strategies and disconnection and reconnection strategies, the consistency and integrity of data between different communication links are ensured, and the continuity and accuracy of conversations are improved.
[0086] Improve system scalability and maintainability: The modular architecture design reduces system complexity, improves system scalability and maintainability, and provides strong support for future business expansion and system upgrades.
[0087] like Figure 4 As shown, an embodiment of the present invention further provides a streaming communication device based on a long connection, comprising:
[0088] The SSE long connection establishment module 10 is used to establish an SSE long connection between the server and the large model when the server is started;
[0089] A WebSocket persistent connection establishing module 20 is used to establish a WebSocket persistent connection between the client and the server;
[0090] The conversation text sending module 30 is used for the client to send the user conversation text input by the user with the big model to the server through the WebSocket long connection;
[0091] Data request module 40, used for receiving the user dialogue text from the client at the server end, processing the user dialogue text, generating a corresponding data request, and sending the data request to the large model through an SSE long connection;
[0092] Model output module 50, used for receiving data requests from the large model, processing the data requests, and transmitting the model output information back to the server through the SSE long connection;
[0093] The message return module 60 is used for the server to receive the model output information for processing, generate a corresponding response message, and send the response message to the client through the WebSocket long connection.
[0094] In a specific embodiment, the streaming communication device based on the long connection further includes: a first disconnection processing module, specifically configured to:
[0095] The large model temporarily stores each returned message, and the stored messages use sessionId+talkId as the key;
[0096] After the client determines that the WebSocket persistent connection is disconnected, it reconnects the WebSocket persistent connection, passes in the talkId, and checks whether the corresponding message exists in the cache. If it exists, it returns the message to the client.
[0097] In a specific embodiment, the streaming communication device based on the long connection further includes: a second disconnection processing module, specifically configured to:
[0098] If the server detects that the current server has a WebSocket persistent connection corresponding to the sessionID in the message, it returns it to the client through the WebSocket persistent connection;
[0099] If the server cannot detect the WebSocket persistent connection, it will cache the message using sessionId as the key;
[0100] When the client and the server reconnect a WebSocket persistent connection, the server detects that the sessionId used to create the WebSocket persistent connection parameter is not empty and regards it as a reconnection. It then searches the cache for the sessionId and, if found, broadcasts a message to all servers to find the server for the WebSocket persistent connection recreated by the client and returns it from the cache.
[0101] In a specific embodiment, the streaming communication device based on the long connection further includes: a third disconnection processing module, specifically configured to:
[0102] If the WebSocket persistent connection between the client and the server is disconnected, the large model has returned all the information to the server, and the server has temporarily stored it. When the client and the server reconnect through the WebSocket persistent connection, the client transmits talkId, and the server checks the cache based on sessionId+talkId to see if the message exists. If so, it returns it to the client.
[0103] If the WebSocket persistent connection between the client and the server is disconnected and the big model has not returned a message to the server, the WebSocket persistent connection is reconnected to the new server. The big model returns a message to the old server on the server side. The server broadcasts the message to all servers. When the new server finds that the current WebSocket persistent connection exists, it returns a message to the client.
[0104] If the WebSocket persistent connection between the client and the server is disconnected, the large model returns half of the message to the server. When the WebSocket persistent connection is reconnected, the client transmits talkId to retrieve cached data, and the large model returns the second half of the information for cache and broadcast.
[0105] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned streaming communication device based on long connection can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.
[0106] The above-mentioned streaming communication device based on long connection can be implemented in the form of a computer program. The computer program can be used in Figure 5 Runs on the computer device shown.
[0107] See also Figure 5 , Figure 5 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.
[0108] See also Figure 5 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0109] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 may execute a streaming communication method based on a long connection.
[0110] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0111] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a streaming communication method based on a long connection.
[0112] The network interface 505 is used to communicate with other devices over the network. Figure 5 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0113] The processor 502 is used to run the computer program 5032 stored in the memory to implement the streaming communication method based on the long connection as described above.
[0114] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0115] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0116] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the streaming communication method based on a long connection as described above.
[0117] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, or any other computer-readable storage medium that can store program codes.
[0118] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0119] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0120] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0121] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0122] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A streaming communication method based on a long connection, characterized in that: include: S10. When the server is started, an SSE long connection is established between the server and the large model; S20, establishing a WebSocket persistent connection between the client and the server; S30, the client sends the user dialogue text entered by the user with the big model to the server through the WebSocket persistent connection; S40, the server receives the user conversation text from the client, processes the user conversation text, generates a corresponding data request, and sends the data request to the big model through the SSE long connection; S50, the large model receives the data request, processes the data request, and transmits the model output information back to the server through the SSE long connection; S60: The server receives the model output information, processes it, generates a corresponding response message, and sends the response message to the client through the WebSocket long connection.
2. The streaming communication method based on long connection according to claim 1, characterized in that: In step S10, establishing an SSE long connection between the server and the large model includes: S11. The server sends a request to the large model to create an SSE long connection thread; S12. The large model establishes an SSE persistent connection with the server according to the request, and returns a message indicating that the SSE persistent connection has been successfully created to the server.
3. The streaming communication method based on long connection according to claim 2, characterized in that: In step S10, establishing an SSE long connection between the server and the large model further includes: S13. Create an SSE heartbeat monitoring thread to monitor the SSE persistent connection heartbeat. If the SSE persistent connection heartbeat is not monitored for more than a preset number of times, the server resends a request to create an SSE persistent connection thread to the large model.
4. The streaming communication method based on long connection according to claim 1, characterized in that: In step S20, establishing a WebSocket persistent connection between the client and the server includes: S21, the client calls the server interface to obtain a token; S22. The client sends a request to the server to create a WebSocket persistent connection and verify the binding token. S23. The server establishes a WebSocket persistent connection with the client according to the request, and returns a message to the client indicating that the WebSocket persistent connection has been successfully established.
5. The streaming communication method based on long connection according to claim 1, characterized in that: Also includes: The large model temporarily stores each returned message, and the temporarily stored message uses sessionId+talkId as the key; After the client determines that the WebSocket persistent connection is disconnected, it reconnects the WebSocket persistent connection, passes in the talkId, and checks whether the corresponding message exists in the cache. If it exists, it returns the message to the client.
6. The streaming communication method based on long connection according to claim 5, characterized in that: Also includes: If the server detects that the current server has a WebSocket persistent connection corresponding to the sessionId in the message, it returns it to the client through the WebSocket persistent connection; If the server cannot detect a WebSocket persistent connection, it will cache messages using sessionId as the key; When the client and the server reconnect to a WebSocket persistent connection, the server detects that the sessionId used to create the WebSocket persistent connection parameter is not empty and considers it as a reconnection. The server then searches the cache for the sessionId and, if found, broadcasts a message to all servers to find the server for the WebSocket persistent connection recreated by the client and returns it from the cache.
7. The streaming communication method based on long connection according to claim 6, characterized in that: Also includes: If the WebSocket persistent connection between the client and the server is disconnected, the large model has returned all the information to the server, and the server has temporarily stored it. When the client and the server reconnect through the WebSocket persistent connection, the client transmits talkId, and the server checks the cache based on sessionId+talkId to see if the message exists. If so, it is returned to the client. If the WebSocket persistent connection between the client and the server is disconnected and the big model has not returned a message to the server, the WebSocket persistent connection is reconnected to the new server. The big model returns a message to the old server on the server side. The server broadcasts the message to all servers. When the new server finds that the current WebSocket persistent connection exists, it returns a message to the client. If the WebSocket persistent connection between the client and the server is disconnected, the large model returns half of the message to the server. When the WebSocket persistent connection is reconnected, the client transmits talkId to retrieve cached data, and the large model returns the second half of the information for cache and broadcast.
8. A streaming communication device based on a long connection, characterized in that: include: The SSE long connection establishment module is used to establish an SSE long connection between the server and the large model when the server is started; WebSocket persistent connection establishment module, used to establish a WebSocket persistent connection between the client and the server; The dialogue text sending module is used by the client to send the user dialogue text entered by the user with the big model to the server through the WebSocket long connection; The data request module is used for the server to receive the user conversation text from the client, process the user conversation text, generate the corresponding data request, and send the data request to the big model through the SSE long connection; The model output module is used for the large model to receive data requests, process the data requests, and transmit the model output information back to the server through the SSE long connection; The message return module is used for the server to receive the model output information for processing, generate the corresponding response message, and send the response message to the client through the WebSocket long connection.
9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the streaming communication method based on a long connection as described in any one of claims 1 to 7 when executing the computer program.
10. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the streaming communication method based on a long connection as described in any one of claims 1 to 7 can be implemented.
Citation Information
Cited By
Streaming AI dialogue data processing method and device, medium and program product
CN121705402A
Streamed AI conversation data processing method, device, medium and program product
CN121705402B
Large-model cross-domain remote calling method and device for UDP (User Datagram Protocol) network
CN121711377A
A large model cross-domain remote invocation method and device for a UDP network
CN121711377B
Client page rendering system and method based on data driving, medium, terminal and program product
CN121858810A