Session data storage method, electronic device and computer readable storage medium
By writing session data to the first database and message queue at the end of the conversation, and asynchronously writing it to the second database, the problem of insufficient reliability of session data storage is solved, and reliable data preservation and long-term storage under abnormal conditions are achieved.
Patent Information
- Application Number
- CN202611315364.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-27
- Publication Date
- 2026-11-17
AI Technical Summary
The reliability of session data storage in existing technologies is insufficient, and data that has been saved in short-term memory but has not been successfully written to long-term memory can be permanently lost due to network jitter, cache failure, and other anomalies.
After this round of dialogue ends, the session data is simultaneously written to the first database and the message queue. The first database is used for short-term memory, and the message queue is asynchronously written to the second database, which is used for long-term memory. Data in the first database is managed by preset deletion conditions and time-to-live to ensure that data can still be asynchronously written to the database in abnormal situations.
It improves the reliability of session data storage, avoids inconsistencies or permanent loss between short-term and long-term storage, and ensures the context continuity of multi-turn dialogues and the long-term preservation of data.
Smart Images

Figure CN123114368A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of session data technology, specifically to a method for storing session data, an electronic device, and a computer-readable storage medium. Background Technology
[0002] With the development of artificial intelligence technology, multi-turn dialogue systems are widely used in human-computer interaction scenarios, and the preservation of conversation data is becoming increasingly important in maintaining context awareness, building user profiles, and realizing historical record retrieval.
[0003] The storage of session data is typically divided into short-term memory storage and long-term memory storage. In existing technologies, real-time session data is usually stored in short-term memory to provide low-latency contextual information for subsequent conversations. Then, the session data stored in short-term memory is filtered, and the filtered session data is transferred to long-term memory. The session data stored in long-term memory is then deleted from short-term memory.
[0004] However, this progressive writing method, starting with short-term data and then moving to long-term data, is prone to a split-brain phenomenon when encountering anomalies such as network jitter, cache failure, or crashes of processes responsible for data transfer. This can result in the session data being stored in short-term memory but failing to be written in long-term history. In this case, if the short-term memory is deleted due to expiration, that portion of the session data will be permanently lost.
[0005] Therefore, improving the reliability of session data storage has become an urgent technical problem to be solved. Summary of the Invention
[0006] In view of the above problems, embodiments of this application provide a method for storing session data, an electronic device, and a computer-readable storage medium to solve the problem that the reliability of session data storage needs to be improved in the prior art.
[0007] According to one aspect of the embodiments of this application, a method for storing session data is provided, the method comprising: in response to the end of the current round of dialogue, acquiring session data of the current round of dialogue; writing the session data into a first database and a message queue, wherein data stored in the first database is deleted when a preset deletion condition is met; and writing the session data in the message queue into a second database, wherein the storage duration of the data in the second database is longer than the storage duration of the data in the first database.
[0008] In an alternative approach, the method further includes: configuring a time-to-live (TTL) for session data written to a first database; performing a deletion operation on data in the first database that meets preset deletion conditions; wherein the preset deletion conditions include that the data has not been accessed and its TTL renewal operation has not been performed during its TTL.
[0009] In one alternative approach, writing session data to a first database and a message queue includes: determining the total number of rounds of historical session data associated with the session window identifier from the first database based on the session window identifier to which the session data belongs; if the total number of rounds of historical session data reaches a preset single session round threshold, then performing a deletion operation on the shortest-lived historical session data associated with the session window identifier in the first database; appending the session data to the first database and writing it to the message queue.
[0010] In one alternative approach, the session data includes user input information, response data corresponding to the input information, and a session window identifier for the current round of dialogue. The method further includes: in response to received current input information, obtaining a target session window identifier carried in the current input information; reading historical session data associated with the target session window identifier from a first database based on the target session window identifier; processing the current input information based on the historical session data to generate target response data corresponding to the current input information; and outputting the target response data, wherein the end time of the current round of dialogue corresponding to the current input information is the time when the target response data output is completed.
[0011] In one alternative approach, the session data includes multi-dimensional identifiers, which include session window identifiers, device identifiers, and vehicle identification numbers; writing the session data to a first database and a message queue includes: writing the session data to the first database using the session window identifier as an index; writing the session data to the message queue; and writing the session data in the message queue to a second database includes: writing the session data in the message queue to the second database using the multi-dimensional identifier as an index.
[0012] In one alternative approach, the multi-dimensional identifier further includes a user identifier and a time range, whereby the time range is used to characterize the start and end information of the current round of dialogue corresponding to the session data. The method further includes: in response to a request to obtain cross-session data, determining the target user identifier and target time period information corresponding to the cross-session data; determining the target cross-session data from the second database based on the target user identifier, the target time period information, the user identifier index and the time range index of the second database; and responding to the request to obtain cross-session data based on the target cross-session data.
[0013] In an optional embodiment, the method further includes: in response to a vehicle diagnostic assistance request, determining a target vehicle identification number (VIN) corresponding to the vehicle diagnostic assistance request, wherein the vehicle diagnostic assistance request is a request to obtain diagnostic reference information corresponding to the same VIN; determining diagnostic assistance session data from a second database based on the target VIN and a VIN index in a second database; generating diagnostic reference information based on the diagnostic assistance session data; and responding to the vehicle diagnostic assistance request based on the diagnostic reference information.
[0014] In an alternative approach, the method further includes: in response to a combined retrieval request, determining combined query conditions corresponding to the combined retrieval request, wherein the combined query conditions are retrieval conditions formed based on at least two of the multi-dimensional identifiers; determining target data from the second database based on the combined query conditions and multiple indexes of the second database; and responding to the combined retrieval request based on the target data.
[0015] According to another aspect of the embodiments of this application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the session data storage method as described in any of the preceding claims.
[0016] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method for storing session data as described in any of the preceding claims.
[0017] This embodiment of the application writes the acquired session data to both a first database and a message queue after the current round of dialogue ends. The message queue then asynchronously writes the data to a second database. Even if the data in the first database is deleted due to meeting preset deletion conditions, or if it encounters anomalies such as network jitter or cache failure, a copy of the data is still retained in the message queue. This ensures that the session data is successfully written to the second database, thereby avoiding the risk of inconsistency or permanent loss of session data between short-term and long-term storage and improving the reliability of session data storage.
[0018] The above description is merely an overview of the technical solutions of the embodiments of this application. In order to better understand the technical means of the embodiments of this application and to implement them in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the embodiments of this application more obvious and understandable, specific implementation methods of this application are described below. Attached Figure Description
[0019] The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 This illustration shows an application scenario diagram of the session data storage method provided in the embodiments of this application; Figure 2 A flowchart illustrating the session data storage method provided in an embodiment of this application is shown; Figure 3 A schematic diagram of the structure of the session data storage device provided in an embodiment of this application is shown; Figure 4A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0020] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited to the embodiments set forth herein.
[0021] The session data storage method provided in this application is applied to electronic devices. Figure 1 This illustration shows an application scenario diagram of the session data storage method provided in the embodiments of this application, such as... Figure 1 As shown, in one alternative approach, such as Figure 1 As shown in P1, the electronic device executing the session data storage method is the user's client device. The session data storage method is integrated into the client device. In this case, the client device itself has computing power, can directly complete the dialogue with the user, and store the session data generated during the dialogue process; in another optional method, such as Figure 1 As shown in P2, the user's client device interacts with another electronic device via network transmission, sending the natural language query text entered by the user on the client device to the electronic device. At this time, the electronic device acts as an independent server or edge node to perform calculations, complete the dialogue with the user, and store the session data generated during the dialogue.
[0022] In automotive diagnostics, the user's client device can be a diagnostic tool, on-board diagnostic terminal, or similar device. It connects to the vehicle's Electronic Control Unit (ECU) via a vehicle communication interface, reading vehicle status information such as fault codes and data streams in real time and reporting the operating conditions. Simultaneously, it receives voice or text input from the repair personnel. The electronic device can be a local diagnostic workstation or a cloud-based diagnostic server. It receives the query text and operating condition data reported by the client device, generates responses to the user's questions and answers locally or in the cloud, completing the dialogue with the user and storing the session data generated during the dialogue.
[0023] Figure 2 This paper illustrates a flowchart of a method for storing session data provided in an embodiment of this application. Figure 2 The process shown can be derived from Figure 1 The execution is performed by the client device in P1 or the electronic device in P2. The following description refers to the execution by the electronic device in P2. Figure 2 The process shown below will be used as an example for explanation. Figure 2 As shown, the method includes the following steps S110~S130: S110, in response to the end of the current round of dialogue, retrieve the session data of the current round of dialogue.
[0024] The end of this round of dialogue refers to the moment when the electronic device generates the final response data for the user's current input information and outputs the response data.
[0025] Conversation data is structured data generated during this question-and-answer process. It includes not only the user's current input information, but also the response data generated by the electronic device after semantic understanding and logical processing of the input information, as well as dimensional information such as the conversation window identifier used to identify the context of this conversation.
[0026] In a specific automotive diagnostic scenario, once the technician queries the cloud-based diagnostic server to "read the engine data stream" and receives a response, the current dialogue session ends. The cloud-based diagnostic server (electronic device) then retrieves the session data, which includes the user's input "read the engine data stream," the natural language understanding results (e.g., the identified domain is the engine system, the intent is to read the data stream, etc.), and the body or summary of the response.
[0027] S120, write session data to the first database and message queue, wherein the data stored in the first database is deleted when the preset deletion conditions are met.
[0028] The first database is a cache-type storage medium with high-speed read and write capabilities, used to hold short-term memory. After the cloud diagnostic server completes the assembly of the session data for this round, it will distribute this same session data to both the first database and the message queue.
[0029] Writing session data to the first database allows electronic devices to read recent context with low latency when new user input arrives within the same session window in a very short time, thus supporting functions such as intent clarification and slot inheritance in multi-turn dialogues.
[0030] Since the first database typically runs in memory and has limited storage space, preset deletion conditions are set for the session data stored in it to prevent data from accumulating indefinitely and causing memory overflow.
[0031] This preset deletion condition can be triggered based on time or storage capacity limitations, as will be explained later. When the data in the first database meets this condition, the electronic device will automatically perform a deletion operation to free up space.
[0032] Preset deletion conditions allow the first database to maintain a lightweight operating state, serving the currently active session context.
[0033] At the same time, the same session data will also be written to the message queue. As a high-throughput asynchronous message channel, the message queue can temporarily cache this data.
[0034] S130, write the session data in the message queue to the second database, wherein the storage duration of the data in the second database is longer than the storage duration of the data in the first database.
[0035] Electronic devices retrieve session data temporarily stored in the dual-write phase of S120 from the message queue through an independent consumer process or service, and then parse and write it into the second database.
[0036] The second database is a persistent index that supports multi-dimensional conditional retrieval and is used to store long-term memory. Unlike the volatility and short lifespan of the first database, the second database adopts a persistent storage mechanism, and its data is stored for a much longer period than that of the first database. It typically does not have a short automatic expiration time, and the data can be retained for a long time or even permanently.
[0037] Once the conversation data is successfully written to the second database, the electronic device establishes a long-term historical index for that round of dialogue, supporting flexible retrieval by user, time range, dialogue window identifier, and other dimensions, which can be used for historical dialogue review, user profile construction, and cross-conversation preference recommendation.
[0038] The process of the consumer reading data from the message queue and writing it to the second database is asynchronous with the process of writing session data to the first database in S120. Therefore, writing data to the second database will not increase the latency for users waiting for response data in the current round of dialogue. Even if network jitter or temporary unavailability of the consumer occurs during this process, the message queue can continue to complete the data writing operation after the network is restored.
[0039] Furthermore, the preset deletion conditions are explained. In an optional embodiment, the method further includes steps S141-S142: S141, Configure the time-to-live (TTL) for session data written to the first database.
[0040] The lifetime is the effective retention period set for data or keys in the cache. After this period, the data will be considered expired.
[0041] In a specific automotive diagnostic scenario, when the cloud-based diagnostic server writes the session data of the current diagnostic Q&A session into the first database, it simultaneously sets a specific time threshold for it, such as 30 minutes or 60 minutes. This lifespan represents the maximum duration for which the session data can remain in the first database. Since multi-turn conversations are typically sequential in time, if the technician continues to ask follow-up questions within a short period, the electronic device can renew the lifespan of the data under the current session window identifier each time it writes a new round of session data into the first database. This means resetting the retention time of the data to the initially set threshold.
[0042] By configuring the time to live, it is possible to ensure that historical data of inactive sessions does not occupy memory resources indefinitely, thereby freeing up storage space to serve new active sessions, while ensuring that the short-term memory of ongoing active sessions can be continuously retained.
[0043] S142, perform a deletion operation on the data in the first database that meets the preset deletion conditions, wherein the preset deletion conditions include that the data has not been accessed during its lifetime and has not had its lifetime extended.
[0044] The preset deletion conditions include that the data has not been accessed within the configured lifetime and has not been renewed. In other words, if the session data is neither read by subsequent conversation requests nor renewed due to a new round of conversation writing within the set lifetime threshold, it means that the current session is inactive or has completely ended, thus meeting the preset deletion conditions.
[0045] For example, after completing one round of engine fault code inquiries, the technician leaves the workstation and does not initiate any further inquiries using the diagnostic tool within 30 minutes. At this point, the session data in the first database corresponding to that session window has reached its lifespan limit, and no access or renewal operations have occurred during this period, thus meeting the preset deletion conditions. The electronic device will automatically delete this expired session data to free up memory in the first database.
[0046] By setting preset deletion conditions, the first database can achieve self-management of short-term memory, which not only ensures context continuity and low-latency reading during active multi-turn dialogues, but also effectively prevents memory expansion and performance degradation caused by the accumulation of expired historical data, so that the first database always maintains a lightweight and efficient operating state.
[0047] To prevent a large number of rounds of interaction within a single session window from causing an excessive amount of data under a certain index in the first database, thereby affecting the read and write performance of data in the first database, in one optional approach, S120 includes sub-steps S121~S125: S121, based on the session window identifier to which the session data belongs, determine the total number of rounds of historical session data associated with the session window identifier from the first database.
[0048] The first database stores multi-round historical session data indexed by session window identifiers, with each round's question and answer records arranged in chronological or round order.
[0049] When the current conversation ends and new conversation data is ready to be written, the electronic device will first query the first database based on the conversation window identifier carried by the current conversation data to find out how many rounds of historical conversation data have been stored under that window, so as to obtain the total number of rounds of the current historical conversation data.
[0050] S123, if the total number of rounds of historical session data reaches the preset single session round threshold, then perform a deletion operation on the shortest-lived historical session data associated with the session window identifier in the first database.
[0051] The single-session round threshold is a pre-configured upper limit, for example, set to 20 rounds, to restrict the maximum number of rounds retained in a single session. If the total number of rounds currently queried has reached this threshold, it indicates that the short-term memory storage for that session window has reached its capacity limit. At this point, to free up storage space for the latest session data, the electronic device will find the record with the shortest lifespan among the historical session data across multiple rounds corresponding to that session window. Typically, the record with the shortest lifespan is the oldest round record that was written earliest, is closest to its expiration time, and has not been accessed or renewed individually for a long time. The electronic device will delete this oldest round record from the first database, thus ensuring that the number of historical records within a single session window remains within a fixed upper limit.
[0052] S125, append session data to the first database and write it to the message queue.
[0053] The electronic device will append the session data acquired in this round as a new round of records to the corresponding session window identifier in the first database.
[0054] At the same time, the same session data will also be written to the message queue to trigger the subsequent asynchronous process of writing to the second database.
[0055] By executing S121~S125, while ensuring the continuity of context in multiple rounds, the limited memory usage of a single session is achieved, avoiding the disorderly expansion of session data, and further improving the operational stability and retrieval efficiency of the first database in high-concurrency scenarios.
[0056] To achieve low-latency context awareness in multi-turn dialogues, the session data includes user input, response data corresponding to the input, and the session window identifier for the current turn of the dialogue.
[0057] User input typically consists of natural language queries or speech-to-text queries entered by repair technicians via client devices, such as "How do I fix this?". Response data is the system's response text or a compressed summary thereof, generated after logical operations by the electronic device, such as specific troubleshooting steps.
[0058] The session window identifier is used to identify a continuous human-computer dialogue instance or a specific diagnostic sub-window opened on the same client device.
[0059] In addition to user input, response data, and session window identifiers, session data can also include Natural Language Understanding (NLU) results generated after semantic understanding of the input. These semantic understanding results specifically include structured information such as domain, intent, and slots. In multi-turn dialogue scenarios, users often ask questions by omitting the subject or referring to previous context. For example, in car diagnostics, they might first enter "Read engine fault codes," receive a response, and then enter "How do I fix this?" In this case, by fully preserving the semantic understanding results of previous turns in the session data of the first database, the electronic device can directly reuse the parsed intent and slots when processing the current input, thereby achieving slot inheritance and reference resolution.
[0060] Accordingly, the method further includes steps S151 to S154: S151, in response to the received current input information, obtain the target session window identifier carried in the current input information.
[0061] When an electronic device receives input information from a user for the current round, the header or context of that input information carries the identifier of the current session window.
[0062] The electronic device first parses and extracts the target session window identifier from the received request to clarify the context of the current conversation.
[0063] S152, read historical session data associated with the target session window identifier from the first database according to the target session window identifier.
[0064] Because the first database uses a key-value structure indexed by the session window identifier, electronic devices can directly use the target session window identifier as the primary key to perform high-speed queries in the first database.
[0065] If the key corresponding to the target session window identifier does not exist in the first database or the list is empty, empty historical session data will be returned, and the downstream processing logic will continue to execute along the path without historical records, without blocking the main process.
[0066] S153, Process the current input information based on historical session data to generate target response data corresponding to the current input information.
[0067] The electronic device reads recent historical conversation data and submits it along with the current input information to the preprocessing module and the natural language understanding module for processing. The historical conversation data provides rich context for the current input information, enabling the electronic device to perform context completion, referential resolution, intent clarification, and slot inheritance.
[0068] For example, a technician first enters "Read engine fault codes". After the electronic device returns a specific fault code, the technician then enters "How do I fix this?". The electronic device, by combining the previous historical conversation data, can accurately understand that "this" refers to the specific engine fault code mentioned earlier, thereby generating accurate target response data that fits the current context.
[0069] S154, Output the target response data, wherein the end time of the current round of dialogue corresponding to the current input information is the time when the target response data output is completed.
[0070] After generating the target response data, the electronic device transmits it back to the client device via the network for display or playback. The completion of this round of question-and-answer interaction signifies its complete end. This moment of completion corresponds to the end point of the current dialogue session as mentioned in the aforementioned process of acquiring the current dialogue session data.
[0071] To enable multi-window history management and multi-dimensional historical record retrieval in complex application scenarios such as vehicle diagnostics, the session data further includes multi-dimensional identifiers, including session window identifiers, device identifiers, and vehicle identification numbers.
[0072] The session window identifier uniquely identifies a single instance of a continuous human-machine dialogue, the device identifier characterizes the diagnostic instrument or terminal that initiated the dialogue, and the vehicle identification number (VIN) is a unique identifier for a specific vehicle. By uniformly carrying these dimensional information within the session data, electronic devices can simultaneously assign complete business tags to the data, laying the data foundation for subsequent hierarchical storage and combined retrieval.
[0073] Accordingly, S120 includes sub-steps S122~S124: S122, using the session window identifier as an index, write the session data into the first database.
[0074] Since the first database provides short-term memory functionality, its core function is to read the recent context of the current session with low latency during multi-turn conversations. Therefore, when writing the current session data into the first database, the electronic device uses the session window identifier as the primary key or main index structure.
[0075] This single-key addressing method ensures the directness and efficiency of read operations. When a technician conducts multiple follow-up inquiries, the electronic device can access the corresponding short-term memory key space in one go based on the currently requested session window identifier, effectively avoiding the problem of cross-referencing between different session window histories when the same technician is handling multiple vehicles simultaneously.
[0076] S124, write session data to the message queue.
[0077] The same session data, carrying complete multi-dimensional identifiers, is delivered to the asynchronous channel and used as the data source for subsequent persistence in the second database.
[0078] Accordingly, S130 includes the sub-step: S131, using the multi-dimensional identifier as an index, writing the session data in the message queue into the second database.
[0079] Unlike the first database, which uses only the session window identifier as the primary key for indexing, the second database is an index library that supports long-term persistence and complex retrieval. When its consumer parses and writes messages, it establishes corresponding index structures for fields such as the session window identifier, device identifier, and vehicle identification number (VIN) carried in the session data. This multi-dimensional index structure allows the second database to go beyond querying by a single session dimension and support combined retrieval based on different business scenarios. For example, when querying the historical operation records of a specific diagnostic instrument, the electronic device can search based on the device identifier; when implementing a vehicle-specific historical diagnostic recommendation function, the electronic device can directly and accurately extract the vehicle's historical medical records from the second database based on the VIN.
[0080] To meet the needs of cross-session historical dialogue review, user profile construction, and cross-device data traceability, user identifiers and time ranges can be further introduced into the multi-dimensional identifiers. Specifically, the multi-dimensional identifiers also include user identifiers and time ranges, with the time range used to characterize the start and end information of the current round of dialogue corresponding to the session data.
[0081] User identifiers are used to identify the account identity of the mechanic or vehicle owner who initiated the conversation, while the time range indicates the specific start and end times of the conversation corresponding to that round. In actual car repair shop operations, mechanics may use different diagnostic equipment at different workstations, or even log into the system on their own mobile devices. In this case, by including user identifiers and time ranges in the conversation data, electronic devices are no longer limited to viewing records by conversation window or vehicle dimension, but instead possess the ability to perform long-term data tracking based on specific personnel and timelines.
[0082] Accordingly, the method further includes steps S161 to S163: S161, in response to the request to obtain cross-session data, determine the target user identifier and target time period information corresponding to the cross-session data.
[0083] Cross-session data refers to a collection of multiple session data generated by the same user identifier at different historical times or on different devices. When a repair technician opens the history page on a mobile terminal and requests to view all their diagnostic dialogue records from yesterday morning, the electronic device receives this cross-session data retrieval request. First, the corresponding query conditions are parsed from this request, namely the target user identifier, such as the technician's account number, and the target time period information, such as the time range from 8:00 AM to 12:00 PM yesterday. This process is independent of the daily single-turn dialogue main chain and is a reading operation actively triggered by business scenarios such as historical queries or profile building.
[0084] S162, Based on the target user identifier, target time period information, user identifier index and time range index of the second database, determine the target cross-session data from the second database.
[0085] Because the electronic device had already built a multi-dimensional inverted index, including user ID and time range, when asynchronously writing session data to the second database in the previous steps, it can efficiently push the target user ID and target time period information as combined search conditions to the second database. Upon receiving a query request, the second database uses the index structure to quickly filter out all historical documents that simultaneously satisfy the criteria of that specific user and the specific time range.
[0086] The combined query method based on multidimensional indexes eliminates the need to traverse and scan the entire dataset, improving the retrieval efficiency and accuracy of long-term historical data and ensuring the accurate extraction of target cross-session data that meets business needs from massive persistent data.
[0087] S163, respond to the request for obtaining cross-session data based on the target cross-session data.
[0088] Electronic devices assemble and sort the retrieved target cross-session data according to time sequence or other business logic, and return it to the client device that initiated the request for display, or provide it to user profiling services for subsequent preference analysis and behavior statistics.
[0089] S161~S163 enables business support in maintenance scenarios. This not only provides maintenance technicians with cross-device historical traceability services, but also provides a data foundation for service quality analysis and technical training review at the store operation level.
[0090] In actual operation at auto repair shops, the same vehicle may visit the shop multiple times, and the technician or diagnostic equipment used each time may be different. To help the current repair technician quickly understand the vehicle's historical diagnostic history, it is necessary to be able to retrieve relevant historical diagnostic data across sessions and devices when the vehicle is accessed or when a technician requests assistance. To achieve business capabilities such as recommending historical diagnostic data for a specific vehicle, in one optional approach, the method further includes steps S171-S174: S171, in response to a vehicle diagnostic assistance request, determine the target vehicle identification number corresponding to the vehicle diagnostic assistance request, wherein the vehicle diagnostic assistance request is a request to obtain diagnostic reference information corresponding to the same vehicle identification number.
[0091] Vehicle diagnostic assistance requests are typically triggered by events such as the vehicle connecting to diagnostic equipment, technicians actively scanning and identifying the vehicle, or the recommendation service module in the background, rather than being directly routed based on the natural language question entered by the user in the current round. When the electronic device receives this request, it parses the target vehicle identification number (VIN) of the vehicle to be diagnosed. The VIN is a unique identifier for a vehicle. By determining the target VIN, the core dimension of the current search can be clearly defined, namely, finding all historical diagnostic records for this specific vehicle.
[0092] S172, Based on the target vehicle identification number and the vehicle identification number index of the second database, determine the diagnostic assistance session data from the second database.
[0093] Since each session data entry written to the second database carries a vehicle identification number (VIN) and an index structure is established for this field, electronic devices can efficiently search the second database directly using the target VIN as the criterion.
[0094] Using this vehicle identification number (VIN) index, electronic devices can aggregate all historical session data for the vehicle, transcending boundaries between different session window identifiers, device identifiers, and user identifiers, to form complete diagnostic assistance session data. This data may include fault code reading records from previous visits to the dealership, data stream analysis results, and final repair plans.
[0095] S173, Generate diagnostic reference information based on diagnostic assistance session data.
[0096] Electronic devices or recommendation services communicating with them process and aggregate the extracted diagnostic assistance session data. For example, electronic devices can extract the vehicle's most frequently occurring fault codes, effective troubleshooting paths taken in historical repairs, or directly display a high-quality diagnostic dialogue from the past as a case study. Through natural language generation or structured data assembly, this historical session data is transformed into diagnostic reference information that can be used by the current technician, such as indicating that the vehicle was brought in three months ago for a specific fault code and the repair measures taken at that time.
[0097] S174, responds to vehicle diagnostic assistance requests based on diagnostic reference information.
[0098] The electronic device pushes the generated diagnostic reference information to the current client device and displays it to the technician in the form of recommendation cards, history prompts, etc.
[0099] By using long-term memory retrieval and response based on vehicle identification numbers, accurate historical diagnostic assistance for the same vehicle can be provided to technicians without interfering with the current main dialogue link. This effectively improves maintenance efficiency and diagnostic accuracy, and solves the problem of historical information gaps caused by different reception personnel or equipment.
[0100] In automotive diagnostic scenarios, single-dimensional retrieval often cannot meet the needs of complex business scenarios. For example, store managers may need to statistically analyze the query records of a specific diagnostic instrument for a specific vehicle within a certain period of time. This requires combining the device identifier, vehicle identification number, and time range for the query. To meet the advanced business needs such as complex and ever-changing store operation management, multi-window historical isolation query, and refined auditing, in one optional approach, this method also includes S181~S183: S181, in response to the combined retrieval request, determine the combined query conditions corresponding to the combined retrieval request, wherein the combined query conditions are retrieval conditions formed based on at least two of the multi-dimensional identifiers.
[0101] A combined search request refers to a data query request initiated by an operational reporting system, a multi-window history page, or a multi-dimensional audit function. When an electronic device receives this request, it parses the combined query conditions from the request parameters.
[0102] The combined query criteria are based on at least two dimensions from the aforementioned multi-dimensional identifiers. For example, the combined query criteria could be a combination of a device identifier and a vehicle identification number, used to query the historical operation records of a specific diagnostic instrument on a specific vehicle; or it could be a combination of a user identifier, a time range, and a session window identifier, used to review the work details of a specific technician in a specific session window within a specific time period.
[0103] S182, determine the target data from the second database based on the combined query conditions and multiple indexes of the second database.
[0104] Because index structures have been established for each dimension of the multi-dimensional identifier when asynchronously writing session data from the message queue to the second database, the second database has the ability to process multiple dimension query conditions simultaneously. Electronic devices push the parsed combined query conditions to the second database, which then uses multiple index structures to perform joint filtering on each dimension of the combined conditions. For example, a search engine can retrieve a set of matching documents for each dimension's index, then find the intersection of these sets to quickly locate the target data that simultaneously satisfies all combined dimensions, thereby improving retrieval efficiency and response speed in complex query scenarios.
[0105] S183, respond to the combined retrieval request based on the target data.
[0106] Electronic devices aggregate, sort, or format the retrieved target data and then return it to the requesting business module or front-end display page. For example, the retrieved historical diagnostic dialogue list can be presented to store managers in report form for equipment utilization statistics or operational quality audits.
[0107] The flexible and precise combination retrieval of persistent long-term memory provided in steps S181 to S183 can not only meet the data isolation and aggregation needs in complex cross-operation environments such as multiple devices, multiple sessions, multiple windows, and multiple vehicles in automotive diagnostic scenarios, but also provide a unified data query interface for upper-level applications such as refined operation management, compliance auditing, and personalized recommendations, thereby enhancing the business scalability of electronic devices and the utilization value of data assets.
[0108] In addition, to cope with abnormal situations in high concurrency and complex network environments, on the one hand, when executing step S120, if the writing of data to the first database or the writing to the message queue fails, the electronic device records the failure log and triggers asynchronous compensation to ensure that the data can eventually be repaired without affecting the successful writing operation on the other side and the response output to the user in the current round; on the other hand, when executing step S130, if the consumer fails to parse the data or fails to write to the second database, the electronic device will retry according to the preset retry strategy. If the retry still fails, the message will be transferred to the dead letter queue and an alarm will be issued to avoid silent data loss.
[0109] This embodiment of the application writes the acquired session data to both a first database and a message queue after the current round of dialogue ends. The message queue then asynchronously writes the data to a second database. Even if the data in the first database is deleted due to meeting preset deletion conditions, or if it encounters anomalies such as network jitter or cache failure, a copy of the data is still retained in the message queue. This ensures that the session data is successfully written to the second database, thereby avoiding the risk of inconsistency or permanent loss of session data between short-term and long-term storage and improving the reliability of session data storage.
[0110] Figure 3 A schematic diagram of the structure of a session data storage device provided in an embodiment of this application is shown. Figure 3 As shown, the storage device 200 for the session data includes: an acquisition module 210, a first writing module 220, and a second writing module 230.
[0111] The acquisition module 210 is used to acquire the session data of the current round of dialogue in response to the end of the current round of dialogue.
[0112] The first writing module 220 is used to write session data to a first database and a message queue, wherein data stored in the first database is deleted when preset deletion conditions are met.
[0113] The second writing module 230 is used to write session data in the message queue into the second database, wherein the storage duration of the data in the second database is longer than the storage duration of the data in the first database.
[0114] The session data storage device 200 provided in this application embodiment also includes a plurality of modules for performing each step of the above-described session data storage method, which will not be described in detail here.
[0115] Figure 4 The diagram shows a schematic of the structure of an electronic device provided in an embodiment of this application. The specific embodiments of this application do not limit the specific implementation of the electronic device 300.
[0116] like Figure 4As shown, the electronic device 300 may include a processor 302 and a memory 304.
[0117] The memory 304 is used to store the computer program 306. The memory 304 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device. The computer program 306 may include computer-executable instructions.
[0118] The processor 302 is used to execute the computer program 306 to implement the above-described method embodiment for storing session data.
[0119] Processor 302 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. Electronic device 300 may include one or more processors of the same type, such as one or more CPUs; or it may include processors of different types, such as one or more CPUs and one or more ASICs.
[0120] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for storing session data.
[0121] This application provides a computer program that can be executed by a processor to implement the above-described method for storing session data.
[0122] This application provides a computer program product, which includes a computer program that, when executed by a processor, implements the above-described method for storing session data.
[0123] In the several embodiments provided in this application, any function, if implemented as a software functional module / unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, part or all of the technical solutions of this application can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or other electronic device) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing computer program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0124] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, the embodiments of this application are not directed to any particular programming language. It should be understood that the content of this application described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of this application.
[0125] It should be noted that the above embodiments are illustrative of this application and not restrictive, and those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. This application can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In claims enumerating several means, several units or modules of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.
[0126] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A storage method of session data, characterized by, The method includes: In response to the end of this round of conversation, retrieve the session data for this round of conversation; The session data is written to a first database and a message queue, wherein the data stored in the first database is deleted when a preset deletion condition is met; The session data in the message queue is written to the second database, wherein the storage duration of the data in the second database is longer than the storage duration of the data in the first database.
2. The method of claim 1, wherein, The method further includes: Configure a time-to-live (TTL) for session data written to the first database; Perform a deletion operation on the data in the first database that meets the preset deletion conditions; The preset deletion conditions include that the data has not been accessed and no lifespan renewal operation has been performed during the lifetime.
3. The method of claim 2, wherein, The step of writing the session data into the first database and the message queue includes: Based on the session window identifier to which the session data belongs, determine the total number of rounds of historical session data associated with the session window identifier from the first database; If the total number of rounds of the historical session data reaches a preset threshold for the number of rounds in a single session, then the shortest-lived historical session data associated with the session window identifier in the first database is deleted. The session data is appended to the first database and written to the message queue.
4. The method according to claim 1, characterized in that, The session data includes user input information, response data corresponding to the input information, and the session window identifier for this round of dialogue; The method further includes: In response to the received current input information, obtain the target session window identifier carried in the current input information; Historical session data associated with the target session window identifier is read from the first database based on the target session window identifier. The current input information is processed based on the historical session data to generate target response data corresponding to the current input information; The target response data is output, wherein the end time of the current round of dialogue corresponding to the current input information is the time when the target response data is output.
5. The method according to claim 1, characterized in that, The session data includes multi-dimensional identifiers, including session window identifier, device identifier, and vehicle identification number; The step of writing the session data into the first database and the message queue includes: Using the session window identifier as an index, the session data is written into the first database; Write the session data into the message queue; The step of writing the session data in the message queue into the second database includes: Using the multi-dimensional identifier as an index, the session data in the message queue is written into the second database.
6. The method according to claim 5, characterized in that, The multi-dimensional identifier also includes a user identifier and a time range, wherein the time range is used to characterize the start and end information of the current round of dialogue corresponding to the session data; The method further includes: In response to a request to obtain cross-session data, the target user identifier and target time period information corresponding to the cross-session data are determined; Based on the target user identifier, the target time period information, the user identifier index and time range index of the second database, the target cross-session data is determined from the second database; The request to retrieve the cross-session data is responded to based on the target cross-session data.
7. The method according to claim 5, characterized in that, The method further includes: In response to a vehicle diagnostic assistance request, the target vehicle identification number corresponding to the vehicle diagnostic assistance request is determined, wherein the vehicle diagnostic assistance request is a request to obtain diagnostic reference information corresponding to the same vehicle identification number. Based on the target vehicle identification number and the vehicle identification number index of the second database, diagnostic assistance session data is determined from the second database; Diagnostic reference information is generated based on the diagnostic assistance session data; The vehicle diagnostic assistance request is responded to based on the diagnostic reference information.
8. The method according to claim 5, characterized in that, The method further includes: In response to a combined retrieval request, determine the combined query conditions corresponding to the combined retrieval request, wherein the combined query conditions are retrieval conditions formed based on at least two of the multi-dimensional identifiers; Based on the combined query conditions and multiple indexes of the second database, the target data is determined from the second database; The combined search request is responded to based on the target data.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the session data storage method according to any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the method for storing session data as described in any one of claims 1 to 8.
