Method, device and equipment for automatically generating business rule based on natural language and storage medium
By collaborating with AI intelligent agents and large language models, DSL expressions are automatically generated and combined with a rule testing module, solving the problems of low efficiency and poor accuracy in business rule conversion. This enables efficient and accurate rule configuration and review processes, and supports multi-dimensional rule execution traceability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies are inefficient and inaccurate in converting business rules from natural language descriptions to executable expressions in rule engines. They are ill-suited to meet the demands for efficient review as business scales expand and product categories increase. Rule configuration is time-consuming, manual conversion has a high error rate, and review results lack detailed traceability.
By collaborating with AI intelligent agents and large language models, domain-specific language (DSL) expressions are automatically generated. These expressions are then simulated and verified using a rule testing module. In the actual execution phase, user data is used to determine the rules and generate review logs to achieve a closed-loop process.
It enables the automated generation of natural language to DSL expressions, reduces manual conversion costs, improves rule configuration efficiency, ensures the accuracy and transparency of rule execution, reduces invalid review processes, and supports multi-dimensional rule execution traceability.
Smart Images

Figure CN121787368A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of rule engine technology, and in particular to a method, apparatus, device, and storage medium for automatically generating business rules based on natural language. Background Technology
[0002] In manufacturing, logistics, and supply chain management, companies handle a large volume of product material configuration and quotation review. These processes rely on complex business rules (such as material compatibility relationships and specification threshold constraints) to ensure accuracy. As business scale expands and product categories increase, the number and complexity of business rules significantly rise. Traditional, manually-driven rule management models are no longer sufficient to meet the demands for efficient and accurate business processes. There is an urgent need to leverage rule engines and artificial intelligence technologies to automate business rule processing, thereby improving process efficiency and reducing labor costs. This has become a crucial direction for optimizing business processes within the industry.
[0003] However, existing technical solutions suffer from low efficiency in the conversion of business rules from natural language descriptions to executable expressions of the rule engine. Summary of the Invention
[0004] This application provides a method, apparatus, device, and storage medium for automatically generating business rules based on natural language, which can improve the efficiency of the conversion process of business rules from natural language descriptions to executable expressions of the rule engine.
[0005] To achieve the above objectives, this application adopts the following technical solution: Firstly, this application provides a method for automatically generating business rules based on natural language, including: Obtain the natural language rule description input by the user; The natural language rule description is sent to the AI agent application, which configures prompt words and workflows, and the workflow calls the large language model. Receive the domain-specific language (DSL) expression returned by the AI agent application, which is generated by the large language model based on the prompt words and the natural language rule description; The DSL expression is imported into the Drools rule engine of the business rule management system and executed to generate rule execution results. Based on the execution result of the rules, output the audit result or prompt information.
[0006] Optionally, the method further includes: Obtain test data simulating business scenarios; Load the DSL expression and the test data into the rule test module; If the test passes, the DSL expression will be imported into the Drools rule engine for execution. If the test fails, regenerate or fine-tune the DSL expression and test again until the test passes.
[0007] Optionally, the step of importing the DSL expression into the Drools rule engine for execution and generating rule execution results includes: Receive actual business material configuration data submitted by users; The DSL expression and the actual business material configuration data are loaded into the Drools rule engine to perform rule determination and generate the rule execution result.
[0008] Optionally, the step of outputting the audit result or prompt information based on the execution result of the rule includes: If the execution result of the rule shows that the DSL expression determines that the actual business material configuration data meets the requirements of the natural language rule description, then the approval result will be output. If the execution result of the rule shows that the DSL expression determines that the actual business material configuration data does not meet the requirements of the natural language rule description, then the audit failure result will be output, and the prompt information of the reason for failure will be output simultaneously. The prompt information corresponds to the constraint logic in the natural language rule description.
[0009] Optionally, the method further includes: After outputting the audit results or prompts, an audit log is generated that includes the audit order number, rule execution details, actual business material configuration data, and audit results. The review logs are stored in a database, and logs can be queried by review number, product type, or time dimension.
[0010] Optionally, the prompt words include the syntax specifications of the Drools Regular Expression DSL, explanations of business domain terminology, and definitions of output data structures.
[0011] Optionally, the test data for the simulated business scenario includes material attribute parameters, product type information, and configuration associations corresponding to the natural language rule description.
[0012] Secondly, this application provides an apparatus for automatically generating business rules based on natural language, comprising: The acquisition module is used to acquire the natural language rule descriptions input by the user; The sending module is used to send the natural language rule description to the AI agent application, wherein the AI agent application is configured with prompt words and workflow, and the workflow calls the large language model; The receiving module is used to receive the domain-specific language (DSL) expression returned by the AI agent application, which is generated by the large language model based on the prompt words and the natural language rule description; The output module is used to import the DSL expression into the business rule management system engine Drools rule engine for execution, generate rule execution results, and output audit results or prompt information based on the rule execution results.
[0013] Thirdly, this application provides a computing device, including a memory and a processor; The memory stores one or more computer programs, the one or more computer programs including instructions; when the instructions are executed by the processor, the computing device performs the method as described in any one of the first aspects.
[0014] Fourthly, this application provides a computer-readable storage medium for storing a computer program for performing the method as described in any one of the first aspects.
[0015] As can be seen from the above technical solution, this application has at least the following beneficial effects: In this application, the automatic generation of natural language to DSL expressions is achieved through the collaboration of AI intelligent agent application and large language model. Non-technical personnel do not need to learn DSL syntax. They only need to input the natural language rule description, and the large language model can generate expressions adapted to the Drools rule engine based on preset prompt words (including DSL syntax specifications and business terminology explanations). This greatly reduces the cost of manual conversion, improves the efficiency of rule configuration, and solves the problems of traditional manual conversion relying on experience and inconsistent quality.
[0016] Meanwhile, the generated DSL expressions are verified through simulated scenarios by the rule testing module, which can identify rule logic vulnerabilities in advance and ensure the accuracy of expressions imported into the Drools rule engine. In the actual execution stage, the rules are judged based on the actual business material configuration data submitted by the user, and the approval / failure conclusion and corresponding reasons for failure are output according to the judgment results. This can help business personnel quickly locate material configuration problems and reduce invalid review processes. In addition, the function of generating and storing review logs enables the traceability of the rule execution process, making it convenient for users to review the review process through multi-dimensional queries, thereby further ensuring the accuracy of business rule execution and the transparency of business processes.
[0017] It should be understood that the descriptions of technical features, technical solutions, beneficial effects, or similar language in this application do not imply that all features and advantages can be achieved in any single embodiment. Rather, it is understood that the description of a feature or beneficial effect means that a specific technical feature, technical solution, or beneficial effect is included in at least one embodiment. Therefore, the descriptions of technical features, technical solutions, or beneficial effects in this specification do not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions, and beneficial effects described in this embodiment can be combined in any suitable manner. Those skilled in the art will understand that embodiments can be implemented without one or more specific technical features, technical solutions, or beneficial effects of a particular embodiment. In other embodiments, additional technical features and beneficial effects may be identified in specific embodiments that do not embody all embodiments. Attached Figure Description
[0018] Figure 1 A flowchart illustrating a method for automatically generating business rules based on natural language, provided in an embodiment of this application; Figure 2 A schematic diagram of an apparatus for automatically generating business rules based on natural language, provided for an embodiment of this application; Figure 3 This is a schematic diagram of a computing device provided in an embodiment of this application. Detailed Implementation
[0019] The terms "first," "second," and "third," etc., used in this application specification and accompanying drawings are used to distinguish different objects, not to limit a specific order.
[0020] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0021] To ensure clarity and conciseness in the description of the following embodiments, a brief introduction to the related technologies is given first: Natural language rule descriptions refer to text content written by non-technical personnel (such as product managers and business specialists) in everyday business language that contains business constraint logic. For example, a smartphone battery capacity must be ≥5000mAh and fast charging power must be ≥65W. This is an intuitive reflection of business requirements and does not need to follow professional grammar rules.
[0022] In manufacturing, logistics, and supply chain management sectors that rely on product material configuration and quotation review, existing business rule management models face major technical challenges: the efficiency of converting business requirements from natural language descriptions into an executable state for the rule engine is extremely low, and the accuracy of rule execution and the traceability of results are poor. This makes it difficult to adapt to the high-efficiency review requirements as business scales up and product categories increase. Specifically, rule configuration is time-consuming, manual conversion has a high error rate, and problems cannot be quickly located when the review fails. This severely slows down the entire process of material configuration and quotation review, affecting the company's business response speed.
[0023] The main reason for the above problems lies in the shortcomings of key aspects of the existing solutions: On the one hand, rule conversion relies too heavily on manual operation. Non-technical personnel need to master the professional syntax of domain-specific languages (DSLs) to convert natural language rule descriptions into expressions executable by the Drools rule engine. The conversion process is prone to logical loopholes due to personal experience biases or grammatical misunderstandings, and it is time-consuming and labor-intensive. On the other hand, rule verification lacks systematic support, relying more on simple manual verification rather than simulation tests covering complex scenarios. It is impossible to identify rule problems in advance, and there is a lack of standardized audit log mechanisms. Audit results lack detailed traceability, further exacerbating the uncertainty of rule execution and the difficulty of problem localization.
[0024] In view of this, embodiments of this application provide a method for automatically generating business rules based on natural language, which can be executed by a processing device. The processing device can be a terminal or a server. Terminals include, but are not limited to, smartphones, tablets, laptops, personal digital assistants, or smart wearable devices. The server can be a cloud server, such as a central server in a central cloud computing cluster or an edge server in an edge cloud computing cluster. Alternatively, the server can be a server in a local data center. A local data center refers to a data center directly controlled by the user.
[0025] This method addresses the issues of low efficiency, poor accuracy, and difficulty in traceability in converting natural language business rules into executable expressions for rule engines in manufacturing, logistics, and supply chain management. It integrates large language model capabilities through AI intelligent agent applications, utilizing preset prompts (including DSL syntax and business terminology explanations) to automatically generate Drools-adapted DSL expressions from natural language, replacing manual conversion and lowering the technical barrier. Simultaneously, a rule testing stage is added to verify the accuracy of DSL expressions in advance using simulated business data, preventing erroneous rules from being executed. Finally, by combining order review log storage and accurate result output, traceability of rule execution and rapid problem localization are achieved. Ultimately, a closed-loop process is constructed, encompassing natural language input, AI-generated DSL, simulation testing verification, actual execution judgment, and result traceability, resolving the pain points of insufficient efficiency and accuracy in existing solutions.
[0026] To make the technical solution of this application clearer and easier to understand, the following describes a method for automatically generating business rules based on natural language, provided by an embodiment of this application, in conjunction with the accompanying drawings. Figure 1 As shown, this figure is a flowchart of a method for automatically generating business rules based on natural language, provided in an embodiment of this application. The method includes: S201, The processing device obtains the natural language rule description input by the user.
[0027] User input refers to the operation of non-technical personnel (such as product managers and business specialists) submitting information through the system's interactive interface (such as a rule entry form built on the Odoo low-code platform). Input methods may include keyboard input, drop-down selection (such as product type, material type), etc., and it is the starting point for the transmission of business requirements.
[0028] Natural language rule descriptions refer to text content written by users in everyday business language that contains clear business constraints and logic. They do not need to follow professional syntax standards and directly reflect business requirements. For example, the sum of the capacity of the memory dummy module and the memory must be equal to 32; a maximum of 2 types of RAID cards can be selected; at most one type of memory can be selected; if the difference between the configuration quantity of the GPU card and FHFL is greater than 0, then the sum of the configuration quantity of the single-width GPU card dedicated riser and riser3 must be less than 4; if an L10 complete machine is configured, only packaging materials and firmware are allowed to be selected, and non-L10 related components cannot be configured; only one L10 complete machine can be selected, etc. These are the original basis for generating rule expressions in the future.
[0029] First, users (such as business specialists) write and submit text containing business constraints, i.e., natural language rule descriptions, in everyday business language through the interactive interface (such as a visual form) provided by the processing device. Then, the processing device captures this input information through the data receiving module, performs preliminary format verification (such as determining whether it contains key business elements), and stores it in a temporary data area to prepare for sending the description to the AI agent application and generating DSL expressions.
[0030] The purpose of this step is to lower the barrier to entry for business rules, so that users do not need to master technical languages and can convey their requirements through natural language. This solves the problem that non-technical personnel need to learn professional syntax to enter rules in traditional solutions, and lays the foundation for subsequent full-process automation.
[0031] S202. The processing device sends the natural language rule description to the AI agent application. The AI agent application configures prompt words and workflows, and the workflow calls the large language model.
[0032] AI intelligent agent applications refer to specialized artificial intelligence applications built to realize natural language rule description and DSL expression conversion. They have the capabilities of task scheduling, model invocation and data interaction. They are the intermediate carrier connecting processing devices and large language models, and can complete the closed-loop operation of receiving descriptions, invoking models and returning results based on preset logic.
[0033] Hint words are pre-configured structured instructions designed to guide large language models in generating DSL expressions that meet specific requirements. Hint words include the syntax specifications of Drools rule expression DSLs (such as if-then conditional structures and variable naming rules), explanations of business domain terms (such as material compatibility relationships and specification threshold definitions), and definitions of output data structures (such as the decision dimensions that the expression must include), ensuring that the expressions generated by the model can be directly adapted to the subsequent execution of the rule engine.
[0034] Workflow is a built-in task execution logic chain in AI intelligent agent applications. It predefines the order and triggering conditions of receiving natural language rule descriptions, loading prompt words, calling large language models, and receiving model outputs. It can automatically connect each link without manual intervention, ensuring the standardization and efficiency of the conversion process.
[0035] Large language models are artificial intelligence models with powerful natural language understanding and text generation capabilities, such as the GPT series and open-source large models. They can parse business logic described by natural language rules based on prompt words and automatically generate expressions that conform to DSL syntax specifications. They provide the computing power support for the conversion between natural language and technical expressions.
[0036] First, the processing device will perform basic verification on the previously acquired natural language rule description (such as "If the chassis is 8*2.5 and is configured with RAID card-9560, then it needs to be paired with 300-000880, and RAID card-9560-8 and RAID card-9560-16i need to meet the combination requirement of 'number of RAID card-9560-8 + number of RAID card-9560-16i × 2'"). After confirming that the key business elements (product type, constraint object, threshold condition) are complete, it will be packaged in a standard format and sent to the preset AI intelligent agent application through a data interface (such as RESTful API) to ensure that the transmitted data is compliant and usable.
[0037] Secondly, after receiving the data, the AI agent application will start the built-in workflow. First, it will load the exclusive prompt words (including Drools DSL syntax specifications, business terminology explanations and output format requirements) from the configuration library. Then, it will automatically call the associated large language model according to the workflow logic and pass the natural language rule description and prompt words to the large language model.
[0038] Finally, guided by prompts, the large language model first parses the business constraint logic in the natural language, and then transforms it into a DSL expression that conforms to Drools requirements. For example, "if(chassis}-(chassis8*2.5)==1and{RAID card-9560}>0,then outputs 300-000880,(RAID card-9560-8]+(RAID card-9560-16i}*2". After the format is verified to be correct, it is fed back to the AI agent application for temporary storage, in preparation for subsequent rule verification and execution.
[0039] The purpose of this step is to replace traditional manual conversion. Through the automated scheduling of AI intelligent agents and the parsing and generation capabilities of large language models, the conversion can be completed without human learning of DSL syntax. This not only improves conversion efficiency but also avoids expression errors caused by human experience bias, solving the problems of high threshold and unstable quality in traditional solutions.
[0040] S203, The processing device receives a domain-specific language (DSL) expression returned by the AI agent application, which is generated by a large language model based on prompt words and natural language rules.
[0041] Domain-Specific Language (DSL) expressions are specialized language expressions designed for the Drools rule engine scenario. They must follow fixed syntax (such as if-then conditional structures and material attribute variable naming rules) and are the core carrier connecting natural language business requirements with rule engine execution. They can be directly parsed by Drools and used for rule determination.
[0042] After the AI agent application calls the large language model and generates a compliant DSL expression, the AI agent application will feed the expression back to the processing device through the data interface. After receiving the DSL expression, the processing device will first verify whether its format meets the execution requirements of the Drools rule engine, such as whether it contains complete judgment conditions and execution result fields. After the verification is passed, it will be stored in the designated data area, providing a technical rule basis for subsequent steps such as importing the rule testing module to verify accuracy and loading it into the Drools rule engine for execution judgment.
[0043] The purpose of this step is to complete the closed loop of transforming business requirements and technical rules, so that the natural language descriptions of non-technical personnel can eventually be transformed into expressions that the rule engine can recognize and execute, laying the foundation for subsequent automated review.
[0044] The method also includes: The processing equipment acquires test data from simulated business scenarios; the test data from simulated business scenarios includes material attribute parameters, product type information, and configuration associations corresponding to natural language rule descriptions.
[0045] Every component of the test data must closely adhere to the information in the natural language rules. For example, if the natural language rule describes it as "The chassis (product type) is 82.5 specification (material attribute parameter) and configured with RAID card-9560 (material attribute parameter), then it needs to be paired with accessory 300-000880, and RAID card-9560-8 and RAID card-9560-16i must meet the combination requirement of 'number of RAID card-9560-8 + number of RAID card-9560-16i × 2' (configuration association)". The corresponding DSL expression is "if(chassis}-(chassis 82.5)==1and{RAID card-9560}>0,then output 300-000880,(RAID card-9560-8]+(RAID card-9560-16i}*2". Therefore, in the corresponding simulated test data, the product type information must be clearly specified as chassis, not other equipment types, to ensure that the test scenario is consistent with the applicable scope of the rules; the material attribute parameters must cover those that comply with the rules (e.g., chassis is 82.5 specification, ...). The test data includes two scenarios: one with RAID card-9560 configured and the other without (e.g., chassis is 42.5mm, RAID card-9560 not configured). This verifies the accuracy of the DSL expression in determining core attribute conditions. The configuration of association relationships must include scenarios that meet the adaptation requirements (300-000880 accessory already paired, RAID card-9560-8=2 and RAID card-9560-16i=3, satisfying the combination relationship) and scenarios that do not meet the adaptation requirements (300-000880 accessory not paired, RAID card-9560-8=1 and RAID card-9560-16i=1, not satisfying the combination relationship). This simulates the complex situation of multi-material collaboration in actual business, thereby verifying whether the DSL expression can completely identify material combination constraints. This test data design, which corresponds one-to-one with the rule description, comprehensively covers configuration scenarios that may occur in actual business, proactively identifying logical problems in the DSL expression regarding threshold judgment, product matching, and material adaptation, ensuring accurate execution after subsequent import into the Drools rule engine.
[0046] The processing device loads the DSL expression and test data into the rule testing module; if the test passes, the DSL expression is imported into the Drools rule engine for execution; if the test fails, the DSL expression is regenerated or fine-tuned and tested again until the test passes.
[0047] First, the processing device retrieves simulated service scenario test data corresponding to the current DSL expression from the system's preset test database. For example, for the natural language rule description "If the chassis is 82.5mm and a RAID card-9560 is configured, then a 300-000880 is required, and the RAID card-9560-8 and RAID card-9560-16i must meet the combination requirement of 'number of RAID card-9560-8 + number of RAID card-9560-16i × 2'", the corresponding DSL expression is "if(chassis}-(chassis 82.5)==1and The expression `{RAID card-9560}>0, then output 300-000880, (RAID card-9560-8]+(RAID card-9560-16i}*2`, yielding two types of test data: one type is "Chassis = Chassis 82.5 (configuration value = 1), RAID card-9560 = 1, 300-000880 = 1, RAID card-9560-8 = 2, RAID card-9560-16i = 3" (satisfying the requirements of associated configuration and combination); the other type is "Chassis = Chassis 82.5 (configuration value = 1), RAID card-9560 = ... 1. "300-000880 not configured, RAID card-9560-8=1, RAID card-9560-16i=1" (Association configuration requirements not met); Next, the processing device loads this DSL expression along with these test data into the rule testing module. The module simulates the execution logic of the Drools rule engine, substitutes the test data into the DSL expression for judgment, and outputs the test pass / fail result. For example, the first type of test data satisfies the dual conditions of "chassis specifications + RAID card configuration", is associated with 300-000880, and has a "2+3×2" combination relationship. The first type of test data is compliant and is deemed to meet the rules. The second type of test data is deemed non-compliant because it does not have 300-000880 configured. If it is consistent with the expectations, the test passes. Finally, the subsequent process is decided based on the test results: If the test passes, it means that the DSL expression logic is correct, and the processing device imports it into the Drools rule engine for actual business review. If the test fails (e.g., the expression omits the multiple logic of "RAID card-9560-16i×2"), the expression is regenerated through the AI intelligent agent application, or the expression syntax is manually fine-tuned, and the test data is reloaded for verification until the test passes.
[0048] The purpose of this step is to build a pre-validation barrier to prevent logically flawed DSL expressions from entering the actual execution stage, ensuring the accuracy of subsequent material configuration review and reducing business rework caused by rule errors.
[0049] S204. The processing device imports the DSL expression into the business rule management system engine Drools rule engine for execution, generating rule execution results.
[0050] The Drools rule engine is an open-source rule engine developed in Java. Its function is to match predefined rule expressions (such as DSL expressions) with business data, automatically execute logical judgments and output results. It supports decoupling of rules from business code and can dynamically adjust rules without restarting the system.
[0051] The rule execution result is structured data generated by the Drools rule engine after it performs a judgment on the DSL expression. It contains the judgment logic chain, such as verifying material attributes, matching rule conditions, drawing judgment conclusions, and the final judgment conclusion (such as conforming to the rule / not conforming to the rule). It is the direct basis for the subsequent output of audit results.
[0052] Specifically, the processing device receives the actual business material configuration data submitted by the user; loads the DSL expression and the actual business material configuration data into the Drools rule engine to perform rule determination and generate rule execution results.
[0053] The specific logic is as follows: First, the processing device receives the actual business material configuration data submitted by the user through the business system interaction interface (such as a hardware configuration review form), and at the same time completes the data integrity verification (such as confirming that key configuration fields such as chassis specifications, RAID card model, and associated accessory number are not missing) to ensure that the data can be used for rule determination; Secondly, the processing device loads the previously tested and verified DSL expression (such as "if (chassis) - (chassis 82.5) == 1 and {RAID card - 9560} > 0, then output 300-000880, (RAID card - 9560 - 8] + (RAID card - 9560 - 16i} * 2") along with the verified actual business material configuration data into the Drools rule engine. The engine will automatically determine the rules by substituting the actual data into the expression according to the business constraint logic preset in the DSL expression. For example, if the actual material data contains "chassis = chassis 82.5 (configuration value = 1) and RAID card - 9560 = 1", then the actual data will be processed accordingly. If the data is "300-000880=1, RAID card-9560-8=2, RAID card-9560-16i=3", the engine will determine that it meets the dual conditions of "chassis specifications + RAID card configuration", is associated with the required accessory 300-000880, and the combination relationship "2+3×2=8" meets the expression requirements, and is therefore deemed to comply with the rules. If the actual material data is "chassis=chassis82.5 (configuration value=1), RAID card-9560=1, not configured 300-000880, RAID card-9560-8=1, RAID card-9560-16i=1", then it is deemed to be non-compliant because the associated accessory configuration requirements are not met. Finally, after the engine completes the judgment, it generates a structured rule execution result containing the judgment logic link and the final judgment conclusion. For example, the judgment process is as follows: verify chassis specifications (compliant with 82.5) → verify RAID card configuration (RAID card exists - 9560) → verify associated accessories (configured 300-000880) → verify combination relationship (2 + 3 × 2 = 8, compliant with expression requirements); judgment conclusion: compliant with the rules, and feedback is sent to the processing device to provide direct basis for subsequent output of audit results and prompt information.
[0054] This step enables the implementation of pre-verified technical rules into real-world business scenario judgments, replacing the traditional manual verification of whether material configurations comply with the rules. This not only ensures the accuracy of the judgment results but also significantly improves the efficiency of material configuration review.
[0055] S205. The processing equipment outputs the audit results or prompt information based on the results of the rule execution.
[0056] Specifically, if the rule execution result shows that the DSL expression determines that the actual business material configuration data meets the requirements of the natural language rule description, then the approval result will be output. If the rule execution result shows that the DSL expression determines that the actual business material configuration data does not meet the requirements of the natural language rule description, then the audit failure result will be output, and the reason for failure will be output simultaneously. The prompt message corresponds to the constraint logic in the natural language rule description.
[0057] After the Drools rule engine generates the rule execution result, the processing device will first parse the judgment conclusion in the result. If the result shows a DSL expression (such as "if(chassis}-(chassis82.5)==1and{RAID card-9560}>0,then outputs 300-000880,(RAID card-9560-8]+(RAID card-9560-16i}*2"), the actual business material configuration data (such as "chassis=chassis8") has been determined. 2.5, RAID card-9560=1, 300-000880=1, RAID card-9560-8=2, RAID card-9560-16i=3) conforms to the original natural language rule description (e.g., "If the chassis is 82.5 and a RAID card-9560 is configured, then a 300-000880 is required, and RAID card-9560-8 and RAID card-9560-16i must satisfy 'RAID card-9560- If the system outputs a result indicating that the configuration is compliant (e.g., "8 units + RAID card -9560-16i unit quantity × 2"), the system will directly output the approved result to the user, clearly indicating that the current configuration is compliant. If the rule execution result shows that the DSL expression determines that the actual data does not conform to the natural language rules (e.g., the actual configuration is "chassis = chassis 82.5, RAID card -9560 = 1, 300-000880 not configured, RAID card -9560-8 = 1, RAID card -9560-16i = 1", which does not meet the constraint requirement of "must be paired with 300-000880"), the system will not only output the conclusion that the review is not approved, but will also simultaneously generate prompt information corresponding to the constraint logic of the natural language rules (e.g., "the chassis is 8*2.5 specification and is configured with RAID card -9560, but is not paired with the required associated accessory 300-000880, which does not meet the business rule requirements"), allowing users to quickly locate the configuration items that need to be corrected without having to look at the technical DSL expression.
[0058] The purpose of this step is to reduce the user's understanding cost by transforming the technical rule judgment results into straightforward business feedback. This ensures the clarity of the review conclusions and reduces the time users spend correcting configurations through accurate prompts, thereby further improving the efficiency of the business process.
[0059] After outputting the audit results or prompts, an audit log is generated, which includes the audit order number, rule execution details, actual business material configuration data, and audit results. The audit log is stored in the database, and the log can be queried by audit order number, product type, or time dimension.
[0060] First, after the system outputs the approval / failure result and prompt information to the user, it automatically triggers the approval log generation logic, integrating four pieces of information according to a preset format: a unique approval number (used to identify a single record), rule execution details (such as calling the DSL expression "if(chassis}-(chassis 82.5)==1and{RAID card-9560}>0,then outputs 300-000880,(RAID card-9560-8]+(RAID card-9560-16i}*2, determining that the actual configuration "not configured with 300-000880" does not meet the standard), the actual business material configuration data submitted by the user (such as chassis=chassis 82.5, RAID card-9560=1, not configured with 300-000880, RAID card-9560-8=1, RAID card-9560-16i=1), and the final approval result (such as approval failure), ensuring that the log information completely covers the entire approval process.
[0061] Next, the processing equipment transmits the generated audit logs to a preset database (such as PostgreSQL) for persistent storage to prevent log loss. At the same time, the database supports queries by three dimensions: accurately locating a single log by audit number, filtering audit records of similar products by product type (such as "hardware equipment configuration, server accessory combination"), and querying all audit data within a certain time period by time dimension (such as "May 2024"), meeting the traceability needs of business personnel for accurate, categorized, and time-based queries.
[0062] The purpose of this step is to build an audit traceability system. When it is necessary to review audit issues (such as why a batch of orders failed the audit) or conduct compliance checks, the audit process can be quickly restored through logs without having to repeatedly check the original data and rules. This not only improves the efficiency of problem investigation but also ensures business compliance and solves the problems of traditional manual audits being unrecorded and difficult to trace.
[0063] Based on the above description, this application has the following beneficial effects: In this application, the automatic generation of natural language to DSL expressions is achieved through the collaboration of AI intelligent agent application and large language model. Non-technical personnel do not need to learn DSL syntax. They only need to input the natural language rule description, and the large language model can generate expressions adapted to the Drools rule engine based on preset prompt words (including DSL syntax specifications and business terminology explanations). This greatly reduces the cost of manual conversion, improves the efficiency of rule configuration, and solves the problems of traditional manual conversion relying on experience and inconsistent quality.
[0064] Meanwhile, the generated DSL expressions are verified through simulated scenarios by the rule testing module, which can identify rule logic vulnerabilities in advance and ensure the accuracy of expressions imported into the Drools rule engine. In the actual execution stage, the rules are judged based on the actual business material configuration data submitted by the user, and the approval / failure conclusion and corresponding reasons for failure are output according to the judgment results. This can help business personnel quickly locate material configuration problems and reduce invalid review processes. In addition, the function of generating and storing review logs enables the traceability of the rule execution process, making it convenient for users to review the review process through multi-dimensional queries, thereby further ensuring the accuracy of business rule execution and the transparency of business processes.
[0065] The above text combined Figure 1 The method for automatically generating business rules based on natural language provided in the embodiments of this application has been described in detail. The apparatus and equipment provided in the embodiments of this application will be described below with reference to the accompanying drawings.
[0066] like Figure 2 As shown in the figure, this is a schematic diagram of an apparatus for automatically generating business rules based on natural language according to an embodiment of this application. The apparatus includes: The acquisition module 301 is used to acquire the natural language rule description input by the user; Sending module 302 is used to send the natural language rule description to the AI agent application, wherein the AI agent application configures prompt words and workflow, and the workflow calls the large language model; The receiving module 303 is used to receive the domain-specific language (DSL) expression returned by the AI agent application, which is generated by the large language model based on the prompt words and the natural language rule description; The processing module 304 is used to import the DSL expression into the business rule management system engine Drools rule engine for execution, generate rule execution results, and output audit results or prompt information based on the rule execution results.
[0067] Optionally, module 301 can also be used to acquire test data for simulated business scenarios; The processing module 304 is further configured to load the DSL expression and the test data into the rule testing module; if the test passes, the DSL expression is imported into the Drools rule engine for execution; if the test fails, the DSL expression is regenerated or fine-tuned and tested again until the test passes.
[0068] Optionally, the processing module 304 is specifically used to receive the actual business material configuration data submitted by the user; load the DSL expression and the actual business material configuration data into the Drools rule engine to perform rule determination and generate the rule execution result.
[0069] Optionally, the processing module 304 is specifically used to output an approval result if the rule execution result shows that the DSL expression determines that the actual business material configuration data meets the requirements of the natural language rule description; If the execution result of the rule shows that the DSL expression determines that the actual business material configuration data does not meet the requirements of the natural language rule description, then the audit failure result will be output, and the prompt information of the reason for failure will be output simultaneously. The prompt information corresponds to the constraint logic in the natural language rule description.
[0070] Optionally, the processing module 304 is also used to generate an audit log containing the audit order number, rule execution details, actual business material configuration data and audit results after outputting the audit results or prompt information; The review logs are stored in a database, and logs can be queried by review number, product type, or time dimension.
[0071] The apparatus for automatically generating business rules based on natural language according to the embodiments of this application can correspond to executing the method described in the embodiments of this application, and the other operations and / or functions of each module / unit of the apparatus for automatically generating business rules based on natural language are respectively for implementing Figure 1 For the sake of brevity, the corresponding processes of each method in the illustrated embodiments will not be described in detail here.
[0072] This application also provides a computing device. For example... Figure 3 As shown in the figure, this is a schematic diagram of a computing device provided in an embodiment of this application. The computing device 700 includes a bus 701, a processor 702, a communication interface 703, and a memory 704. The processor 702, the memory 704, and the communication interface 703 communicate with each other via the bus 701.
[0073] The 701 bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 3 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0074] The processor 702 can be any one or more of the following processors: central processing unit (CPU), graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).
[0075] The communication interface 703 is used for communication with external devices.
[0076] Memory 704 may include volatile memory, such as random access memory (RAM). Memory 704 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0077] The memory 704 stores executable code, and the processor 702 executes the executable code to perform the aforementioned method for automatically generating business rules based on natural language.
[0078] Specifically, in achieving Figure 2 In the case of the illustrated embodiment, and Figure 2 When the modules or units of the device for automatically generating business rules based on natural language described in the embodiments are implemented by software, the execution... Figure 2 The software or program code required for the functions of each module / unit can be partially or wholly stored in the memory 704. The processor 702 executes the program code corresponding to each unit stored in the memory 704, and executes the aforementioned method for automatically generating business rules based on natural language.
[0079] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the above-described method for automatically generating business rules based on natural language.
[0080] This application also provides a computer program product comprising one or more computer instructions. When the computer instructions are loaded and executed on a computing device, all or part of the processes or functions described in this application are generated.
[0081] The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, or data center to another website, computer, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0082] When the computer program product is executed by a computer, the computer executes any of the aforementioned methods for automatically generating business rules based on natural language. The computer program product can be a software installation package; when any of the aforementioned methods for automatically generating business rules based on natural language is required, the computer program product can be downloaded and executed on the computer.
[0083] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.
[0084] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be covered within the scope of protection of this application.
Claims
1. A method for automatically generating business rules based on natural language, characterized in that, The method includes: Obtain the natural language rule description input by the user; The natural language rule description is sent to the AI agent application, which configures prompt words and workflows, and the workflow calls the large language model. Receive the domain-specific language (DSL) expression returned by the AI agent application, which is generated by the large language model based on the prompt words and the natural language rule description; The DSL expression is imported into the Drools rule engine of the business rule management system and executed to generate rule execution results. Based on the execution result of the rules, output the audit result or prompt information.
2. The method according to claim 1, characterized in that, The method further includes: Obtain test data simulating business scenarios; Load the DSL expression and the test data into the rule test module; If the test passes, the DSL expression will be imported into the Drools rule engine for execution. If the test fails, regenerate or fine-tune the DSL expression and test again until the test passes.
3. The method according to claim 1, characterized in that, The step of importing the DSL expression into the Drools rule engine for execution and generating rule execution results includes: Receive actual business material configuration data submitted by users; The DSL expression and the actual business material configuration data are loaded into the Drools rule engine to perform rule determination and generate the rule execution result.
4. The method according to claim 1, characterized in that, The step of outputting audit results or prompt information based on the execution result of the rules includes: If the execution result of the rule shows that the DSL expression determines that the actual business material configuration data meets the requirements of the natural language rule description, then the approval result will be output. If the execution result of the rule shows that the DSL expression determines that the actual business material configuration data does not meet the requirements of the natural language rule description, then the audit failure result will be output, and the prompt information of the reason for failure will be output simultaneously. The prompt information corresponds to the constraint logic in the natural language rule description.
5. The method according to claim 1, characterized in that, The method further includes: After outputting the audit results or prompts, an audit log is generated that includes the audit order number, rule execution details, actual business material configuration data, and audit results. The review logs are stored in a database, and logs can be queried by review number, product type, or time dimension.
6. The method according to claim 1, characterized in that, The prompts include the syntax specifications of the Drools Regular Expression DSL, explanations of business domain terminology, and definitions of the output data structure.
7. The method according to claim 2, characterized in that, The test data for the simulated business scenarios includes material attribute parameters, product type information, and configuration associations corresponding to the natural language rule descriptions.
8. An apparatus for automatically generating business rules based on natural language, characterized in that, The device includes: The acquisition module is used to acquire the natural language rule descriptions input by the user; The sending module is used to send the natural language rule description to the AI agent application, wherein the AI agent application is configured with prompt words and workflow, and the workflow calls the large language model; The receiving module is used to receive the domain-specific language (DSL) expression returned by the AI agent application, which is generated by the large language model based on the prompt words and the natural language rule description; The processing module is used to import the DSL expression into the business rule management system engine Drools rule engine for execution, generate rule execution results, and output audit results or prompt information based on the rule execution results.
9. A computing device, characterized in that, Including memory and processor; The memory stores one or more computer programs, the one or more computer programs including instructions; when the instructions are executed by the processor, the computing device performs the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program for performing the method as described in any one of claims 1 to 7.