Excel automatic implementation method and device based on intelligent agent and medium
Through an agent-based method, using a large language model to disassemble user needs and generate code, the flexibility and adaptability problems of Excel operation tasks in the prior art are solved, and complex Excel automation operations without programming knowledge are achieved.
Patent Information
- Application Number
- CN202510504617.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-08-08
AI Technical Summary
The prior art is difficult to flexibly complete Excel operation tasks according to user's needs descriptions. Especially under complex business needs, it is impossible to quickly adapt to Excel version updates and user needs changes, and users need to have certain programming knowledge.
Through an agent-based method, the user's demand description is broken down into several steps of execution plans using a large language model, the first code is generated, and the user's modification opinions are corrected into the second code, and the Excel file path and target data samples are combined to dynamically generate the code to meet user needs.
It realizes complex Excel operations without programming knowledge. The system can flexibly respond to various needs changes, improves the flexibility and adaptability of Excel automation, and ensures that the generated code accurately reflects user needs and preferences.
Smart Images

Figure CN120449844A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an Excel automation implementation method, device and medium based on an intelligent agent. Background Art
[0002] With the rapid advancement of information technology, the demand for data processing and automation has skyrocketed. Excel, a comprehensive and widely used spreadsheet tool, has played a vital role in numerous business areas, encompassing data analysis, report preparation, budget management, and more. However, for professionals without a programming background, automating complex Excel operations is not an easy task. In recent years, the rise of natural language processing (NLP) and robotic process automation (RPA) technologies has provided new solutions to this problem. Existing technologies typically combine natural language processing (NLP) with predefined rules or templates to parse user descriptions and convert them into corresponding Excel instructions.
[0003] However, existing Excel automation technologies require users to have certain programming knowledge and often rely on predefined rules or templates to parse user requirements and translate them into Excel commands. This makes it difficult to accurately understand and execute complex business requirements the first time. Furthermore, user requirements may change with Excel version updates and the introduction of new features. Existing technologies struggle to adapt quickly to these changes and fail to provide flexible solutions to meet user needs. With the maturity of large language models and the rise of intelligent agent applications, users can now automate Excel by simply describing their business requirements, without requiring software development skills. Large language models offer applications such as language understanding, text generation, and spelling and grammar checking. They can understand business requirements expressed in natural language and generate code. An AI agent (Artificial Intelligence Agent) is a computer program with autonomy, learning, and reasoning capabilities. The large model is the "brain" of the AI agent, providing knowledge and understanding, while the agent is the user and executor of this knowledge. The agent can "hands-on" acquire user business data and run the code generated by the large language model, automatically completing business operations based on the user's business requirement description. Summary of the Invention
[0004] The present invention provides an Excel automation implementation method, device and medium based on an intelligent agent, so as to solve the problem that it is difficult to flexibly complete Excel operation tasks according to user's requirement description.
[0005] To achieve the above objectives, the present application provides an agent-based Excel automation implementation method, comprising:
[0006] Obtain user requirement description and Excel file;
[0007] Decomposing the demand description into several execution plans according to the large language model to obtain a plan set; wherein the large language model controls the instructions through dynamic prompt words;
[0008] Generate a first code based on the Excel file path corresponding to the plan set and the target data sample in combination with the plan set;
[0009] The plan set is executed according to the first code, the first code is modified according to the user's modification opinions on the plan execution status to obtain a second code, and the plan set is executed on the Excel file according to the second code.
[0010] The present invention first obtains the user's demand description and Excel file, and then breaks down the demand description into several execution plans according to preset prompt words. This process is completely independent of any preset fixed format or template, helping to convert abstract and general requirements into specific and actionable steps, making subsequent code generation and execution more accurate and efficient. Based on the Excel file path and target data sample corresponding to the plan set obtained by the disassembly, the first code is generated in combination with the plan set itself. This means that the code is tailored to the user's actual needs, rather than relying on preset templates or rules. This dynamic code generation method greatly improves the flexibility and adaptability of the system. After the plan set is executed, the user's modification opinions on the plan execution are collected, and the first code is modified accordingly to obtain the second code. This process allows users to directly participate in the optimization of the code, ensuring that the final generated code can accurately reflect the user's needs and preferences. Moreover, as the task evolves and user needs change, the dynamic prompt words can be easily updated and adjusted, enabling the large language model to quickly adapt to new scenarios and requirements without requiring large-scale modification or retraining of the model itself, thereby providing a more efficient and accurate solution for tasks such as Excel automation.
[0011] Compared with the existing technology, the present invention can gradually approach the optimal solution through the process of disassembly, generation, execution and correction; even if the initial code may not fully meet the user's needs, after execution and correction, the final generated code will be closer and closer to the user's expected result. This gradual approximation method enables the system to flexibly respond to various complex and changing needs, thus solving the problem of difficulty in flexibly completing Excel operation tasks according to user demand descriptions.
[0012] As a preferred solution, the requirement description is decomposed into several execution plans based on the large language model to obtain a plan set, specifically:
[0013] selecting a first operation type that has the highest degree of matching with the requirement description from a set of optional operation types according to the large language model, and reading the requirement description according to preset software requirements; wherein the set of optional operation types is composed of a plurality of prompt words;
[0014] A plurality of execution plans are generated according to the first operation type and the software requirement to obtain the plan set.
[0015] The preferred solution's workflow doesn't simply rely on a pre-set, fixed-format Excel file. Instead, it first selects the first operation type that best matches the requirement description, allowing for flexible adaptation to different Excel file types and operation requirements. The resulting multi-step execution plan is also based on the specific requirement description and selected operation type, meaning the plan can be customized for each unique task, rather than following a fixed template or format.
[0016] As a preferred solution, according to the Excel file path corresponding to the plan set and the target data sample, the first code is generated in combination with the plan set, specifically:
[0017] Extracting the Excel file path and the target data sample from the requirement description;
[0018] According to the Excel file path and the target data sample, a first prompt word is dynamically generated in combination with the plan set and the existing plan code, and the large language model is called according to the first prompt word to generate the first code; wherein, the existing plan code is the code generated by the user in the previous plan.
[0019] By combining existing planned code, this preferred solution can efficiently utilize historical code resources and avoid rewriting code for the same or similar functions. Furthermore, since existing planned code is generated based on the user's previous needs and plans, combining this code can maintain consistency in coding style and naming conventions, helping to reduce maintenance and comprehension difficulties caused by inconsistent coding styles.
[0020] As a preferred solution, the Excel file path and the target data sample are extracted from the requirement description, specifically:
[0021] According to the large model, extract the Excel file path from the requirement description;
[0022] According to the Excel file path, read the first N rows of data of each worksheet in the Excel file to obtain a first data sample;
[0023] Determine the data location and data type in the Excel file according to the first data sample to obtain a second data sample;
[0024] The target data sample is composed of the first data sample and the second data sample.
[0025] This preferred solution automatically extracts Excel file paths from the requirements description using a large model, reducing the tediousness of manual input and improving efficiency. The target data sample, formed by combining the first and second data samples, contains both the actual data content and the data structure and type information, providing an accurate and reliable foundation for subsequent data processing.
[0026] As a preferred solution, the plan set is executed according to the first code, and the first code is modified according to the user's modification opinion on the plan execution status to obtain a second code, which is specifically:
[0027] According to the data calling method, in a fully automatic mode, the plan set is executed according to the first code, and if the execution of the plan set deviates from a preset normal standard, the plan set is switched to a semi-automatic mode;
[0028] In the semi-automatic mode, obtaining the user's modification opinions on the execution of the plan;
[0029] A second prompt word is dynamically generated according to the modification suggestion, and the large language model is called according to the second prompt word to correct the first code to obtain the second code.
[0030] In this preferred solution, when the execution of the plan deviates from the preset normal standards, the system can automatically switch to semi-automatic mode, allowing users to intervene and provide modification suggestions; this flexibility enables the system to adapt to changing needs and environments, improving the system's adaptability and robustness.
[0031] As a preferred solution, the data calling method is specifically as follows:
[0032] Store the file path and sample data required for each execution plan in the preset memory;
[0033] When executing the first plan, if no new file needs to be read or written, the corresponding data already in the preset memory is called to execute the first plan; wherein, the first plan is a plan that has not been executed, and the new file is a file that has not been read or written.
[0034] This preferred solution allows the system to directly access data stored in pre-set memory when the execution plan doesn't require reading or writing new files. This significantly reduces the need to frequently call large language models to repeatedly analyze Excel data, effectively reducing token usage, significantly shortening user wait times, and lowering overall system resource consumption. Furthermore, rather than loading all data into memory all at once, this process dynamically loads and releases data based on the execution plan's needs. This ensures fast data access while avoiding wasted memory resources and optimizing memory usage.
[0035] As a preferred solution, after obtaining the second code, the method further includes:
[0036] Dynamically generate review prompt words based on preset standards and the second code, call the large language model based on the review prompt words to perform a security review on the second code, and if the security review fails, regenerate the second code based on the large model;
[0037] Run the second code that has passed the review in a virtual environment; if an error occurs that a dependent library is missing, install the missing library in the virtual environment; if a code running error occurs, regenerate the second code according to the error information.
[0038] This preferred solution conducts a security review of the second code according to preset standards, which can effectively identify and eliminate potential security vulnerabilities and risks, ensuring that the code meets security requirements before deployment. If the security review fails, the code is regenerated based on the large model. This process can be repeated until the code that meets security standards is generated, thereby further improving the security of the code. The virtual environment is mainly used to provide an independent operating environment, so that different projects can have their own independent dependency packages and versions without interfering with each other. By installing missing dependency libraries and regenerating code based on error messages, it can ensure that the system can recover quickly when encountering problems, thereby enhancing the stability and reliability of the system.
[0039] The present application also provides an agent-based Excel automation implementation device, comprising an input module, a disassembly module, a code module, and an execution module;
[0040] The input module is used to obtain the user's demand description and Excel file;
[0041] The decomposition module is used to decompose the demand description into several execution plans according to the large language model to obtain a plan set; wherein the large language model performs instruction control through dynamic prompt words;
[0042] The code module is configured to generate a first code in combination with the plan set according to the Excel file path corresponding to the plan set and the target data sample;
[0043] The execution module is used to execute the plan set according to the first code, modify the first code according to the user's modification opinions on the plan execution status, obtain the second code, and execute the plan set on the Excel file according to the second code.
[0044] As a preferred solution, the disassembly module includes a reading unit and a planning unit;
[0045] The reading unit is configured to select a first operation type that has the highest degree of matching with the requirement description from a set of optional operation types according to the large language model, and read the requirement description according to the preset software requirements; wherein the set of optional operation types is composed of a plurality of prompt words;
[0046] The planning unit is used to generate a plurality of execution plans according to the first operation type and the software requirement to obtain the plan set.
[0047] As a preferred solution, the code module includes a sample unit and a code unit;
[0048] Wherein, the sample unit is used to extract the Excel file path and the target data sample from the requirement description;
[0049] The code unit is used to dynamically generate a first prompt word based on the Excel file path and the target data sample, in combination with the plan set and the existing plan code, and call the large language model to generate the first code based on the first prompt word; wherein the existing plan code is the code generated by the user in the previous plan.
[0050] As a preferred solution, the sample unit includes a path subunit, a data subunit, a type subunit and a combination subunit;
[0051] The path subunit is used to extract the Excel file path from the requirement description according to the large model;
[0052] The data subunit is configured to read the first N rows of data of each worksheet in the Excel file according to the Excel file path to obtain a first data sample;
[0053] The type subunit is configured to determine the data location and data type in the Excel file according to the first data sample to obtain a second data sample;
[0054] The combining subunit is configured to form the target data sample from the first data sample and the second data sample.
[0055] As a preferred solution, the execution module includes a switching unit, an opinion unit and a correction unit;
[0056] The switching unit is configured to execute the plan set according to the first code in a fully automatic mode according to the data calling method, and switch to a semi-automatic mode if the execution of the plan set deviates from a preset normal standard;
[0057] The opinion unit is used to obtain the user's modification opinion on the execution of the plan in the semi-automatic mode;
[0058] The correction unit is configured to dynamically generate a second prompt word according to the modification suggestion, and call the large language model to correct the first code according to the second prompt word to obtain the second code.
[0059] As a preferred solution, the data calling method is specifically as follows:
[0060] Store the file path and sample data required for each execution plan in the preset memory;
[0061] When executing the first plan, if no new file needs to be read or written, the corresponding data already in the preset memory is called to execute the first plan; wherein, the first plan is a plan that has not been executed, and the new file is a file that has not been read or written.
[0062] As a preferred solution, after obtaining the second code, the method further includes:
[0063] Dynamically generate review prompt words based on preset standards and the second code, call the large language model based on the review prompt words to perform a security review on the second code, and if the security review fails, regenerate the second code based on the large model;
[0064] Run the second code that has passed the review in a virtual environment; if an error occurs that a dependent library is missing, install the missing library in the virtual environment; if a code running error occurs, regenerate the second code according to the error information.
[0065] The present application also provides a storage medium on which a computer program is stored. The computer program is called and executed by a computer to implement the above-mentioned Excel automation implementation method based on an intelligent agent. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1This is a flow chart of an agent-based Excel automation implementation method provided in an embodiment of the present application;
[0067] Figure 2 This is the overall flow chart provided by the embodiment of the present application;
[0068] Figure 3 This is the overall architecture diagram provided by the embodiment of the present application;
[0069] Figure 4 It is a structural diagram of an Excel automation implementation device based on an intelligent agent provided in an embodiment of the present application. DETAILED DESCRIPTION
[0070] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0071] In the description of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. Therefore, features specified as "first" and "second" may explicitly or implicitly include one or more of such features. In the description of this application, unless otherwise specified, "several" means two or more.
[0072] The embodiment of the present application provides an agent-based Excel automation implementation method, which aims to lower the development threshold of Excel automation, allowing ordinary users to complete complex Excel automation operations only through natural language descriptions, thereby ensuring the accuracy and flexibility of tasks in complex business scenarios.
[0073] Example 1:
[0074] See also Figure 1 The embodiment of the present application provides an agent-based Excel automation implementation method, including S1 to S4. The specific implementation steps are as follows:
[0075] S1. Obtain the user's requirement description and Excel file.
[0076] Step S1 of the embodiment of the present application is specifically as follows:
[0077] The user's input requirement description and uploaded Excel file are obtained through the chat window; the requirement description is a natural language description, including but not limited to data query, data modification, file creation, format setting, data analysis, automated processing and other requirements for Excel files.
[0078] For example, the requirement description can be: From the "Data" sheet of the Assessment Statistics List_202410.xlsx, read the records whose "Group" contains the "Development Position" or "Test" keyword, retain only the "Name", "Group", and "Total Score" columns, and write the header fields and data results into the "Development Position" sheet.
[0079] S2. Decompose the demand description into several execution plans based on the large language model to obtain a plan set; the large language model controls instructions through dynamic prompt words.
[0080] Step S2 of the embodiment of the present application is specifically as follows:
[0081] Using a large language model, a first operation type with the highest matching degree with the requirement description is selected from a set of optional operation types, and the requirement description is read according to the preset software requirements; wherein the large language model controls the instructions through dynamic prompt words;
[0082] Generate several execution plans based on the first operation type and software requirements to obtain a plan set, and express each plan in the form of a dictionary. Each plan should contain the following elements:
[0083] ① "Plan" name: It must clearly and concisely summarize the core business operations performed by the plan, such as "Read Excel file contents."
[0084] ② “Operation” steps: This is a detailed list of operation details that must fully cover all steps and rules mentioned in the requirements without omission, for example: [“1. Verify whether the file exists”, “2. Read the data content line by line”].
[0085] ③ “Dependency” relationship: Indicates the execution results of other plans on which the implementation of this plan must be based. The data type is a list. If there is no dependency, fill in “[]”.
[0086] ④ "Operation type": You need to select the most suitable operation type from the "Optional operation type set".
[0087] Store the multiple execution plans within a plan set sequentially in a list. Finally, serialize the entire plan set into a standard JSON-formatted data. When developing JSON-formatted data, adhere to the principle of simplicity, including only the minimum necessary to meet requirements to ensure efficient and accurate execution. For example, the format of "JSON-formatted data" is: [{{"Plan 1":"XX","Operation":["XX","XX"],"Dependencies":[],"Operation Type":"1. Open a browser and enter a URL"}},{{"Plan 2":"YY","Operation":["YY","YY"],"Dependencies":["Plan 1"],"Operation Type":"4. Calculate data in memory"}}].
[0088] The optional operation type set consists of several prompt words, including:
[0089] ① Web page automation operations, including opening websites, clicking and filling in web pages, and downloading files.
[0090] ②Open the Excel file and read the data.
[0091] ③Open the IM client program, such as WeChat, QQ, or DingTalk.
[0092] ④Data is calculated in memory.
[0093] ⑤Others.
[0094] ⑥Create or open an Excel file, then write the data and save it.
[0095] The process in Example S2 doesn't simply rely on a pre-set, fixed-format Excel file. Instead, it first selects the first operation type that best matches the requirement description, allowing it to flexibly adapt to different Excel files and operation requirements. The generated multi-step execution plan is also based on the specific requirement description and the selected operation type. This means that the plan can be customized for each unique task, rather than following a fixed template or format. Furthermore, plan decomposition helps reduce the need for large models and improves execution speed.
[0096] S3. Generate a first code based on the Excel file path corresponding to the plan set and the target data sample in combination with the plan set.
[0097] Step S3 of the embodiment of the present application includes S3.1 to S3.2, specifically:
[0098] S3.1. According to the large model, the absolute path of the Excel file is extracted from the requirement description to obtain the Excel file path; if the Excel file path is not directly provided in the requirement description, the user is interacted with through the chat window to consult the user to obtain the accurate Excel file path.
[0099] According to the Excel file path, enable the preset Excel reading function (this function relies on the pandas library, which is an open source library for data analysis and manipulation in Python). This function will traverse each worksheet in the Excel file and extract the first N rows of data from each worksheet as analysis samples. By default, the value of N is 50; if the length of the read text data exceeds the preset safety threshold, a corresponding gradual reduction strategy is adopted: first, N is halved to 25 lines, and the text length is re-evaluated; if the length still exceeds the standard, the halving operation is continued until the length of the read text data meets the safety standard, thereby effectively preventing the large model processing overlimit problem caused by excessive data input, and obtaining the first data sample;
[0100] By analyzing the first data sample, determining the data location and data type in the Excel file, and obtaining a second data sample; wherein the data location includes the location (row number, column number) of the header field;
[0101] The target data sample is composed of the first data sample and the second data sample.
[0102] After dynamic data sampling, the accuracy of the Excel file path and target data sample is determined based on the big model and corrected so as to correctly understand the data location in the Excel file and meet user needs accurately and efficiently.
[0103] In this embodiment, S3.1 automatically extracts the Excel file path from the requirement description using a large model, reducing the tediousness of manual input and improving efficiency. The target data sample formed by combining the first data sample and the second data sample contains both the actual data content and the data structure and type information, providing an accurate and reliable foundation for subsequent data processing.
[0104] S3.2. Dynamically generate a first prompt word based on the Excel file path and target data sample, combined with the plan set and the existing plan code. Based on the first prompt word, call the large language model to generate a first code. The existing plan code is the code generated by the user for the previous plan. If it is Plan 1, the existing plan code is blank, and a code can be generated from scratch. The first code is Python code.
[0105] The following is an example of a large model prompt word (first prompt word) template, which is designed to allow the large model to answer as required (the variables wrapped in {} will be dynamically injected with actual data at runtime):
[0106] === ...
[0107] Data directory: {BusinessParameters.get('data directory',")}
[0108] File path: {business parameter ['file path']}
[0109] Sheet header row number dictionary: {business parameter ['sheet header row number dictionary']}
[0110] The sheet's most matching header: {business parameter ['sheet's most matching header_json']}
[0111] The data sample that best matches the sheet: {business parameter ['sheet best matching data sample_json']}
[0112] === ...
[0113] ========Plan: Code corresponding to {name of the previous plan} - Start ========
[0114] {Agent instance.Plan name_python code [name of the previous plan]}
[0115] =========Plan: {name of the previous plan} Corresponding code - End === ...
[0116] =========New software requirement description-start========
[0117] {str(single plan and step dictionary['operation'])}
[0118] Required file path: {file path}.
[0119] There are similar files in the {data directory} directory that need to be read (if the requirements are not specifically specified, hidden files, such as files with a ~ prefix, are ignored)
[0120] ==========New software requirement description-End=========
[0121] ====Special Notes-Beginning====
[0122] {User Feedback}
[0123] ====Special Notes-End====
[0124] Please modify the code in the executed plan based on the newly added software requirement description and known business parameters.
[0125] The new code output needs to include complete functions, including the existing code functions and the latest required functions. You cannot omit necessary existing code in order to keep the answer concise.
[0126] By combining existing planned code, this embodiment S3.2 can efficiently utilize historical code resources and avoid rewriting code for the same or similar functions. Furthermore, because the existing planned code is generated based on the user's previous needs and plans, combining this code can maintain consistency in coding style, naming conventions, and other aspects, helping to reduce maintenance and understanding difficulties caused by inconsistent coding styles.
[0127] S4. Execute the plan set according to the first code, modify the first code according to the user's modification suggestions on the plan execution status, obtain the second code, and execute the plan set on the Excel file according to the second code.
[0128] Step S4 of the embodiment of the present application includes S4.1 to S4.2, specifically:
[0129] S4.1. Execute the plan set according to the first code in fully automatic mode, based on the data call method. If the plan set's execution deviates from the preset normal standard, switch to semi-automatic mode and format the output results into user-friendly text for display in the chat window. "User-friendly text" refers to the use of structured typography in text presentation, with clearly defined subheadings, logical paragraph spacing, and visually guided indentation, to present the plan content in an orderly, user-friendly manner.
[0130] In semi-automatic mode, users' suggestions for modifying the plan execution status are obtained through the chat interface. For example, users may suggest that "date columns should be displayed in the standard year-month-day format."
[0131] A second prompt word is dynamically generated based on the modification suggestion, and the large language model is called based on the second prompt word to correct the first code to obtain the second code, and execute it until the user confirms that the plan is executed correctly; wherein the second code is Python code.
[0132] Among them, the data calling method is:
[0133] Store the file path and sample data required for each execution plan in the preset memory;
[0134] When executing the first plan, if no new file needs to be read or written, the corresponding data already in the preset memory is called to execute the first plan; wherein the first plan is a plan that has not been executed, and the new file is a file that has not been read or written.
[0135] The following is a detailed description of the fully automatic mode and semi-automatic mode:
[0136] ① Full-automatic / semi-automatic mode switching mechanism: When users are processing complex multi-step tasks, the full-automatic mode is activated by default; when it is detected that the planned execution path deviates from the preset normal standard, the semi-automatic mode can be immediately switched to intervene and adjust, and the full-automatic operation can be seamlessly restored after correction through manual instructions.
[0137] ② Step-by-step confirmation mechanism in semi-automatic mode: If in semi-automatic mode, when the demand is decomposed into multi-step plans, the user will be asked whether the results of the plan decomposition are appropriate; and after each sub-plan is executed, the result verification link is automatically triggered, requiring user confirmation, and the user is allowed to choose to re-execute the previous step plan.
[0138] ③ Dual fault tolerance strategy in fully automatic mode: In fully automatic mode, the maximum number of code iterations is set to three, and the retry threshold for a single sub-plan failure is limited to two. A circuit breaker mechanism is used to prevent resource overconsumption. If a sub-plan execution exception occurs, the system automatically falls back to the previous successful node and re-arranges the execution logic.
[0139] In this embodiment, S4.1, when the plan execution deviates from the preset normal standard, the system can automatically switch to semi-automatic mode, allowing the user to intervene and provide modification suggestions. This flexibility enables the system to adapt to changing needs and environments, improving the system's adaptability and robustness.
[0140] Furthermore, when the execution plan doesn't require reading or writing new files, the system can directly call data from pre-set memory. This significantly reduces the need to frequently call large language models to repeatedly analyze Excel data, effectively reducing token usage, significantly shortening user wait times, and lowering overall system resource consumption. Furthermore, this process doesn't load all data into memory all at once. Instead, data is dynamically loaded and released based on the execution plan's needs. This ensures fast data access while avoiding wasted memory resources and optimizing memory usage.
[0141] S4.2. Before running the code, dynamically generate review prompts based on preset standards and the second code. Based on the review prompts, invoke the macro model to perform a security review of the second code. For example, the code is checked for virus signatures, dead loops, or other characteristics that consume significant computer resources. If the security review fails, regenerate qualified second code based on the macro model. It should be noted that the macro model used in this security review is different from the macro model used to generate the code in this embodiment. A different macro model is used here to ensure the objectivity of the review results and to prevent the generated code from causing irreparable damage to the user's local system or implanting viruses.
[0142] Run the approved second code in a virtual environment; if a ModuleNotFoundError dependency library missing alarm is triggered, the missing dependency is automatically installed in the virtual environment through pip and re-executed; if the running process captures log information containing the "ERROR" or "WARNING" keywords, indicating a code execution error, the error information is automatically parsed and the second code is intelligently reconstructed (up to three iterative corrections are performed for each task to balance efficiency); among them, the virtual environment is built by the Python standard tool chain (venv / conda) and implements isolated management; ModuleNotFoundError is an error type in Python, indicating that the Python interpreter cannot find the specified module; pip is Python's package management tool for installing, managing and upgrading Python packages.
[0143] Export the revised second code and execute the plan set on the Excel file according to the revised second code.
[0144] In this embodiment, S4.2 performs a security review on the second code according to preset standards, which can effectively identify and eliminate potential security vulnerabilities and risks, ensuring that the code meets security requirements before deployment. If the security review fails, the code is regenerated based on the large model. This process can be repeated until code that meets security standards is generated, thereby further improving the security of the code. In order to ensure the stable operation of the solution proposed in this embodiment, a fixed Python environment needs to be configured. At the same time, in order to meet the Excel automation operation requirements submitted by the user each time, another Python environment needs to be prepared. This environment is dynamic and may require the installation of required dependency libraries based on actual conditions. Therefore, in order to avoid mutual interference between the two, this embodiment uses Python virtual environment technology to build independent operating environments for different projects. In this way, each project can have its own dependency package and version, ensuring that they do not interfere with each other and achieve efficient operation. By downloading and installing missing dependency libraries and regenerating code based on error messages, it can be ensured that the system can recover quickly when encountering problems, thereby enhancing the stability and reliability of the system.
[0145] To apply this application example, please refer to Figure 2-3 ;
[0146] Figure 2 This is the overall flow chart provided by the embodiment of the present application, which shows the approximate process of data processing in Example 1; specifically: first, parse the user's natural language input and convert it into an executable task plan. Then, according to the task type (such as file processing, web page automation, etc.), select the appropriate tool to read or operate the specified file. The Python code finally generated has dual-mode characteristics: it supports instant execution to complete a single task, and can be encapsulated as a standard function module, seamlessly integrated into the RPA (Robotic Process Automation) workflow to achieve long-term reuse, forming a sustainably expandable automation asset library.
[0147] Figure 3 This is the overall architecture diagram provided by the embodiment of the present application, showing the overall architecture of Example 1, including the user chat interface (client), websocket communication layer, process control layer (including toolbox, prompt word construction, Python virtual environment), large language model call layer, and large language model, specifically:
[0148] The interactive interface design is similar to that of instant messaging applications. The user chat interface (client) is presented in the form of a conversational window. The backend service is deployed on the user's local device and establishes a real-time two-way communication link with the front-end user chat interface through the WebSocket protocol of the WebSocket communication layer. The core architecture is divided into two major intelligent processing layers:
[0149] ① Process control layer: This is the core of building an intelligent process control center. Its core functions include: demand analysis and task splitting, multi-stage automated execution scheduling, intelligent switching of human-machine collaboration modes (fully automatic / semi-automatic), code generation and dynamic debugging, and cross-system resource coordination and management, realizing intelligent management and control of the entire Excel automation process;
[0150] ② Large language model call layer: This layer is used to create a modular large model access layer, achieve standardized adaptation of multiple AI interfaces, and establish a full-dimensional call monitoring system. This layer accurately records the complete conversation context (input parameters and output results) of each model interaction, computing resource consumption indicators (token usage, processing time), and supports multi-model comparative analysis and performance optimization, forming a traceable AI service call log.
[0151] The large language model refers to the large model used in this embodiment, such as GPT4, deepseekR1, Qwen72B-instruct and other large language model services. You can choose a large model on the Internet or a privately deployed large model.
[0152] Overall, this embodiment has the following beneficial effects:
[0153] The present invention first obtains the user's demand description and breaks it down into several execution plans according to preset prompt words. This process is completely independent of any preset fixed format or template, helping to convert abstract and general needs into specific and actionable steps, making subsequent code generation and execution more accurate and efficient. Based on the Excel file path and target data sample corresponding to the plan set obtained by the disassembly, the first code is generated in combination with the plan set itself. This means that the code is tailored to the user's actual needs, rather than relying on preset templates or rules. This dynamic code generation method greatly improves the flexibility and adaptability of the system. After the plan set is executed, the user's modification opinions on the plan execution status are collected, and the first code is modified accordingly to obtain the second code. This process allows the user to directly participate in the optimization of the code, ensuring that the final generated code can accurately reflect the user's needs and preferences. Moreover, as the task evolves and user needs change, the dynamic prompt words can be easily updated and adjusted, enabling the large language model to quickly adapt to new scenarios and requirements without requiring large-scale modification or retraining of the model itself, thereby providing a more efficient and accurate solution for tasks such as Excel automation.
[0154] In summary, this application greatly simplifies Excel automation processes, enabling ordinary users to automate complex data processing using only natural language. It also supports flexible switching between semi-automatic and fully automatic modes, ensuring accurate and efficient business operations. It also broadens the range of work modes, making it easy to meet complex business needs; achieves efficient local processing, freeing itself from cloud constraints; and produces independently running Python code that can be generated once and reused endlessly, breaking through the limitations of large model input tokens.
[0155] Example 2:
[0156] See also Figure 4 , an embodiment of the present application provides an Excel automation implementation device based on an intelligent agent, comprising an input module 10, a disassembly module 20, a code module 30 and an execution module 40;
[0157] The input module 10 is used to obtain the user's demand description and Excel file;
[0158] The decomposition module 20 is used to decompose the demand description into several execution plans according to the large language model to obtain a plan set; wherein the large language model performs instruction control through dynamic prompt words;
[0159] A code module 30 is configured to generate a first code based on the Excel file path corresponding to the plan set and the target data sample in combination with the plan set;
[0160] The execution module 40 is used to execute the plan set according to the first code, modify the first code according to the user's modification opinions on the plan execution status, obtain the second code, and execute the plan set on the Excel file according to the second code.
[0161] In one embodiment, the input module 10 is specifically:
[0162] The user's input requirement description and uploaded Excel file are obtained through the chat window; the requirement description is a natural language description, including but not limited to data query, data modification, file creation, format setting, data analysis, automated processing and other requirements for Excel files.
[0163] For example, the requirement description can be: From the "Data" sheet of the Assessment Statistics List_202410.xlsx, read the records whose "Group" contains the "Development Position" or "Test" keyword, retain only the "Name", "Group", and "Total Score" columns, and write the header fields and data results into the "Development Position" sheet.
[0164] In one embodiment, the disassembly module 20 includes a reading unit and a planning unit;
[0165] The reading unit is configured to use a large language model to select a first operation type that has the highest degree of matching with the requirement description from a set of optional operation types, and read the requirement description according to preset software requirements; wherein the large language model performs instruction control through dynamic prompt words;
[0166] The planning unit is used to generate several execution plans based on the first operation type and software requirements, obtain a plan set, and express each plan in the form of a dictionary. Each plan should contain the following elements:
[0167] ① "Plan" name: It must clearly and concisely summarize the core business operations performed by the plan, such as "Read Excel file contents."
[0168] ② “Operation” steps: This is a detailed list of operation details that must fully cover all steps and rules mentioned in the requirements without omission, for example: [“1. Verify whether the file exists”, “2. Read the data content line by line”].
[0169] ③ “Dependency” relationship: Indicates the execution results of other plans on which the implementation of this plan must be based. The data type is a list. If there is no dependency, fill in “[]”.
[0170] ④ "Operation type": You need to select the most suitable operation type from the "Optional operation type set".
[0171] Store the multiple execution plans within a plan set sequentially in a list. Finally, serialize the entire plan set into a standard JSON-formatted data. When developing JSON-formatted data, adhere to the principle of simplicity, including only the minimum necessary to meet requirements to ensure efficient and accurate execution. For example, the format of "JSON-formatted data" is: [{{"Plan 1":"XX","Operation":["XX","XX"],"Dependencies":[],"Operation Type":"1. Open a browser and enter a URL"}},{{"Plan 2":"YY","Operation":["YY","YY"],"Dependencies":["Plan 1"],"Operation Type":"4. Calculate data in memory"}}].
[0172] The optional operation type set consists of several prompt words, including:
[0173] ① Web page automation operations, including opening websites, clicking and filling in web pages, and downloading files.
[0174] ②Open the Excel file and read the data.
[0175] ③Open the IM client program, such as WeChat, QQ, or DingTalk.
[0176] ④Data is calculated in memory.
[0177] ⑤Others.
[0178] ⑥Create or open an Excel file, then write the data and save it.
[0179] The process of the decomposition module 20 in this embodiment does not simply rely on a pre-set, fixed-format Excel file. Instead, it first selects the first operation type that best matches the requirement description, allowing it to flexibly adapt to different types of Excel files and operation requirements. The generated multi-step execution plan is also based on the specific requirement description and the selected operation type, which means that the plan can be customized for each unique task rather than following a fixed template or format. Furthermore, plan decomposition helps reduce the need for large models and improves execution speed.
[0180] In one embodiment, the code module 30 includes a path subunit, a data subunit, a type subunit, a combination subunit, and a code unit, specifically:
[0181] Among them, the path sub-unit is used to extract the absolute path of the Excel file from the requirement description according to the large model to obtain the Excel file path; if the Excel file path is not directly provided in the requirement description, the chat window is used to interact with the user and consult the user to obtain the accurate Excel file path.
[0182] The data subunit is used to enable the preset Excel reading function according to the Excel file path (this function relies on the pandas library, which is an open source library for data analysis and manipulation in Python). This function will traverse each worksheet in the Excel file and extract the first N rows of data from each worksheet as analysis samples. By default, the value of N is 50; if the length of the read text data exceeds the preset safety threshold, a corresponding step-by-step reduction strategy is adopted: first, N is halved to 25 lines, and the text length is re-evaluated; if the length still exceeds the standard, the halving operation is continued until the length of the read text data meets the safety standard, thereby effectively preventing the large model processing overlimit problem caused by excessive data input, and obtaining the first data sample;
[0183] The type subunit is configured to determine the data location and data type in the Excel file by analyzing the first data sample, thereby obtaining a second data sample; wherein the data location includes the location (row number, column number) of the header field;
[0184] The combining subunit is configured to form a target data sample from the first data sample and the second data sample.
[0185] Combined with the sub-unit, it is also used to determine whether the Excel file path and target data sample are accurate and make corrections based on the large model after dynamic data sampling, so as to correctly understand the data location in the Excel file and meet user needs accurately and efficiently.
[0186] In this embodiment, the path subunit, data subunit, type subunit, and combination subunit automatically extract the Excel file path from the requirement description through a large model, reducing the tedious manual input and improving efficiency. The target data sample formed by combining the first data sample and the second data sample contains both the actual data content and the data structure and type information, providing an accurate and reliable foundation for subsequent data processing.
[0187] The code unit is used to dynamically generate a first prompt word based on the Excel file path and target data sample, combined with the plan set and the existing plan code, and call the large language model to generate a first code based on the first prompt word. The existing plan code is the code generated by the user in the previous plan. If it is plan 1, the existing plan code is empty and a code can be generated from scratch. The first code is Python code.
[0188] The following is an example of a large model prompt word (first prompt word) template, which is designed to allow the large model to answer as required (the variables wrapped in {} will be dynamically injected with actual data at runtime):
[0189] === ...
[0190] Data directory: {BusinessParameters.get('data directory',")}
[0191] File path: {business parameter ['file path']}
[0192] Sheet header row number dictionary: {business parameter ['sheet header row number dictionary']}
[0193] The sheet's most matching header: {business parameter ['sheet's most matching header_json']}
[0194] The data sample that best matches the sheet: {business parameter ['sheet best matching data sample_json']}
[0195] === ...
[0196] ========Plan: Code corresponding to {name of the previous plan} - Start ========
[0197] {Agent instance.Plan name_python code [name of the previous plan]}
[0198] =========Plan: {name of the previous plan} Corresponding code - End === ...
[0199] ==========New software requirement description-start=========
[0200] {str(single plan and step dictionary['operation'])}
[0201] Required file path: {file path}.
[0202] There are similar files in the {data directory} directory that need to be read (if the requirements are not specifically specified, hidden files, such as files with a ~ prefix, are ignored)
[0203] ==========New software requirement description-End=========
[0204] ====Special Notes-Beginning====
[0205] {User Feedback}
[0206] ====Special Notes-End====
[0207] Please modify the code in the executed plan based on the newly added software requirement description and known business parameters.
[0208] The new code output needs to include complete functions, including the existing code functions and the latest required functions. You cannot omit necessary existing code in order to keep the answer concise.
[0209] By combining existing planned code, the code unit of this embodiment can efficiently utilize historical code resources and avoid rewriting code for the same or similar functions. Furthermore, since the existing planned code is generated based on the user's previous needs and plans, combining this code can maintain consistency in coding style, naming conventions, and other aspects, helping to reduce maintenance and understanding difficulties caused by inconsistent coding styles.
[0210] In one embodiment, the execution module 40 includes a switching unit, an opinion unit, a correction unit, and a review unit, specifically:
[0211] The switching unit is configured to execute the plan set according to the first code in a fully automatic mode based on the data calling method. If the execution of the plan set deviates from a preset normal standard, the switching unit is configured to switch to a semi-automatic mode and format the output result into user-friendly text for display in the chat window. The "user-friendly text" refers to the use of structured typesetting in text presentation, with clearly hierarchical subheadings, logical paragraph spacing, and visually guided indentation, so that the content of each plan is presented in an orderly manner in a user-friendly reading manner.
[0212] The opinion unit is used to obtain user feedback on plan execution in a semi-automatic chat interface. For example, a user may suggest that the date column should be displayed in the standard format of year-month-day.
[0213] The correction unit is used to dynamically generate a second prompt word according to the modification suggestion, call the large language model according to the second prompt word to correct the first code, obtain the second code, and execute it until the user confirms that the plan is executed correctly; wherein the second code is Python code.
[0214] Among them, the data calling method is:
[0215] Store the file path and sample data required for each execution plan in the preset memory;
[0216] When executing the first plan, if no new file needs to be read or written, the corresponding data already in the preset memory is called to execute the first plan; wherein the first plan is a plan that has not been executed, and the new file is a file that has not been read or written.
[0217] The following is a detailed description of the fully automatic mode and semi-automatic mode:
[0218] ① Full-automatic / semi-automatic mode switching mechanism: When users are processing complex multi-step tasks, the full-automatic mode is activated by default; when it is detected that the planned execution path deviates from the preset normal standard, the semi-automatic mode can be immediately switched to intervene and adjust, and the full-automatic operation can be seamlessly restored after correction through manual instructions.
[0219] ② Step-by-step confirmation mechanism in semi-automatic mode: If in semi-automatic mode, when the demand is decomposed into multi-step plans, the user will be asked whether the results of the plan decomposition are appropriate; and after each sub-plan is executed, the result verification link is automatically triggered, requiring user confirmation, and the user is allowed to choose to re-execute the previous step plan.
[0220] ③ Dual fault tolerance strategy in fully automatic mode: In fully automatic mode, the maximum number of code iterations is set to three, and the retry threshold for a single sub-plan failure is limited to two. A circuit breaker mechanism is used to prevent resource overconsumption. If a sub-plan execution exception occurs, the system automatically falls back to the previous successful node and re-arranges the execution logic.
[0221] In the switching unit, suggestion unit, and correction unit of this embodiment, when the plan execution deviates from the preset normal standard, the system can automatically switch to semi-automatic mode, allowing users to intervene and provide modification suggestions. This flexibility enables the system to adapt to changing needs and environments, improving the system's adaptability and robustness.
[0222] Furthermore, when the execution plan doesn't require reading or writing new files, the system can directly call data from pre-set memory. This significantly reduces the need to frequently call large language models to repeatedly analyze Excel data, effectively reducing token usage, significantly shortening user wait times, and lowering overall system resource consumption. Furthermore, this process doesn't load all data into memory all at once. Instead, data is dynamically loaded and released based on the execution plan's needs. This ensures fast data access while avoiding wasted memory resources and optimizing memory usage.
[0223] The review unit is configured to dynamically generate review prompts based on preset standards and the second code before running the code, and to call the large model based on the review prompts to perform a security review on the second code, for example, to check whether the code has virus characteristics, whether the code has characteristics such as infinite loops that consume a large amount of computer resources, and if the security review fails, to regenerate qualified second code based on the large model. It should be noted that the large model used in the security review here is different from the large model used to generate the code in this embodiment. A different large model is used here to ensure the objectivity of the review results and to prevent the generated code from causing irreparable damage to the user's local system or implanting viruses.
[0224] The review unit is also used to run the second code that has passed the review in a virtual environment; if a ModuleNotFoundError dependency library missing alarm is triggered, the missing dependency is automatically installed in the virtual environment through pip and re-executed; if the running process captures log information containing the "ERROR" or "WARNING" keywords, indicating that a code execution error has occurred, the error information is automatically parsed and the second code is intelligently reconstructed (each task is performed up to three iterative corrections to balance efficiency); among them, the virtual environment is built by the Python standard tool chain (venv / conda) and implements isolated control; ModuleNotFoundError is an error type in Python, indicating that the Python interpreter cannot find the specified module; pip is Python's package management tool, used to install, manage and upgrade Python packages.
[0225] The review unit is further used to export the revised second code and execute the plan set on the Excel file according to the revised second code.
[0226] In this embodiment, the review unit performs a security review on the second code according to preset standards, which can effectively identify and eliminate potential security vulnerabilities and risks, ensuring that the code meets security requirements before deployment; if the security review fails, the code is regenerated based on the large model. This process can be repeated until the code that meets the security standards is generated, thereby further improving the security of the code. In order to ensure the stable operation of the solution proposed in this embodiment, a fixed Python environment needs to be configured; at the same time, in order to meet the Excel automation operation requirements submitted by the user each time, another Python environment needs to be prepared. This environment is dynamic and may require the installation of the required dependency libraries according to the actual situation; therefore, to avoid mutual interference between the two, this embodiment uses Python virtual environment technology to build independent operating environments for different projects; in this way, each project can have its own dependency package and version, ensuring that they do not interfere with each other and achieve efficient operation; by downloading and installing missing dependency libraries, and regenerating code based on error messages, it can be ensured that the system can recover quickly when encountering problems, thereby enhancing the stability and reliability of the system.
[0227] To apply this application example, please refer to Figure 2-3 ;
[0228] Figure 2This is the overall flow chart provided by the embodiment of the present application, which shows the approximate process of data processing in Example 2; specifically: first, parse the user's natural language input and convert it into an executable task plan. Then, according to the task type (such as file processing, web page automation, etc.), select the appropriate tool to read or operate the specified file. The Python code finally generated has dual-mode characteristics: it supports instant execution to complete a single task, and can be encapsulated as a standard function module, seamlessly integrated into the RPA (Robotic Process Automation) workflow for long-term reuse, and form a sustainably expandable automation asset library.
[0229] Figure 3 This is the overall architecture diagram provided by the embodiment of the present application, showing the overall architecture of Example 2, including the user chat interface (client), websocket communication layer, process control layer (including toolbox, prompt word construction, Python virtual environment), large language model call layer, and large language model. Specifically:
[0230] The interactive interface design is similar to that of instant messaging applications. The user chat interface (client) is presented in the form of a conversational window. The backend service is deployed on the user's local device and establishes a real-time two-way communication link with the front-end user chat interface through the WebSocket protocol of the WebSocket communication layer. The core architecture is divided into two major intelligent processing layers:
[0231] ① Process control layer: This is the core of building an intelligent process control center. Its core functions include: demand analysis and task splitting, multi-stage automated execution scheduling, intelligent switching of human-machine collaboration modes (fully automatic / semi-automatic), code generation and dynamic debugging, and cross-system resource coordination and management, realizing intelligent management and control of the entire Excel automation process;
[0232] ② Large language model call layer: This layer is used to create a modular large model access layer, achieve standardized adaptation of multiple AI interfaces, and establish a full-dimensional call monitoring system. This layer accurately records the complete conversation context (input parameters and output results) of each model interaction, computing resource consumption indicators (token usage, processing time), and supports multi-model comparative analysis and performance optimization, forming a traceable AI service call log.
[0233] The large language model refers to the large model used in this embodiment, such as GPT4, deepseekR1, Qwen72B-instruct and other large language model services. You can choose a large model on the Internet or a privately deployed large model.
[0234] Overall, this embodiment has the following beneficial effects:
[0235] The present invention first obtains the user's demand description and breaks it down into several execution plans according to preset prompt words. This process is completely independent of any preset fixed format or template, helping to convert abstract and general needs into specific and actionable steps, making subsequent code generation and execution more accurate and efficient. Based on the Excel file path and target data sample corresponding to the plan set obtained by the disassembly, the first code is generated in combination with the plan set itself. This means that the code is tailored to the user's actual needs, rather than relying on preset templates or rules. This dynamic code generation method greatly improves the flexibility and adaptability of the system. After the plan set is executed, the user's modification opinions on the plan execution status are collected, and the first code is modified accordingly to obtain the second code. This process allows the user to directly participate in the optimization of the code, ensuring that the final generated code can accurately reflect the user's needs and preferences. Moreover, as the task evolves and user needs change, the dynamic prompt words can be easily updated and adjusted, enabling the large language model to quickly adapt to new scenarios and requirements without requiring large-scale modification or retraining of the model itself, thereby providing a more efficient and accurate solution for tasks such as Excel automation.
[0236] In summary, this application greatly simplifies Excel automation processes, enabling ordinary users to automate complex data processing using only natural language. It also supports flexible switching between semi-automatic and fully automatic modes, ensuring accurate and efficient business operations. It also broadens the range of work modes, making it easy to meet complex business needs; achieves efficient local processing, freeing itself from cloud constraints; and produces independently running Python code that can be generated once and reused endlessly, breaking through the limitations of large model input tokens.
[0237] Example 3:
[0238] An embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the Excel automation implementation method based on an agent;
[0239] Wherein, the Excel automation implementation method based on the intelligent agent, if implemented in the form of a software functional unit and used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.
Claims
1. An agent-based Excel automation implementation method, characterized in that: include: Obtain user requirement description and Excel file; Decomposing the demand description into several execution plans according to the large language model to obtain a plan set; wherein the large language model controls the instructions through dynamic prompt words; Generate a first code based on the Excel file path corresponding to the plan set and the target data sample in combination with the plan set; The plan set is executed according to the first code, the first code is modified according to the user's modification opinions on the plan execution status to obtain a second code, and the plan set is executed on the Excel file according to the second code.
2. The Excel automation implementation method based on an agent according to claim 1, characterized in that: The requirement description is decomposed into several execution plans based on the large language model to obtain a plan set, specifically: selecting a first operation type that has the highest degree of matching with the requirement description from a set of optional operation types according to the large language model, and reading the requirement description according to preset software requirements; wherein the set of optional operation types is composed of a plurality of prompt words; A plurality of execution plans are generated according to the first operation type and the software requirement to obtain the plan set.
3. The Excel automation implementation method based on an agent as claimed in claim 1, characterized in that: According to the Excel file path and target data sample corresponding to the plan set, a first code is generated in combination with the plan set, specifically: Extracting the Excel file path and the target data sample from the requirement description; According to the Excel file path and the target data sample, a first prompt word is dynamically generated in combination with the plan set and the existing plan code, and the large language model is called according to the first prompt word to generate the first code; wherein, the existing plan code is the code generated by the user in the previous plan.
4. The Excel automation implementation method based on an agent as claimed in claim 3, characterized in that: Extract the Excel file path and the target data sample from the requirement description, specifically: According to the large model, extract the Excel file path from the requirement description; According to the Excel file path, read the first N rows of data of each worksheet in the Excel file to obtain a first data sample; Determine the data location and data type in the Excel file according to the first data sample to obtain a second data sample; The target data sample is composed of the first data sample and the second data sample.
5. The Excel automation implementation method based on agent according to claim 1, characterized in that: The plan set is executed according to the first code, and the first code is modified according to the user's modification opinion on the plan execution status to obtain a second code, which is specifically: According to the data calling method, in a fully automatic mode, the plan set is executed according to the first code, and if the execution of the plan set deviates from a preset normal standard, the plan set is switched to a semi-automatic mode; In the semi-automatic mode, obtaining the user's modification opinions on the execution of the plan; A second prompt word is dynamically generated according to the modification suggestion, and the large language model is called according to the second prompt word to correct the first code to obtain the second code.
6. The Excel automation implementation method based on an agent as claimed in claim 5, characterized in that: The data calling method is specifically as follows: Store the file path and sample data required for each execution plan in the preset memory; When executing the first plan, if no new file needs to be read or written, the corresponding data already in the preset memory is called to execute the first plan; wherein, the first plan is a plan that has not been executed, and the new file is a file that has not been read or written.
7. The Excel automation implementation method based on an agent as claimed in claim 1, characterized in that: After obtaining the second code, the method further includes: Dynamically generate review prompt words based on preset standards and the second code, call the large language model based on the review prompt words to perform a security review on the second code, and if the security review fails, regenerate the second code based on the large model; Run the second code that has passed the review in a virtual environment; if an error occurs that a dependent library is missing, install the missing library in the virtual environment; if a code running error occurs, regenerate the second code according to the error information.
8. An Excel automation implementation device based on an intelligent agent, characterized in that: Includes input module, disassembly module, code module and execution module; The input module is used to obtain the user's demand description and Excel file; The decomposition module is used to decompose the demand description into several execution plans according to the large language model to obtain a plan set; wherein the large language model performs instruction control through dynamic prompt words; The code module is configured to generate a first code in combination with the plan set according to the Excel file path corresponding to the plan set and the target data sample; The execution module is used to execute the plan set according to the first code, modify the first code according to the user's modification opinions on the plan execution status, obtain the second code, and execute the plan set on the Excel file according to the second code.
9. The Excel automation implementation device based on intelligent agent according to claim 8, characterized in that: The disassembly module includes a reading unit and a planning unit; The reading unit is configured to select a first operation type that has the highest degree of matching with the requirement description from a set of optional operation types according to the large language model, and read the requirement description according to the preset software requirements; wherein the set of optional operation types is composed of a plurality of prompt words; The planning unit is used to generate a plurality of execution plans according to the first operation type and the software requirement to obtain the plan set.
10. The Excel automation implementation device based on intelligent agent according to claim 8, characterized in that: The code module includes a sample unit and a code unit; Wherein, the sample unit is used to extract the Excel file path and the target data sample from the requirement description; The code unit is used to dynamically generate a first prompt word based on the Excel file path and the target data sample, in combination with the plan set and the existing plan code, and call the large language model to generate the first code based on the first prompt word; wherein the existing plan code is the code generated by the user in the previous plan.
11. The Excel automation implementation device based on intelligent agent according to claim 10, characterized in that: The sample unit includes a path subunit, a data subunit, a type subunit and a combination subunit; The path subunit is used to extract the Excel file path from the requirement description according to the large model; The data subunit is configured to read the first N rows of data of each worksheet in the Excel file according to the Excel file path to obtain a first data sample; The type subunit is configured to determine the data location and data type in the Excel file according to the first data sample to obtain a second data sample; The combining subunit is configured to form the target data sample from the first data sample and the second data sample.
12. The Excel automation implementation device based on intelligent agent according to claim 8, characterized in that: The execution module includes a switching unit, an opinion unit and a correction unit; The switching unit is configured to execute the plan set according to the first code in a fully automatic mode according to the data calling method, and switch to a semi-automatic mode if the execution of the plan set deviates from a preset normal standard; The opinion unit is used to obtain the user's modification opinion on the execution of the plan in the semi-automatic mode; The correction unit is configured to dynamically generate a second prompt word according to the modification suggestion, and call the large language model to correct the first code according to the second prompt word to obtain the second code.
13. The Excel automation implementation device based on intelligent agent according to claim 12, characterized in that: The data calling method is specifically as follows: Store the file path and sample data required for each execution plan in the preset memory; When executing the first plan, if no new file needs to be read or written, the corresponding data already in the preset memory is called to execute the first plan; wherein, the first plan is a plan that has not been executed, and the new file is a file that has not been read or written.
14. The Excel automation implementation device based on intelligent agent according to claim 8, characterized in that: After obtaining the second code, the method further includes: Dynamically generate review prompt words based on preset standards and the second code, call the large language model based on the review prompt words to perform a security review on the second code, and if the security review fails, regenerate the second code based on the large model; Run the second code that has passed the review in a virtual environment; if an error occurs that a dependent library is missing, install the missing library in the virtual environment; if a code running error occurs, regenerate the second code according to the error information.
15. A storage medium, characterized in that: The storage medium stores a computer program, which is called and executed by a computer to implement an agent-based Excel automation implementation method as described in any one of claims 1 to 7 above.
Citation Information
Cited By
Intelligent plug-in method and system based on large language model
CN120780297A