A method, system, electronic device, and storage medium for dynamically enhancing prompt words.

By using dynamic knowledge graph parsing and generating structured enhanced prompts, the problem of inaccurate parameter recognition caused by static prompt generation in existing technologies is solved, achieving more efficient tool calls and dialogue coherence, and adapting to multi-turn dialogue scenarios.

CN122133652APending Publication Date: 2026-06-02TONGFANG KNOWLEDGE DIGITAL PUBLISHING TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TONGFANG KNOWLEDGE DIGITAL PUBLISHING TECH CO LTD
Filing Date
2026-05-06
Publication Date
2026-06-02

Smart Images

  • Figure CN122133652A_ABST
    Figure CN122133652A_ABST
Patent Text Reader

Abstract

This invention relates to the field of computer technology and discloses a method, system, electronic device, and storage medium for dynamically enhancing prompts. The method includes: acquiring the user's current request and the corresponding dialogue history context to form complete dialogue information containing temporal relationships; performing contextual semantic parsing on the current request and dialogue history context to obtain structured parsing information; querying a dynamic knowledge graph based on the structured parsing information and the information retrieved from the dynamic knowledge graph; performing context-aware completion and formatting processing on the parameters required for tool calls based on the structured parsing information and the information retrieved from the dynamic knowledge graph to obtain a processed parameter set; and dynamically generating structured enhanced prompts for submission to a large language model based on the processed parameter set and the corresponding tool description. This invention enables effective management and utilization of multi-turn dialogue context.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and specifically to a method, system, electronic device, and storage medium for dynamically enhancing prompt words. Background Technology

[0002] In existing intelligent agent systems, tool calls using large language models typically follow the model context protocol.

[0003] Existing technical solutions generally include the following steps: the user submits a request in natural language; the system generates static prompt words based on predefined tool descriptions to guide the large language model in constructing the function call request; the large language model converts the user request into specific function call parameters based on the given prompt words; the generated function call is sent to the corresponding server endpoint for execution, and the result is returned to the user.

[0004] The existing technology has the following drawbacks:

[0005] Because the prompts are statically generated and do not take into account the dialogue history context, parameters that depend on context information cannot be correctly identified, resulting in missing parameters. For implicit expressions, such as parameters that are vaguely mentioned or indirectly referred to, existing systems struggle to accurately capture and convert them into structured data. Once a prompt template is set, it is not easy to adjust and it is difficult to adapt to changes in needs in different scenarios; If a call fails, the system will have difficulty using the existing context information to perform effective error correction or parameter supplementation.

[0006] Therefore, this application provides a method for dynamically enhancing prompt words to solve the above-mentioned technical problems. Summary of the Invention

[0007] The purpose of this invention is to provide a method, system, electronic device, and storage medium for dynamically enhancing prompt words, so as to solve the technical problem of inaccurate tool invocation caused by the lack of context utilization in the prior art.

[0008] To address the aforementioned technical problems, this invention provides a method for dynamically enhancing prompt words, comprising: In response to the current user request and the corresponding dialogue history context, a complete dialogue information containing temporal relationships is formed. The current request and the dialogue history context are subjected to contextual semantic parsing, and structured parsing information containing user intent, explicit parameters and implicit parameters is obtained through intent recognition and parameter extraction; Based on the structured parsing information, a dynamic knowledge graph is queried. The dynamic knowledge graph includes a tool layer, a parameter layer, and a context layer. The tool layer stores tool descriptions, the parameter layer stores parameter specifications, and the context layer stores parameter instances generated in historical dialogues. Based on the structured parsing information and the information queried from the dynamic knowledge graph, the parameters required for tool invocation are subjected to context-aware completion and formatting processing. The completion and formatting processing includes parameter missing identification, completion based on historical parameter instances, and format standardization according to parameter specifications to obtain the processed parameter set. Based on the processed parameter set and the corresponding tool description, structured enhancement prompts for submission to the large language model are dynamically generated, wherein the structured enhancement prompts integrate tool descriptions, parameter sets, and instantiation call constraints.

[0009] In some specific embodiments, in response to the acquired current user request and the corresponding dialogue history context, a complete dialogue information containing temporal relationships is formed, further including: The system captures natural language requests submitted by users in text or speech-to-speech form in real time through the input interface, and uses them as the current request after preprocessing. Based on the user session identifier, retrieve all historical interaction records of the user from the persistent storage medium from the beginning of the current session to the present to form a historical dialogue list; The current request is inserted into the end of the history dialogue list in chronological order to form a coherent dialogue flow, resulting in a dialogue context that includes the chronological order. The combined complete dialogue text sequence is output as context information.

[0010] In some specific embodiments, contextual semantic parsing is performed on the current request and the dialogue history context. Structured parsing information containing user intent, explicit parameters, and implicit parameters is obtained through intent recognition and parameter extraction. This further includes: The current request is subjected to intent recognition. By using a pre-trained intent classification model or a rule-based keyword matching method, the semantic orientation of the current request is analyzed to determine the target tool to which the user's intent is directed. Explicit parameters are extracted from the current request, and named entity recognition or slot filling methods are used to extract explicitly mentioned parameters and their corresponding values ​​from the request text. By combining the dialogue history context, the parameters implicit in the current request are analyzed, the pronouns and omissions are resolved, and the implicit parameter quantity is extracted from the historical dialogue through semantic association and added to the parameter set. The output contains structured parsed information including the user intent, explicit parameters, and implicit parameters.

[0011] In some specific embodiments, based on the structured parsed information, a dynamic knowledge graph is queried. This dynamic knowledge graph includes a tool layer, a parameter layer, and a context layer. The tool layer stores tool descriptions, the parameter layer stores parameter specifications, and the context layer stores parameter instances generated in historical dialogues. Further, it includes: Based on the user intent in the structured parsed information, a matching tool entity is searched in the tool layer of the dynamic knowledge graph to obtain the tool's name, function description, and invocation method; Based on the parsed tool description, parameter nodes associated with the tool are extracted from the parameter layer of the knowledge graph to obtain the name, data type, format requirements, and whether each parameter is required. Based on the implicit parameters in the structured parsing information, the parameter assignment records that have appeared in the historical dialogue are retrieved in the context layer of the knowledge graph using the implicit parameters as clues, and historical parameter instances that match the historical context of the dialogue are selected. The tool descriptions, parameter specifications, and historical parameter examples are integrated and combined into a structured knowledge set as the retrieved information.

[0012] In some specific embodiments, based on the structured parsed information and the information queried from the dynamic knowledge graph, the parameters required for tool invocation are subjected to context-aware completion and formatting processing. This completion and formatting processing includes parameter missing identification, completion based on historical parameter instances, and format standardization according to parameter specifications, resulting in a processed parameter set. Further, it includes: Identify missing but necessary parameters in the structured parsing information, compare the parameter set contained in the structured parsing information with the list of required parameters in the parameter specification, and determine the missing parameter items; Based on the missing parameters, extract the corresponding historical parameter instances from the queried information to complete them. For each missing parameter, find the record with the same parameter name in the historical parameter instance and select the most recent or most relevant value as the completion value. Based on the parameter specifications in the queried information, the completed parameter values ​​are formatted and standardized. All parameter values ​​are converted according to the format constraints defined in the parameter specifications to obtain the formatted parameter values. The output is a processed parameter set containing all required parameters in a standardized format.

[0013] In some specific embodiments, based on the processed parameter set and the corresponding tool description, structured enhancement prompts for submission to the large language model are dynamically generated. These structured enhancement prompts integrate tool descriptions, parameter sets, and instantiated call constraints, and further include: The tool descriptions retrieved from the dynamic knowledge graph are integrated, and the tool's name, function description, and calling method are organized to form the part of the prompt that introduces the tool's purpose; The processed parameter set and the corresponding parameter specifications are integrated, and the completed and formatted parameter values ​​are matched with the parameter specifications to form a parameter description section. Based on the dialogue history context, examples are selected from the historical parameter instances to construct a demonstration statement showing how to fill in the parameters, while clarifying the constraints and generating exemplified call constraints. Based on the tool description, parameter set, and calling constraints, structured enhanced prompt words are constructed according to a preset template or dynamically generated logic.

[0014] In some specific embodiments, the method further includes: The structured enhanced prompt words are submitted to the large language model through the model context protocol interface, and the model returns standard tool call instructions that conform to the tool call format. The tool name and parameters are parsed from the standard tool invocation instructions, the corresponding tool server endpoint is invoked to execute the tool invocation, and the execution result is obtained. The call result is fed back to the user, and the parameter instances confirmed in the current conversation are added to the context layer of the dynamic knowledge graph. Record the complete information of this interaction into the dialogue history context.

[0015] Based on the same concept, the present invention also provides a prompt word dynamic enhancement system, comprising: The complete dialogue information generation module is configured to respond to the current user request and the corresponding dialogue history context to form complete dialogue information containing temporal relationships. The structured information parsing module is configured to perform contextual semantic parsing on the current request and the dialogue history context, and obtain structured parsing information containing user intent, explicit parameters and implicit parameters through intent recognition and parameter extraction; The dynamic knowledge graph query module is configured to query the dynamic knowledge graph based on the structured parsing information. The dynamic knowledge graph includes a tool layer, a parameter layer, and a context layer. The tool layer stores tool descriptions, the parameter layer stores parameter specifications, and the context layer stores parameter instances generated in historical dialogues. The parameter set processing and generation module is configured to perform context-aware completion and formatting processing on the parameters required for tool invocation based on the structured parsing information and the information queried from the dynamic knowledge graph. The completion and formatting processing includes parameter missing identification, completion based on historical parameter instances, and format standardization according to parameter specifications to obtain the processed parameter set. The structured enhancement prompt dynamic generation module is configured to dynamically generate structured enhancement prompts for submission to the large language model based on the processed parameter set and the corresponding tool description. The structured enhancement prompts integrate the tool description, parameter set, and instantiation call constraints.

[0016] Based on the same concept, the present invention also provides an electronic device, including: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of a prompt word dynamic enhancement method.

[0017] Based on the same concept, the present invention also provides a computer-readable storage medium storing a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform the steps of a prompt word dynamic enhancement method.

[0018] Compared with existing technologies, its advantages are as follows: This invention discloses a method, system, electronic device, and storage medium for dynamically enhancing prompt words, which can improve the accuracy of invocation: by using contextual semantic parsing and automatic completion based on historical parameter instances, it reduces invocation failures caused by missing information and improves the first-time success rate of tool invocation.

[0019] Enhance dialogue coherence: Utilize a dynamic knowledge graph that includes tool layers, parameter layers, and context layers to associate multi-turn dialogue information, enabling the system to understand referencing and omission, and achieve parameter reuse in multi-turn interactions.

[0020] High compatibility: Deployed as an independent enhancement layer on the model context protocol client, it does not depend on a specific large language model and is easy to integrate into existing systems.

[0021] Optimize prompt efficiency: Dynamically generated structured enhanced prompts are integrated with tool descriptions, parameter sets, and instantiated call constraints, resulting in high information density and strong targeting, reducing the understanding burden of large language models. Attached Figure Description

[0022] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 This is a flowchart illustrating some specific embodiments of the method for dynamically enhancing prompt words according to the present invention; Figure 2 This is an architectural block diagram of another embodiment of the prompt word dynamic enhancement method of the present invention; Figure 3 This is a flowchart of another embodiment of the method for dynamically enhancing prompt words according to the present invention; Figure 4 This is a schematic diagram of the structure of a prompt word dynamic enhancement system of the present invention in some specific embodiments; Figure 5 This is a schematic diagram of the structure of an electronic device according to some specific embodiments of the present invention; In the diagram, 710 is the processor; 720 is the memory; 730 is the input device; and 740 is the output device. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0024] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the application. The singular forms "a," "the," and "the" as used in the embodiments of this application are also intended to include the plural forms, and "multiple" generally includes at least two unless the context clearly indicates otherwise.

[0025] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0026] It should be understood that although the terms first, second, third, etc., may be used in the embodiments of this application, these descriptions should not be limited to these terms. These terms are only used to distinguish the descriptions. For example, first may also be referred to as second without departing from the scope of the embodiments of this application, and similarly, second may also be referred to as first.

[0027] Depending on the context, the words “if” or “suppose” as used here can be interpreted as “when” or “in response to determination” or “in response to detection.” Similarly, depending on the context, the phrases “if determination” or “if detection (of the stated condition or event)” can be interpreted as “when determination” or “in response to determination” or “when detection (of the stated condition or event)” or “in response to detection (of the stated condition or event).”

[0028] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that an article or device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such an article or device. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the article or device that includes said element.

[0029] It should be noted that any symbols and / or numbers present in the specification that are not marked in the accompanying drawings are not reference numerals.

[0030] Reference Figure 1 A method for dynamically enhancing prompt words, comprising: S101, in response to the current user request and the corresponding dialogue history context, form complete dialogue information including temporal relationships; S102, perform contextual semantic parsing on the current request and the dialogue history context, and obtain structured parsing information containing user intent, explicit parameters and implicit parameters through intent recognition and parameter extraction; S103, based on the structured parsing information, query the dynamic knowledge graph, which includes a tool layer, a parameter layer and a context layer, wherein the tool layer stores tool descriptions, the parameter layer stores parameter specifications, and the context layer stores parameter instances generated in historical dialogues; S104, based on the structured parsing information and the information queried from the dynamic knowledge graph, the parameters required for tool invocation are performed with context-aware completion and formatting processing, wherein the completion and formatting processing includes parameter missing identification, completion based on historical parameter instances, and format standardization according to parameter specifications, to obtain the processed parameter set; S105, Based on the processed parameter set and the corresponding tool description, dynamically generate structured enhancement prompts for submission to the large language model, wherein the structured enhancement prompts integrate tool descriptions, parameter sets, and instantiation call constraints.

[0031] Specifically, in this embodiment of the invention, the user's current request and the corresponding dialogue history context are obtained to form complete dialogue information containing temporal relationships. Specifically, the current request submitted by the user in natural language is received through an input interface. Simultaneously, based on the user's session identifier, all historical interaction records of the user from the start of the current session to the present are retrieved from persistent storage. The current request is inserted into the end of the historical dialogue list in chronological order, forming a coherent dialogue flow, thus obtaining a dialogue context containing chronological order. Contextual semantic parsing is performed based on the current request and the dialogue history context. The target tool indicated by the user's intent is determined through intent recognition. Explicitly mentioned parameters are extracted from the current request using named entity recognition or slot filling techniques. The implicit parameter quantity is identified by combining the dialogue history context with referential resolution and omission completion techniques. Finally, structured parsing information containing the user's intent, explicit parameters, and implicit parameters is output. Based on this structured parsing information query dynamic knowledge graph, the dynamic knowledge graph adopts a three-layer structure design. The tool layer stores the name, function description, and invocation method of the tool entity; the parameter layer stores the name, data type, format requirements, and necessity of each parameter associated with the tool; and the context layer stores parameter assignment records generated in historical dialogues. During a query, the matching tool entity is located in the tool layer according to the user's intent to obtain the tool description, and the matching historical parameter instances are retrieved in the context layer based on the parsed implicit parameters. Based on the structured parsing information and the information queried from the dynamic knowledge graph, the parameters required for tool invocation are completed and formatted with context awareness. Specifically, this includes: comparing the currently parsed parameter set with the list of required parameters in the parameter specification to identify missing parameter items; for each missing parameter, searching for records with the same parameter name from historical parameter instances and selecting the most recent or most relevant assignment for completion; and standardizing all parameter values ​​according to the format constraints defined in the parameter specification to obtain a processed parameter set containing all required parameters and with a unified format. Based on the processed parameter set and the corresponding tool description, a structured enhancement prompt word is dynamically generated for submission to the large language model. This prompt word integrates the tool description, parameter set, and exemplified call constraints extracted from historical parameter instances, and constructs structured text containing tool call guidance, parameter descriptions, and example demonstrations according to preset templates or dynamic combination rules.

[0032] In some applications, in response to the acquired user's current request and the corresponding dialogue history context, a complete dialogue information containing temporal relationships is formed. This includes capturing the user's natural language request in text or speech-to-speech form in real time through an input interface, preprocessing it, and using it as the current request; retrieving all historical interaction records of the user from the persistent storage medium since the start of the current session based on the user's session identifier, forming a historical dialogue list; inserting the current request into the end of the historical dialogue list in chronological order to form a coherent dialogue flow, obtaining a dialogue context containing chronological order; and outputting the combined complete dialogue text sequence as context information.

[0033] Understandably, the system captures user requests in real-time via an input interface, either directly inputting text or submitting voice requests which are then converted into natural language through speech recognition. This natural language request undergoes preprocessing, including removing invalid characters, correcting spelling errors, and standardizing terminology. The processed result is then used as the current request. Based on the unique session identifier associated with the user, all historical interaction records of the user from the start of the current session to the current moment are retrieved from persistent storage. This includes historical user input requests and system responses, and these historical interaction records are arranged chronologically to form a historical dialogue list. The current request is then inserted chronologically at the end of the historical dialogue list, appending it as the latest dialogue turn while maintaining the original historical dialogue sequence. This creates a coherent dialogue flow that fully reflects the entire conversation's development, resulting in a dialogue context with a clear chronological order. The combined complete dialogue text sequence is output as contextual information for subsequent semantic parsing steps. This contextual information includes both the semantic content of the current request and background information accumulated from historical dialogues.

[0034] In some applications, contextual semantic parsing is performed on the current request and the dialogue history context. Structured parsing information containing user intent, explicit parameters, and implicit parameters is obtained through intent recognition and parameter extraction. This includes: identifying the intent of the current request by analyzing its semantic direction using a pre-trained intent classification model or rule-based keyword matching method to determine the target tool the user intent is targeting; extracting explicit parameters from the current request by using named entity recognition or slot filling methods to extract explicitly mentioned parameters and their corresponding values ​​from the request text; analyzing implicit parameters in the current request in conjunction with the dialogue history context, resolving pronoun and ellipsis issues, and extracting implicit parameter quantities from historical dialogues through semantic association and adding them to the parameter set; and outputting structured parsing information containing the user intent, explicit parameters, and implicit parameters.

[0035] Understandably, the process involves intent recognition of the current request. This is achieved by analyzing the semantic meaning of the request using a pre-trained intent classification model or rule-based keyword matching to determine the target tool the user intends to access. The intent classification model, trained on a large-scale corpus, maps natural language requests to predefined tool categories, while the keyword matching method identifies user intent using a pre-defined trigger word list. Explicit parameters are extracted from the current request using named entity recognition (NAME) or slot filling methods to directly extract explicitly mentioned parameters and their corresponding values ​​from the request text. NAME models can identify entity types such as names, places, dates, and numbers in the text, while slot filling methods match based on predefined parameter templates. The process also involves analyzing implicit parameters in the current request within the context of the dialogue history. This includes resolving pronouns and omissions by extracting implicit parameters from historical dialogues through semantic association and adding them to the parameter set. Resolving pronouns determines their referents by analyzing the semantic association between pronouns and entities in historical dialogues, while omission completion infers the number of missing parameters based on contextual semantics and parameter specifications. The output contains structured parsed information including user intent, explicit parameters, and implicit parameters. This information is encapsulated according to a predetermined data structure, providing a foundation for subsequent knowledge graph queries and parameter completion.

[0036] In some applications, based on the structured parsed information, a dynamic knowledge graph is queried. This dynamic knowledge graph comprises a tool layer, a parameter layer, and a context layer. The tool layer stores tool descriptions, the parameter layer stores parameter specifications, and the context layer stores parameter instances generated in historical dialogues. This process includes: searching for matching tool entities in the tool layer of the dynamic knowledge graph based on the user intent in the structured parsed information, obtaining the tool's name, function description, and invocation method; extracting parameter nodes associated with the tool from the parameter layer of the knowledge graph based on the parsed tool description, obtaining the name, data type, format requirements, and whether each parameter is required; retrieving parameter assignment records that have appeared in historical dialogues from the context layer of the knowledge graph based on implicit parameters in the structured parsed information, using these implicit parameters as clues, and filtering out historical parameter instances that match the historical context of the dialogue; and integrating the tool descriptions, parameter specifications, and historical parameter instances into a structured knowledge set as the queried information.

[0037] Understandably, based on the user intent in the structured parsed information, matching tool entities are searched in the tool layer of the dynamic knowledge graph to obtain the tool's name, function description, and invocation method. The tool layer uses tool entities as nodes, with each entity associated with a unique tool identifier, and stores information such as the tool's natural language description and API definition. Based on the parsed tool description, parameter nodes associated with the tool are extracted from the parameter layer of the knowledge graph, obtaining the name, data type, format requirements, and whether each parameter is required. The parameter layer uses parameter entities as nodes, with each entity associated with its tool identifier, and stores metadata such as the parameter's value range, format constraints, and default value. Based on the implicit parameters in the structured parsed information, parameter assignment records appearing in historical dialogues are retrieved in the context layer of the knowledge graph, using these implicit parameters as clues. Historical parameter instances matching the dialogue's historical context are then selected. The context layer uses parameter instances as nodes, with each instance recording information such as parameter name, parameter value, associated session identifier, and generation time. Instances form a network structure through semantic association. The tool descriptions, parameter specifications, and historical parameter examples obtained from the above queries are integrated into a structured knowledge set as the query information, which is then used in subsequent parameter completion and formatting steps.

[0038] In some applications, based on the structured parsed information and information queried from the dynamic knowledge graph, context-aware completion and formatting processing is performed on the parameters required for tool invocation. This completion and formatting process includes parameter missing identification, completion based on historical parameter instances, and format standardization according to parameter specifications, resulting in a processed parameter set. This includes identifying parameters missing from the structured parsed information but necessary for tool invocation; comparing the parameter set contained in the structured parsed information with the list of required parameters in the parameter specifications to determine missing parameter items; extracting corresponding historical parameter instances from the queried information for completion based on the missing parameters; searching for records with the same parameter name in the historical parameter instances for each missing parameter, and selecting the most recent or most relevant assignment as the completion value; standardizing the format of the completed parameter values ​​according to the parameter specifications in the queried information, converting all parameter values ​​according to the format constraints defined in the parameter specifications to obtain standardized parameter values; and outputting a processed parameter set containing all necessary parameters and format standardization.

[0039] Understandably, parameter missing identification involves comparing the parameter set contained in the structured parsed information with the list of required parameters in the parameter specifications retrieved from the knowledge graph, item by item, to determine which parameters necessary for tool invocation are missing from the currently parsed parameters. Based on the identified missing parameters, corresponding historical parameter instances are extracted from the retrieved information for completion. Specifically, for each missing parameter, records with the same parameter name are searched in the historical parameter instance set, and the most recent occurrence or the most suitable value for the current context is selected as the completion value based on timestamps or semantic relevance. According to the format constraints defined in the parameter specifications, all parameter values ​​are standardized, including data type conversion, unit unification, enumeration value validation, and date format normalization, ensuring that each parameter value meets the technical requirements for tool invocation. The result is a complete parameter set containing all required parameters in a unified format, for subsequent dynamic generation of prompts.

[0040] In some applications, based on the processed parameter set and corresponding tool descriptions, structured enhanced prompts for submission to a large language model are dynamically generated. These structured enhanced prompts integrate tool descriptions, parameter sets, and exemplified call constraints. This includes integrating tool descriptions retrieved from the dynamic knowledge graph, organizing the tool's name, function description, and invocation method information to form the tool's purpose section; integrating the processed parameter set and its corresponding parameter specifications, matching the completed and formatted parameter values ​​with the parameter specifications to form the parameter description section; combining the dialogue history context, selecting examples from historical parameter instances to construct demonstration statements showing how to fill in the parameters, while clarifying constraints and generating exemplified call constraints; and constructing structured enhanced prompts based on the tool descriptions, parameter sets, and call constraints, according to a preset template or dynamically generated logic.

[0041] Understandably, integrating tool descriptions retrieved from dynamic knowledge graphs, including tool names, functional descriptions, and invocation methods, forms the tool usage description section in the prompt, enabling the large language model to clearly understand the tool to be invoked and its basic functions. Integrating the processed parameter set and its corresponding parameter specifications, and mapping the completed and formatted parameter values ​​to the data types and format requirements in the parameter specifications, forms the parameter description section, clearly displaying the name, value, and required format constraints for each parameter. Combining the dialogue history context, examples relevant to the current scenario are selected from historical parameter instances to construct sample statements demonstrating how to fill in the parameters, while clarifying the constraints in the invocation process and generating exemplified invocation constraints, providing intuitive reference examples for the large language model. Based on the above tool descriptions, parameter sets, and invocation constraints, combined according to a preset template structure or dynamically generated logic, a clear, complete, and targeted structured enhanced prompt is constructed. This prompt effectively guides the large language model to accurately understand the user's intent and generate the required tool invocation instructions.

[0042] In some applications, the method further includes submitting the structured enhanced prompt words to a large language model through a model context protocol interface, receiving standard tool invocation instructions that conform to the tool invocation format returned by the model; parsing the tool name and parameters according to the standard tool invocation instructions, calling the corresponding tool server endpoint to execute the tool invocation, and obtaining the execution result; feeding back the invocation result to the user, and adding the parameter instances confirmed in the current dialogue to the context layer of the dynamic knowledge graph; and recording the complete information of this interaction to the dialogue history context.

[0043] Understandably, the generated structured augmented prompts are submitted to the large language model via the model context protocol interface, and the model returns standard tool invocation instructions conforming to the tool invocation format. Specifically, a communication connection is established with the external large language model through the model context protocol adapter. The dynamically generated structured augmented prompts are encapsulated according to the format specified by the protocol and sent to the large language model. The large language model understands the prompt content and generates tool invocation instructions, which typically adopt a standardized format of function calls or parameter filling. The model receives and parses these instructions. Based on the parsed tool name and parameters, the corresponding tool service endpoint is called through a predefined service interface to execute the actual tool invocation, including sending requests to third-party services, waiting for responses, and receiving execution results. The obtained invocation results are fed back to the user in natural language or structured form. At the same time, the confirmed parameter instances from this round of dialogue are added to the context layer of the dynamic knowledge graph for reuse in subsequent dialogues. The complete information of this interaction, including user requests, system-generated prompts, tool invocation instructions, invocation results, and timestamps, is recorded in the dialogue history context for semantic parsing and context awareness in subsequent rounds, forming a closed-loop update interaction mechanism.

[0044] The following is combined with Figure 2 and Figure 3 Another embodiment of the prompt word dynamic enhancement method of the present invention is described below: This embodiment includes: Acquisition and Parsing: Acquire the current user request and historical dialogue, and jointly analyze them through the context-aware parsing unit to identify intent, explicit and implicit parameters.

[0045] Knowledge Graph Query and Completion: Query the "Tools-Parameters-Context" knowledge graph to obtain tool specifications, and automatically complete missing parameters and format parameter values ​​based on the context.

[0046] Dynamic prompt generation: Based on the current dialogue state, target tool, and completed parameters, enhanced prompt words are dynamically constructed. These prompt words incorporate customized tool descriptions, instantiated examples, and key constraints.

[0047] Execution and Update: The enhanced prompts are sent to the LLM to generate accurate invocation instructions. After execution, the effective information from this round is updated to the context and knowledge graph.

[0048] like Figure 2 As shown, it is deployed on the MCP client side as an intelligent enhancement middleware layer between the LLM server and the MCP server.

[0049] It mainly includes the following core modules: Context management module: Stores and manages the complete conversation history.

[0050] Parsing Unit: Analyzes the user's current request and historical dialogue to identify intent and parameters.

[0051] Dynamic knowledge graph: storing the relationships between tool specifications, parameter constraints, and historical parameter values.

[0052] Dynamic prompt generator (core): Based on the parsing results and knowledge graph, it completes the parameters and generates enhanced prompt words.

[0053] MCP protocol adapter: Communicates with external LLM and tool servers.

[0054] like Figure 3 As shown, When a user makes a new request, follow these steps: Get context: Collect current requests and historical conversations.

[0055] Joint parsing: The parsing unit analyzes the text and outputs structured results (e.g., {"Intent": "Driving route", "Explicit parameters": {"Date": "The day after tomorrow"}, "Parameters to be completed": ["Destination"]}).

[0056] Query and completion: The prompt generator queries the knowledge graph. If a "parameter to be completed" (such as "destination") is found, it is automatically searched for and filled in from the historical context (e.g., "Shanghai" is retrieved from previous conversations). Simultaneously, the parameters are standardized and formatted.

[0057] Generate dynamic prompts: Integrate the completed parameters, relevant tool descriptions, call examples, and format constraints into a clearly structured enhanced prompt word.

[0058] Invocation and Update: The prompt words are sent to the LLM via the MCP protocol to execute the tool invocation and return the results to the user. Simultaneously, the valid information is updated to the context and knowledge graph to optimize subsequent interactions.

[0059] The following describes this embodiment in conjunction with application scenarios: Self-driving route (with missing parameters resolved): dialogue: User's first round: "I want to go to Shanghai" (system record).

[0060] User's second request: "Help me plan my driving route for the day after tomorrow."

[0061] Processing: When parsing the second round of requests, the intent was identified as "driving route," with the explicit parameter "the day after tomorrow," but the "destination" was missing. The system automatically retrieved "Shanghai" from the first round's history to complete the request. The generated dynamic prompt explicitly states: "Known: Destination = Shanghai (from historical conversation). Date = the day after tomorrow (please format as YYYY-MM-DD)." Based on this, LLM can generate a complete and correctly formatted call command in one go, without needing to ask the user.

[0062] Data Query (Resolving Formatting Errors): User request: "Query last month's sales figures".

[0063] Processing: The intent and parameter "Time: Last Month" are parsed. The knowledge graph defines this parameter as needing to be in "YYYY-MM" format. The dynamic prompt generator automatically converts "Last Month" into a specific month (e.g., "2025-11") and emphasizes the format constraint in the prompt. This avoids calling errors caused by non-standard date formats output by the LLM.

[0064] Key Mechanism Explanation: Dynamic Knowledge Graph: This graph serves as the system's "memory" and "rule base." It not only statically defines tools but also dynamically records specific parameter values ​​generated in each dialogue, forming a historical instance network. When encountering pronouns or ellipsis, this network is used for association and reasoning to achieve context completion.

[0065] Dynamic prompt generation: a key step in transforming "context" and "knowledge" into instructions that LLMs can efficiently understand. Its core lies in moving away from fixed templates and selecting the most relevant information (historical parameters, constraints, examples) based on the actual situation of the current dialogue to generate customized prompts, thus reducing the cognitive load on LLMs.

[0066] For the purpose of simplicity, the method steps disclosed in the above embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0067] like Figure 4 As shown, the present invention also provides a prompt word dynamic enhancement system, comprising: The complete dialogue information generation module 201 is configured to generate complete dialogue information containing temporal relationships in response to the current user request and the corresponding dialogue history context. The structured information parsing module 202 is configured to perform contextual semantic parsing on the current request and the dialogue history context, and obtain structured parsing information containing user intent, explicit parameters and implicit parameters through intent recognition and parameter extraction; The dynamic knowledge graph query module 203 is configured to query the dynamic knowledge graph based on the structured parsing information. The dynamic knowledge graph includes a tool layer, a parameter layer, and a context layer. The tool layer stores tool descriptions, the parameter layer stores parameter specifications, and the context layer stores parameter instances generated in historical dialogues. The parameter set processing and generation module 204 is configured to perform context-aware completion and formatting processing on the parameters required for tool calls based on the structured parsing information and the information queried from the dynamic knowledge graph. The completion and formatting processing includes parameter missing identification, completion based on historical parameter instances, and format standardization according to parameter specifications to obtain the processed parameter set. The structured enhancement prompt word dynamic generation module 205 is configured to dynamically generate structured enhancement prompt words for submission to the large language model based on the processed parameter set and the corresponding tool description, wherein the structured enhancement prompt words integrate the tool description, parameter set and instantiation call constraints.

[0068] It is worth noting that although only some basic functional modules are disclosed in the embodiments of this invention, it does not mean that the composition of this system is limited to the above-mentioned basic functional modules. On the contrary, based on the above-mentioned basic functional modules, those skilled in the art can arbitrarily add one or more functional modules in combination with existing technology to form an infinite number of embodiments or technical solutions. That is to say, this system is open rather than closed. The fact that this embodiment only discloses a few basic functional modules should not be considered as the scope of protection of this invention being limited to the disclosed basic functional modules. At the same time, for the sake of convenience, the above devices are described separately according to their functions as various units and modules. Of course, in implementing this invention, the functions of each unit and module can be implemented in one or more software and / or hardware.

[0069] like Figure 5 As shown, the present invention also provides an electronic device, including: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of a prompt word dynamic enhancement method.

[0070] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. For example... Figure 5The structure shown in this embodiment of the invention includes an electronic device comprising one or more processors 710 and a memory 720; the processors 710 in this electronic device may be one or more. Figure 5 Taking a processor 710 as an example; a memory 720 is used to store one or more programs; the one or more programs are executed by the one or more processors 710, so that the one or more processors 710 implement a prompt word dynamic enhancement method as described in any one of the embodiments of the present invention.

[0071] The electronic device may also include an input device 730 and an output device 740.

[0072] The processor 710, memory 720, input device 730, and output device 740 in this electronic device can be connected via a bus or other means. Figure 5 Taking the example of a connection between China and Israel via a bus.

[0073] The memory 720 in this electronic device serves as a computer-readable storage medium, capable of storing one or more programs. These programs can be software programs, computer-executable programs, or modules, such as the program instructions / modules corresponding to the prompt word dynamic enhancement method provided in this embodiment of the invention. The processor 710 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the memory 720, thereby implementing the prompt word dynamic enhancement method described in the above embodiment.

[0074] The memory 720 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 720 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 720 may further include memory remotely located relative to the processor 710, which can be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0075] Input device 730 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the electronic device. Output device 740 may include display devices such as a display screen.

[0076] The present invention also provides a computer-readable storage medium storing a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform the steps of a prompt word dynamic enhancement method.

[0077] Specifically, the computer storage medium in this embodiment of the invention can be any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. For example, a computer-readable storage medium can be—but is not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0078] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for dynamically enhancing prompt words, characterized in that, include: In response to the current user request and the corresponding dialogue history context, a complete dialogue information containing temporal relationships is formed. The current request and the dialogue history context are subjected to contextual semantic parsing, and structured parsing information containing user intent, explicit parameters and implicit parameters is obtained through intent recognition and parameter extraction; Based on the structured parsing information, a dynamic knowledge graph is queried. The dynamic knowledge graph includes a tool layer, a parameter layer, and a context layer. The tool layer stores tool descriptions, the parameter layer stores parameter specifications, and the context layer stores parameter instances generated in historical dialogues. Based on the structured parsing information and the information queried from the dynamic knowledge graph, the parameters required for tool invocation are subjected to context-aware completion and formatting processing. The completion and formatting processing includes parameter missing identification, completion based on historical parameter instances, and format standardization according to parameter specifications to obtain the processed parameter set. Based on the processed parameter set and the corresponding tool description, structured enhancement prompts for submission to the large language model are dynamically generated, wherein the structured enhancement prompts integrate tool descriptions, parameter sets, and instantiation call constraints.

2. The method for dynamically enhancing prompt words according to claim 1, characterized in that, In response to the acquired current user request and the corresponding dialogue history context, complete dialogue information containing temporal relationships is formed, further including: The system captures natural language requests submitted by users in text or speech-to-speech form in real time through the input interface, and uses them as the current request after preprocessing. Based on the user session identifier, retrieve all historical interaction records of the user from the persistent storage medium from the beginning of the current session to the present to form a historical dialogue list; The current request is inserted into the end of the history dialogue list in chronological order to form a coherent dialogue flow, resulting in a dialogue context that includes the chronological order. The combined complete dialogue text sequence is output as context information.

3. The method for dynamically enhancing prompt words according to claim 1, characterized in that, Contextual semantic parsing is performed on the current request and the dialogue history context. Structured parsing information containing user intent, explicit parameters, and implicit parameters is obtained through intent recognition and parameter extraction. This further includes: The current request is subjected to intent recognition. By using a pre-trained intent classification model or a rule-based keyword matching method, the semantic orientation of the current request is analyzed to determine the target tool to which the user's intent is directed. Explicit parameters are extracted from the current request, and named entity recognition or slot filling methods are used to extract explicitly mentioned parameters and their corresponding values ​​from the request text. By combining the dialogue history context, the parameters implicit in the current request are analyzed, the pronouns and omissions are resolved, and the implicit parameter quantity is extracted from the historical dialogue through semantic association and added to the parameter set. The output contains structured parsed information including the user intent, explicit parameters, and implicit parameters.

4. The method for dynamically enhancing prompt words according to claim 1, characterized in that, Based on the structured parsed information, a dynamic knowledge graph is queried. This dynamic knowledge graph comprises a tool layer, a parameter layer, and a context layer. The tool layer stores tool descriptions, the parameter layer stores parameter specifications, and the context layer stores parameter instances generated in historical dialogues. Further, it includes: Based on the user intent in the structured parsed information, a matching tool entity is searched in the tool layer of the dynamic knowledge graph to obtain the tool's name, function description, and invocation method; Based on the parsed tool description, parameter nodes associated with the tool are extracted from the parameter layer of the knowledge graph to obtain the name, data type, format requirements, and whether each parameter is required. Based on the implicit parameters in the structured parsing information, the parameter assignment records that have appeared in the historical dialogue are retrieved in the context layer of the knowledge graph using the implicit parameters as clues, and historical parameter instances that match the historical context of the dialogue are selected. The tool descriptions, parameter specifications, and historical parameter examples are integrated and combined into a structured knowledge set as the retrieved information.

5. The method for dynamically enhancing prompt words according to claim 1, characterized in that, Based on the structured parsed information and the information queried from the dynamic knowledge graph, the parameters required for tool invocation are subjected to context-aware completion and formatting processing. This completion and formatting processing includes parameter missing identification, completion based on historical parameter instances, and format standardization according to parameter specifications, resulting in a processed parameter set. Further, it includes: Identify missing but necessary parameters in the structured parsing information, compare the parameter set contained in the structured parsing information with the list of required parameters in the parameter specification, and determine the missing parameter items; Based on the missing parameters, extract the corresponding historical parameter instances from the queried information to complete them. For each missing parameter, find the record with the same parameter name in the historical parameter instance and select the most recent or most relevant value as the completion value. Based on the parameter specifications in the queried information, the completed parameter values ​​are formatted and standardized. All parameter values ​​are converted according to the format constraints defined in the parameter specifications to obtain the formatted parameter values. The output is a processed parameter set containing all required parameters in a standardized format.

6. The method for dynamically enhancing prompt words according to claim 1, characterized in that, Based on the processed parameter set and the corresponding tool description, structured enhancement prompts are dynamically generated for submission to the large language model. These structured enhancement prompts integrate tool descriptions, parameter sets, and instantiated call constraints, and further include: The tool descriptions retrieved from the dynamic knowledge graph are integrated, and the tool's name, function description, and calling method are organized to form the part of the prompt that introduces the tool's purpose; The processed parameter set and the corresponding parameter specifications are integrated, and the completed and formatted parameter values ​​are matched with the parameter specifications to form a parameter description section. Based on the dialogue history context, examples are selected from the historical parameter instances to construct a demonstration statement showing how to fill in the parameters, while clarifying the constraints and generating exemplified call constraints. Based on the tool description, parameter set, and calling constraints, structured enhanced prompt words are constructed according to a preset template or dynamically generated logic.

7. The method for dynamically enhancing prompt words according to claim 1, characterized in that, The method further includes: The structured enhanced prompt words are submitted to the large language model through the model context protocol interface, and the model returns standard tool call instructions that conform to the tool call format. The tool name and parameters are parsed from the standard tool invocation instructions, the corresponding tool server endpoint is invoked to execute the tool invocation, and the execution result is obtained. The call result is fed back to the user, and the parameter instances confirmed in the current conversation are added to the context layer of the dynamic knowledge graph. Record the complete information of this interaction into the dialogue history context.

8. A dynamic enhancement system for prompt words, characterized in that, include: The complete dialogue information generation module is configured to respond to the current user request and the corresponding dialogue history context to form complete dialogue information containing temporal relationships. The structured information parsing module is configured to perform contextual semantic parsing on the current request and the dialogue history context, and obtain structured parsing information containing user intent, explicit parameters and implicit parameters through intent recognition and parameter extraction; The dynamic knowledge graph query module is configured to query the dynamic knowledge graph based on the structured parsing information. The dynamic knowledge graph includes a tool layer, a parameter layer, and a context layer. The tool layer stores tool descriptions, the parameter layer stores parameter specifications, and the context layer stores parameter instances generated in historical dialogues. The parameter set processing and generation module is configured to perform context-aware completion and formatting processing on the parameters required for tool invocation based on the structured parsing information and the information queried from the dynamic knowledge graph. The completion and formatting processing includes parameter missing identification, completion based on historical parameter instances, and format standardization according to parameter specifications to obtain the processed parameter set. The structured enhancement prompt dynamic generation module is configured to dynamically generate structured enhancement prompts for submission to the large language model based on the processed parameter set and the corresponding tool description. The structured enhancement prompts integrate the tool description, parameter set, and instantiation call constraints.

9. An electronic device, characterized in that, include: The system includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; the memory stores a computer program, which, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It stores a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform the steps of the method according to any one of claims 1 to 7.