Question and answer system based on multiple AIs
By designing a multi-AI-based question-and-answer system, using concurrent execution modules and cache mechanisms, the response delay problem of existing AI systems is solved, faster response results are pushed, and system response efficiency is improved.
Patent Information
- Application Number
- CN202411310578.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2025-01-10
AI Technical Summary
The existing AI Q&A system has a long response time due to network delay or background computing capabilities, and there is a problem of response delay.
Design a multi-AI-based question and answer system, log in to multiple third-party AI systems through the initialization module, establish a question distribution queue and client response queue, and adopt concurrent execution module and cache module to realize long-connected resource recycling of third-party AI systems and The time sorting and push of the response results is ensured that the response results arrive at the client in the order of reception time.
It effectively solves the problem of large feedback time delay in response problems of a single AI system, and improves the response speed and response efficiency.
Smart Images

Figure CN119296530A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of intelligent AI, and in particular relates to a question-answering system based on multiple AIs. Background Art
[0002] In the AI systems of the prior art, each AI question-answering system is a web-based application, and the response time of each AI is long due to network delay or background computing power. Summary of the invention
[0003] The purpose of this embodiment is to provide a question-answering system based on multiple AIs, which is used to solve the problem of long response delay of AIs due to network delay or background computing capacity.
[0004] The present invention provides a multi-AI based question-answering system, comprising:
[0005] Initialization module: used to log in to multiple third-party AI systems, establish question distribution queues, and establish client response queues; wherein the third-party AI systems and question distribution queues are in a one-to-one correspondence;
[0006] Login module: used to respond to client user login and establish client session, including
[0007] The establishing of the client session comprises establishing a session based on a WEBSOCKET connection;
[0008] Question distribution module: used to execute the third-party AI system question request according to the request data in the question distribution queue. The question distribution module is a concurrent execution module under an independent thread;
[0009] Cache module: used to respond to the client's historical question cache, including establishing REDIS memory mapping cache table, establishing file cache table, and establishing database cache table;
[0010] Session persistence module: used to respond to the client's survival packet status refresh and resource recovery;
[0011] Resource recovery module: used for long connection resource recovery of third-party AI systems, including detecting that the third-party AI system connection is idle for more than a preset time and releasing the long connection resources of the third-party AI system;
[0012] Questioning module: used to respond to the client's question request and execute the question distribution of the third-party AI system and obtain the answer result of the third-party AI system, and also includes placing the answer result of the third-party AI system into the client answer queue according to the order of receipt time;
[0013] Response module: used to execute client data push according to the client response queue, wherein the execution of client data push includes executing the client response queue head data acquisition and pushing to the client, wherein the queue head is the first data, and also includes executing the first data deletion operation after acquiring the first data push.
[0014] Furthermore, log in to multiple third-party AI systems, including:
[0015] The third-party AI login module is used to perform third-party AI system login according to the configuration parameters;
[0016] A third-party AI session maintenance module, used to maintain a long connection after logging into the third-party AI system, wherein the long connection maintenance includes an SSE connection with the third-party AI system;
[0017] Furthermore, the distribution of questions by the third-party AI system includes executing the client request content and inserting it into the distribution queue table.
[0018] Furthermore, executing the insertion of the client request content into the distribution queue table also includes executing data locking of the distribution queue table, including locking of a shared data area.
[0019] Furthermore, the session maintaining module further includes determining that the client is invalid and disconnecting the WEBSOCKET connection when it is detected that the update time difference between two requests from the client is greater than the maximum setting time.
[0020] Further, detecting the idle time of the WEBSOCKET connection of the client includes detecting the time interval between two adjacent data of the WEBSOCKET request content.
[0021] Furthermore, the interval time between two adjacent data includes the second request time of the client minus the first request time.
[0022] Furthermore, releasing the long connection resources of the third-party AI system includes disconnecting the SSE connection with the third-party AI system.
[0023] Furthermore, the time sorting includes that the first time arrival result of the response result of the third-party AI system is the first data in the client response queue.
[0024] Furthermore, the questioning module also includes executing a questioning request of a third-party AI system by combining N rounds of client request data according to the content of the REDIS memory mapping cache table, wherein N is greater than 1. A multi-AI based question-answering system provided by the present invention solves the problem of a large delay in the feedback time of answering questions by a single AI system.
[0025] The present invention provides a multi-AI based question-answering system, which solves the problem of long feedback delay in answering questions by a single AI system.
[0026] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 : A system structure diagram of a multi-AI based question answering system provided in an embodiment of the present invention;
[0028] Figure 2 : A network topology diagram of a multi-AI based question-answering system provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention. In the following embodiments, the codes are written in go language, and the database part adopts sql syntax. The implementation part in the embodiments is not limited to go language, and other languages can also achieve the same function, such as PHP, nodejs, C or C++, which is not limited in the present invention.
[0030] A question-answering system based on multiple AIs (see Figure 1 ), Figure 2 It is a network topology diagram of the present invention, comprising:
[0031] P01: Initialization module: used to log in to multiple third-party AI systems, create a problem distribution queue group, create a client response queue; create a login session queue; wherein the third-party AI system and the problem distribution queue group are in a one-to-one correspondence. In this embodiment, multiple third-party AI system logins read the third-party AI system login account and password through a database or configuration file and initiate a login request to the third-party AI system. The implementation method adopts the open of the os library of the go language to read the configuration file. The login of the third-party AI system includes a third-party AI login module, which is used to execute the third-party AI system login according to the configuration parameters; a third-party AI session maintenance module, which is used to perform long connection maintenance and establish session data after the third-party AI system logs in, wherein the long connection maintenance includes an SSE connection with the third-party AI system;
[0032] In the embodiment, if an SSE connection is established after the third-party AI system successfully logs in, it is used to receive the response result data of the third-party AI system. When connecting to the SSE of the third-party AI system, the initialization module is the SSE (Server-Sent Events) connection established when the client initiates an https request. A secondary login request is initiated using Post or Get of the http library, and the session establishment of the third-party AI system is executed according to the returned result, including using the REDIS framework to create a memory mapping MAP data list; a channel is created for each third-party AI system to establish a connection, and a channel execution module corresponds to a problem distribution queue, which is created by the go func syntax of the go language. The channel function is a processing module for the connection of the third-party AI system with concurrent access; the problem distribution queue group, the client response queue, and the login session queue are implemented by the slice queue of the go language. The syntax includes slice creation, and the pseudo code is as follows:
[0033]
[0034] The embodiment also includes creating a synchronization lock for accessing the problem distribution queue group and the client response queue, which is used to synchronize the access of the two queues to prevent data confusion and abnormal access to the queue. The synchronization lock access code is as follows:
[0035] Define synchronization lock lock sync.Mutex;
[0036] Use synchronization lock lock.Lock();
[0037] Release the synchronization lock lock.Unlock();
[0038] P02: Login module: used to respond to client user login and establish client session, wherein the establishment of client session includes establishing a session based on WEBSOCKET connection and inserting request parameters into the login session queue. In this embodiment, a memory mapping table under the REDIS framework is established based on the user session identifier in the client request parameter, the key is the user session identifier, the value is the structure data, the structure data includes the login time and the update time. In the embodiment, the client uses a long connection mode, and the beego framework of the go language is used to respond to the client's Get request to execute the access link creation of the WEBSOCKET long connection. The instructions include upgrader=websocket.Upgrader and upgrade.Upgrade, wherein websocket is the WEBSOCKET operation library of the go language, and can also be implemented by calling the C++ library or other third-party operation library using the go language. The login module also includes executing account and password authentication. If the account and password authentication is successful, data insertion into the login session queue is executed;
[0039] P03: Question distribution module: used to execute the third-party AI system question request according to the request data in the question distribution queue group. The question distribution module is a concurrent execution module under an independent thread. In this embodiment, the independent thread is created by the initialization module through the go func syntax. The question distribution module periodically polls the question distribution queue group. When accessing the question distribution queue group, a synchronization lock is used to lock the queue to prevent the request initiated by the client from conflicting with it, so that the present invention reports an access exception error. The following code is added before and after the statement block for executing the question distribution queue group to prevent access exception errors:
[0040] lock.Lock()
[0041] Get client question requests from the question queue
[0042] lock.Unlock()
[0043] The question distribution module obtains the client's question request from the question queue, executes the second request construction, and then initiates an https request to the third-party AI system and obtains the third-party AI response result. The syntax of the go language used in the embodiment is as follows:
[0044]
[0045] P04: Cache module: used to respond to the client's historical question cache, including establishing a REDIS memory mapping cache table, establishing a file cache table, and establishing a database cache table; in the embodiment, a REDIS memory mapping cache table is established to cache historical questions and the answer results of the third-party AI system when the client asks multiple rounds of questions, and is used as the historical question content of the third-party AI system when the client asks questions later, and as the request parameter for the question distribution module to initiate a request to the third-party AI system, to ensure that the answer result of the third-party AI system can have the coherence of multiple rounds of questions. The understanding result is returned, the file cache table is established for the historical log record of the server error check, and the database cache table is used for the back-end management website to query the log of historical questions;
[0046] P05: Session maintenance module: used for responding to the status refresh and resource recovery of the client survival packet; in the embodiment, in response to the client sending a heartbeat packet through a timer, the update time in the session connection established by the login module is updated, and the server uses a timer to periodically poll the update time difference of two requests in the login session queue to determine whether the client is still alive. If the time difference between the two question requests from the client is greater than the set default maximum survival time, it is determined that the client has expired, which is set to 24 hours in this implementation. If the client fails, the corresponding data in the login session module is deleted.
[0047] P06: Resource recovery module: used for long connection resource recovery of third-party AI system, including detecting that the third-party AI system connection is idle for more than a preset time, and releasing the long connection resources of the third-party AI system; in this embodiment, the idle connection of the third-party AI system is detected by the timer module of the session maintenance module polling the problem distribution queue group, detecting the insertion time of the record in each third-party distribution queue in the queue group, and obtaining the insertion time of the last record in the queue. If the insertion time is greater than the set maximum third-party AI system survival time, it is determined that the third-party AI system fails. If the third-party AI system fails, the connection resources with the third-party AI system are released. In the embodiment, the SSE connection resources established with the third-party AI system are released, including disconnecting and clearing the third-party session data.
[0048] P07: Questioning module: used to respond to the client's question request and execute the question distribution of the third-party AI system and obtain the answer result of the third-party AI system. In the embodiment, the questioning module combines N rounds of client request data according to the content of the REDIS memory mapping cache table to execute the question request of the third-party AI system, wherein N is greater than 1, and the combination of historical data initiates the question so that the third-party AI system can establish a relevant answer according to the submitted question; it also includes placing the answer result of the third-party AI system in the client answer queue according to the order of reception time. In this implementation, executing the question distribution of the third-party AI system includes constructing a question identifier and question content according to the question request parameters of the client and synchronously distributing them to the question distribution queue group. When executing the question distribution queue group insertion, the synchronization lock is used to insert the question distribution queue group data. The questioning module also includes obtaining the answer result of the third-party AI system. Since the return time of the third-party AI answer result will not be returned at the same time, this module places the returned results in the client answer queue in the order of time according to the time sequence, that is, the result returned earliest in time is placed in the first record of the queue, and it can be first-in-first-out when it is obtained;
[0049] P08: Response module: used to execute client data push according to the client response queue, wherein the execution of client data push includes executing the acquisition of the client response queue head data and pushing it to the client, wherein the queue head is the first data. In this embodiment, the response module uses the timer statement of the go language to poll the client response queue. If there is data in the client response queue, the third-party AI system response result push client instruction is executed, and the instruction content includes the following syntax:
[0050]
[0051] Where conn is the WEBSOCKET connection object, time.After(500*time.Millisecond) is a 0.5 second timer;
[0052] This module also includes executing the first data deletion operation after obtaining the first data push, and the deletion queue operation includes executing the deletion slice instruction, and the code is: client response queue = append (client response queue [: index], client response queue [index+1:]).
[0053] The present invention provides a multi-AI based question-answering system, which solves the problem of long feedback delay in answering questions by a single AI system.
[0054] The above description is only an embodiment of the present invention and is not intended to limit the scope of protection of the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A multi-AI based question-answering system, characterized in that: include: Initialization module: used to log in to multiple third-party AI systems, establish question distribution queues, and establish client response queues; wherein the third-party AI systems and question distribution queues are in a one-to-one correspondence; Login module: used to respond to client user login and establish client session, wherein establishing client session includes establishing session based on WEBSOCKET connection; Question distribution module: used to execute the third-party AI system question request according to the request data in the question distribution queue. The question distribution module is a concurrent execution module under an independent thread; Cache module: used to respond to the client's historical question cache, including establishing REDIS memory mapping cache table, establishing file cache table, and establishing database cache table; Session persistence module: used to respond to the client's survival packet status refresh and resource recovery; Resource recovery module: used for long connection resource recovery of third-party AI systems, including detecting that the third-party AI system connection is idle for more than a preset time and releasing the long connection resources of the third-party AI system; Questioning module: used to respond to the client's question request and execute the question distribution of the third-party AI system and obtain the answer result of the third-party AI system, and also includes placing the answer result of the third-party AI system into the client answer queue according to the order of receipt time; Response module: used to execute client data push according to the client response queue, wherein the execution of client data push includes executing the client response queue head data acquisition and pushing to the client, wherein the queue head is the first data, and also includes executing the first data deletion operation after acquiring the first data push.
2. The multi-AI based question-answering system according to claim 1, characterized in that: The logging into multiple third-party AI systems includes: The third-party AI login module is used to perform third-party AI system login according to the configuration parameters; The third-party AI session maintenance module is used to perform long connection maintenance after the third-party AI system logs in, wherein the long connection maintenance includes the SSE connection with the third-party AI system.
3. The multi-AI based question answering system according to claim 1, characterized in that: The question distribution of the third-party AI system includes executing the client request content and inserting it into the distribution queue table.
4. The multi-AI based question answering system according to claim 3, characterized in that: The executing the client request content insertion into the distribution queue table also includes executing data locking of the distribution queue table, including locking of a shared data area.
5. The multi-AI based question answering system according to claim 1, characterized in that: The session maintaining module also includes a method for determining that the client is invalid and disconnecting the WEBSOCKET connection when the update time difference between two requests from the client is greater than a maximum setting time.
6. The multi-AI based question answering system according to claim 5, characterized in that: The detecting of the idle time of the WEBSOCKET connection of the client includes detecting the interval time between two adjacent data of the request content of the WEBSOCKET.
7. The multi-AI based question answering system according to claim 6, characterized in that: The interval time between two adjacent data includes the second request time of the client minus the first request time.
8. The multi-AI based question answering system according to claim 1, characterized in that: The releasing of the long connection resources of the third-party AI system includes disconnecting the SSE connection with the third-party AI system.
9. The multi-AI based question answering system according to claim 1, characterized in that: The time sorting includes that the first time arrival result of the response result of the third-party AI system is the first data in the client response queue.
10. The multi-AI based question answering system according to claim 1, characterized in that: The questioning module also includes executing a questioning request of a third-party AI system for N rounds of client request data according to the content combination of the REDIS memory mapping cache table, where N is greater than 1.
Citation Information
Cited By
Real-time distribution method, system and equipment for AI dialogue streams based on publishing and subscribing mode, medium and program product
CN121567542A
Data processing system, method, device, storage medium, and program product
CN121691449A