Code execution method and device based on agent and electronic equipment
By combining large language models and intelligent agents, the code execution task path is dynamically adjusted, which solves the problem of lack of flexibility and automation of traditional code assistance tools, realizes efficient and accurate code execution, meets personalized needs, and reduces operational complexity and development costs.
Patent Information
- Application Number
- CN202510714814.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-12
AI Technical Summary
Traditional code assistance tools are difficult to meet the personalized needs of different projects, lack flexibility, are cumbersome to operate, and are difficult to achieve efficient automation, which affects project development efficiency.
The agent-based code execution method dynamically adjusts the task execution path through the combination of a large language model and an agent, determines the task execution path and code execution instructions, realizes the combination of code and context, meets personalized needs, and improves flexibility and automation.
It improves the efficiency, accuracy and automation of code execution tasks, reduces the complexity of operations, reduces development costs and improves user experience.
Smart Images

Figure CN120631470A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of code analysis, and in particular to an agent-based code execution method, device, and electronic device. Background Art
[0002] At present, with the in-depth application of artificial intelligence in the field of software development, code assistance tools play an important role in code completion, optimization, review, etc.
[0003] However, traditional code assistance tools mostly rely on preset rules or scripts, making it difficult to dynamically adjust the analysis and generation process, difficult to meet the personalized needs of different projects, and lack flexibility. Traditional code assistance tools require users to manually select files and configure parameters, which is cumbersome to operate and difficult to achieve efficient automation, thus affecting project development efficiency. Summary of the Invention
[0004] The embodiments of the present application provide a method, device and electronic device for executing code based on an intelligent agent. The embodiments provided by the present application solve the technical problems in the prior art that traditional code assistance tools are difficult to meet the personalized needs of different projects, lack flexibility, are cumbersome to operate, and are difficult to achieve efficient automation, thereby affecting the efficiency of project development. The embodiments provided by the present application can meet the personalized needs of different projects, improve flexibility, and reduce the cumbersomeness of operation. In addition, the present application improves the execution efficiency, execution accuracy and degree of automation of code execution tasks.
[0005] In a first aspect of the embodiments of the present application, the embodiments of the present application provide an agent-based code execution method, the agent-based code execution method comprising:
[0006] Determine a code execution task and a task prompt word corresponding to the code execution task based on user needs;
[0007] Inputting the code execution task and the task prompt word into a large language model, performing code analysis and task decomposition on the code execution task, and determining a task execution path corresponding to the code execution task and code execution instructions under the execution path;
[0008] Inputting the task execution path and the code execution instruction into the intelligent agent, controlling the intelligent agent to execute the corresponding task action according to the code execution instruction under the task execution path, and determining the task execution result;
[0009] The task execution result is input into the large language model, and the task execution path is dynamically adjusted until the code execution task is completed.
[0010] In a feasible implementation, the task prompt word includes task target prompt information, code execution rule prompt information, code termination condition, and code analysis calling tool prompt information. The code execution task and the task prompt word are input into a large language model, code analysis and task decomposition are performed on the code execution task, and the task execution path corresponding to the code execution task and the code execution instructions under the execution path are determined, including:
[0011] Inputting the code execution task and the task prompt word into a large language model, performing task decomposition on the code execution task according to the task goal, and determining a task execution path corresponding to the code execution task;
[0012] Each subtask in the task execution path is subjected to code analysis according to the code execution rule prompt information, the code termination condition prompt information and the code analysis calling tool prompt information to determine the code execution instructions corresponding to each subtask in the execution path.
[0013] In a feasible implementation, inputting the task execution path and the code execution instruction into the agent, controlling the agent to perform the corresponding task action according to the code execution instruction under the task execution path, and determining the task execution result includes:
[0014] For each of the subtasks, the subtask and the code execution instruction corresponding to the subtask are input into the agent, the code execution instruction is parsed based on the task prompt word, and the task action corresponding to the subtask is determined;
[0015] Execute the task action corresponding to the subtask and determine the task execution result corresponding to the subtask. In a feasible implementation, inputting the task execution result into the large language model and dynamically adjusting the task execution path until the code execution task is completed includes:
[0016] Inputting the current task execution result corresponding to the current subtask into the large language model, and dynamically adjusting the next subtask in the task execution path;
[0017] Determining whether all subtasks in the dynamically adjusted task execution path have been completed;
[0018] If so, it is determined that the code execution task is completed.
[0019] In a feasible implementation manner, after determining whether all subtasks in the dynamically adjusted task execution path have been completed, the method further includes:
[0020] If there are unfinished subtasks in the dynamically adjusted task execution path, the unfinished subtasks are continued to be executed based on the dynamically adjusted task execution path.
[0021] In a feasible implementation manner, after inputting the task execution result into the large language model and dynamically adjusting the task execution path, the method further includes:
[0022] Based on the task execution results corresponding to each subtask, a target execution result corresponding to the code execution task is determined.
[0023] In a feasible implementation, the code analysis calling tool prompt information includes code parsing tool prompt information and code completion tool prompt information, and performing code analysis on each subtask in the task execution path according to the code execution rule prompt information, the code termination condition prompt information, and the code analysis calling tool prompt information to determine the code execution instructions corresponding to each subtask in the execution path includes:
[0024] Performing code parsing on each subtask in the task execution path according to the code execution rule prompt information, the code termination condition prompt information, and the code parsing tool prompt information to determine a candidate code execution code corresponding to each subtask in the execution path;
[0025] The candidate code execution codes are completed based on the code completion tool to determine the code execution instructions corresponding to the subtasks in the execution path.
[0026] In a second aspect of the embodiments of the present application, the embodiments of the present application provide an agent-based code execution device, wherein the agent-based code execution includes:
[0027] A first determining module is used to determine a code execution task and a task prompt word corresponding to the code execution task based on user needs;
[0028] a second determination module, configured to input the code execution task and the task prompt word into a large language model, perform code analysis and task decomposition on the code execution task, and determine a task execution path corresponding to the code execution task and code execution instructions under the execution path;
[0029] a third determining module, configured to input the task execution path and the code execution instruction into an agent, control the agent to execute a corresponding task action according to the code execution instruction under the task execution path, and determine a task execution result;
[0030] A dynamic adjustment module is used to input the task execution result into the large language model and dynamically adjust the task execution path until the code execution task is completed.
[0031] According to a third aspect of the embodiments of the present application, an electronic device is provided, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and the machine-readable instructions are executed by the processor when running, such as the steps of the above-mentioned agent-based code execution method.
[0032] In a fourth aspect of the embodiments of the present application, the embodiments of the present application provide a computer-readable storage medium on which a computer program is stored. When the computer program is run by a processor, the steps of the above-mentioned agent-based code execution method are executed.
[0033] The embodiments of the present application provide a method, device, and electronic device for executing code based on an intelligent agent. Compared with the prior art, the embodiments provided by the present application determine the code execution task and the task prompt word corresponding to the code execution task based on user needs, and input the code execution task and the task prompt word into a large language model. Then, code analysis and task decomposition are performed on the code execution task to determine the task execution path corresponding to the code execution task and the code execution instructions under the execution path. The task execution path and the code execution instructions are then input into the intelligent agent, and the intelligent agent is controlled to execute the corresponding task action according to the code execution instructions under the task execution path to determine the task execution result. Finally, the task execution result is input into the large language model, and the task execution path is dynamically adjusted until the code execution task is completed. The embodiments provided by the present application can dynamically adjust the task execution path based on the execution result, realize the combination of code and context, and thus meet the personalized needs of different projects, improve flexibility, and reduce the tediousness of operation. In addition, by combining the large language model and the intelligent agent, the present application improves the execution efficiency, execution accuracy, execution quality, and degree of automation of the code execution task, thereby reducing the development cost of the code execution task.
[0034] The embodiments provided in this application can perform multiple rounds of code execution in combination with the task execution results corresponding to multiple rounds of subtasks, thereby reducing the frequency of user interaction and operations, and thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A flowchart of an agent-based code execution method provided in an embodiment of the present application is shown;
[0036] Figure 2A structural block diagram of an agent-based code execution device provided in an embodiment of the present application is shown;
[0037] Figure 3 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown.
[0038] Figure 2 and Figure 3 The corresponding relationship between the reference numerals and the names of the drawings is as follows:
[0039] 200 Agent-based code execution device; 210 First determination module; 220 Second determination module; 230 Third determination module; 240 Fourth determination module; 250 Fifth determination module; 300 Electronic device; 310 Processor; 320 Memory; 330 Bus. DETAILED DESCRIPTION
[0040] In order to better understand the technical solutions provided by the embodiments of this specification, the technical solutions of the embodiments of this specification are described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiments of this specification and the specific features in the embodiments are detailed descriptions of the technical solutions of the embodiments of this specification, rather than limitations on the technical solutions of this specification. In the absence of conflict, the embodiments of this specification and the technical features in the embodiments can be combined with each other.
[0041] In this article, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of further restrictions, the elements defined by the statement "comprising a ..." do not exclude the presence of other identical elements in the process, method, article or equipment comprising the elements. The term "two or more" includes two or more than two cases.
[0042] First, the application scenarios to which this application is applicable are introduced. The embodiments provided in this application are applicable to the field of code analysis technology, and in particular, relate to a method, device and electronic device for executing code based on an intelligent agent.
[0043] At present, most traditional code assistance tools rely on preset rules or scripts, making it difficult to dynamically adjust the analysis and generation process, difficult to meet the personalized needs of different projects, and lack flexibility. Traditional code assistance tools require users to manually select files and configure parameters, which is cumbersome to operate and difficult to achieve efficient automation, thus affecting project development efficiency.
[0044] Based on this, embodiments of the present application provide an agent-based code execution method, device, and electronic device.
[0045] Figure 1 This is a flowchart of a method for determining a fault identification model provided in an embodiment of the present application. Figure 1 As shown, the execution method of the agent-based code includes the following steps:
[0046] S101: Determine a code execution task and a task prompt word corresponding to the code execution task based on user needs.
[0047] In this step, the embodiment provided in this application can determine the code execution task that the user wants to perform and the task prompt words that guide the intelligent agent or large language model to understand the above code execution task based on the user's project requirements.
[0048] Among them, the user needs in the embodiments provided in this application can be customized and used according to different application scenarios. The user needs in the embodiments provided in this application can be user-entered code text information and / or user-spoken natural language, such as user questions.
[0049] S102: Input the code execution task and the task prompt word into the large language model, perform code analysis and task decomposition on the code execution task, and determine the task execution path corresponding to the code execution task and the code execution instructions under the execution path.
[0050] In this step, the embodiment provided by the present application can input the code execution task and the above-mentioned task prompt words into the large language model together, so that the large language model performs code analysis and task decomposition on the received code execution task, and after the analysis is completed, automatically generates and outputs a task execution path formed by multiple subtasks, and determines the code execution instructions corresponding to each subtask under the above-mentioned task execution path.
[0051] Exemplarily, the task prompt words include task target prompt information, code execution rule prompt information, code termination condition prompt information, and code analysis calling tool prompt information. The task execution path corresponding to the code execution task and the code execution instructions under the execution path are determined in the following manner:
[0052] The code execution task and task prompt words are input into the large language model, the code execution task is decomposed according to the task goal, and the task execution path corresponding to the code execution task is determined; each subtask in the task execution path is analyzed according to the code execution rule prompt information, code termination condition prompt information and code analysis call tool prompt information, and the code execution instructions corresponding to each subtask in the execution path are determined.
[0053] It can be understood that the embodiment provided by the present application inputs the code execution task and the task prompt word into the large language model, and first decomposes the code execution task through the large language model. The specific task decomposition method can be to decompose the code execution task into various subtasks according to the task target prompt information in the task prompt word, and independently plan each subtask to determine the planned task execution path; then, the embodiment provided by the present application analyzes the various subtasks in the task execution path according to the constraint information in the task prompt word (such as code execution rule prompt information, code termination condition prompt information and code analysis call tool prompt information), and generates code execution instructions corresponding to each subtask.
[0054] Among them, the task target prompt information in the embodiment provided by this application can be the code analysis, optimization and generated target file of the task target prompt information that the user hopes to complete, among which the task target prompt information is specifically "Please analyze the following Python code, check whether there is an infinite loop, and optimize the code structure."
[0055] The code execution rule prompt information in the embodiments provided in this application can be customized and used according to different application scenarios. The code execution rule prompt information in the embodiments provided in this application can be code naming specifications, code business logic consistency, and code style, etc. Among them, the code execution rule prompt information is specifically "Please ensure that the optimized code complies with the preset coding specifications and improves operating efficiency."
[0056] The code termination condition prompt information in the embodiments provided in this application can be customized and used according to different application scenarios. The code termination condition prompt information in the embodiments provided in this application can be standard information for completing the code execution task, condition information for the code to pass quality inspection, and specific indicators achieved by optimization, etc.
[0057] The code analysis calling tool prompt information in the embodiments provided in this application can be customized and used according to different application scenarios. The code analysis calling tool prompt information in the embodiments provided in this application can be code parsing tool prompt information and code completion tool prompt information, wherein the code analysis calling tool prompt information is specifically "You can use the AST parsing tool to analyze the code structure, or use the refactoring tool to optimize the code."
[0058] Exemplarily, the code analysis calling tool prompt information in the embodiment provided by this application includes code parsing tool prompt information and code completion tool prompt information. Each subtask in the task execution path is analyzed according to the code execution rule prompt information, the code termination condition prompt information, and the code analysis calling tool prompt information to determine the code execution instructions corresponding to each subtask in the execution path, specifically:
[0059] Each subtask in the task execution path is parsed according to the code execution rule prompt information, code termination condition prompt information and code parsing tool prompt information to determine the candidate code execution code corresponding to each subtask in the execution path; each candidate code execution code is completed based on the code completion tool to determine the code execution instruction corresponding to each subtask in the execution path.
[0060] In the above, the embodiment provided by the present application first performs code analysis on each subtask in the code task execution path according to the code execution rule prompt information, the code termination condition prompt information and the code parsing tool prompt information, such as standardizing the code in each subtask according to the prescribed code style, naming conventions and business logic consistency, and terminating the analysis when the above code reaches the termination condition information of the running test or debugging specified by the code termination condition prompt information, and at the same time uses the Abstract Syntax Tree (AST) code parsing tool prompt information to parse the above code to determine the candidate code execution code corresponding to each subtask in the execution path.
[0061] After generating the candidate code execution codes corresponding to each subtask, the embodiment provided by the present application can use a code completion tool to complete the above-mentioned candidate code execution codes, so that the candidate code execution codes corresponding to each subtask can be standardized according to a unified format, and the code execution instructions corresponding to each subtask in the execution path can be determined.
[0062] In the above, the code analysis calling tool prompt information in the embodiment provided by this application can also include environment perception prompt information for identifying the code execution environment, file retrieval prompt information for finding related code in the code library, and instruction execution prompt information for executing run tests or debugging commands.
[0063] S103: Input the task execution path and code execution instructions into the intelligent agent, control the intelligent agent to execute the corresponding task action according to the code execution instructions under the task execution path, and determine the task execution result.
[0064] In this step, after determining the code execution instructions for each subtask under the task execution path, the embodiment provided by the present application inputs the task execution path and the code execution instructions into the intelligent agent, so that the intelligent agent can intelligently execute the corresponding task actions according to the code execution instructions, and generate a corresponding task execution result, and feed back the above task execution result to the large language model so that the large language model can adjust the task execution path in real time.
[0065] Exemplarily, for each subtask, the subtask and the code execution instructions corresponding to the subtask are input into the intelligent agent, the code execution instructions are parsed based on the task prompt words, and the task action corresponding to the subtask is determined; the task action corresponding to the subtask is executed to determine the task execution result corresponding to the subtask.
[0066] In this step, the embodiment provided in this application requires that for each subtask, the code execution instructions of the subtask be parsed by the intelligent agent, and the above-mentioned intelligent agent generates the task action corresponding to the subtask, and then the intelligent agent executes the above-mentioned task action, and after execution, generates a task execution result and feeds it back to the large language model.
[0067] It should be noted that the task execution results in the embodiments provided in this application can be customized and used according to different code execution tasks. The task execution results in the embodiments provided in this application can specifically be code generation, directory generation or file retrieval.
[0068] S104: Input the task execution result into the large language model and dynamically adjust the task execution path until the code execution task is completed.
[0069] In this step, after the large language model in the embodiment provided in this application receives the task execution results fed back by the intelligent agent, the large language model will dynamically adjust the task execution path based on the fed-back execution results to ensure that the code execution task can be completed efficiently.
[0070] It can be understood that the embodiments provided in this application achieve an understanding of the code context based on the feedback execution results, and thus can more accurately determine and update the task execution path to achieve more precise execution of code execution tasks.
[0071] Exemplarily, the current task execution result corresponding to the current subtask is input into the large language model, and the next subtask in the task execution path is dynamically adjusted; it is determined whether all subtasks in the dynamically adjusted task execution path have been completed; if so, it is determined that the code execution task has been completed.
[0072] In the above, in the embodiment provided by the present application, after the current task execution result corresponding to the current subtask is input into the large language model, the large language model updates the next subtask in the execution path according to the current task execution result to ensure the smooth progress of the code execution task and determine the execution progress of the code execution task in real time.
[0073] After dynamically adjusting the next subtask in the task execution path, the embodiment provided in the present application will continue to determine whether all subtasks in the task execution path have been completed. If so, it means that the code execution task required by the above-mentioned user has been completed. At this time, the task execution results corresponding to each subtask will be integrated and sorted out to determine the target execution result corresponding to the code execution task.
[0074] Exemplarily, if there are unfinished subtasks in the dynamically adjusted task execution path, the unfinished subtasks are continued to be executed based on the dynamically adjusted task execution path.
[0075] In the above, when there is an unfinished subtask, the unfinished subtask and all subtasks after the unfinished subtask will continue to be executed according to the dynamically adjusted task execution path.
[0076] Illustratively, the embodiments provided in the present application may also determine the target execution result corresponding to the code execution task based on the task execution results corresponding to each subtask.
[0077] It can be understood that after determining that the code execution task is completed, the embodiment provided by this application will integrate and sort out the task execution results corresponding to all the above tasks, generate the task execution results corresponding to the task, achieve high automation and improve the quality of code generation.
[0078] An embodiment of the present application provides a method for executing code based on an intelligent agent. Compared with the prior art, the embodiment provided by the present application determines the code execution task and the task prompt word corresponding to the code execution task based on user needs, and inputs the code execution task and the task prompt word into a large language model. Then, code analysis and task decomposition are performed on the code execution task to determine the task execution path corresponding to the code execution task and the code execution instructions under the execution path. The task execution path and the code execution instructions are then input into the intelligent agent, and the intelligent agent is controlled to execute the corresponding task action according to the code execution instructions under the task execution path to determine the task execution result. Finally, the task execution result is input into the large language model, and the task execution path is dynamically adjusted until the code execution task is completed. The embodiment provided by the present application can dynamically adjust the task execution path based on the execution result, realize the combination of code and context, and thus meet the personalized needs of different projects. While improving flexibility, it reduces the tediousness of operation. In addition, by combining the large language model and the intelligent agent, the present application improves the execution efficiency, execution accuracy, execution quality and degree of automation of the code execution task, and reduces the development cost of the code execution task.
[0079] The embodiments provided in this application can perform multiple rounds of code execution in combination with the task execution results corresponding to multiple rounds of subtasks, thereby reducing the frequency of user interaction and operations, and thereby improving the user experience.
[0080] Figure 2 This is a structural block diagram of an agent-based code execution device provided in an embodiment of the present application. Figure 2 As shown, the agent-based code execution device 200 includes:
[0081] The first determining module 210 is configured to determine a code execution task and a task prompt word corresponding to the code execution task based on user needs.
[0082] The second determination module 220 is used to input the code execution task and the task prompt word into the large language model, perform code analysis and task decomposition on the code execution task, and determine the task execution path corresponding to the code execution task and the code execution instructions under the execution path.
[0083] The third determination module 230 is used to input the task execution path and code execution instructions into the intelligent agent, control the intelligent agent to execute the corresponding task action according to the code execution instructions under the task execution path, and determine the task execution result.
[0084] The execution module is configured to continue executing the unfinished subtask based on the dynamically adjusted task execution path if there is an unfinished subtask in the dynamically adjusted task execution path.
[0085] The fifth determining module 250 is configured to determine a target execution result corresponding to the code execution task based on the task execution results corresponding to each subtask.
[0086] Exemplarily, the task prompt words include task target prompt information, code execution rule prompt information, code termination condition, and code analysis calling tool prompt information. The second determining module 220 is specifically used to:
[0087] The code execution task and task prompt words are input into the large language model, the code execution task is decomposed according to the task target prompt information, and the task execution path corresponding to the code execution task is determined.
[0088] Each subtask in the task execution path is analyzed according to the code execution rule prompt information, the code termination condition prompt information and the code analysis calling tool prompt information to determine the code execution instructions corresponding to each subtask in the execution path.
[0089] Exemplarily, the third determining module 230 is specifically configured to:
[0090] For each subtask, the subtask and the corresponding code execution instructions are input into the intelligent agent, and the code execution instructions are parsed based on the task prompt words to determine the task action corresponding to the subtask.
[0091] Execute the task action corresponding to the subtask and determine the task execution result corresponding to the subtask.
[0092] Exemplarily, the fourth determining module 240 is specifically configured to:
[0093] The current task execution result corresponding to the current subtask is input into the large language model to dynamically adjust the next subtask in the task execution path.
[0094] Determine whether all subtasks in the dynamically adjusted task execution path have been completed;
[0095] If so, it is determined that the code execution task is completed.
[0096] Exemplarily, after determining whether all subtasks in the dynamically adjusted task execution path have been completed, the method further includes:
[0097] If there are unfinished subtasks in the dynamically adjusted task execution path, the unfinished subtasks will continue to be executed based on the dynamically adjusted task execution path.
[0098] Exemplarily, the code analysis calling tool prompt information includes code parsing tool prompt information and code completion tool prompt information. Each subtask in the task execution path is analyzed according to the code execution rule prompt information, the code termination condition prompt information, and the code analysis calling tool prompt information to determine the code execution instructions corresponding to each subtask in the execution path, including:
[0099] Each subtask in the task execution path is parsed according to the code execution rule prompt information, the code termination condition prompt information and the code parsing tool prompt information to determine the candidate code execution code corresponding to each subtask in the execution path.
[0100] The code completion tool is used to complete the execution code of each candidate code and determine the code execution instructions corresponding to each subtask in the execution path.
[0101] An embodiment of the present application provides an agent-based code execution device 200. Compared with the prior art, the embodiment provided by the present application determines the code execution task and the task prompt word corresponding to the code execution task based on user needs, and inputs the code execution task and the task prompt word into a large language model. Then, code analysis and task decomposition are performed on the code execution task to determine the task execution path corresponding to the code execution task and the code execution instructions under the execution path. The task execution path and the code execution instructions are then input into the agent, and the agent is controlled to execute the corresponding task action according to the code execution instructions under the task execution path to determine the task execution result. Finally, the task execution result is input into the large language model, and the task execution path is dynamically adjusted until the code execution task is completed. The embodiment provided by the present application can dynamically adjust the task execution path based on the execution result, realize the combination of code and context, and thus meet the personalized needs of different projects. While improving flexibility, it reduces the tediousness of operation. In addition, by combining the large language model and the agent, the present application improves the execution efficiency, execution accuracy, execution quality and degree of automation of the code execution task, and reduces the development cost of the code execution task.
[0102] The embodiments provided in this application can perform multiple rounds of code execution in combination with the task execution results corresponding to multiple rounds of subtasks, thereby reducing the frequency of user interaction and operations, and thereby improving the user experience.
[0103] See also Figure 3 , Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the electronic device 300 includes a processor 310 , a memory 320 , and a bus 330 .
[0104] The memory 320 stores machine-readable instructions executable by the processor 310. When the electronic device 300 is running, the processor 310 communicates with the memory 320 via the bus 330. When the machine-readable instructions are executed by the processor 310, the above-mentioned Figure 1 The specific implementation of the steps of the agent-based code execution method in the method embodiment shown can be found in the method embodiment and will not be repeated here.
[0105] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the computer program can execute the above-mentioned Figure 1 The specific implementation of the steps of the agent-based code execution method in the method embodiment shown can be found in the method embodiment and will not be repeated here.
[0106] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0107] It should be noted that, in the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0108] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-readable program code.
[0109] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0110] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0111] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0112] An embodiment of the present application also provides a computer program product, which includes computer software instructions. When the computer software instructions are run on a processing device, the processing device executes the process of the execution method of the agent-based code.
[0113] A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)).
[0114] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0115] In the several embodiments provided in this application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0116] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0117] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0118] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0119] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
[0120] Although the preferred embodiments of this specification have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of this specification.
[0121] Obviously, those skilled in the art may make various changes and modifications to this specification without departing from the spirit and scope of this specification. Thus, if such changes and modifications fall within the scope of the claims of this specification and their equivalents, this specification is intended to include such changes and modifications.
Claims
1. A method for executing code based on an agent, characterized in that: The agent-based code execution method includes: Determine a code execution task and a task prompt word corresponding to the code execution task based on user needs; Inputting the code execution task and the task prompt word into a large language model, performing code analysis and task decomposition on the code execution task, and determining a task execution path corresponding to the code execution task and code execution instructions under the execution path; Inputting the task execution path and the code execution instruction into the intelligent agent, controlling the intelligent agent to execute the corresponding task action according to the code execution instruction under the task execution path, and determining the task execution result; The task execution result is input into the large language model, and the task execution path is dynamically adjusted until the code execution task is completed.
2. The agent-based code execution method according to claim 1, wherein the task prompt word includes task target prompt information, code execution rule prompt information, code termination condition prompt information, and code analysis call tool prompt information; the code execution task and the task prompt word are input into a large language model, code analysis and task decomposition are performed on the code execution task, and the task execution path corresponding to the code execution task and the code execution instructions under the execution path are determined, including: Inputting the code execution task and the task prompt word into a large language model, performing task decomposition on the code execution task according to the task target prompt information, and determining a task execution path corresponding to the code execution task; Each subtask in the task execution path is subjected to code analysis according to the code execution rule prompt information, the code termination condition prompt information and the code analysis calling tool prompt information to determine the code execution instructions corresponding to each subtask in the execution path.
3. The agent-based code execution method according to claim 2, wherein inputting the task execution path and the code execution instruction into the agent, controlling the agent to perform the corresponding task action according to the code execution instruction under the task execution path, and determining the task execution result comprises: For each of the subtasks, the subtask and the code execution instruction corresponding to the subtask are input into the agent, the code execution instruction is parsed based on the task prompt word, and the task action corresponding to the subtask is determined; Execute the task action corresponding to the subtask and determine the task execution result corresponding to the subtask.
4. The agent-based code execution method according to claim 3, wherein inputting the task execution result into the large language model and dynamically adjusting the task execution path until the code execution task is completed comprises: Inputting the current task execution result corresponding to the current subtask into the large language model, and dynamically adjusting the next subtask in the task execution path; Determining whether all subtasks in the dynamically adjusted task execution path have been completed; If so, it is determined that the code execution task is completed.
5. The agent-based code execution method according to claim 4, further comprising: after determining whether all subtasks in the dynamically adjusted task execution path have been completed: If there are unfinished subtasks in the dynamically adjusted task execution path, the unfinished subtasks are continued to be executed based on the dynamically adjusted task execution path.
6. The agent-based code execution method according to claim 3, after inputting the task execution result into the large language model and dynamically adjusting the task execution path, the method further comprises: Based on the task execution results corresponding to each subtask, a target execution result corresponding to the code execution task is determined.
7. The agent-based code execution method according to claim 2, wherein the code analysis calling tool prompt information includes code parsing tool prompt information and code completion tool prompt information, and performing code analysis on each subtask in the task execution path according to the code execution rule prompt information, the code termination condition prompt information, and the code analysis calling tool prompt information to determine the code execution instructions corresponding to each subtask in the execution path, comprising: Performing code parsing on each subtask in the task execution path according to the code execution rule prompt information, the code termination condition prompt information, and the code parsing tool prompt information to determine a candidate code execution code corresponding to each subtask in the execution path; The candidate code execution codes are completed based on the code completion tool to determine the code execution instructions corresponding to the subtasks in the execution path.
8. An agent-based code execution device, characterized in that: The execution of the agent-based code includes: A first determining module is used to determine a code execution task and a task prompt word corresponding to the code execution task based on user needs; a second determination module, configured to input the code execution task and the task prompt word into a large language model, perform code analysis and task decomposition on the code execution task, and determine a task execution path corresponding to the code execution task and code execution instructions under the execution path; a third determining module, configured to input the task execution path and the code execution instruction into an agent, control the agent to execute a corresponding task action according to the code execution instruction under the task execution path, and determine a task execution result; A dynamic adjustment module is used to input the task execution result into the large language model and dynamically adjust the task execution path until the code execution task is completed.
9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and the machine-readable instructions are executed by the processor when running, as described in any one of claims 1-7 above, according to the steps of the agent-based code execution method.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, performs the steps of the agent-based code execution method according to any one of claims 1 to 7.
Citation Information
Cited By
API completion method fusing traditional deep learning and LLM
CN121300847A