Intelligent number asking method and device, electronic equipment and storage medium
Through MCP protocol and large language model analysis, the intelligent query system can achieve flexible and secure interface-level queries without complex configuration, solving the problems of cumbersome configuration and SQL injection in existing technologies.
Patent Information
- Application Number
- CN202510903038.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-01
- Publication Date
- 2025-10-03
AI Technical Summary
Existing intelligent question-answering technology is cumbersome to configure, has low flexibility, and carries the risk of SQL injection and sensitive information leakage.
The Model Context Protocol (MCP) is adopted as the standard protocol. The query intent is analyzed through a large language model, and the MCP tool is used to call the backend service interface to generate the answer text.
It enables flexible queries without complicated configuration, avoids SQL injection risks, and provides better query flexibility and security.
Smart Images

Figure CN120745832A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent question-answering technology, and in particular to an intelligent question-answering method, device, electronic device, and storage medium. Background Art
[0002] Intelligent Querying is an interactive data analysis tool based on artificial intelligence technology. Its core goal is to help users quickly obtain and interpret data and generate decision-support information in a conversational manner through natural language processing (NLP), deep learning, and large-scale model technologies. For non-programming professionals, they can directly obtain data from the backend system through natural language, and the presentation form is not limited to digital human voice dialogue, text dialog boxes, etc.
[0003] There are two traditional ways of asking numbers: 1. Preset query instructions: pre-configure question and answer pairs. When a user's intent matches a question (the hit logic may be full-text search or vector search), a pre-configured fixed answer template is displayed. The answer template contains the query instruction. By triggering the query instruction, the query results are obtained and populated into the question, realizing dynamic data query capabilities.
[0004] For example, the question-answer pair is "attendance rate" and "today's attendance rate is {queryAttendance}". When the user asks "today's attendance rate", the question "attendance rate" is hit, and the corresponding answer is parsed. When the command {queryAttendance} is parsed, the attendance rate is queried, and the result is filled in the answer, resulting in the answer "today's attendance rate is 98%".
[0005] The disadvantages of this approach include: 1. It requires a lot of configuration work, as it requires not only the command itself but also the query API information. 2. It's cumbersome to configure, requiring a large number of query and answer pairs for complex business scenarios. 3. It's inflexible, as it's unable to handle answers that require combined queries. 4. It's not intelligent and can't recognize user input parameters like "today."
[0006] Second, NL2SQL converts user questions into SQL statements through a specific language model, retrieves data after querying the database, and is summarized and answered by LLM.
[0007] For example, if the question is "People who are late today", assuming the user table is u and the attendance table is a, the converted SQL pseudo code is "select u. left join a on u.uid=a.uid where a.late=true and a.date=today”.
[0008] Disadvantages: 1. Insufficient support for complex queries, such as nested and cross-table queries. 2. Dependency on database structure design and data quality, resulting in a complex development process. 3. Security risks: Direct database access can easily lead to SQL injection and sensitive information leakage. 4. Immature semantic-to-SQL parsing capabilities. Summary of the Invention
[0009] In view of this, it is necessary to provide an intelligent number-asking method, device, electronic device and storage medium to solve the problems of cumbersome configuration of existing technologies, easy to cause SQL injection and sensitive information leakage.
[0010] In order to solve the above problems, in a first aspect, the present invention provides an intelligent number-asking method, comprising: Obtaining the query text entered by the user and the MCP tool list respectively; each MCP tool in the MCP tool list is constructed according to the interface description information of each backend service interface; Determining the query intent of the query text by using a large language model, and determining a target MCP tool from the MCP tool list according to the query intent; Calling a target service interface through the target MCP tool to obtain answer information from the backend; Generate an answer text according to the answer information.
[0011] In a possible implementation, the interface description information includes an interface description file, which is generated by the MCP tool in the following manner: Get the interface description files of each backend service interface; Parsing the interface description file and generating a configuration file for the MCP tool; The MCP tool is generated by registering the configuration file on the MCP server.
[0012] In a possible implementation, obtaining the interface description files of each backend service interface includes: An interface description file is generated according to the interface documents of each backend service interface through a first preset software program; the interface description file is a YAML or JSON format file that complies with the OpenAPI specification.
[0013] In a possible implementation, parsing the interface description file and generating a configuration file for the MCP tool includes: The interface description file is parsed by a second preset software program, and a configuration file of the MCP tool is automatically generated.
[0014] In a possible implementation, calling a target service interface by the target MCP tool includes: Determining, by the large language model, incoming query parameters based on the query text and tool information of the target MCP tool; Initiate a query request to the target service interface according to the input parameters and the API information in the tool information.
[0015] In one possible implementation, the method is applied to an intelligent questioning system; the intelligent questioning system includes the large language model and an MCP client; the MCP client is in communication with an MCP server; the MCP server includes the MCP tool; and obtaining the MCP tool list includes: Obtaining an MCP tool list from the MCP server via the MCP client; The calling of the target service interface by the target MCP tool to obtain the answer information from the backend includes: Invoking the target MCP tool through the MCP client or the large language model, so that the target MCP tool calls a target service interface; The answer information is obtained from the MCP server through the MCP client or the large language model; the answer information is generated by the backend after the target service interface is called and sent to the MCP server.
[0016] In a possible implementation, generating a response text according to the response information includes: Generate an answer text based on the query text and the answer information through the large language model.
[0017] In a second aspect, the present invention further provides an intelligent number-asking device, comprising: An information acquisition module is used to obtain the query text input by the user and the MCP tool list respectively; each MCP tool in the MCP tool list is constructed according to the interface description information of each backend service interface; a target MCP tool determination module, configured to determine the query intent of the query text using a large language model, and determine a target MCP tool from the MCP tool list according to the query intent; A target service interface calling module, configured to call a target service interface through the target MCP tool to obtain answer information from the backend; The answer text determination module is used to generate an answer text according to the answer information.
[0018] In a third aspect, the present invention further provides an electronic device comprising a memory and a processor, wherein the memory is used to store a program; and the processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in any one of the above-mentioned intelligent number-asking methods.
[0019] In a fourth aspect, the present invention further provides a computer-readable storage medium for storing a computer-readable program, wherein the program or instructions, when executed by a processor, can implement the steps in any one of the above-mentioned intelligent number-asking methods.
[0020] The beneficial effects of the present invention are: The Model Context Protocol (MCP), as a standard protocol, provides a unified interface for the interaction between AI models and external tools / data sources, similar to the "USB-C interface" in the AI field. The present invention constructs an MCP tool based on the interface description information of each back-end service interface. After the user enters the query text, the query intent of the query text can be analyzed by a large language model, as well as the target MCP tool that matches the query intent. The target service interface of the back-end is then called through the target MCP tool to obtain answer information from the back-end and generate an answer text. Compared with the existing question-and-answer query method, the present invention can save tedious question-and-answer configuration operations; compared with the existing SQL query method, it can avoid the risk of SQL injection and has better query flexibility, allowing users to perform professional interface-level queries through natural language. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 A schematic diagram of a flow chart of an embodiment of the intelligent number-asking method provided by the present invention; Figure 2 A schematic diagram of a flow chart of another embodiment of the intelligent number-asking method provided by the present invention; Figure 3 A schematic diagram of the intelligent number-asking method provided by the present invention; Figure 4 A schematic structural diagram of an embodiment of the intelligent number-asking device provided by the present invention; Figure 5 This is a schematic structural diagram of an embodiment of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0023] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of the present invention.
[0024] In the description of the embodiments of the present invention, unless otherwise specified, "multiple" means two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0025] The terms "first," "second," and the like used in the embodiments of the present invention are used to distinguish similar objects, and are not used to describe a specific order or precedence, nor are they used to indicate or imply relative importance or implicitly specify the number of technical features indicated. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of a class, and do not limit the number of objects. For example, the first object can be one or more.
[0026] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute a separate or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0027] Reference Figure 1 , which shows a flow chart of an embodiment of the intelligent number-asking method provided by the present invention, the method includes: S101, respectively obtaining a query text input by a user and an MCP tool list; each MCP tool in the MCP tool list is constructed according to the interface description information of each backend service interface.
[0028] The interface description information can be an interface description file. You can extract routing, description, request type, parameters, and return value information from the interface description file of the backend service interface and reorganize it into a configuration file in the toolsSchema format. Use the MCP official open source Typescript SDK "@modelcontextprotocol / sdk MCP" to directly register and generate the MCP tool.
[0029] In one example, taking JSON format as an example, a typical OpenAPI 3.0 JSON interface description file can be as follows: " / api / fetchAttendanceByDate": { "post": { "description": "Get the attendance rate for a certain day based on the input date", "parameters": [], "requestBody": { "content": { "application / json": { "schema": { "type": "object", "properties": { "date": { "type": "string", "title": "Date" } } } } } }, "responses": { "200": { "content": { "application / json": { "schema": { "type": "object", "properties": { "properties": { "attendance": { "type": "number", "title": "Attendance Rate" } } } } } } } } } } In one example, the MCP tool list may be returned in the following format: { method: "tools / list"}{ "tools": [ { "name": "get_alerts", "description": "Get weather warning information\nArgs:\nstate: state name\n", "inputSchema": { "properties": { "state": { "title": "State", "type": "string" } }, "required": [ "state" ], "type": "object" } } ]} This embodiment exemplarily displays an MCP tool list, which includes the get_alerts tool.
[0030] S102: Determine the query intent of the query text using a large language model, and determine a target MCP tool from the MCP tool list based on the query intent.
[0031] The large language model may be DeepSeek, Claude, etc. The large language model can be used to analyze the intent of the query text and determine the target MCP tool with a query function matching the query intent from the MCP tool list based on the query intent.
[0032] The target MCP tool may include one or more. For complex query functions, a large language model may decompose the query into multiple target MCP tool calls, and the calling process may be parallel or step-by-step.
[0033] S103: Call the target service interface through the target MCP tool to obtain response information from the backend.
[0034] Each MCP tool may correspond to a service interface. After calling the target MCP tool, the target MCP tool will further call the corresponding target service interface to obtain response information from the backend.
[0035] S104: Generate a response text based on the response information.
[0036] The intelligent number-asking method provided in this embodiment can be applied to an intelligent number-asking system, which can be a software system running on a terminal device. The terminal device can be a tablet computer, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a mobile phone, or other terminal device. This embodiment does not impose any restrictions on the specific type of terminal device.
[0037] In summary, this embodiment constructs an MCP tool based on the interface description information of each back-end service interface. After the user enters a query text, the query intent of the query text can be analyzed through a large language model, as well as the target MCP tool that matches the query intent. The target MCP tool then calls the target service interface of the back-end to obtain answer information from the back-end and generate an answer text. Compared with the existing question-and-answer query method, the present invention can save tedious question-and-answer configuration operations; compared with the existing SQL query method, it can avoid the risk of SQL injection. It also has better query flexibility, allowing users to perform professional interface-level queries through natural language, and non-invasively integrate the functions of the back-end service interface without changing the existing back-end code.
[0038] In some embodiments of the present invention, the MCP tool is generated by: obtaining interface description files of various backend service interfaces; parsing the interface description files and generating configuration files for the MCP tool; and registering the generated MCP tool on the MCP server through the configuration files.
[0039] In one example, the key pseudo code for registering and generating an MCP tool is as follows: const toolsSchema=[{ name: "fetchAttendanceByDate", description: "Get the attendance rate for a certain day based on the input date", inputSchema: { type: "object", properties: { date: { type: "string", description: "Date"}, }, required: ["date"] } }] mcpServer.setRequestHandler(ListToolsRequestSchema, async () =>{ return { tools: toolsSchema }; }) In some embodiments of the present invention, the step of obtaining the interface description file of each backend service interface includes: generating an interface description file based on the interface document of each backend service interface through a first preset software program; the interface description file is a YAML or JSON format file that complies with the OpenAPI specification.
[0040] OpenAPI (Open API) is a technical specification that allows third-party developers to access and integrate specific services through standardized interfaces. It is based on the HTTP protocol and uses JSON or YAML format to describe the interface. It supports automated tools to generate documents, client / server code, and implement API debugging and testing. It also supports automatic document generation, such as Swagger UI.
[0041] In this embodiment, the backend service interface can first be described according to the OpenAPI protocol, such as the OpenAPI 3.0 protocol, to obtain key information such as description, routing, method type, input parameters, request header, body, return value type, etc. Since most backend services currently require the output of service interface description documents, and OpenAPI 3.0 is one of the most popular interface description standards, this step is often completed automatically.
[0042] The interface document can then be exported as an interface description file in YAML or JSON format that complies with the OpenAPI specification through a first preset software program. The first preset software program can be a Swagger software program or an APIFox software program.
[0043] In this embodiment, no matter whether the backend is built based on Go, Node or Java, it is only necessary to adapt the OpenAPI3.0 protocol to generate an interface description file, and generate an MCP tool through the interface description file. No modification of the backend is required, and it is easy to expand to new systems and existing systems.
[0044] In some embodiments of the present invention, the step of parsing the interface description file and generating the configuration file of the MCP tool may include: parsing the interface description file by a second preset software program and automatically generating the configuration file of the MCP tool.
[0045] The second preset software program can be self-built software. After generating the configuration file of the MCP tool, the subsequent MCP tool registration process can also be automatically completed.
[0046] In this embodiment, the configuration file generation and MCP tool registration are automatically completed by the second preset software program, which can save time and labor costs.
[0047] In some embodiments of the present invention, the step of calling the target service interface through the target MCP tool includes: determining the query input parameters based on the query text and the tool information of the target MCP tool through the large language model; and initiating a query request to the target service interface based on the input parameters and the API information in the tool information.
[0048] When an MCP tool triggers a call, it searches for the specified toolSchema (tool information) based on the name attribute (tool name) of the MCP tool in the toolsSchema (tool list). After obtaining the toolSchema, it initiates a WebAPI call. In an example, the key pseudo code is as follows: mcpServer.setRequestHandler(CallToolRequestSchema, async (request) =>{ / / request.params.name is the name of the called tool const toolSchema=toolsSchema.find(x=>{return x.name==request.params.name}) / / callWebAPI is a method for initiating an HTTP request based on the WebAPI request information described in toolSchema. The specific content will not be described in detail here. const res=await callWebAPI(toolSchema) return { content: [ { type: "text", text: JSON.stringify({ data: res. }) } ] }; break; } }); Reference Figure 2 , shows a flow chart of another embodiment of the intelligent number-asking method provided by the present invention, the method being applied to an intelligent number-asking system; the intelligent number-asking system includes a large language model and an MCP client; the MCP client is in communication with an MCP server; the MCP server includes an MCP tool; obtaining a list of MCP tools, the method comprising: S201: Obtain an MCP tool list from an MCP server via an MCP client.
[0049] Since MCP is just a protocol, you can implement the client and server yourself based on this protocol, or you can use the officially provided TypeScript SDK toolkit to implement it. The above describes the method of using the toolkit TypeScript SDK to implement it. In fact, you can also implement it yourself or use other third-party MCP toolkits. There are no restrictions on language and method, as long as you comply with the protocol.
[0050] S202 : determining the query intent of the query text input by the user through a large language model, and determining a target MCP tool from the MCP tool list according to the query intent.
[0051] S203: calling a target MCP tool through the MCP client or the large language model, so that the target MCP tool calls a target service interface.
[0052] The large language model can have the FunctionCall function, so that the large language model can call the MCP tool through the MCP protocol in FunctionCall.
[0053] S204, obtaining answer information from the MCP server through the MCP client or the large language model; the answer information is generated by the backend after the target service interface is called and sent to the MCP server.
[0054] If the target MCP tool is called using the MCP client, the answer information is obtained from the MCP server through the MCP client; if the target MCP tool is called using the large language model, the answer information is obtained from the MCP server through the large language model.
[0055] S205: Generate an answer text based on the query text and answer information using a large language model.
[0056] This embodiment can realize that the interface of the backend service can be used as a tool by the intelligent data query system, so that the intelligent data query system has the ability to access the interface and obtain data.
[0057] Reference Figure 3 , showing a schematic diagram of an intelligent number-asking method provided by the present invention. The MCP server (MCPServer) needs to implement an interface called "tools / list," which returns a list of MCP tools. Upon startup, the MCP client (MCP Client) first requests the MCP tool list from the MCP server and returns it to the Large Language Model (LLM) for interpretation.
[0058] For example, the above interface provides a tool for obtaining weather warning information for a specific location. When the LLM receives the question "What's the weather like in Region A?", it determines based on its previously understood list of tools that it needs to call the get_alerts tool and infers the parameter as Region A based on the tool's input schema (all of which are LLM's function call capabilities). At this point, the LLM initiates a tool call command to the MCP server via the MCP client, or directly calls the tool via the MCP protocol in FunctionCall. This process is officially encapsulated for us.
[0059] MCP defines the rules for the MCP client to initiate tool calls to the MCP server, and for the MCP server to respond to the calls. The rules are as follows: 1. Using JSONRPC2.0 protocol; 2. The request example is as follows: { "jsonrpc": "2.0", "method": "get_alerts", "params": ["A region"], "id": 1} 3. The response example is as follows: { "jsonrpc": "2.0", "result": "Thunderstorm warning, north wind level 3~4", "id": 1} When the MCP server receives the request, it calls the business interface and, after receiving the backend return information, organizes it into a response format and returns it to the MCP client.
[0060] After receiving the response from the MCP server, the MCP client sends the data to the LLM for integration and generates the final return result: "Thunderstorm warning for area A today, north wind level 3~4."
[0061] At this point, the entire process of intelligent number asking is described.
[0062] In summary, this embodiment has the following beneficial effects: 1. Non-intrusive integration: No need to modify existing backend code. Most modern backend systems basically follow the OpenAPI 3.0 protocol and produce interface documents. Swagger's YAML or JSON files can be used to parse and generate MCP tool configuration and automated tool registration.
[0063] 2. Compatibility: Whether the backend is built on Go, Node, or Java, it only needs to adapt to the OpenAPI 3.0 protocol without any modification to the backend. It is easy to expand to new and existing systems.
[0064] 3. High security: Compared with the NL2SQL solution, the present invention directly calls the public interface and has no SQL security issues unless the interface itself is insecure.
[0065] 4. Low complexity: The workload of the present invention is independent of the number of interfaces. MCP configuration is generated and registration is completed through YAML / JSON parsing, without the need for complicated configuration.
[0066] 5. High intelligence: The present invention can automatically analyze the tools and parameters to be called based on the tool list through LLM. Complex functions can be decomposed into multi-step tool calls, allowing users to perform professional interface-level queries through natural language.
[0067] 6. Standardization and compatibility: Based on industry standards such as OpenAPI 3.0 and MCP, the system ensures broad compatibility with existing backend services and future scalability.
[0068] Reference Figure 4 , which shows a schematic structural diagram of an embodiment of an intelligent number-asking device provided by the present invention, wherein the device 400 includes: The information acquisition module 401 is used to respectively acquire the query text input by the user and the MCP tool list; each MCP tool in the MCP tool list is constructed according to the interface description information of each backend service interface; A target MCP tool determination module 402 is configured to determine the query intent of the query text using a large language model, and determine a target MCP tool from the MCP tool list based on the query intent; The target service interface calling module 403 is used to call the target service interface through the target MCP tool to obtain the response information from the backend; The answer text determination module 404 is used to generate an answer text according to the answer information.
[0069] It should be noted that the implementation principles or implementation processes of the above modules can refer to the embodiments of the above-mentioned intelligent number-asking method, and will not be described in detail here.
[0070] Reference Figure 5 , shows an electronic device 500 provided by the present invention. The electronic device 500 includes a processor 501, a memory 502 and a display 503. Figure 5 Only some of the components of the electronic device 500 are shown, but it should be understood that implementation of all of the shown components is not required, and more or fewer components may be implemented instead.
[0071] In some embodiments, the processor 501 may be a central processing unit (CPU), a microprocessor, or other data processing chip, configured to execute program codes stored in the memory 502 or process data, such as the intelligent number-finding method of the present invention.
[0072] In some embodiments, processor 501 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, processor 501 may be local or remote. In some embodiments, processor 501 may be implemented on a cloud platform. In one embodiment, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, multiple clouds, or any combination thereof.
[0073] In some embodiments, the memory 502 may be an internal storage unit of the electronic device 500, such as a hard disk or memory of the electronic device 500. In other embodiments, the memory 502 may also be an external storage device of the electronic device 500, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 500.
[0074] Furthermore, the memory 502 may include both an internal storage unit of the electronic device 500 and an external storage device. The memory 502 is used to store application software installed in the electronic device 500 and various data.
[0075] In some embodiments, display 503 can be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. Display 503 is used to display information about electronic device 500 and to display a visual user interface. Components 501-503 of electronic device 500 communicate with each other via a system bus.
[0076] In one embodiment, when the processor 501 executes the smart number query program in the memory 502, the following steps may be implemented: Obtain the query text entered by the user and the MCP tool list respectively; each MCP tool in the MCP tool list is constructed according to the interface description information of each backend service interface; Determine the query intent of the query text through a large language model, and determine the target MCP tool from the MCP tool list based on the query intent; Call the target service interface through the target MCP tool to obtain the response information from the backend; Generate answer text based on the answer information.
[0077] It should be understood that, when the processor 501 executes the intelligent number-asking program in the memory 502 , in addition to the above functions, it can also implement other functions. For details, please refer to the description of the corresponding method embodiment above.
[0078] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 500 mentioned. The electronic device 500 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, or the like. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices equipped with IOS, Android, Microsoft, or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 500 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0079] In one embodiment, the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by the processor, the steps of any one of the above-mentioned intelligent number-asking methods are implemented.
[0080] Those skilled in the art will appreciate that all or part of the process steps of the above-described embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, such as a magnetic disk, an optical disk, a read-only memory, or a random access memory.
[0081] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with this technical field within the technical scope disclosed by the present invention should be covered by the scope of protection of the present invention.
Claims
1. An intelligent number-asking method, characterized in that: include: Obtaining the query text entered by the user and the MCP tool list respectively; each MCP tool in the MCP tool list is constructed according to the interface description information of each backend service interface; Determining the query intent of the query text by using a large language model, and determining a target MCP tool from the MCP tool list according to the query intent; Calling a target service interface through the target MCP tool to obtain answer information from the backend; Generate an answer text according to the answer information.
2. The intelligent number-asking method according to claim 1, characterized in that: The interface description information includes an interface description file, which is generated by the MCP tool in the following manner: Get the interface description files of each backend service interface; Parsing the interface description file and generating a configuration file for the MCP tool; The MCP tool is generated by registering the configuration file on the MCP server.
3. The intelligent number-asking method according to claim 2, characterized in that: The interface description files of each backend service interface are obtained, including: An interface description file is generated according to the interface documents of each backend service interface through a first preset software program; the interface description file is a YAML or JSON format file that complies with the OpenAPI specification.
4. The intelligent number-asking method according to claim 2, characterized in that: The interface description file is parsed and a configuration file of the MCP tool is generated, including: The interface description file is parsed by a second preset software program, and a configuration file of the MCP tool is automatically generated.
5. The intelligent number-asking method according to claim 1, characterized in that: The calling of the target service interface by the target MCP tool includes: Determining, by the large language model, incoming query parameters based on the query text and tool information of the target MCP tool; Initiate a query request to the target service interface according to the input parameters and the API information in the tool information.
6. The intelligent number-asking method according to claim 1, characterized in that: The method is applied to an intelligent questioning system; the intelligent questioning system includes the large language model and an MCP client; the MCP client is in communication with an MCP server; the MCP server includes the MCP tool; obtaining the MCP tool list includes: Obtaining an MCP tool list from the MCP server via the MCP client; The calling of the target service interface by the target MCP tool to obtain the answer information from the backend includes: Invoking the target MCP tool through the MCP client or the large language model, so that the target MCP tool calls a target service interface; The answer information is obtained from the MCP server through the MCP client or the large language model; the answer information is generated by the backend after the target service interface is called and sent to the MCP server.
7. The intelligent number-asking method according to claim 6, characterized in that: Generating a response text according to the response information includes: Generate an answer text based on the query text and the answer information through the large language model.
8. An intelligent number-asking device, characterized in that: include: An information acquisition module is used to obtain the query text input by the user and the MCP tool list respectively; each MCP tool in the MCP tool list is constructed according to the interface description information of each backend service interface; a target MCP tool determination module, configured to determine the query intent of the query text using a large language model, and determine a target MCP tool from the MCP tool list according to the query intent; A target service interface calling module, configured to call a target service interface through the target MCP tool to obtain answer information from the backend; The answer text determination module is used to generate an answer text according to the answer information.
9. An electronic device, characterized in that: comprising a memory and a processor, wherein, The memory is used to store programs; The processor is coupled to the memory and is configured to execute the program stored in the memory to implement the steps of the intelligent number-asking method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps of the intelligent number-asking method described in any one of claims 1 to 7.
Citation Information
Cited By
Data query method and device, computer equipment, storage medium and program product
CN121412268A
Interface configuration method and device based on large language model, medium and electronic equipment
CN121681003A