A code generation method, apparatus, device, medium, and product

CN122963512APending Publication Date: 2026-10-23INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610835954.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-10
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0004]本发明提供了一种代码生成方法、装置、介质和产品,解决目前代码一次性生成完整代码在复杂场景出现逻辑错误的问题,通过解析得到的目标任务、任务依赖图和子约束条件生成代码;保障复杂任务下的代码生成逻辑

Benefits of technology

[0010]本发明实施例的技术方案,通过解析得到的目标任务、任务依赖图和子约束条件生成代码,解决目前代码一次性生成完整代码在复杂场景出现逻辑错误的问题;保障复杂任务下的代码生成逻辑。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122963512A_ABST
    Figure CN122963512A_ABST
Patent Text Reader

Abstract

The application discloses a code generation method and device, a medium and a product, relates to the technical field of artificial intelligence and software engineering, and can be applied to the field of financial technology. A transaction request text is parsed to obtain a target task and a task dependency graph; the target task includes at least one subtask and a sub-constraint condition corresponding to the subtask; an initial code is generated by traversing the target task according to the task dependency graph through a large language model; and the initial code is simulated according to the sub-constraint condition to obtain a target code. According to the technical scheme, the target task, the task dependency graph and the sub-constraint condition obtained through parsing are used to generate a code; the code generation logic under a complex task is ensured, and the problem that a complete code generated at one time has a logic error in a complex scene is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of interdisciplinary technology of artificial intelligence and software engineering, and can be applied to the field of financial technology. In particular, it relates to a code generation method, device, medium and product. Background Technology

[0002] In the development of financial business systems, business logic often involves a combination of multiple conditions and strict regulatory constraints. For example, transaction business needs to verify transaction amount, currency, account status, anti-money laundering rules, and transaction time period restrictions; risk control rules need to monitor changes in customer risk level, product risk matching, concentration limits, and blacklist blocking in real time.

[0003] Traditional large-scale model code generation often generates complete functions or modules in a single step. While this can speed up simple scenarios, it's prone to logical omissions in complex business scenarios. For example, forgetting to validate blacklists or record audit logs before transactions; hard-coded errors in risk control thresholds; or failure to consider boundary cases with multiple conditions. These issues lead to high post-launch repair costs, and errors often only surface after testing or deployment, impacting overall development quality. Furthermore, traditional code completion methods are susceptible to errors in complex financial business scenarios, leading to the possibility of overlooking crucial logic, and manual verification and modification are costly. Therefore, there is an urgent need for a code generation method that can automatically and accurately generate corresponding business code based on complex business logic. Summary of the Invention

[0004] This invention provides a code generation method, apparatus, medium, and product that solves the problem of logical errors occurring when generating complete code in complex scenarios. It generates code by parsing the target task, task dependency graph, and sub-constraints, thus ensuring the logical generation of code under complex tasks.

[0005] According to one aspect of the present invention, a code generation method is provided, comprising: The transaction request text is parsed to obtain the target task and task dependency graph; the target task includes at least one subtask and the sub-constraints corresponding to the subtask. The target task is traversed according to the task dependency graph using a large language model to generate initial code; The initial code is simulated based on the sub-constraints to obtain the target code.

[0006] According to another aspect of the present invention, a code generation apparatus is provided, comprising: The parsing module is used to parse the transaction request text to obtain the target task and the task dependency graph; the target task includes at least one subtask and the sub-constraints corresponding to the subtask; The traversal generation module is used to traverse the target task according to the task dependency graph using a large language model to generate initial code; The simulation module is used to simulate the initial code according to the sub-constraints to obtain the target code.

[0007] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the code generation method described in any embodiment of the present invention.

[0008] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the code generation method described in any embodiment of the present invention.

[0009] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program that, when executed by a processor, implements the code generation method according to any embodiment of the present invention.

[0010] The technical solution of this invention generates code by parsing the target task, task dependency graph and sub-constraints, which solves the problem of logical errors in complex scenarios when the code is generated in one go; and ensures the code generation logic under complex tasks.

[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 This is a flowchart of a code generation method provided according to an embodiment of the present invention; Figure 2This is a flowchart of a method for generating a target task and a task dependency graph according to an embodiment of the present invention; Figure 3 This is a flowchart of a code generation method provided according to an embodiment of the present invention; Figure 4 This is a flowchart of a method for generating a target code block according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a code generation device according to an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of an electronic device that implements the code generation method of this invention. Detailed Implementation

[0014] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0015] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification, claims and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product or device.

[0016] Furthermore, it should be noted that the information collected in the technical solution of this invention is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of related data all comply with the relevant laws, regulations and standards of relevant countries and regions, necessary confidentiality measures have been taken, and public order and good morals are not violated. Corresponding operation entry points are provided for users to choose to authorize or refuse.

[0017] Figure 1 This invention provides a flowchart of a code generation method, applicable to business code generation, particularly in complex transaction business logic within financial scenarios. The method can be executed by a code generation device, which can be implemented in hardware and / or software and configured within a server. Figure 1 As shown, the method includes: S110. Parse the transaction request text to obtain the target task and task dependency graph; the target task includes at least one subtask and the corresponding sub-constraints.

[0018] The transaction request text is the transaction request corresponding to the payment transaction, which is input according to the preset business specifications. The amount, currency, payer, payee, and customer ID in the transaction request are described in structured natural language. The subtasks in the target task are the business logic tasks corresponding to the payment transaction request, which are represented as SIR (Specification-Interface-Requirement) in JSON format. They include subtasks, inputs and outputs, and sub-constraints corresponding to the subtasks. For example, if the payment transaction needs to verify limits, blacklists, and risk matching, then each business logic task corresponds to a subtask. The sub-constraints in the target task are task constraints. For example, the limit verification subtask needs to verify whether the transaction amount exceeds the user's limit, thereby restricting the payment transaction. The task dependency graph is the flowchart of the subtasks corresponding to the target task.

[0019] Specifically, the transaction request text is parsed to obtain the transaction content, transaction constraints, and business process. Subtasks corresponding to the business logic are generated based on the transaction content and transaction constraints. The subtasks are integrated to obtain the target task. A task dependency graph corresponding to the target task is generated based on the business process and subtasks, and the subtasks in the target task carry their corresponding sub-constraints.

[0020] Optional, such as Figure 2 The method shown involves parsing a transaction request text to obtain the target task and task dependency graph, including: S111. Parse the transaction request text to obtain transaction keywords, sub-constraints, and business processes.

[0021] The transaction keywords include transaction amount, payee identifier, product identifier, and customer identifier; the sub-constraints include limit constraints, account constraints, risk matching constraints, log call conditions, and result output conditions; the limit constraints indicate whether the transaction is subject to a limit; the account constraints indicate whether the account for the transaction is at risk; the risk matching constraints indicate whether the transaction is at risk; the log call conditions indicate whether the transaction is at risk; and the result output conditions indicate whether the transaction is executed.

[0022] Specifically, the transaction request text is parsed to obtain the transaction keywords corresponding to this transaction, such as transaction amount, payee identifier, and customer identifier; and the corresponding processing logic is found as sub-constraints based on the business transaction. Based on the sub-constraints, a business process is generated to determine whether the transaction should be executed.

[0023] S112. Perform hash calculation on the sub-constraints to obtain the sub-constraint identifiers.

[0024] The sub-condition identifier is used to distinguish each sub-task.

[0025] Specifically, hash calculations are performed on the sub-constraints to obtain sub-condition identifiers, which are used to distinguish each subtask.

[0026] S113. Construct at least one subtask based on the sub-constraint, the sub-condition identifier, and the transaction key corresponding to the sub-constraint; the subtask includes the sub-constraint.

[0027] Specifically, based on the sub-constraint, find the sub-condition identifier and transaction keyword corresponding to the constraint to construct the sub-task corresponding to the sub-constraint; each sub-task includes the sub-constraint.

[0028] Optionally, at least one subtask may be constructed based on the sub-constraint, the sub-constraint identifier, and the transaction key corresponding to the sub-constraint, including: Based on the sub-condition identifiers of the limit constraint, the first limit sub-task is constructed with the customer identifier as input and the customer limit as output. Based on the sub-condition identifiers of the limit constraint, the customer limit and transaction amount are used as inputs, and whether passage is allowed is used as the output to construct the second limit sub-task; Based on the sub-condition identifiers of the account risk constraints, the payee identifier and blacklist list are used as inputs, and whether the match is achieved is used as the output to construct risk sub-tasks. Based on the sub-condition identifiers of the risk matching constraints, customer identifiers, product identifiers, and risk level tables are used as inputs, and whether the risk passes is used as the output to construct a level sub-task. Based on the sub-condition identifiers of the log call conditions, the audit of the transaction request text is used as the output to construct the log call subtask; Based on the outputs of the second limit subtask, risk subtask, and level subtask, and the result mapping table as input, the task result is used as output; a task result subtask is constructed.

[0029] The system includes: a customer limit (daily limit for the customer corresponding to the customer identifier); a first and second limit subtasks to constrain transaction amounts, allowing for either limit-based or limit-based transactions; a blacklist of pre-defined high-risk accounts; a risk subtask to constrain accounts; a risk level table to represent the mapping between customer risk levels and customer identifiers, and between product risk levels and product identifiers; a log call subtask to output audit logs; and a task result that can be either a successful or unsuccessful transaction, with a corresponding reason code for unsuccessful transactions. If the outputs of the second limit subtask, risk subtask, and level subtask are all "successful," the transaction is successful. If the second limit subtask fails, the task result is "unsuccessful," with the reason code "limit exceeded."

[0030] Specifically, based on the sub-condition identifiers of the limit constraint, the customer identifier is used as input and the customer limit is used as output to construct the first limit sub-task, which can be represented as T1; based on the sub-condition identifiers of the limit constraint, the customer limit and transaction amount are used as input and whether passage is allowed is used as output to construct the second limit sub-task, which can be represented as T2; based on the sub-condition identifiers of the account risk constraint, the payee identifier and blacklist list are used as input and whether a match is found is used as output to construct the risk sub-task, which can be represented as T3; Based on the sub-condition identifiers of the risk matching constraints, and taking the customer identifier, product identifier, and risk level table as input, with the risk pass / fail status as output, a level subtask is constructed, which can be represented as T4; based on the sub-condition identifiers of the log call conditions, and taking the audit of transaction requests as output, a log call subtask is constructed, which can be represented as T5; based on the outputs of the second limit subtask, risk subtask, and level subtask, and the result mapping table as input, and taking the task result as output, a task result subtask is constructed, which can be represented as T6.

[0031] Understandably, generating corresponding subtasks through business logic transforms the refined business specification into subtasks, allowing code to be generated gradually based on these subtasks. This avoids logical omissions caused by generating code all at once, significantly improving the correctness and executability of the generated code. It is particularly suitable for complex business logics such as financial transactions and risk control rules, reducing the amount of manual modification required later.

[0032] S114. Sort at least one subtask according to the business process to construct the target task.

[0033] Among them, the business process represents the business logic relationship, indicating the dependency relationship between subtasks.

[0034] Specifically, at least one subtask is sorted according to the business process. For example, if subtasks T1 and T2 are dependent, they are packaged into one subtask and processed in parallel with the other subtasks T2, T3, and T4. T5, as a call log, can be executed before transaction execution or before transaction rejection. T6 is executed after the subtasks that are processed in parallel, and is placed last. The subtasks are sorted according to the dependencies of the business process to obtain the target task.

[0035] S115. Establish a task dependency graph based on the sub-condition identifiers and the sub-tasks in the target task.

[0036] Specifically, sub-condition identifiers are used to distinguish subtasks in the target task, and a task dependency graph is established based on the business process logic relationship of the subtasks in the target task. Nodes in the task dependency graph can be sub-condition identifiers used to distinguish subtasks, and node information can be subtasks. Edges can be the logical dependencies between subtasks corresponding to their business processes.

[0037] Understandably, by converting the transaction request text into a SIR in JSON format, the subtasks between the target tasks are identified. Further, the business process is obtained based on the structure of the SIR, and a task dependency graph is generated. This enables the task decomposition of business code in complex scenarios, resulting in subtasks. Subsequent sub-business code can be generated based on these subtasks, ensuring code generation efficiency and accuracy. Furthermore, the task dependency graph can be used to integrate the sub-business code, improving the accuracy of business code generation.

[0038] S120. The target task is traversed based on the task dependency graph using a large language model to generate initial code.

[0039] Among them, the large language model can be an LLM model, which is used to generate a thought chain based on the target task, and then generate the corresponding business code; the initial code is the code corresponding to the target task, which can be complete business code.

[0040] Specifically, the target task is traversed by the large language model according to the task dependency graph to obtain the task reasoning corresponding to each subtask. The subtask code corresponding to each task is generated based on the task reasoning, and the subtask code is encapsulated according to the dependency relationship of the task dependency graph to generate the initial code.

[0041] S130. Simulate the initial code based on the sub-constraints to obtain the target code.

[0042] The target code is the initial code that passes the self-constraint conditions.

[0043] Specifically, the initial code is pre-simulated online based on the sub-constraints and the corresponding sample data. Once all simulations pass, the target code is obtained and logged.

[0044] Optionally, the initial code is simulated based on the sub-constraints to obtain the target code, including: Generate corresponding positive and negative sample data based on the sub-constraints; the positive and negative sample data each include corresponding sample labels. The initial code was simulated using positive and negative sample data, and the simulation results were obtained. If the simulation results match the sample labels, the initial code will be used as the target code; If the simulation results do not match the sample labels, the simulation results, initial code, and sample data corresponding to the simulation results will be integrated and output.

[0045] Among them, positive sample data and negative sample data are the sample data corresponding to the sub-constraint conditions. For example, the positive sample data given by the risk sub-task is a randomly generated payee identifier, and its corresponding negative sample data can be the payee identifier in the blacklist. The sample label can be pass or fail.

[0046] Specifically, positive and negative sample data are generated based on the sub-constraints. Each sample data carries a corresponding sample label: positive sample data is labeled "pass," and negative sample data is labeled "fail." Positive or negative sample data is input into the initial code to simulate online trading and obtain the simulation result. If the limit constraint in the sub-constraints is exceeded, the simulation result returns LIMIT_EXCEEDED; if the account constraint in the sub-constraints is exceeded, the simulation result returns BLACKLIST_HIT; if the risk matching constraint in the sub-constraints is exceeded, the simulation result returns RISK_MISMATCH. If the simulation result matches the sample label, the initial code is used as the target code. If the simulation result does not match the sample label (i.e., the positive sample data is labeled "pass," but the simulation result is "fail"), the simulation result, the initial code, and the sample data corresponding to the simulation result are integrated and output.

[0047] Understandably, by simulating sample data online and setting positive and negative sample data in conjunction with the sub-constraints corresponding to each sub-task, the accuracy and executability of business code generation can be improved. This is especially suitable for complex business logics such as financial transactions and risk control rules, enabling timely and accurate verification of sub-tasks under the business logic, timely detection of business logic errors, and further improvement of business code generation efficiency.

[0048] This invention parses transaction request text to obtain a target task and a task dependency graph. The target task includes at least one subtask and corresponding sub-constraints. A large language model traverses the target task according to the task dependency graph to generate initial code. The initial code is then simulated based on the sub-constraints to obtain the target code. This technical solution generates code by parsing the target task, task dependency graph, and sub-constraints, ensuring logical code generation for complex tasks and solving the problem of logical errors occurring in complex scenarios when generating complete code in a single step.

[0049] Figure 3 This is a flowchart of a code generation method provided by an embodiment of the present invention. The embodiments of the present invention supplement the initial code generation method based on the above embodiments. It should be noted that for parts not described in detail in the embodiments of the present invention, please refer to the relevant descriptions in other embodiments. For example... Figure 3 As shown, the method includes: S210. Parse the transaction request text to obtain the target task and task dependency graph; the target task includes at least one subtask and the sub-constraints corresponding to the subtask.

[0050] S220. Traverse the subtasks in the target task according to the order of the task dependency graph to obtain subtask information.

[0051] The subtask information is in JOSN format corresponding to the subtask.

[0052] Specifically, the subtasks in the target task are traversed according to the order of the task dependency graph to obtain information on at least one subtask.

[0053] S230. Convert the subtask information into a task format and generate subtask instructions.

[0054] The subtask instructions include subtask text, inputs, outputs, and sub-constraints; the subtask instructions are in Prompt format, and the subtask text is a task description.

[0055] Specifically, the task format of each subtask information is converted to generate subtask instructions, including subtask text, input, output, and sub-constraints.

[0056] S240. Generate target code blocks based on subtask instructions using a large language model and task dependency graph.

[0057] The target code block is the code block corresponding to the subtask.

[0058] Specifically, reasoning is performed using a large language model and task dependency graph to obtain a reasoning chain, and the target code block corresponding to the subtask is generated based on the reasoning chain and subtask instructions.

[0059] Optional, such as Figure 4 The method for generating target code blocks, as shown, generates target code blocks based on subtask instructions using a large language model and task dependency graph, including: S241. Reason about subtask instructions using a large language model and task dependency graph to obtain the task reasoning chain.

[0060] The task reasoning chain consists of the steps involved in task execution.

[0061] Specifically, by using a large language model and task dependency graph to reason about subtask instructions, a task reasoning chain is obtained. For example, for this transaction task, it is necessary to first call the limit service, then compare the amount, and then compare the risk level.

[0062] S242. Generate the initial code block based on the task inference chain.

[0063] The initial code block is the initial code corresponding to the subtask, and it needs to be constrained and validated.

[0064] Specifically, the corresponding code block is generated based on this reasoning as the initial code block.

[0065] S243. Call the verification tool and sub-constraints to perform multi-dimensional evaluation of the initial code block and output the target code block.

[0066] The verification tools may include integrity testing and constraint testing of the code; multi-dimensional evaluation includes integrity and constraint satisfaction; the target code block is the initial code block that has been successfully verified.

[0067] Specifically, the verification tool and sub-constraints are invoked to evaluate the initial code block in terms of completeness and constraint satisfaction from multiple dimensions. The verification is then determined based on the evaluation results. If the verification is successful, the initial code block is output as the target code block.

[0068] Optionally, the initial code block is evaluated from multiple dimensions using verification tools and sub-constraints, and the target code block is output, including: The unit test tool and sub-constraints in the verification tool are invoked to verify the constraints of the initial code block and obtain the constraint trust value. The static code analysis tool in the verification tool is invoked to perform a logical check on the initial code block and obtain a logical trust value. The confidence level is obtained based on the constraint trust value and the logical trust value; If the confidence level is higher than the confidence threshold, the initial code block will be output as the target code block.

[0069] The unit testing tool verifies the constraints of each subtask; the static code analysis tool performs logical verification of the code block syntax; the constraint trust value is the value corresponding to the constraint condition; the logical trust value is the business logic trust value; the confidence level is obtained by weighted aggregation of the constraint trust value and the logical trust value; the confidence level threshold is used to indicate whether the initial code block meets the conditions for output; preferably 0.85; it should be noted that relevant technical personnel can set the confidence level threshold according to actual needs, and the embodiments of the present invention do not impose specific limitations on this.

[0070] Specifically, the unit testing tool and sub-constraints in the verification tool are used to verify the constraints of the initial code block and obtain the constraint trust value; the static code analysis tool in the verification tool is used to check the business logic of the initial code block and obtain the logic trust value; the constraint trust value and the logic trust value are weighted and aggregated to obtain the confidence score; if the confidence score is higher than or equal to the confidence score threshold, the initial code block is output as the target code block; if the confidence score is lower than the confidence score threshold, the sub-task instructions are re-inferred through the large language model and task dependency graph, and the corresponding code block is generated based on the inference result.

[0071] Understandably, by calling verification tools to validate code blocks and determine whether they meet constraints and syntactic business logic, it is possible to ensure that each task focuses on a single business rule and avoid dependency errors caused by generating code all at once.

[0072] S250. Encapsulate the target code block according to the order of the task dependency graph to generate the initial code.

[0073] Specifically, the target code blocks are encapsulated according to the dependency order of the task dependency graph to obtain the initial code.

[0074] In one optional embodiment of the present invention, after generating the initial code, a static analysis check can be performed on the complete business code, mainly checking the syntax, type, and interface compatibility. If the check passes, the initial code is output so that there are no syntax or interface problems during the code encapsulation process, avoiding the situation where the initial code cannot run in subsequent online simulations, and further ensuring the reliability and accuracy of the generated initial code.

[0075] Understandably, generating code block by block through a large model in multi-step inference ensures that code blocks can generate corresponding code blocks according to business logic, avoiding logical omissions caused by one-time generation. This can significantly improve the correctness and executability of the generated code, and is especially suitable for complex business logic such as financial transactions and risk control rules, reducing the amount of manual modification later.

[0076] S260. Simulate the initial code based on the sub-constraints to obtain the target code.

[0077] This invention combines a large language model, target task, and task dependency graph to decompose complex business tasks, construct their dependencies according to the task dependency graph, and use the large language model to reason about sub-tasks and dependencies to generate corresponding code blocks. This enables code generation block by block in multi-step reasoning, improving the accuracy of business code generation and further enhancing the efficiency of business code generation.

[0078] Figure 5 This invention provides a schematic diagram of a code generation device according to an embodiment of the present invention. This embodiment is applicable to business code generation, particularly to business code generation under complex transaction business logic in financial scenarios. The code generation device can be implemented in hardware and / or software and can be configured in a server. Figure 5 As shown, the code generation device 300 includes a parsing module 310, a traversal generation module 320, and a simulation module 330: The parsing module 310 is used to parse the transaction request text to obtain the target task and the task dependency graph; the target task includes at least one subtask and the sub-constraints corresponding to the subtask. The traversal generation module 320 is used to traverse the target task based on the task dependency graph using a large language model to generate initial code; The simulation module 330 is used to simulate the initial code based on the sub-constraints to obtain the target code.

[0079] This invention parses transaction request text to obtain a target task and a task dependency graph. The target task includes at least one subtask and corresponding sub-constraints. A large language model traverses the target task according to the task dependency graph to generate initial code. The initial code is then simulated based on the sub-constraints to obtain the target code. This technical solution generates code by parsing the target task, task dependency graph, and sub-constraints, ensuring logical code generation for complex tasks and solving the problem of logical errors occurring in complex scenarios when generating complete code in a single step.

[0080] Optionally, the parsing module 310 includes a parsing subunit, a hash calculation unit, a subtask construction unit, a sorting unit, and a task dependency graph establishment unit; The parsing subunit is used to parse the transaction request text to obtain transaction keywords, sub-constraints, and business processes. Transaction keywords include transaction amount, payee identifier, product identifier, and customer identifier. Sub-constraints include limit constraints, account risk constraints, risk matching constraints, log call conditions, and result output conditions. The hash calculation unit is used to perform hash calculations on sub-constraints to obtain sub-constraint identifiers; A subtask construction unit is used to construct at least one subtask based on sub-constraints, sub-condition identifiers, and transaction keywords corresponding to the sub-constraints; a subtask includes sub-constraints. The sorting unit is used to sort at least one subtask according to the business process to construct the target task; The task dependency graph building unit is used to build a task dependency graph based on the sub-condition identifier and the sub-tasks in the target task.

[0081] Optionally, the subtask construction unit is also used to construct the first quota subtask based on the subcondition identifier of the quota constraint, taking the customer identifier as input and the customer quota as output. Based on the sub-condition identifiers of the limit constraint, the customer limit and transaction amount are used as inputs, and whether passage is allowed is used as the output to construct the second limit sub-task; Based on the sub-condition identifiers of the account risk constraints, the payee identifier and blacklist list are used as inputs, and whether the match is achieved is used as the output to construct risk sub-tasks. Based on the sub-condition identifiers of the risk matching constraints, customer identifiers, product identifiers, and risk level tables are used as inputs, and whether the risk passes is used as the output to construct a level sub-task. Based on the sub-condition identifiers of the log call conditions, the audit of the transaction request text is used as the output to construct the log call subtask; Based on the outputs of the second limit subtask, risk subtask, and level subtask, and the result mapping table as input, the task result is used as output; a task result subtask is constructed.

[0082] The traversal generation module 320 includes a traversal unit, a format conversion unit, a code block generation unit, and an initial code generation unit; The traversal unit is used to traverse the subtasks in the target task according to the order of the task dependency graph and obtain subtask information. The format conversion unit is used to convert the subtask information into a task format and generate subtask instructions; the subtask instructions include subtask text, input, output and sub-constraints. The code block generation unit is used to generate target code blocks based on subtask instructions using a large language model and task dependency graph. The initial code generation unit is used to encapsulate target code blocks according to the order of the task dependency graph and generate initial code.

[0083] Optionally, the code block generation unit is also used to reason about subtask instructions through a large language model and task dependency graph to obtain a task reasoning chain; Generate an initial code block based on the task inference chain; The initial code block is evaluated from multiple dimensions using verification tools and sub-constraints, and the target code block is output.

[0084] Optionally, the code block generation unit is also used to call the unit testing tools and sub-constraints in the verification tool to perform constraint verification on the initial code block and obtain the constraint trust value; The static code analysis tool in the verification tool is invoked to perform a logical check on the initial code block and obtain a logical trust value. The confidence level is obtained based on the constraint trust value and the logical trust value; If the confidence level is higher than the confidence threshold, the initial code block will be output as the target code block.

[0085] Optionally, the simulation module 330 is also used to generate corresponding positive and negative sample data based on the sub-constraints; the positive and negative sample data respectively include corresponding sample labels; The initial code was simulated using positive and negative sample data, and the simulation results were obtained. If the simulation results match the sample labels, the initial code will be used as the target code; If the simulation results do not match the sample labels, the simulation results, initial code, and sample data corresponding to the simulation results will be integrated and output.

[0086] The code generation apparatus provided in the embodiments of the present invention can execute the code generation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0087] According to embodiments of the present invention, the present invention also provides an electronic device, a readable storage medium, and a computer program product.

[0088] Figure 6 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0089] like Figure 6As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0090] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0091] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as code generation methods.

[0092] In some embodiments, the code generation method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the code generation method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the code generation method by any other suitable means (e.g., by means of firmware).

[0093] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include: implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0094] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0095] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0096] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0097] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0098] A computing system can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product within the cloud computing service system. This addresses the shortcomings of traditional physical hosts and dedicated virtual services, such as high management difficulty and weak business scalability.

[0099] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0100] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A code generation method, characterized in that, include: The transaction request text is parsed to obtain the target task and task dependency graph; the target task includes at least one subtask and the sub-constraints corresponding to the subtask. The target task is traversed according to the task dependency graph using a large language model to generate initial code; The initial code is simulated based on the sub-constraints to obtain the target code.

2. The method according to claim 1, characterized in that, The process of parsing the transaction request text to obtain the target task and task dependency graph includes: The transaction request text is parsed to obtain transaction keywords, sub-constraints, and business processes. The transaction keywords include transaction amount, payee identifier, customer identifier, and product identifier. The sub-constraints include limit constraints, account risk constraints, risk matching constraints, log call conditions, and result output conditions. The sub-constraints are hashed to obtain sub-constraint identifiers; At least one subtask is constructed based on the sub-constraint, the sub-condition identifier, and the transaction keyword corresponding to the sub-constraint; the subtask includes the sub-constraint. The at least one subtask is sorted according to the business process to construct the target task; A task dependency graph is established based on the sub-condition identifiers and the sub-tasks in the target task.

3. The method according to claim 2, characterized in that, The step of constructing at least one sub-task based on the sub-constraint, the sub-condition identifier, and the transaction keyword corresponding to the sub-constraint includes: Based on the sub-condition identifiers of the limit constraint, the customer identifier is used as input and the customer limit is used as output to construct the first limit sub-task; Based on the sub-condition identifiers of the limit constraint, the customer limit and the transaction amount are used as inputs, and whether passage is allowed is used as the output to construct a second limit sub-task; Based on the sub-condition identifiers of the account risk constraints, the payee identifier and blacklist list are used as inputs, and whether the match is achieved is used as the output to construct a risk sub-task; Based on the sub-condition identifiers of the risk matching constraints, the customer identifier, the product identifier, and the risk level table are used as inputs, and whether the risk passes is used as the output to construct a level sub-task; Based on the sub-condition identifier of the log call condition, the audit of the transaction request text is used as the output to construct the log call subtask; Based on the outputs of the second limit subtask, the risk subtask, and the level subtask, and the result mapping table as input, the task result is used as output; a task result subtask is constructed.

4. The method according to claim 1, characterized in that, The step of traversing the target task according to the task dependency graph using a large language model to generate initial code includes: The subtasks in the target task are traversed according to the order of the task dependency graph to obtain subtask information; The subtask information is converted into a task format to generate subtask instructions; the subtask instructions include subtask text, input, output, and sub-constraints. The target code block is generated based on the subtask instructions using the large language model and the task dependency graph. The target code blocks are encapsulated according to the order of the task dependency graph to generate initial code.

5. The method according to claim 4, characterized in that, The step of generating target code blocks based on the subtask instructions using the large language model and the task dependency graph includes: The task inference chain is obtained by reasoning about the subtask instructions using a large language model and the task dependency graph. Generate an initial code block based on the task inference chain; The initial code block is evaluated from multiple dimensions using the verification tool and the sub-constraints, and the target code block is output.

6. The method according to claim 5, characterized in that, The invocation verification tool and the sub-constraints perform a multi-dimensional evaluation of the initial code block, outputting the target code block, including: The unit testing tool in the verification tool and the sub-constraint conditions are invoked to perform constraint condition verification on the initial code block to obtain the constraint trust value; The static code analysis tool in the verification tool is invoked to perform a logical check on the initial code block to obtain a logical trust value; The confidence level is obtained based on the constraint trust value and the logical trust value; If the confidence level is higher than the confidence level threshold, then the initial code block is output as the target code block.

7. The method according to claim 1, characterized in that, The step of simulating the initial code based on the sub-constraints to obtain the target code includes: Based on the sub-constraints, corresponding positive and negative sample data are generated; the positive and negative sample data each include corresponding sample labels. The initial code is simulated using the positive and negative sample data, and the simulation results are obtained. If the simulation result matches the sample label, then the initial code is used as the target code; If the simulation result does not match the sample label, the simulation result, the initial code, and the sample data corresponding to the simulation result will be integrated and output.

8. A code generation device, characterized in that, include: The parsing module is used to parse the transaction request text to obtain the target task and task dependency graph; The target task includes at least one subtask and sub-constraints corresponding to the subtask; The traversal generation module is used to traverse the target task according to the task dependency graph using a large language model to generate initial code; The simulation module is used to simulate the initial code according to the sub-constraints to obtain the target code.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the code generation method of any one of claims 1-7.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the code generation method according to any one of claims 1-7.