A Mini Program Code Automatic Generation System Based on Intelligent Agents and Its Control Method
The intelligent agent-based mini-program code automatic generation system solves the problem of high requirements for users' programming skills and industry knowledge in existing technologies. It achieves highly accurate code generation without manual programming, ensuring that the code meets user needs and improving user interaction experience and system stability.
Patent Information
- Application Number
- CN202511164403.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-20
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2045-08-20
AI Technical Summary
Existing industry software requires high levels of programming skills and industry knowledge from users when generating mini-program code, and lacks support for specific industries, making it difficult for users to obtain executable logic code that conforms to industry standards. Existing intelligent agent programming assistance tools lack fine-grained understanding and often recall erroneous code.
An agent-based automatic code generation system for mini-programs is adopted, including a user requirement input module, a mini-program generation module, and a stage verification module. The system automatically generates and verifies mini-program code through agents, utilizing user-described agents, code implementation agents, and reflective agents in cooperation. The RAG module is used for vectorization and retrieval from a preset knowledge base to ensure that the code meets user requirements.
It enables intelligent code generation without manual programming, improving the accuracy and security of code generation, ensuring that the code meets user needs, and enhancing user interaction experience and system stability.
Smart Images

Figure CN120653231B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of assisted programming, specifically relating to an automatic code generation system for mini-programs based on intelligent agents and its control method. Background Technology
[0002] Current industry software, such as Seeyon zxdoc's Python programming, involves full-code programming with only examples and supporting functions, requiring a high level of programming ability, function proficiency, and industry knowledge from the user.
[0003] Similarly, TsMast's C mini-program and Vector's Canoe combine a graphical interface for manually adding code blocks with manual programming, which also places high demands on users' programming skills, function proficiency, and industry knowledge.
[0004] Current industry software heavily relies on documentation, requiring users to possess strong reading comprehension and programming backgrounds. Even then, users may still encounter difficulties due to insufficiently detailed and easy-to-understand documentation, often relying on human guidance. While various intelligent agent programming aids exist, such as ChatGPT, GitHub Copilot, Tabnine, CodeGeeX, and Synonym, their knowledge coverage extends to general programming syntax, lacking support for industry-specific communication protocols, system integration documentation, and SDKs (e.g., automotive electronics). Although there are precedents for using RAG for assisted processing, traditional RAG systems often simply cut technical documents into fixed-length chunks, lacking an understanding of fine-grained contexts such as "protocol type, call constraints, and hardware limits." This often results in recalling ambiguous or inappropriate fragments, leading to frequent manual troubleshooting of mismatched code. In summary, users typically only receive syntax-level suggestions, rarely obtaining complete, industry-standard executable logic code. This limits the accuracy of assistance in actual development, and currently, no system can directly and automatically generate small program code that meets user needs. Summary of the Invention
[0005] To address the technical problems existing in the prior art, this invention provides an automatic code generation system for mini-programs based on intelligent agents and its control method. It does not rely on manual programming, is not limited by the technical field, and is highly efficient, accurate, and easy to operate.
[0006] The technical problem solved by this invention is achieved through the following technical solution:
[0007] A smart agent-based automatic code generation system for WeChat mini-programs includes:
[0008] The user requirement input module is used to input the user's requirements for the generated mini-program code in text form;
[0009] The mini-program generation module is used to automatically generate mini-program code that meets user needs through intelligent agents.
[0010] The phase verification module is used to complete the verification at each stage during the process of the intelligent agent automatically generating the mini-program code;
[0011] The interaction module is used to enable users to log in across platforms and interact with data.
[0012] The control method for an agent-based automatic code generation system for WeChat mini-programs includes the following steps:
[0013] Step S1: After logging in to the C language applet, the user obtains a unique identity authentication.
[0014] Step S2: The user inputs their requirements through a C language applet;
[0015] Step S3: The C language applet delivers the user's request to the intelligent agent. If the intelligent agent verifies that the user's unique identity authentication is valid, then step S4 is executed; otherwise, the request is rejected.
[0016] Step S4: The agent translates the user requirement into a user requirement code, and then verifies whether the user requirement code is correct. If it is correct, proceed to step S5. If it is incorrect, return an error message, update the user requirement, and repeat step S4.
[0017] Step S5: The agent searches the preset knowledge base according to the user's code requirements, edits the search results, and obtains the preliminary compilation result of the mini-program code. It verifies whether the preliminary compilation result of the mini-program code meets the user's requirements. If it does, it outputs the execution result of the mini-program code and implements step S6. If it does not, it corrects the errors detected by the agent. The correction includes adjusting the parameters of the preliminary compilation result of the mini-program code, modifying the process, and refactoring and optimizing.
[0018] Step S6: The agent verifies the execution result of the mini-program code. If the execution meets the requirements, the entire automatic generation process of the mini-program code is completed and the result is output. If the execution does not meet the requirements, S3 is repeated.
[0019] Furthermore, in steps S4-S6, the intelligent agent includes a user-described intelligent agent, a code-implemented intelligent agent, and a reflective intelligent agent; among which,
[0020] User-described agents can translate user requirements into user requirement code, which is then input into the code-implementing agent.
[0021] The code-implemented intelligent agent can output preliminary compilation results of the mini-program code that meet the user's requirements based on the user's code requirements;
[0022] The reflective agent is used to verify whether the user's code requirements are correct, whether the initial compilation results of the mini-program code meet the user's requirements, and whether the execution results of the mini-program code meet the running requirements. At the same time, it analyzes the differences between the current execution results of the mini-program code and the user's requirements, and intelligently adjusts and corrects the generated mini-program code.
[0023] Furthermore, in step S1, the unique identity authentication obtained is a valid token. The token serves as the credential for user authentication and authorization across all platforms. After obtaining the token, the C language applet carries it. In step S3, a request is sent to the agent via a network request. Upon receiving the request, the agent verifies it through the Redis system on the cloud platform. The Redis system is used to store and verify the validity of the token. During the verification process, the Redis system quickly checks whether the token exists in the current system's cache data. If it exists and is valid, the agent will continue to process the request; otherwise, the request is rejected and the user is prompted to log in again.
[0024] Furthermore, in step S5, parameter adjustment refers to adjusting the parameters of function calls involved in the preliminary compilation results of the mini-program code based on the detection results of the reflective agent.
[0025] Process modification refers to optimizing the execution flow of the initial results of the mini-program code compilation;
[0026] Refactoring and optimization refers to optimizing the initial compilation results of the mini-program code after confirming that the logic is correct.
[0027] Furthermore, in step S6, when executing the result of the mini-program code, the logical correctness is verified through the log information, message receiving interface, system variables, and graphical window of the mini-program code execution result.
[0028] Furthermore, reflecting on whether the intelligent agent verifies whether the user requirement code is correct means verifying whether the code can be compiled normally. If it can be compiled, the user requirement code is judged to be correct; if it cannot be compiled, the user requirement code is judged to be incorrect.
[0029] The reflection agent checks whether the initial compilation result of the intelligent verification mini-program code meets the user's requirements. Specifically, the reflection agent compares the user's required code with the preset knowledge base to check whether the code logic of the initial compilation result of the mini-program code is correct and whether the function call parameters are correct. If the result is correct, it outputs it to the C language mini-program through the SSE protocol.
[0030] Furthermore, the user description agent, code implementation agent, and reflection agent all use the RAG module to vectorize their respective input text information into information vectors. These vectors are then retrieved from a pre-defined knowledge base. The RRF reciprocal ranking fusion algorithm is then used to uniformly rank the semantic units retrieved from the pre-defined knowledge base corresponding to the information vectors with the keyword search results. This achieves a fusion of semantic unit relevance and keyword precision. Specifically, a ranking list is first obtained through a keyword retrieval tool. Then, a sorted list is obtained through a semantic search engine. Finally, after calculation, the semantic units are sorted from highest to lowest according to the user text description's relevance. The k semantic units with the highest relevance are then used for the final generated semantic units. The specific calculation formula is as follows:
[0031] ;
[0032] In the formula, d represents the current semantic unit, and Score RRF This represents the final fusion score of the current semantic unit.
[0033] R keyword (d) represents the ranking of the current semantic unit in the keyword retrieval ranking list, R semantic (d) represents the rank of the current semantic unit in the semantic retrieval ranking list, and k is the number of semantic units.
[0034] Furthermore, the user-described agent, the code-implemented agent, and the reflective agent each contain their respective pre-defined knowledge bases;
[0035] When the user-described agent, the code-implemented agent, and the reflective agent vectorize their respective input text information, RAG first stores the original data, then stores the vectorized data, and finally identifies the labels.
[0036] The preset knowledge base includes preset mini-program functions and industry document code;
[0037] The industry document code is generated by parsing the industry document syntax and semantics to obtain the industry document semantic units. Then, each smallest industry document semantic unit is labeled with metadata tags and stored in a preset knowledge base. When the agent searches the preset knowledge base, it first identifies and stores several metadata tags corresponding to the vectorized vector data, and then performs industry document semantic unit retrieval based on the several metadata tags.
[0038] Furthermore, when the reflexive agent verifies whether the user's requirement code is correct, it searches the preset knowledge base to see if it contains the semantic unit corresponding to the current user's requirement code. If some code is not included in the preset knowledge base, the missing user code portion is output back to the code generation agent as a difference, and the next instruction is immediately rejected. The user code input is then returned to the corresponding step. Based on the input of the previous step and the semantic units in the preset knowledge base, RAG calls Function Calling and MCP as needed to obtain the current time and location information.
[0039] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0040] Different intelligent agents are processed through RAG, so both full and segmented code can be included. At the same time, the required professional knowledge and industry documents are placed in the preset knowledge base, and programming code is provided directly. The non-prompt programming eliminates the need for manual programming. Full programming can be directly handed over to the system. Users only need to describe the requirements to be implemented to the intelligent agent, and the intelligent agent will automatically generate mini-program code that meets the user's needs.
[0041] 2. This invention utilizes the cooperation of a user-demand intelligence agent, a code implementation intelligence agent, and a reflective intelligence agent to perform stage verification at each process step, ensuring that the generated code meets the expected functions, effectively avoiding the occurrence of illusion problems, improving the accuracy of the mini-program code generation process, and solving data security and obsolescence issues through RAG and FunctionCalling technologies.
[0042] 3. This invention uses the SSE protocol to establish a long-term connection with the intelligent agent, ensuring that messages are not lost and maintaining a good user interaction experience. At the same time, the cross-platform login problem is also effectively solved, improving the stability and compatibility of the system. Attached Figure Description
[0043] Figure 1 This is a system structure diagram of Example 1;
[0044] Figure 2 This is a flowchart of the control method in Example 1;
[0045] Figure 3 This is a schematic diagram of the effect example 1. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0047] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0048] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0049] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of this invention is in use. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention. In addition, the terms "first," "second," "third," etc., are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0050] Furthermore, terms such as "horizontal," "vertical," and "sag" do not imply that components must be absolutely horizontal or suspended, but rather that they can be slightly tilted. For example, "horizontal" simply means that its direction is more horizontal relative to "vertical," and does not mean that the structure must be completely horizontal, but can be slightly tilted.
[0051] In the description of this invention, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0052] Example 1
[0053] like Figure 1 As shown, a WeChat Mini Program code automatic generation system based on intelligent agents includes:
[0054] The user requirement input module is used to input the user's requirements for the generated mini-program code in text form;
[0055] The mini-program generation module is used to automatically generate mini-program code that meets user needs through intelligent agents.
[0056] The phase verification module is used to complete the verification at each stage during the process of the intelligent agent automatically generating the mini-program code;
[0057] The interaction module is used to enable users to log in across platforms and interact with data.
[0058] The control method for an agent-based automatic code generation system for WeChat mini-programs includes the following steps:
[0059] Step S1: After logging in to the C language mini-program, the user obtains a unique identity, namely a valid token. The token serves as the credential for user authentication and authorization across all platforms. After obtaining the token, the C language mini-program carries it with it.
[0060] Step S2: The user inputs their requirements through a C language applet;
[0061] Step S3: The C language applet delivers the user's request to the agent. If the agent verifies the user's unique identity authentication is valid, then step S4 is executed; otherwise, the request is rejected. (Specifically, the request is sent to the agent via a network request. After receiving the request, the agent verifies it through the Redis system on the cloud platform. The Redis system is used to store and verify the validity of the token. During the verification process, the Redis system quickly checks whether the token exists in its system's cache data. If it exists and is valid, the agent will continue to process the request; otherwise, the request is rejected and the user is prompted to log in again.)
[0062] Step S4: The agent translates the user requirement into a user requirement code, and then verifies whether the user requirement code is correct. If it is correct, proceed to step S5. If it is incorrect, return an error message, update the user requirement, and repeat step S4.
[0063] Step S5: The agent searches the preset knowledge base based on the user's required code, edits the search results, and obtains the preliminary compilation result of the mini-program code. It verifies whether the preliminary compilation result of the mini-program code meets the user's requirements. If it does, it outputs the execution result of the mini-program code and proceeds to step S6. If it does not, it corrects the errors or inconsistencies detected by the agent. The correction includes parameter adjustment, process modification, and refactoring optimization of the preliminary compilation result of the mini-program code (parameter adjustment refers to adjusting the parameters of function calls involved in the preliminary compilation result of the mini-program code based on the detection results of the reflective agent; process modification refers to optimizing the execution process of the preliminary compilation result of the mini-program code; refactoring optimization refers to optimizing the preliminary compilation result of the mini-program code after confirming that the logic is correct).
[0064] Step S6: The agent performs execution verification on the results of the mini-program code execution (during execution verification, it verifies the logical correctness of the mini-program code execution results through its log information, message receiving interface, system variables, and graphical window). If the execution meets the requirements, the entire automatic generation process of the mini-program code is completed and the results are output. If the execution does not meet the requirements, S3 is repeated.
[0065] It should be noted that in this embodiment, the intelligent agent includes a user-described intelligent agent, a code-implemented intelligent agent, and a reflective intelligent agent; wherein,
[0066] User-described agents can translate user requirements into user requirement code, which is then input into the code-implementing agent.
[0067] The code-implemented intelligent agent can output the preliminary compilation result of the mini-program code that meets the user's requirements based on the user's code (the process includes searching the code in the preset knowledge base, or optimizing it through the large models that can be applied in the existing technology to generate the result).
[0068] The reflective agent is used to verify whether the user requirement code is correct (verifying whether the user requirement code is correct means checking whether the code can be compiled normally; if it can, the user requirement code is judged to be correct; if it cannot, the user requirement code is judged to be incorrect), whether the preliminary compilation result of the mini-program code meets the user requirements (the reflective agent verifies whether the preliminary compilation result of the mini-program code meets the user requirements; specifically, the reflective agent compares the user requirement code with the preset knowledge base to check whether the code logic of the preliminary compilation result of the mini-program code is correct and whether the function call parameters are correct; if the result is correct, it is output to the C language mini-program through the SSE protocol), and whether the execution result of the mini-program code meets the running requirements. At the same time, it analyzes the difference between the current execution result of the mini-program code and the user requirements, and intelligently adjusts and corrects the generated mini-program code.
[0069] In this embodiment, the user description agent, code implementation agent, and reflection agent all use the RAG module to vectorize their respective input text information into information vectors. These vectors are then retrieved from a preset knowledge base. The RRF reciprocal ranking fusion algorithm is then used to uniformly rank the semantic units in the preset knowledge base corresponding to the information vectors with the keyword search results. This achieves a fusion of semantic unit relevance and keyword precision. Specifically, a ranking list is first obtained through a keyword search engine. Then, a sorted list is obtained through a semantic search engine. Finally, after calculation, all documents are sorted from highest to lowest according to their user text description accuracy. The k semantic units with the highest accuracy are then selected for use in the final semantic unit generation. The specific calculation formula is as follows:
[0070] ;
[0071] In the formula, d represents the current semantic unit, and Score RRF This represents the final fusion score of the current semantic unit.
[0072] R keyword (d) represents the ranking of the current semantic unit in the keyword retrieval ranking list, R semantic (d) represents the rank of the current semantic unit in the semantic retrieval ranking list, and k is the number of semantic units.
[0073] In this embodiment, the user-described agent, the code-implemented agent, and the reflective agent each contain their respective preset knowledge bases.
[0074] When the user-described agent, the code-implemented agent, and the reflective agent vectorize their respective input text information, RAG first stores the original data, then stores the vectorized data, and finally identifies the labels.
[0075] The preset knowledge base includes preset mini-program functions and industry documentation code (user manuals, function interface documentation code, etc.).
[0076] The industry document code is generated by parsing the industry document syntax and semantics to obtain the industry document semantic units. Then, each smallest industry document semantic unit is labeled with metadata tags and stored in a preset knowledge base. When the agent searches the preset knowledge base, it first identifies and stores several metadata tags corresponding to the vectorized vector data, and then performs industry document semantic unit retrieval based on the several metadata tags.
[0077] In this embodiment, when the reflexive agent verifies whether the user requirement code is correct, it searches the preset knowledge base to see if it contains the semantic unit corresponding to the current user requirement code. If some code is not included in the preset knowledge base, the missing user code is output back to the code generation agent as a difference, and the next instruction is immediately rejected, and the process is regressed to the step corresponding to the user code input. Based on the input of the previous step and the semantic unit in the preset knowledge base, RAG calls Function Calling and MCP as needed to obtain the current time and location information.
[0078] Meanwhile, in step S6, verifying whether the mini-program code meets user requirements can also be divided into three stages in actual use: static analysis stage, compilation stage, and user acceptance stage. In the static analysis stage, the reflective agent directly checks the mini-program code to determine whether there are any syntax errors. In the compilation stage, the user clicks the compile and run button or compiles in the compiler built into the agent. If no error occurs, it is considered qualified. In the user acceptance stage, if the user does not click to regenerate, it is considered error-free.
[0079] It should be noted that the user requirement agent, the code implementation agent, and the reflection agent all have a built-in large model. The agents input the results to the large model through the RAG module, and the large model outputs the results based on the input content and the knowledge in the preset knowledge base. The large model can be a cloud-based large model, incorporating local business knowledge for fine-tuning, and then deployed locally to ensure the security of data files. The preset database and the large model provide question-and-answer services to the cloud service, while the cloud service provides question-and-answer responses for the system in this embodiment.
[0080] Example 1
[0081] like Figure 3 As shown, after implementing the technical solution according to Embodiment 1, the pre-set knowledge base contains various necessary industry documents and is then fine-tuned.
[0082] The vector database and the large model used in this example can provide question-and-answer services to the cloud service, which in turn provides question-and-answer responses to the agent-based mini-program code automatic generation system on the computer.
[0083] The computer-based agent-based mini-program code automatic generation system includes an agent dialog box that can communicate with the user. The agent service provided in the cloud displays the response here.
[0084] Users can also selectively or completely copy the agent's answers to the full code editor of the C mini-program.
[0085] Users can also switch to segmented editing and view the code on the left.
[0086] After compiling and running the entire program, it can execute the sending and receiving functions that need to be performed.
[0087] Therefore, it can be seen that the C mini-program code is displayed in a structured manner as segmented editing and full editing, and the code is broken down into different nodes according to the syntax tree for display.
[0088] In this example, the large model of the intelligent agent incorporates automotive industry business processes and adds corresponding content to a pre-set knowledge base, which also includes various diagnostic communication protocols and system programming methods.
[0089] The code obtained from the intelligent agent through user communication can be directly applied to the full-process code editing and compilation for execution.
[0090] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0091] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0092] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A control method for an agent-based automatic code generation system for mini-programs, characterized in that, The system includes, The user requirement input module is used to input the user's requirements for the generated mini-program code in text form; The mini-program generation module is used to automatically generate mini-program code that meets user needs through intelligent agents. The phase verification module is used to complete the verification at each stage during the process of the intelligent agent automatically generating the mini-program code; The interaction module is used to enable users to log in across platforms and interact with data. The method Includes the following steps, Step S1: After logging in to the C language applet, the user obtains a unique identity authentication. Step S2: The user inputs their requirements through a C language applet; Step S3: The C language applet delivers the user's request to the intelligent agent. If the intelligent agent verifies that the user's unique identity authentication is valid, then step S4 is executed; otherwise, the request is rejected. Step S4: The intelligent agent translates the user's requirements into user requirement codes, and then verifies whether the user requirement codes are correct. If correct, proceed to step S5; if incorrect, return an error message, update the user requirements, and repeat step S4. Step S5: The agent searches a preset knowledge base based on the user's required code. After editing the search results, a preliminary compilation result of the mini-program code is obtained. The agent verifies whether the preliminary compilation result of the mini-program code meets the user's requirements. If it does, the execution result of the mini-program code is output, and step S6 is implemented. If it does not meet the requirements, the agent corrects the errors detected by the agent. The correction includes parameter adjustment, process modification, and refactoring optimization of the preliminary compilation result of the mini-program code. Parameter adjustment refers to adjusting the function call parameters involved in the preliminary compilation result of the mini-program code based on the detection results of the agent. Process modification refers to optimizing the execution flow of the preliminary compilation result of the mini-program code. Refactoring and optimization refers to optimizing the initial compilation results of the mini-program code after confirming that the logic is correct. Step S6: The intelligent agent verifies the execution result of the mini-program code. If the execution meets the requirements, the entire automatic generation process of the mini-program code is completed and the result is output. If the execution does not meet the requirements, S3 is repeated. Furthermore, when executing the execution result of the mini-program code, the logical correctness is verified through the log information, message receiving interface, system variables, and graphical window of the execution result of the mini-program code. In steps S4-S6, the intelligent agent includes a user-described intelligent agent, a code-implemented intelligent agent, and a reflective intelligent agent; wherein, The user description agent can translate user requirements into user requirement code, and then input it into the code implementation agent; The code enables the intelligent agent to output preliminary compilation results of the mini-program code that meet the user's requirements, based on the user's code requirements. The reflexive agent is used to verify whether the user requirement code is correct, whether the preliminary compilation result of the mini-program code meets the user requirements, and whether the execution result of the mini-program code meets the running requirements. It also analyzes the differences between the current execution result of the mini-program code and the user requirements, and adjusts and corrects the generated mini-program code. Specifically, verifying whether the user requirement code is correct means checking whether the code can be compiled normally. If it can, the user requirement code is determined to be correct; if it cannot, the user requirement code is determined to be incorrect. Verifying whether the preliminary compilation result of the mini-program code meets the user requirements involves the reflexive agent comparing the user requirement code with a preset knowledge base to check whether the code logic of the preliminary compilation result of the mini-program code is correct and whether the function call parameters are correct. If the result is correct, it is output to the C language mini-program via the SSE protocol. The user description agent, code implementation agent, and reflection agent all use the RAG module to vectorize their respective input text information into information vectors. These vectors are then retrieved from a pre-defined knowledge base. The RRF reciprocal ranking fusion algorithm is then used to uniformly rank the semantic units in the pre-defined knowledge base corresponding to the information vectors with the keyword search results. This achieves a fusion of semantic unit relevance and keyword precision. Specifically, a ranking list is first obtained through a keyword retrieval tool. Then, a sorted list is obtained through a semantic search engine. Finally, after calculation, the semantic units are sorted from highest to lowest according to the user text description's relevance. The k semantic units with the highest relevance are then used for the final generated semantic units. The specific calculation formula is as follows: ; In the formula, d represents the current semantic unit, and Score RRF This represents the final fusion score of the current semantic unit. R keyword (d) represents the ranking of the current semantic unit in the keyword retrieval ranking list, R semantic (d) represents the rank of the current semantic unit in the semantic retrieval ranking list, where k is the number of semantic units; The user-described intelligent agent, the code-implemented intelligent agent, and the reflective intelligent agent each contain their corresponding preset knowledge base; When the user-described agent, the code-implemented agent, and the reflective agent vectorize their respective input text information, RAG first stores the original data, then stores the vectorized data, and finally identifies the labels. The preset knowledge base includes preset mini-program functions and industry document code; The industry document code is obtained by parsing the industry document syntax and semantics to obtain the industry document semantic unit. Then, each smallest industry document semantic unit is tagged with metadata and stored in a preset knowledge base. When the agent searches the preset knowledge base, it first identifies several metadata tags corresponding to the vectorized vector data and stores the several metadata tags. Then, it performs industry document semantic unit retrieval based on the several metadata tags. When the reflexive agent verifies whether the user's requirement code is correct, it searches the preset knowledge base to see if it contains the semantic unit corresponding to the current user's requirement code. If some code is not included in the preset knowledge base, the missing user code portion is output back to the code generation agent as a difference, and the next instruction is immediately rejected, and the corresponding step of the user code input is returned. The RAG calls FunctionCalling and MCP to obtain the current time and location information as needed, based on the input of the previous step and the semantic unit in the preset knowledge base.
2. The control method for the automatic generation system of mini-program code based on intelligent agents according to claim 1, characterized in that, In step S1, the unique identity authentication obtained is a valid token. This token serves as proof of user authentication and authorization across all platforms. After obtaining the token, the C language applet carries it. In step S3, a request is sent to the agent via a network request. Upon receiving the request, the agent verifies it using the Redis system on the cloud platform. The Redis system is used to store and verify the validity of the token. During the verification process, the Redis system quickly checks whether the token exists in the current system's cache data. If it exists and is valid, the agent will continue to process the request; otherwise, the request will be rejected and the user will be prompted to log in again.
Citation Information
Patent Citations
Multi-agent-based programmable logic controller structured text generation method
CN120450033A