CN117373450A - Streaming data return method, device, equipment and storage medium - Google Patents

Streaming data return method, device, equipment and storage medium Download PDF

Info

Publication number
CN117373450A
CN117373450A CN202311316740.1A CN202311316740A CN117373450A CN 117373450 A CN117373450 A CN 117373450A CN 202311316740 A CN202311316740 A CN 202311316740A CN 117373450 A CN117373450 A CN 117373450A
Authority
CN
China
Prior art keywords
chatgpt
streaming data
server
browser
socket connection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311316740.1A
Other languages
Chinese (zh)
Inventor
请求不公布姓名
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Shuzhilian Technology Co Ltd
Original Assignee
Chengdu Shuzhilian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu Shuzhilian Technology Co Ltd filed Critical Chengdu Shuzhilian Technology Co Ltd
Priority to CN202311316740.1A priority Critical patent/CN117373450A/en
Publication of CN117373450A publication Critical patent/CN117373450A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/22Procedures used during a speech recognition process, e.g. man-machine dialogue
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/26Speech to text systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • Acoustics & Sound (AREA)
  • Multimedia (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application provides a streaming data return method, device, equipment and storage medium, relates to the technical field of streaming data return, and is used for solving the problem that ChatGpt streaming data is not smooth enough in display. The method comprises the following steps: establishing socket connection between a browser and a ChatGpt server; according to the socket connection, calling the ChatGpt server to return ChatGpt streaming data to the browser; and calling the browser to display the ChatGpt streaming data.

Description

Streaming data return method, device, equipment and storage medium
Technical Field
The application relates to the technical field of communication, and provides a streaming data return method, device, equipment and storage medium.
Background
With the vigorous development of chat-forming pre-training-converters (Chat Generative Pre-trained Transformer, chatGpt), streaming data is often displayed so that the problem processing effect is more anthropomorphic, and therefore, the use experience of users is improved. In the prior art, for the return of the streaming data, the POST/GET interface is generally called, and the streaming data is returned in a mode of directly requesting the data return, however, the mode needs to wait for the completion of the server processing and then display the returned streaming data, so that the waiting time is long, and the ChatGpt streaming data display is not smooth enough.
Therefore, how to smoothly display ChatGpt streaming data is a problem to be solved at present.
Disclosure of Invention
The embodiment of the application provides a streaming data return method, device, equipment and storage medium, which are used for solving the problem that the ChatGpt streaming data display is not smooth enough.
In one aspect, a method for streaming data return is provided, the method comprising:
establishing socket connection between a browser and a ChatGpt server;
according to the socket connection, calling the ChatGpt server to return ChatGpt streaming data to the browser;
and calling the browser to display the ChatGpt streaming data.
The beneficial effects of this application are: since a socket connection is established between the browser and the ChatGpt server, and the ChatGpt streaming data is returned based on the socket connection. Therefore, the return time of the ChatGpt streaming data can be greatly shortened, and further, the ChatGpt streaming data can be displayed more smoothly. In addition, since the socket connection can be encrypted, the transmission security of the ChatGpt streaming data can be enhanced.
In one implementation, the step of establishing a socket connection between the browser and the ChatGpt server includes:
invoking the browser to send a first socket connection request to the proxy layer;
and establishing first socket connection between the browser and the proxy layer according to the first socket connection request.
The beneficial effects of this application are: because the proxy layer is arranged between the browser and the server, when the socket connection between the browser and the ChatGpt server is established, the first socket connection between the browser and the proxy layer can be established firstly so as to further complete the socket connection establishment between the browser and the ChatGpt server, and the return time of the subsequent ChatGpt streaming data can be shortened.
In one implementation, the step of establishing a socket connection between the browser and the ChatGpt server includes:
configuring a ChatGpt address of the ChatGpt server at a proxy layer;
according to the ChatGpt address, calling the proxy layer to send a second socket connection request to the ChatGpt server;
and establishing second socket connection between the proxy layer and the ChatGpt server according to the second socket connection request.
The beneficial effects of this application are: because the proxy layer is arranged between the browser and the server, the second socket connection between the proxy layer and the ChatGpt server can be further established based on the configured ChatGpt address, so that the socket connection between the browser and the ChatGpt server is established, and the return time of the subsequent ChatGpt streaming data is shortened.
In one implementation manner, the step of calling the ChatGpt server to return ChatGpt streaming data to the browser according to the socket connection includes:
according to the first socket connection, calling the ChatGpt server to return the ChatGpt streaming data to the proxy layer;
and calling the proxy layer to return the ChatGpt streaming data to the browser according to the second socket connection.
The beneficial effects of this application are: because the socket connection between the browser and the ChatGpt server can be divided into a first socket connection and a second socket connection, when the ChatGpt streaming data is returned, the ChatGpt streaming data can be returned through the first socket connection and the second socket connection in sequence, so that the return time of the ChatGpt streaming data is shortened.
In one implementation, before calling the ChatGpt server to return ChatGpt streaming data to the browser according to the socket connection, the method further includes:
invoking the browser to send a data return request to the proxy layer;
according to the data return request, calling the proxy layer to send an HTTP request to the ChatGpt server;
and calling the ChatGpt server to configure the receivable event stream type as text/event-stream according to the HTTP request.
The beneficial effects of this application are: since the receivable event stream type is configured as text/event-stream, when ChatGpt streaming data is returned according to text/event-stream, the ChatGpt streaming data can be regarded as a series of stream events and returned in text form, thereby reducing polling consumption and enhancing real-time performance.
In one implementation, before calling the ChatGpt server to return ChatGpt streaming data to the browser according to the socket connection, the method further includes:
calling the ChatGpt server to acquire ChatGpt streaming data in a byte stream mode;
calling the ChatGpt server to create a streaming entity;
determining whether the streaming entity conforms to an entity structure.
The beneficial effects of this application are: because the streaming entity is created, the processing control can be uniformly performed on the ChatGpt streaming data without additional processing when the ChatGpt streaming data is returned later.
In one implementation, after determining whether the streaming entity conforms to an entity structure, the method further comprises:
and if the streaming entity is determined to be in accordance with the entity structure, calling the ChatGpt server to return the ChatGpt streaming data to the browser according to the streaming entity.
The beneficial effects of this application are: because the ChatGpt streaming data is returned according to the streaming entity, the ChatGpt streaming data can be uniformly processed and controlled without additional processing.
In one implementation, after the ChatGpt streaming data is presented on the browser, the method further comprises:
determining whether the proxy layer sends an HTPP request to the ChatGpt server in a preset time period;
and if the proxy layer sends an HTPP request to the ChatGpt server in a preset time period, disconnecting the socket connection.
The beneficial effects of this application are: because the socket connection is disconnected when no HTPP request exists in the preset time period, the resource consumption can be greatly reduced.
In one implementation, the step of calling the browser to expose the ChatGpt streaming data includes:
invoking the browser to receive the ChatGpt streaming data;
sorting the ChatGpt streaming data to obtain sorted ChatGpt streaming data;
and sending the tidied ChatGpt streaming data to a front end for display.
The beneficial effects of this application are: the arranged ChatGpt streaming data is sent to the front end for display, so that the ChatGpt streaming data can be displayed more smoothly.
In one implementation, the socket connection is any one of a socket long connection and a socket short connection.
The beneficial effects of this application are: because the connection can be set as a socket long connection or a socket short connection according to actual conditions, more tcp establishment/closing operations can be omitted when the socket long connection is used for returning the ChatGpt streaming data, waste is reduced, and time is saved. When the socket short connection is used for returning the ChatGpt streaming data, the management can be simpler, and no extra control means is needed.
In one aspect, there is provided a streaming data return apparatus, the apparatus comprising:
the connection establishment unit is used for establishing socket connection between the browser and the ChatGpt server;
the data return unit is used for calling the ChatGpt server to return ChatGpt streaming data to the browser according to the socket connection;
and the data display unit is used for calling the browser to display the ChatGpt streaming data.
In one aspect, an electronic device is provided that includes a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing any of the methods described above when executing the computer program.
In one aspect, a computer storage medium having stored thereon computer program instructions which, when executed by a processor, implement any of the methods described above.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are required to be used in the embodiments or the related technical descriptions will be briefly described below, and it is apparent that the drawings in the following description are only embodiments of the present application, and other drawings may be obtained according to the provided drawings without inventive effort for a person having ordinary skill in the art.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application;
fig. 2 is a schematic flow chart of a streaming data return method according to an embodiment of the present application;
fig. 3 is a schematic diagram of a streaming data return device according to an embodiment of the present application.
The marks in the figure: 10-streaming data return device, 101-processor, 102-memory, 103-I/O interface, 104-database, 30-streaming data return means, 301-connection setup unit, 302-data return unit, 303-data presentation unit, 304-parameter configuration unit, 305-entity creation unit, 306-connection disconnection unit.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the present application more apparent, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure. Embodiments and features of embodiments in this application may be combined with each other arbitrarily without conflict. Also, while a logical order is depicted in the flowchart, in some cases, the steps depicted or described may be performed in a different order than presented herein.
With the vigorous development of chat-forming pre-training-converters (Chat Generative Pre-trained Transformer, chatGpt), streaming data is often displayed so that the problem processing effect is more anthropomorphic, and therefore, the use experience of users is improved. In the prior art, for the return of the streaming data, the POST/GET interface is generally called, and the streaming data is returned in a mode of directly requesting the data return, however, the mode needs to wait for the completion of the server processing and then display the returned streaming data, so that the waiting time is long, and the ChatGpt streaming data display is not smooth enough.
Based on this, the embodiment of the application provides a streaming data return method, in which firstly, a socket connection can be established between a browser and a ChatGpt server; then, the ChatGpt server can be called to return ChatGpt streaming data to the browser according to socket connection; finally, a browser can be invoked to expose ChatGpt streaming data. Therefore, in the embodiment of the application, since a socket connection is established between the browser and the ChatGpt server, and the ChatGpt streaming data is returned based on the socket connection. Therefore, the return time of the ChatGpt streaming data can be greatly shortened, and further, the ChatGpt streaming data can be displayed more smoothly. In addition, since the socket connection can be encrypted, the transmission security of the ChatGpt streaming data can be enhanced.
After the design concept of the embodiment of the present application is introduced, some simple descriptions are made below for application scenarios applicable to the technical solution of the embodiment of the present application, and it should be noted that the application scenarios described below are only used to illustrate the embodiment of the present application and are not limiting. In the specific implementation process, the technical scheme provided by the embodiment of the application can be flexibly applied according to actual needs.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application. The application scenario may include a streaming data return device 10.
The streaming data return device 10 may be used to quickly return ChatGpt streaming data, for example, a personal computer (Personal Computer, PC), a server, a portable computer, and the like. The streaming data return device 10 may include one or more processors 101, memory 102, I/O interfaces 103, and a database 104. Specifically, the processor 101 may be a central processing unit (central processing unit, CPU), or a digital processing unit or the like. The memory 102 may be a volatile memory (RAM), such as a random-access memory (RAM); the memory 102 may also be a nonvolatile memory (non-volatile memory), such as a read-only memory (rom), a flash memory (flash memory), a hard disk (HDD) or a Solid State Drive (SSD); or memory 102, is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory 102 may be a combination of the above. The memory 102 may store part of program instructions of the streaming data return method provided in the embodiment of the present application, where the program instructions, when executed by the processor 101, can be used to implement the steps of the streaming data return method provided in the embodiment of the present application, so as to solve the problem that ChatGpt streaming data is not displayed smoothly enough. The database 104 may be configured to store data such as ChatGpt streaming data, a first socket connection request, a ChatGpt address, a second socket connection request, a data return request, and an HTTP request, which are related to the scheme provided in the embodiment of the present application.
In the embodiment of the present application, the streaming data return device 10 may acquire the first socket connection request through the I/O interface 103, and then, the processor 101 of the streaming data return device 10 may solve the problem that the ChatGpt streaming data is not smooth enough in displaying according to the program instruction of the streaming data return method provided in the embodiment of the present application in the memory 102. In addition, data such as ChatGpt streaming data, a first socket connection request, a ChatGpt address, a second socket connection request, a data return request, and an HTTP request may be stored in the database 104.
Of course, the method provided in the embodiment of the present application is not limited to the application scenario shown in fig. 1, but may be used in other possible application scenarios, and the embodiment of the present application is not limited. The functions that can be implemented by each device in the application scenario shown in fig. 1 will be described together in the following method embodiments, which are not described in detail herein. The method according to the embodiment of the present application will be described below with reference to the accompanying drawings.
As shown in fig. 2, a flowchart of a streaming data return method according to an embodiment of the present application is shown, and the method may be performed by the streaming data return device 10 in fig. 1, and specifically, the flowchart of the method is described below.
Step 201: and establishing a socket connection between the browser and the ChatGpt server.
In order to timely and smoothly return the ChatGpt streaming data, in the embodiment of the application, socket connection can be established between the browser and the ChatGpt server so as to improve user experience.
Step 202: and calling the ChatGpt server to return the ChatGpt streaming data to the browser according to the socket connection.
In order to directly show the ChatGpt streaming data on the browser, in the embodiment of the present application, after the socket connection is established, the ChatGpt server may be directly called according to the socket connection to return the ChatGpt streaming data to the browser.
Step 203: the browser is invoked to expose ChatGpt streaming data.
In the embodiment of the application, after the browser receives the returned ChatGpt streaming data, the browser can be directly called to show that the ChatGpt streaming data is displayed.
Further, since a socket connection is established between the browser and the ChatGpt server, and ChatGpt streaming data is returned based on the socket connection. Therefore, the return time of the ChatGpt streaming data can be greatly shortened, and further, the ChatGpt streaming data can be displayed more smoothly. In addition, since the socket connection can be encrypted, the transmission security of the ChatGpt streaming data can be enhanced.
In one possible implementation manner, in order to process (for example, filter, modify, intercept or transit) the sending request/data, in this embodiment of the present application, a proxy layer may be set between the browser and the ChatGpt server, and, further, based on the proxy layer, in order to shorten the return time of the ChatGpt streaming data, in this embodiment of the present application, the browser may be called to send a first socket connection request to the proxy layer; then, a first socket connection may be established between the browser and the proxy layer according to the first socket connection request.
Furthermore, since the proxy layer is arranged between the browser and the server, when the socket connection between the browser and the ChatGpt server is established, the first socket connection between the browser and the proxy layer can be established firstly so as to further complete the socket connection establishment between the browser and the ChatGpt server, and the return time of the subsequent ChatGpt streaming data can be shortened.
Of course, in the embodiment of the present application, the proxy layer may be a HTTP (Hyper Text Transfer Protocol) proxy or SOCKS (Socket Secure) proxy, and further, according to the actual situation, the proxy server may be selectively determined to perform the proxy. For example, if it is desired to filter, modify, or intercept a client's HTTP request, allowing or prohibiting a particular access request, an HTTP proxy may be selected to process the HTTP request. If only the request or the response is relayed, the SOCKS proxy can be selected to process the request such as HTTP, FTP, SMTP, etc.
In one possible implementation manner, in order to further shorten the return time of the ChatGpt streaming data, in the embodiment of the present application, the ChatGpt address of the ChatGpt server may be configured at the proxy layer; then, according to the ChatGpt address, the proxy layer can be called to send a second socket connection request to the ChatGpt server; finally, a second socket connection may be established between the proxy layer and the ChatGpt server according to the second socket connection request.
Furthermore, since the proxy layer is arranged between the browser and the server, the second socket connection between the proxy layer and the ChatGpt server can be further established based on the configured ChatGpt address, so that the socket connection between the browser and the ChatGpt server is established, and the return time of the subsequent ChatGpt streaming data is shortened.
In one possible implementation manner, in order to further shorten the return time of the ChatGpt streaming data, in an embodiment of the present application, the ChatGpt server may be called according to the first socket connection to return the ChatGpt streaming data to the proxy layer; the proxy layer may then be invoked to return ChatGpt streaming data to the browser according to the second socket connection.
Further, since the socket connection between the browser and the ChatGpt server can be divided into two parts, namely the first socket connection and the second socket connection, when the ChatGpt streaming data is returned, the ChatGpt streaming data can be returned through the first socket connection and the second socket connection in sequence, so that the return time of the ChatGpt streaming data is shortened.
In one possible implementation manner, in order to reduce polling consumption and enhance real-time performance, in this embodiment of the present application, before calling the ChatGpt server to return ChatGpt streaming data to the browser according to socket connection, firstly, the browser may be called to send a data return request to the proxy layer; then, the proxy layer can be called to send an HTTP request to the ChatGpt server according to the data return request; finally, the ChatGpt server can be invoked to configure the receivable event stream type as text/event-stream according to the HTTP request.
Furthermore, since the receivable event stream type is configured as text/event-stream, when ChatGpt streaming data is returned according to text/event-stream, the ChatGpt streaming data can be regarded as a series of stream events and returned in text form, thereby reducing polling consumption and enhancing real-time.
In one possible implementation manner, in order to further shorten the return time of the ChatGpt streaming data, in this embodiment of the present application, before calling the ChatGpt server to return the ChatGpt streaming data to the browser according to the socket connection, the ChatGpt server may be first called to obtain the ChatGpt streaming data in a byte stream manner; the ChatGpt server can then be invoked to create a streaming entity; finally, it may be determined whether the streaming entity conforms to the entity structure.
Furthermore, since the streaming entity is created, the processing control can be uniformly performed on the ChatGpt streaming data without additional processing when the ChatGpt streaming data is returned later.
In one possible implementation manner, in order to further shorten the return time of the ChatGpt streaming data, in an embodiment of the present application, after determining whether the streaming entity conforms to the entity structure, if it is determined that the streaming entity conforms to the entity structure, the ChatGpt server may be invoked to return the ChatGpt streaming data to the browser according to the streaming entity. Furthermore, the ChatGpt streaming data is returned according to the streaming entity, so that the ChatGpt streaming data can be uniformly processed and controlled without additional processing.
In a possible implementation manner, in order to reduce resource consumption, in this embodiment of the present application, after the ChatGpt streaming data is displayed on the browser, it may also be determined whether the proxy layer sends an HTPP request to the ChatGpt server in a preset period of time; if the agent layer sends an HTPP request to the ChatGpt server in a preset time period, the socket connection can be disconnected. Furthermore, since the socket connection is disconnected when there is no HTPP request within the preset time period, the resource consumption can be greatly reduced.
In one possible real-time manner, in order to further make the display of the ChatGpt streaming data smoother, in the embodiment of the present application, when the browser is called to display the ChatGpt streaming data, firstly, the browser may be called to receive the ChatGpt streaming data; then, the ChatGpt streaming data can be sorted to obtain sorted ChatGpt streaming data; and finally, the tidied ChatGpt streaming data can be sent to the front end for display. Furthermore, the arranged ChatGpt streaming data is sent to the front end for display, so that the ChatGpt streaming data can be displayed more smoothly.
In one possible implementation, to reduce waste and save time, in an embodiment of the present application, the socket connection may be any one of a socket long connection and a socket short connection. Furthermore, as the connection can be set as a socket long connection or a socket short connection according to the actual situation, when the socket long connection is used for returning the ChatGpt streaming data, more tcp establishment/closing operations can be omitted, waste is reduced, and time is saved. When the socket short connection is used for returning the ChatGpt streaming data, the management can be simpler, and no extra control means is needed.
In summary, in the embodiment of the present application, since a socket connection is established between the browser and the ChatGpt server, and the ChatGpt streaming data is returned based on the socket connection. Therefore, the return time of the ChatGpt streaming data can be greatly shortened, and further, the ChatGpt streaming data can be displayed more smoothly. In addition, since the socket connection can be encrypted, the transmission security of the ChatGpt streaming data can be enhanced.
Based on the same inventive concept, the embodiment of the present application provides a streaming data return apparatus 30, as shown in fig. 3, the streaming data return apparatus 30 includes:
a connection establishing unit 301, configured to establish a socket connection between the browser and the ChatGpt server;
the data return unit 302 is configured to call the ChatGpt server to return ChatGpt streaming data to the browser according to socket connection;
and the data display unit 303 is used for calling the browser to display the ChatGpt streaming data.
Optionally, the connection establishment unit 301 is further configured to:
calling a browser to send a first socket connection request to an agent layer;
and establishing a first socket connection between the browser and the proxy layer according to the first socket connection request.
Optionally, the connection establishment unit 301 is further configured to:
configuring a ChatGpt address of a ChatGpt server at a proxy layer;
according to the ChatGpt address, calling the proxy layer to send a second socket connection request to the ChatGpt server;
and establishing a second socket connection between the proxy layer and the ChatGpt server according to the second socket connection request.
Optionally, the data return unit 302 is further configured to:
calling a ChatGpt server to return ChatGpt streaming data to the proxy layer according to the first socket connection;
and according to the second socket connection, calling the proxy layer to return the ChatGpt streaming data to the browser.
Optionally, the streaming data return device 30 further includes a parameter configuration unit 304, where the parameter configuration unit 304 is configured to:
invoking a browser to send a data return request to the proxy layer;
according to the data return request, calling a proxy layer to send an HTTP request to the ChatGpt server;
according to the HTTP request, the ChatGpt server is called to configure the receivable event stream type as text/event-stream.
Optionally, the streaming data return apparatus 30 further includes an entity creation unit 305, and the entity creation unit 305 is configured to:
calling a ChatGpt server to acquire ChatGpt streaming data in a byte stream mode;
calling a ChatGpt server to create a streaming entity;
it is determined whether the streaming entity conforms to the entity structure.
Optionally, the data return unit 302 is further configured to:
and if the streaming entity is determined to be in accordance with the entity structure, calling the ChatGpt server to return ChatGpt streaming data to the browser according to the streaming entity.
Optionally, the streaming data return device 30 further comprises a disconnection unit 306, the disconnection unit 306 being configured to:
determining whether an agent layer sends an HTPP request to a ChatGpt server in a preset time period;
if the agent layer sends an HTPP request to the ChatGpt server in a preset time period, the socket connection is disconnected.
Optionally, the data display unit 303 is configured to:
invoking a browser to receive ChatGpt streaming data;
sorting the ChatGpt streaming data to obtain sorted ChatGpt streaming data;
and sending the tidied ChatGpt streaming data to the front end for display.
The streaming data return device 30 may be used to perform the method performed by the streaming data return device in the embodiment shown in fig. 2, and therefore, the description of the functions that can be implemented by each functional module of the streaming data return device 30 and the like with reference to the embodiment shown in fig. 2 will not be repeated.
In some possible implementations, aspects of the methods provided herein may also be implemented in the form of a program product comprising program code for causing a computer device to carry out the steps of the methods according to the various exemplary embodiments of the application described herein above, when the program product is run on the computer device, e.g. the computer device may carry out the method as carried out by the streaming data return apparatus in the embodiment shown in fig. 2.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by hardware associated with program instructions, where the foregoing program may be stored in a computer readable storage medium, and when executed, the program performs steps including the above method embodiments; and the aforementioned storage medium includes: a mobile storage device, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk or an optical disk, or the like, which can store program codes. Alternatively, the above-described integrated units of the present invention may be stored in a computer-readable storage medium if implemented in the form of software functional modules and sold or used as separate products. Based on such understanding, the technical solutions of the embodiments of the present invention may be embodied in essence or a part contributing to the prior art in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: a removable storage device, ROM, RAM, magnetic or optical disk, or other medium capable of storing program code.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to cover such modifications and variations.

Claims (13)

1. A method of streaming data return, the method comprising:
establishing socket connection between a browser and a ChatGpt server;
according to the socket connection, calling the ChatGpt server to return ChatGpt streaming data to the browser;
and calling the browser to display the ChatGpt streaming data.
2. The method of claim 1, wherein the step of establishing a socket connection between the browser and the ChatGpt server comprises:
invoking the browser to send a first socket connection request to the proxy layer;
and establishing first socket connection between the browser and the proxy layer according to the first socket connection request.
3. The method of claim 1, wherein the step of establishing a socket connection between the browser and the ChatGpt server comprises:
configuring a ChatGpt address of the ChatGpt server at a proxy layer;
according to the ChatGpt address, calling the proxy layer to send a second socket connection request to the ChatGpt server;
and establishing second socket connection between the proxy layer and the ChatGpt server according to the second socket connection request.
4. The method of claim 1, wherein the step of invoking the ChatGpt server to return ChatGpt streaming data to the browser according to the socket connection comprises:
according to the first socket connection, calling the ChatGpt server to return the ChatGpt streaming data to the proxy layer;
and calling the proxy layer to return the ChatGpt streaming data to the browser according to the second socket connection.
5. The method of claim 1, wherein before invoking the ChatGpt server to return ChatGpt streaming data to the browser according to the socket connection, the method further comprises:
invoking the browser to send a data return request to the proxy layer;
according to the data return request, calling the proxy layer to send an HTTP request to the ChatGpt server;
and calling the ChatGpt server to configure the receivable event stream type as text/event-stream according to the HTTP request.
6. The method of claim 1, wherein before invoking the ChatGpt server to return ChatGpt streaming data to the browser according to the socket connection, the method further comprises:
calling the ChatGpt server to acquire ChatGpt streaming data in a byte stream mode;
calling the ChatGpt server to create a streaming entity;
determining whether the streaming entity conforms to an entity structure.
7. The method of claim 5, wherein after determining whether the streaming entity conforms to an entity structure, the method further comprises:
and if the streaming entity is determined to be in accordance with the entity structure, calling the ChatGpt server to return the ChatGpt streaming data to the browser according to the streaming entity.
8. The method of claim 1, wherein after exposing the ChatGpt streaming data on the browser, the method further comprises:
determining whether the proxy layer sends an HTPP request to the ChatGpt server in a preset time period;
and if the proxy layer sends an HTPP request to the ChatGpt server in a preset time period, disconnecting the socket connection.
9. A method as defined in claim 1, wherein the step of invoking the browser to expose the ChatGpt streaming data comprises:
invoking the browser to receive the ChatGpt streaming data;
sorting the ChatGpt streaming data to obtain sorted ChatGpt streaming data;
and sending the tidied ChatGpt streaming data to a front end for display.
10. The method of claim 1, wherein the socket connection is any one of a socket long connection and a socket short connection.
11. A streaming data return apparatus, the apparatus comprising:
the connection establishment unit is used for establishing socket connection between the browser and the ChatGpt server;
the data return unit is used for calling the ChatGpt server to return ChatGpt streaming data to the browser according to the socket connection;
and the data display unit is used for calling the browser to display the ChatGpt streaming data.
12. An electronic device, the device comprising:
a memory for storing program instructions;
a processor for invoking program instructions stored in the memory and for performing the method of any of claims 1-10 in accordance with the obtained program instructions.
13. A storage medium storing computer-executable instructions for causing a computer to perform the method of any one of claims 1-10.
CN202311316740.1A 2023-10-11 2023-10-11 Streaming data return method, device, equipment and storage medium Pending CN117373450A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311316740.1A CN117373450A (en) 2023-10-11 2023-10-11 Streaming data return method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311316740.1A CN117373450A (en) 2023-10-11 2023-10-11 Streaming data return method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117373450A true CN117373450A (en) 2024-01-09

Family

ID=89401627

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311316740.1A Pending CN117373450A (en) 2023-10-11 2023-10-11 Streaming data return method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117373450A (en)

Similar Documents

Publication Publication Date Title
CN109067890B (en) CDN node edge computing system based on docker container
US9918228B2 (en) Session completion through co-browsing
US10693795B2 (en) Providing access to application program interfaces and Internet of Thing devices
CN110321283B (en) Interface test case generation method and device, computer device and storage medium
TW202119255A (en) Inference system, inference method, electronic device and computer storage medium
CN107453872B (en) Unified security authentication method and system based on Mesos container cloud platform
WO2021238596A1 (en) Interface calling method and apparatus, and computer-readable storage medium
CN108900627B (en) Network request method, terminal device and storage medium
JP2004310298A (en) Information processing system, information processor, session management method, and program
WO2014110929A1 (en) Method, device, and system for uploading data
CN114124929A (en) Cross-network data processing method and device
CN109725887B (en) Data interaction method and device based on message research and development framework and terminal equipment
CN107332854B (en) Message serialization negotiation method and service providing equipment
CN107517188A (en) A kind of data processing method and device based on Android system
CN111294377B (en) Dependency network request sending method, terminal device and storage medium
CN106612263B (en) Method and equipment for processing application access request
CN112988311A (en) On-line experimental method based on WEB server
CN113254014A (en) Sketch plug-in-based interface development method, device and system
CN113055348B (en) Cross-platform data request method and device and electronic equipment
WO2017185632A1 (en) Data transmission method and electronic device
CN112732547B (en) Service testing method and device, storage medium and electronic equipment
CN111767558A (en) Data access monitoring method, device and system
CN117373450A (en) Streaming data return method, device, equipment and storage medium
CN113687919B (en) Control method, device, equipment and storage medium for micro-service management
CN114489603A (en) Code generation method, apparatus, electronic device, medium, and product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination