Document generation method and device, equipment, storage medium and program product

Automatically generate environment configuration documents through a large language model, solving the problem of automation of software development project environment configuration, realizing a stable and efficient environment configuration process, and avoiding the defects of manual configuration.

CN120429009AActive Publication Date: 2025-08-05LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202510847287.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-24
Publication Date
2025-08-05
Estimated Expiration
2045-06-24

AI Technical Summary

Technical Problem

In the prior art, the environment configuration process of software development projects is time-consuming and depends on manual modification, and cannot fully automate it, resulting in inefficient configuration and poor reliability, especially in complex projects that are prone to errors.

Method used

Use the large language model to generate environment configuration documents, obtain basic images, determine the configuration list and perform dependency conflict verification, generate and execute configuration commands, and combine basic images to generate mirror statements to achieve fully automated configuration.

Benefits of technology

It realizes fully automated configuration of the software development project environment, ensures the stability and reliability of the configuration process, avoids the tedious process of environmental damage and manual configuration, and improves configuration efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120429009A_ABST
    Figure CN120429009A_ABST
Patent Text Reader

Abstract

The invention discloses a document generation method and device, equipment, a storage medium and a program product, and relates to the technical field of computers, a large language model is applied to Dockerfile generation of environment configuration, the whole process of Dockerfile generation and environment configuration is realized by using language understanding and generation capabilities of the large language model, and the universality is very high. The basic mirror image is independently operated in the target environment, and configuration is performed in the target environment, so that the execution environment and the observation environment can be isolated, the configured environment is prevented from being damaged, and the stability and reliability of the configuration process are guaranteed. According to the method, the environment configuration document can be automatically generated based on the large language model, and the technical effect of fully automatically configuring the software development project environment can be achieved through the environment configuration document.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a document generation method, apparatus, device, storage medium, and program product. Background Art

[0002] Configuring the development environment is a crucial initial step in the software development process. The accuracy and efficiency of this configuration directly impact the subsequent code execution and testing. Configuring the environment is time-consuming and requires high developer skills.

[0003] Using an environment configuration document, or Dockerfile, as a template for configuring the environment can speed up configuration. However, in real-world applications, Dockerfiles cannot meet the personalized configuration requirements of software development projects. Developers still need to manually modify a large amount of content, and true automated configuration remains unattainable.

[0004] Therefore, for those skilled in the art, how to obtain an environment configuration document that can achieve fully automated configuration is a problem that they urgently need to solve. Summary of the Invention

[0005] The present application provides a document generation method, apparatus, device, storage medium and program product, which can generate an environment configuration document that can automatically configure the software development project environment.

[0006] This application provides a document generation method, including: Obtain the base image for the software development project and run it in the target environment; Use large language models to determine the configuration list of software development projects and verify dependency conflicts on the configuration list; If the conflict verification passes, the large language model is used to generate commands corresponding to the configuration list, and the commands are executed in the target environment to configure the software development project environment; When the configuration is complete and the configuration test passes, an image statement is generated by combining the base image and the executed commands. Use mirror statements to generate environment configuration documents that automatically configure the software development project environment.

[0007] The present application also provides a document generation device, comprising: The image running module is used to obtain the base image of the software development project and run the base image in the target environment; A configuration detection module is used to determine the configuration list of a software development project using a large language model and verify dependency conflicts on the configuration list; The image configuration module is used to generate commands corresponding to the configuration list using a large language model when conflict verification passes, and execute the commands in the target environment to configure the software development project environment; The image statement generation module is used to generate image statements by combining the base image and executed commands after the configuration is completed and the configuration test passes; The document generation module is used to generate environment configuration documents for automatically configuring the software development project environment using mirror statements.

[0008] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned document generation methods when executing the computer program.

[0009] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned document generation methods are implemented.

[0010] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned document generation methods when executed by a processor.

[0011] This application applies a large language model to Dockerfile generation for environment configuration. Leveraging the language understanding and generation capabilities of the large language model, this approach implements the entire Dockerfile generation and environment configuration process, offering strong versatility. By running a base image and performing configuration within the target environment, the execution and observation environments can be isolated, preventing corruption of the configured environment and ensuring the stability and reliability of the configuration process. The specific process for generating this environment configuration document involves first obtaining and running the base image of the software development project in the target environment. Using the large language model, the configuration list of the software development project can be obtained and verified for dependency conflicts. If the conflict verification passes, the large language model is used to generate commands corresponding to the configuration list and execute the commands in the target environment, thereby configuring the software development project environment in the target environment. Once the configuration is complete and the configuration test passes, an environment matching the software development project has been configured in the target environment. At this point, based on the executed commands during the configuration process and combined with the base image, image statements that automatically replicate the software development project environment can be generated. Based on these image statements, an environment configuration document capable of automatically configuring the software development project environment can be generated.

[0012] Therefore, the present application can automatically generate an environment configuration document based on a large language model, and the environment configuration document can achieve the technical effect of fully automated configuration of the software development project environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0014] Figure 1 A flowchart of a document generation method provided in an embodiment of the present application; Figure 2 A schematic diagram of the structure of a document generation device provided in an embodiment of the present application; Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application; Figure 4 A schematic diagram of the specific structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0015] The following will be combined with the accompanying 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 them. 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.

[0016] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.

[0017] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0018] In the software development process, environment configuration is a crucial initial step. The accuracy and efficiency of this configuration directly impact the subsequent execution and testing of the code. At the same time, environment configuration is a time-consuming task. As projects grow in size and complexity, the technology stacks involved become increasingly diverse, the dependencies become more complex, and environment configuration becomes increasingly difficult. For example, when working on deep learning projects, not only must the Python version be compatible with various deep learning frameworks (such as TensorFlow and PyTorch), but the correct installation and configuration of acceleration libraries such as CUDA (a core library for high-performance computing) and cuDNN (a deep neural network library) must also be considered. Problems in any of these steps can prevent the code from running properly. When faced with an unfamiliar code base, developers often need to spend a considerable amount of time and effort configuring the environment required to run and test the code.

[0019] Manual environment configuration is not only inefficient but also prone to errors. For example, manual configuration can lead to incomplete dependency installation or version mismatches due to developer oversight, resulting in unreliable configuration results. Furthermore, environment configuration requires a high level of developer skill and requires handling various configuration issues. Once problems arise during the configuration process, they are difficult to quickly locate and resolve.

[0020] With the advent of Docker (containers), environment configuration documents, or Dockerfiles, can be used as templates for environment configuration. For example, for Python projects, Dockerfiles pre-set a basic Python (a programming language) image version and provide a framework of instructions for installing common dependency libraries. This provides convenience, but when projects have unique dependency requirements or complex configuration steps, Dockerfiles struggle to meet individual needs. Developers still need to manually modify a large amount of content, making true automated configuration impossible.

[0021] The configuration steps of the Docker container environment can be divided into: 1. Build the image: Use Dockerfile to define the image content, and then build the image through the docker build command; 2. Run the container: Use the docker run command to start the container from the image. When the container is running, Docker will allocate an independent file system, network and process space for it. In order to achieve true automated configuration, this application provides a document generation method that can automatically generate an environment configuration document based on a large language model. The environment configuration document can realize fully automated configuration of the software development project environment. In other words, this application focuses on automatically generating a Dockerfile that matches the software development project. For details, please refer to Figure 1 , Figure 1This is a flow chart of a document generation method provided in an embodiment of the present application, which includes the following steps.

[0022] S101. Obtain a base image for a software development project and run the base image in a target environment.

[0023] Among them, the software development project can be any project that requires development environment configuration before development, such as deep learning projects, Python projects, etc.

[0024] The base image may be the latest base image corresponding to the mainstream language of the software development project.

[0025] The target environment can be specifically a sandbox environment based on a Docker container for actual environment configuration operations. In other words, the target environment is also an internal environment in which the base image is run and configured based on container technology.

[0026] S102: Determine a configuration list of the software development project using a large language model and perform dependency conflict verification on the configuration list.

[0027] Software development projects have a code repository (i.e., a code base). In this embodiment, a Large Language Model (LLM) can be used to identify objects to be installed and configured (such as dependent libraries and databases) based on the code repository information. These objects are then added to the configuration list for dependency conflict verification. Dependency conflict verification can also be performed using the LLM. For detailed instructions, please refer to relevant dependency conflict verification solutions and will not be detailed here.

[0028] Specifically, the large language model can be a large model that has been pre-trained and fine-tuned to achieve dependency library determination, dependency conflict verification, command generation, and sentence verification. Pre-training is defined as follows: The core of pre-training is to use a large-scale data set to perform preliminary training on the model so that the model can learn a common feature representation. Fine-tuning refers to conducting small-scale training on the basis of the pre-trained model for specific task objectives (downstream tasks, such as implementing dependency library determination, dependency conflict verification, command generation, and sentence verification) and task data (downstream data (such as data related to implementing dependency library determination, dependency conflict verification, command generation, and sentence verification)), to achieve minor adjustments to the pre-trained model parameters, and ultimately obtain a model adapted to specific tasks and data. For specific information on how to train a large language model, please refer to the training plan for the large language model, which will not be elaborated here.

[0029] In one embodiment of the present application, determining a configuration list for a software development project using a large language model includes: using the large language model to determine dependent libraries to be configured from the code base of the software development project; and adding the dependent libraries to the configuration list. In other words, the software development project can be used to view the code base of the software development project, determine the dependent libraries to be configured, and then add the dependent libraries to the configuration list.

[0030] For example, using a large language model, you can use commands in an external environment to view the directory structure and file contents of the code library, thereby determining the dependencies that need to be installed (such as dependent libraries) and adding the dependencies to the configuration list.

[0031] In a specific embodiment of the present application, when the conflict verification fails, the method includes: using a large language model to determine a reasonable and conflict-avoiding target version from multiple versions of the dependency library; downloading a new dependency library corresponding to the target version; and updating the configuration list using the new dependency library. That is, when a conflict is found in the dependency library, a reasonable and conflict-avoiding target version can be determined from multiple versions of the dependency library based on the large language model. Then, the target version is downloaded, and the configuration list is updated based on the downloaded new dependency library. In other words, in order to avoid dependency conflicts between third-party libraries installed first and later, in this embodiment, the third-party libraries to be downloaded and installed are first added to the configuration list. If there is no conflict between the third-party libraries in the configuration list, the installation is immediately carried out in order; if there is a conflict in the constraints of different third-party libraries, the large language model is used to determine a reasonable download version that avoids conflicts to update the configuration list. In this way, the dependency conflict problem can be solved and subsequent steps can be continued.

[0032] S103: When the conflict verification passes, the large language model is used to generate commands corresponding to the configuration list, and the commands are executed in the target environment to configure the software development project environment.

[0033] While ensuring that there are no conflicts between the dependencies in the configuration list, the large language model can be used to generate commands corresponding to the configuration list, and the target environment can execute the commands, thereby configuring the software development project environment in the target environment.

[0034] The commands may include all commands involved in installing and configuring the dependencies corresponding to the configuration list.

[0035] In a specific embodiment of the present application, a large language model is used to generate commands corresponding to a configuration list, and the commands are executed in a target environment to configure a software development project environment, including: obtaining executed actions in the target environment and feedback information corresponding to the executed actions; inputting the executed actions and feedback information into the large language model to obtain the currently executed specified action and the specified command corresponding to the specified action; and using the specified command to execute the specified action in the target environment.

[0036] In the process of generating commands using a large language model, the external environment can be responsible for recording event history in each round of interaction with the target environment, such as , where a is the executed command and o is the feedback information of the internal environment after the command is executed.

[0037] Based on this information, the large language model can generate the current action Among them, E t This is an ordered set of historical actions, representing the current state of the internal environment. It forms the basis for the action in step t, as it encompasses all records from step t-1 onward. After multiple rounds of action execution, the resulting set of tuples, Et, consisting of sequential commands and their execution results, is called a historical action sequence.

[0038] Through this iterative process, the large language model can obtain the current state of the internal environment in real time and make corresponding decisions through reasoning, that is, clarify the specified action to be performed at present, and generate the specified command corresponding to the specified action, so as to perform the specified action in the target environment with the help of the specified command.

[0039] The specified action may be a corresponding action required to perform environment configuration, such as viewing, installing, and modifying parameters.

[0040] In one specific embodiment of the present application, executing a command in a target environment to configure a software development project environment includes: determining whether the command will change the state of the target environment; if so, recording a current snapshot of the target environment, and then executing the command in the target environment; if the command fails, rolling back the target environment using the current snapshot. Specifically, in this embodiment, if the current command fails (i.e., returns a non-zero return code), a rollback mechanism is introduced to restore the environment to its previous state. Specifically, each time a command is executed, a "docker commit" command is used to snapshot the current state. After the command completes, the return code is checked. If the return code is non-zero, the current image is replaced with the most recently committed image (i.e., the image corresponding to the current snapshot). For commands that do not change the environment state (such as the cat command used to view file contents, merge files, or create new files), the rollback mechanism is not applied. That is, before generating the current image, it is necessary to verify whether the command will change the target environment. If so, the current image is generated; otherwise, no current image is generated.

[0041] In a specific implementation of the present application, it also includes: obtaining feedback information of the target environment; if the feedback information is that the target class used in the code does not exist in the base image, then re-obtaining the base image of the software development project. In the configuration process of the container environment, the first step is to select the base image. An error in the selection of the base image may be irreparable, and the environment configuration needs to be restarted based on a new base image. That is, when it is found that a base image does not meet the requirements, another base image can be replaced. Specifically, if the large language model finds that the currently selected base image is incorrect or unsuitable during the configuration process, the base image can be reselected. For example, when the large language model receives feedback from the internal environment that a class used in the code does not exist in the python version of the current base image, it will decide to reselect the base image. It should be noted that once a new image is selected, all previous configurations will be invalid, the executed commands will be cleared, and the configuration process will start again.

[0042] S104: When the configuration is completed and the configuration test passes, an image statement is generated by combining the base image and the executed commands.

[0043] After completing all configurations corresponding to the configuration list, you can perform a configuration test on the target environment. If the configuration test passes, you can combine the base image and the executed commands to generate an image statement for replicating the configuration of the software development project environment. The image statement is the Dockerfile statement.

[0044] In one embodiment of the present application, configuration testing includes running an entry program for the software development project within the target environment; if the entry program successfully runs, the configuration test is determined to have passed; if the entry program fails, the configuration test is determined to have failed. After the environment configuration is complete, the entry program in the code repository can be executed to test whether the current environment is successfully configured. If the test passes without error, the environment configuration is successful.

[0045] If the configuration test fails, the configuration process records (including the base image, dependent libraries, error messages, executed commands, and feedback information after the command) are fed back to the large language model; all configuration records are deleted; and the process returns to step S101 and reconfigures. In other words, after the configuration is completed, if it is found that the configuration fails, the error information can be fed back to the large language model, allowing the large language model to make further adjustments and iterate the environment configuration for a new round.

[0046] In a specific embodiment of the present application, a mirror statement is generated in combination with a base image and an executed command, including: generating a mirror creation statement with the base image as the mirror source; determining a successfully executed command from the executed commands; if the successfully executed command is a target command that changes the environment state, the target command is converted into a corresponding mirror configuration statement. Based on the base image as the mirror source, a mirror creation statement, i.e., a FROM statement, is generated. The latest image of the mainstream language of the project is used as the base image. For example, for a python project, python:latest is used as the base image, and then the statement is made in the dockerfile through the FROM instruction: FROM python:latest. Taking into account that in the actual process of configuring the software development project environment in the target environment, commands that fail to execute may be encountered, and these failed commands have no effect on the configuration environment. Therefore, when generating a mirror statement, the mirror configuration statement can be generated only based on the successfully executed command.

[0047] Determining a successfully executed command from the executed commands includes: obtaining a return code from the executed command; determining whether the executed command was successfully executed using the return code; and if so, determining the executed command as a successfully executed command. Specifically, if the return code is non-zero, it indicates that the execution failed; if the return code is zero, it indicates that the execution was successful.

[0048] In a specific embodiment of the present application, the target command is converted into a corresponding mirror configuration statement, including: if the directory corresponding to the target command when it is executed is not the root directory, a working directory setting statement is generated based on the directory corresponding to the target command when it is executed, and a corresponding mirror configuration statement is generated based on the target command; if the target command is a code editing command, the target command is executed to obtain the edited target script; a file addition statement is generated for adding the target script; if the target command is a variable for setting the target environment, the target command is converted into an environment variable setting statement; if the target command is a network port listening command, the target command is converted into an expose port statement; if the target command is an external file access command, the target command is converted into a create data volume statement.

[0049] The following provides examples of converting various successfully executed target commands.

[0050] Successful commands (those with a return code of 0) are preceded by "RUN" (RUN is used to install dependencies and compile code) to form a Dockerfile statement. Failed commands (those with a non-zero return code) are not included in the Dockerfile because the internal environment is rolled back. Furthermore, commands like "cat" that do not modify the current container state are not included in the Dockerfile.

[0051] For path switching during command execution, that is, if the directory when the command is executed is not the root directory, add the statement of "WORKDIR" (set working directory) command to switch to the corresponding directory to the Dockerfile before running the command.

[0052] If the base image changes during the environment construction process, you need to delete all previous configuration statements and import the new base image to generate it from scratch.

[0053] When a code editing command (such as sed) is encountered, the editing command is executed and the edited script is copied to the container through the "ADD" statement.

[0054] For environment variable setting operations performed in the internal environment, add them to the Dockerfile through the ENV instruction.

[0055] For the necessary network port listening commands executed in the internal environment, add them to the Dockerfile through the EXPOSE instruction.

[0056] For external file access commands executed in the internal environment, create a mount point or declare a volume for the container in the Dockerfile using the VOLUME instruction.

[0057] Please refer to Table 1 for an explanation of the relevant mirroring instructions: Table 1 is a comparison table of commonly used mirror instructions and their descriptions

[0058] The statement examples in Table 1 are for reference only.

[0059] S105. Generate an environment configuration document for automatically configuring the software development project environment using the mirror statement.

[0060] Specifically, by adding the corresponding image statements to the Dockerfile in the order of command execution, you can get an environment configuration document that automatically configures the software development project environment.

[0061] A Dockerfile is a text file that contains a series of instructions for creating a Docker image. It is the core of Docker image building, automating the image creation process by defining the basic environment, installing software, and configuring parameters.

[0062] In one specific embodiment of the present application, a mirror statement is used to generate an environment configuration document for automatically configuring a software development project environment. This includes: using a large language model to perform syntax checking on the mirror statement; after the check passes, using the mirror statement to generate the environment configuration document. In other words, after the mirror statement is generated, it can also be syntax checked using the large language model to ensure the accuracy of the mirror statement and the reliability of the environment configuration document generated using the mirror statement.

[0063] The document generation method provided in the embodiments of the present application applies a large language model to the generation of Dockerfiles for environment configuration. Leveraging the language understanding and generation capabilities of the large language model, the entire process of Dockerfile generation and environment configuration is implemented with high versatility. By running the base image separately in the target environment and performing configuration within it, the execution environment and observation environment can be isolated, preventing the configured environment from being corrupted and ensuring the stability and reliability of the configuration process. The specific process for generating the environment configuration document includes first obtaining and running the base image of the software development project in the target environment. Using the large language model, the configuration list of the software development project can be obtained and then verified for dependency conflicts. If the conflict verification is clear, the large language model is used to generate commands corresponding to the configuration list and the commands are executed in the target environment, thereby configuring the software development project environment in the target environment. When the configuration is complete and the configuration test passes, it indicates that an environment matching the software development project has been configured in the target environment. At this point, based on the executed commands during the configuration process and combined with the base image, image statements that can automatically replicate the software development project environment can be generated. Based on these image statements, an environment configuration document that can automatically configure the software development project environment can be generated.

[0064] Therefore, the present application can automatically generate an environment configuration document based on a large language model, and the environment configuration document can achieve the technical effect of fully automated configuration of the software development project environment.

[0065] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware.

[0066] To facilitate those skilled in the art to better implement the document generation method provided in the embodiment of the present application, the document generation method is described in detail below with reference to an actual application scenario as an example.

[0067] When actually applying the method provided in the embodiments of this application, it can be considered to consist of three parts: an internal environment, an external environment, and a configuration document generator. The external environment is a process. The internal environment (i.e., the target environment) is a container environment and an execution process. The configuration document generator is also a process.

[0068] Specifically, the Docker container corresponding to the internal environment is used to actually perform environment configuration operations. It uses the latest image of the project's mainstream language as the base image. For example, for Python projects, it uses python:latest as the base image, and runs external environment configuration commands in the base image.

[0069] The external environment (i.e., the external environment) assists in configuring the internal environment. The external environment is responsible for executing actions and obtaining information about the internal environment's execution results. During each interaction, the external environment also records the event history, including the actions executed by the LLM and the corresponding execution results. Furthermore, the external environment has a rollback mechanism. When a command in the internal environment fails, the environment is restored to its previous state, preventing corruption. This mechanism utilizes the "docker commit" command to create an environment snapshot, restoring the environment to its state before the command was executed. Meanwhile, the large language model resides in the external environment.

[0070] The configuration document generator is a program that converts successfully executed environment-building statements in the internal environment into statements recognized by the Dockerfile. For example, if the statement "rm –fr / home / aa.sh" was previously executed in the internal environment, the configuration document generator will convert it to "RUN rm –fr / home / aa.sh" and write it into the Dockerfile. Specifically, the configuration document generator begins its work when all configuration commands specified by the external environment have been successfully executed in the internal environment. Based on a set of pre-designed rules, it converts successfully executed commands in the internal environment into Dockerfile statements. It also uses a large language model to verify Dockerfile statements.

[0071] Among them, the statements executed in the internal environment are generated by the large language model reasoning and serve as the objects to be converted by the configuration environment generator; the large language model can help complete whether the syntax of the Dockerfile file generated by the configuration document generator meets the requirements, that is, whether there are any syntax errors.

[0072] In other words, the external environment first obtains the code repository information to be configured. The large language model then guides the internal environment through the external environment, gradually executing configuration commands. During this process, the external environment continuously records event history, including each executed command, execution results, and changes in environment status. Once all tests in the internal environment have successfully completed, the configuration file generator generates a runnable Dockerfile based on the recorded successful commands, following established rules and verification with the large language model.

[0073] The functions and effects of the three components mentioned above are described below.

[0074] The internal environment is a sandbox environment based on a Docker container, used for actual environment configuration operations. It is initialized with the latest base image corresponding to the project's mainstream language and the codebase for the required environment configuration. Using the Python base environment as an example, the internal environment supports the following four basic operations that can be performed in the external environment.

[0075] 1. Environment review. By executing commands such as "ls," "cat," and "pip list," the external environment can obtain the current status of the internal environment, including directory structure, file contents, and installed third-party library versions, providing a basis for subsequent configuration decisions. For example, use the "ls" command to view the code library directory structure and use "pip list" to view installed Python libraries.

[0076] 2. Dependency Installation. Responsible for installing third-party libraries required by the project repository, including installation using commands such as "pip install," "apt-get install," or "yum install." To avoid dependency conflicts between third-party libraries installed first and later, this patent proposes the following design: third-party libraries to be downloaded and installed are first added to a waiting list. If there are no conflicts in the third-party libraries in the waiting list, they are immediately installed and executed in order; if there are conflicting constraints between different third-party libraries, the large language model in the external environment is used to determine a reasonable download version to avoid conflicts.

[0077] 3. File Editing. When necessary, the internal environment will run the external environment to modify the configuration files in the internal environment, but the project files in the project path are prohibited. For example, if the correct execution of the project requires modifying the / etc / host configuration file, the internal environment will run the external environment to make the modification.

[0078] 4. Command execution. The internal environment allows the external environment to operate on it by executing bash commands, for example, by executing export PYTHONPATH= / home / src to set and modify environment variables. Furthermore, after the environment is configured, the internal environment allows the external environment to execute the code repository's entry point program to test whether the current environment is successfully configured. If the test passes without errors, the environment configuration is successful. If the test fails, the error information is fed back to the external environment's large language model for further adjustments and a new round of iterative environment configuration.

[0079] It should be noted that the internal environment and the external environment will exchange information, mainly including 1. The instructions generated by the large model in the external environment are transmitted to the internal environment; 2. The feedback information of the execution of the instructions in the internal environment is obtained by the external environment. For example, a communication service is started in both the internal and external environments, and the instructions generated by the large model in the external environment are transmitted to the internal environment by calling the communication service of the internal environment; the feedback information of the execution of the instructions in the internal environment calls the communication service of the external environment to transmit the feedback information to the external environment. For another example, the instructions generated by the large model in the external environment are written into a fixed file, and the internal environment periodically accesses the file to obtain the instructions to be executed; the feedback information after the instructions are executed in the internal environment is written into another fixed file, and the external environment periodically accesses the file or the feedback information of the execution of the instructions in the internal environment.

[0080] The external environment obtains feedback from the internal environment and performs actions to assist the internal environment in configuration. The basic operations that can be performed by the external environment include the following four categories.

[0081] 1. Record history, execute actions, and obtain feedback. In each round of interaction between the internal and external environments, the external environment is responsible for recording the event history. Based on this recorded event history, the large language model generates the current action. Through this iterative process, the large language model can obtain the current state of the internal environment in real time and make inferences to make appropriate decisions.

[0082] 2. Rollback mechanism. If the current command fails (i.e., returns a non-zero return code), a rollback mechanism is introduced to restore the environment to its previous state. Specifically, each time a command is executed, a snapshot of the current state is taken using the "docker commit" command. After the command completes, the return code is checked. If the return code is non-zero, the current image is replaced with the most recently committed image. However, for commands that generally do not change the environment (such as "cat"), the rollback mechanism is not applied.

[0083] 3. Change the base image. If the large language model discovers during configuration that the currently selected base image is incorrect or unsuitable, it can reselect a new base image. For example, if the large language model receives feedback from the internal environment that a class used in the code does not exist in the Python version of the current base image, it will decide to reselect the base image. Once a new image is selected, all previous configurations will be invalidated, executed commands will be cleared, and the configuration process will restart.

[0084] 4. Integration of input information into the large language model. In each interaction with the external environment, the internal environment generates output information (such as logs) after executing commands. This information is added to the event history and, through appropriate truncation, is fed into the large language model as prompts.

[0085] The configuration file generator starts working after the internal environment configuration is successfully completed and the project entry program is tested. The process of generating Dockerfile by the configuration file generator is as follows.

[0086] 1. First, convert the successfully executed commands in the internal environment into statements in the Dockerfile according to the rules, including but not limited to the generation of the following statements.

[0087] A. Use the latest image of the project's mainstream language as the base image. For example, for a Python project, use python:latest as the base image and declare it in the Dockerfile using the FROM instruction: FROM python:latest.

[0088] B. For successfully executed commands (i.e., commands with a return code of 0), "RUN" is added before them to form a Dockerfile statement. For failed commands (i.e., commands with a non-zero return code), these commands are not included in the Dockerfile because the internal environment is rolled back. Furthermore, commands such as "cat" that do not modify the current container state are not added to the Dockerfile.

[0089] C. For path switching during command execution, that is, if the directory when the command is executed is not the root directory, add a statement in the Dockerfile that switches the "WORKDIR" command to the corresponding directory before running the command.

[0090] D. If the base image changes during the environment construction process, you need to delete all previous configuration statements and import the new base image to generate it from scratch.

[0091] E. When encountering a code editing command (such as sed), the editing command is executed and the edited script is copied to the container through the "ADD" statement.

[0092] F. For the environment variable setting operations performed in the internal environment, add them to the Dockerfile through the ENV instruction.

[0093] G. For the necessary network port listening commands executed in the internal environment, add them to the Dockerfile through the EXPOSE instruction.

[0094] H. For external file access commands executed in the internal environment, create a mount point or declare a volume for the container in the Dockerfile using the VOLUME instruction.

[0095] 2. Secondly, after the Dockerfile statement is generated through rule generation, an external large language model is called to verify and correct the generated Dockerfile syntax.

[0096] If there is a Python project whose code base contains some basic functional functions and unit tests and depends on two third-party libraries, such as cv2 and matplotlib, the process of generating the corresponding Dockerfile for the Python project is as follows.

[0097] 1. By default, python:latest is selected as the base image and a Docker container is created in the internal environment.

[0098] 2. For large language models such as ChatGPT, the code library directory structure and file contents are viewed in the external environment using the "ls" and "cat" commands. The dependencies cv2 and matplotlib (a drawing library that can create various types of visual charts, such as line charts, scatter plots, and bar charts) that need to be installed are identified and added to the configuration waiting list of the external environment.

[0099] 3. The resident check process of the external environment checks the waiting list and confirms that there are no dependency conflicts between cv2 and matplotlib, confirming that the environment configuration can be started.

[0100] 4. Large language models such as ChatGPT generate environment configuration commands, such as `pip install cv2 matplotlib`. This command, used in the command line, uses `pip install cv2 matplotlib` to install two third-party libraries using the Python package management tool `pip`. `pip install` is a fixed command format used to install Python packages; `cv2` refers to the `OpenCV-Python` library. `cv2` is a common alias for this library in Python code. This library is primarily used for computer vision tasks such as image processing, video analysis, and object detection.

[0101] 5. Execute the pip install command in the internal environment. If a version conflict or other error occurs during execution, a rollback mechanism will be activated, restoring the environment to its pre-installation state. Repeat step 5 until the execution completes successfully. During this repetition, large language models such as ChatGPT will also receive error messages indicating version conflicts or other errors, which they use to analyze and update generated configuration commands.

[0102] 6. After installation is complete, the project entry program runs in the internal environment. If the test passes, indicating successful environment configuration, the Dockerfile generator based on the large language model begins its work. It converts successfully executed commands into Dockerfile statements according to the rules, generating a runnable Dockerfile. This includes the base image, dependency installation commands, file copying and command execution related to code editing, and setting relevant environment variables.

[0103] 7. If the test fails, the large language model makes further configuration adjustments based on the error message, which may involve reselecting the base image, checking dependency versions, updating dependency versions, or further modifying the code until the test passes.

[0104] 8. Reconfigure the internal environment based on the Dockerfile to complete the configuration.

[0105] Automated configuration based on LLM. Unlike existing technologies that rely on manual configuration, this application applies large language models to the generation of Dockerfiles for environment configuration. Leveraging the language understanding and generation capabilities of LLMs, this approach implements the entire process of Dockerfile generation and environment configuration, and is highly versatile.

[0106] The execution and observation environments are isolated. The internal environment serves as the actual configured Docker container, and the external environment retrieves the internal environment's configuration status to configure the internal environment. This solution effectively isolates the impact of configuration errors, prevents environmental damage, and ensures the stability and reliability of the configuration process.

[0107] Environment configuration rollback: The rollback mechanism of the present invention can quickly restore the environment when a command fails to execute, avoiding environmental damage and ensuring that the environment is always in a correct and controllable state.

[0108] In other words, the method provided by the embodiments of this application can solve the problems of low efficiency, poor reliability, and excessive developer requirements during the environment configuration process. Through the interaction between the internal and external environments, the environment configuration of the common code repository is automated, avoiding the tedious process of manual configuration. At the same time, it ensures that the generated Dockerfile accurately reflects the configuration process, avoiding environmental damage caused by command execution failure during the environment configuration process.

[0109] Please refer to Figure 2 , an embodiment of the present application further provides a document generation device, the device comprising: The image running module 101 is used to obtain the base image of the software development project and run the base image in the target environment; A configuration detection module 102 is configured to determine a configuration list of a software development project using a large language model and perform dependency conflict verification on the configuration list; The image configuration module 103 is used to generate commands corresponding to the configuration list using the large language model when the conflict verification passes, and execute the commands in the target environment to configure the software development project environment; The image statement generation module 104 is used to generate an image statement by combining the base image and the executed command when the configuration is completed and the configuration test passes; The document generation module 105 is used to generate an environment configuration document for automatically configuring the software development project environment using the mirror statement.

[0110] By applying the apparatus provided in the embodiments of the present application, a large language model is applied to Dockerfile generation for environment configuration. Leveraging the language understanding and generation capabilities of the large language model, the entire process of Dockerfile generation and environment configuration is implemented with high versatility. By running the base image separately in the target environment and performing configuration within it, the execution environment and observation environment can be isolated, preventing the configured environment from being corrupted and ensuring the stability and reliability of the configuration process. The specific process for generating the environment configuration document includes first obtaining and running the base image of the software development project in the target environment. Using the large language model, the configuration list of the software development project can be obtained and then verified for dependency conflicts. If the conflict verification passes, the large language model is used to generate commands corresponding to the configuration list and the commands are executed in the target environment, thereby configuring the software development project environment in the target environment. When the configuration is complete and the configuration test passes, it indicates that an environment matching the software development project has been configured in the target environment. At this point, based on the executed commands during the configuration process and combined with the base image, image statements that can automatically replicate the software development project environment can be generated. Based on these image statements, an environment configuration document that can automatically configure the software development project environment can be generated.

[0111] Therefore, the present application can automatically generate an environment configuration document based on a large language model, and the environment configuration document can achieve the technical effect of fully automated configuration of the software development project environment.

[0112] In a specific embodiment of the present application, the mirror configuration module is specifically used to determine whether a command will change the state of the target environment; if so, after recording the current snapshot of the target environment, the command is executed in the target environment; if the command execution fails, the target environment is rolled back using the current snapshot.

[0113] In a specific implementation of the present application, it further includes: a reset module for obtaining feedback information of the target environment; if the feedback information indicates that the target class used in the code does not exist in the base image, the base image of the software development project is re-obtained.

[0114] In a specific implementation of the present application, the configuration detection module is specifically used to use a large language model to determine the dependent library to be configured from the code library of the software development project; and add the dependent library to the configuration list.

[0115] In a specific embodiment of the present application, a configuration detection module is specifically used to use a large language model to determine a reasonable and conflict-free target version from multiple versions of a dependency library; download a new dependency library corresponding to the target version; and update the configuration list using the new dependency library.

[0116] In a specific implementation of the present application, the document generation module is specifically configured to perform grammatical detection on the mirror sentence using a large language model; after the detection passes, the mirror sentence is used to generate an environment configuration document.

[0117] In a specific embodiment of the present application, a configuration test module is used to run an entry program of a software development project in a target environment; if the entry program runs successfully, it is determined that the configuration test has passed; if the entry program fails to run, it is determined that the configuration test has failed.

[0118] In a specific embodiment of the present application, the mirror configuration module is specifically used to obtain the executed actions in the target environment and the feedback information corresponding to the executed actions; input the executed actions and feedback information into the large language model to obtain the specified action to be executed and the specified command corresponding to the specified action; and use the specified command to execute the specified action in the target environment.

[0119] In a specific embodiment of the present application, the image statement generation module is specifically used to generate an image creation statement with a base image as the image source; determine a successfully executed command from the executed commands; if the successfully executed command is a target command that changes the environment state, the target command is converted into a corresponding image configuration statement.

[0120] In a specific embodiment of the present application, the mirror statement generation module is specifically used to generate a working directory setting statement based on the directory corresponding to the target command when the target command is executed, and generate a corresponding mirror configuration statement based on the target command if the directory corresponding to the target command when the target command is executed is not the root directory; if the target command is an editing code command, the target command is executed to obtain the edited target script; a file addition statement for adding the target script is generated; if the target command is a variable for setting the target environment, the target command is converted into an environment variable setting statement; if the target command is a network port listening command, the target command is converted into an expose port statement; if the target command is an external file access command, the target command is converted into a create data volume statement.

[0121] In a specific embodiment of the present application, the mirror statement generation module is specifically used to obtain the return code of the executed command; use the return code to determine whether the executed command is successfully executed; if so, determine the executed command as a successfully executed command.

[0122] For the description of the features in the embodiment corresponding to the document generation device, please refer to the relevant description of the embodiment corresponding to the document generation method, and no further details will be given here.

[0123] Corresponding to the above method embodiment, an embodiment of the present application further provides an electronic device. The electronic device described below and the document generation method described above can refer to each other.

[0124] See also Figure 3 As shown, the electronic device includes: a memory 332 for storing computer programs; a processor 322 for implementing the steps of the document generation method of the above method embodiment when executing the computer program.

[0125] For details, please refer to Figure 4 , Figure 4 This is a schematic diagram of the specific structure of an electronic device provided in this embodiment. This electronic device may vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) (for example, one or more processors) and memory 332. The memory 332 stores one or more computer programs 342 or data 344. The memory 332 may be temporary storage or permanent storage. The program stored in the memory 332 may include one or more modules (not shown), each of which may include a series of instruction operations in the data processing device. Furthermore, the processor 322 may be configured to communicate with the memory 332 to execute the series of instruction operations in the memory 332 on the electronic device 301.

[0126] The electronic device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input / output interfaces 358 , and / or one or more operating systems 341 .

[0127] The steps in the document generation method described above can be implemented by the structure of an electronic device.

[0128] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any of the above document generation method embodiments when run.

[0129] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0130] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above document generation method embodiments are implemented.

[0131] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned document generation method embodiments are implemented.

[0132] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0133] The technical solution provided by the present application is described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only intended to help understand the method and core ideas of the present application. It should be noted that, for those skilled in the art, without departing from the principles of the present application, several improvements and modifications may be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.

Claims

1. A document generation method, characterized in that: include: Obtain a base image for the software development project and run the base image in the target environment; Determining a configuration list of the software development project using a large language model and performing dependency conflict verification on the configuration list; If the conflict verification passes, generating commands corresponding to the configuration list using the large language model, and executing the commands in the target environment to configure the software development project environment; When the configuration is completed and the configuration test passes, an image statement is generated by combining the base image and the executed commands; The mirror statement is used to generate an environment configuration document for automatically configuring the software development project environment.

2. The document generation method according to claim 1, wherein: Executing the command in the target environment to configure the software development project environment includes: Determining whether the command will change the state of the target environment; If yes, after recording the current snapshot of the target environment, executing the command in the target environment; If the command execution fails, the target environment is rolled back using the current snapshot.

3. The document generation method according to claim 1, wherein: Also includes: Obtaining feedback information of the target environment; If the feedback information indicates that the target class used in the code does not exist in the base image, the base image of the software development project is re-obtained.

4. The document generation method according to claim 1, wherein: A configuration list of the software development project is determined using a large language model, including: Determining a dependent library to be configured from a code base of the software development project using the large language model; Add the dependent library to the configuration list.

5. The document generation method according to claim 4, characterized in that: Conflict verification fails in the following cases: Determine a reasonable and conflict-free target version from multiple versions of the dependent library using the large language model; Download the new dependency library corresponding to the target version; The configuration list is updated using the new dependency library.

6. The document generation method according to claim 1, wherein: Using the mirror statement, an environment configuration document for automatically configuring the software development project environment is generated, including: Performing grammar detection on the mirror sentence using the large language model; After the detection is passed, the environment configuration document is generated using the mirror statement.

7. The document generation method according to claim 1, wherein: Configuration testing, including: Running an entry program of the software development project in the target environment; If the entry program runs successfully, it is determined that the configuration test has passed; If the entry program fails to run, it is determined that the configuration test has failed.

8. The document generation method according to claim 1, wherein: Generating commands corresponding to the configuration list using the large language model, and executing the commands in the target environment to configure the software development project environment, including: Obtaining the executed actions in the target environment and feedback information corresponding to the executed actions; Inputting the executed action and the feedback information into the large language model to obtain a designated action to be executed and a designated command corresponding to the designated action; The specified action is executed in the target environment using the specified command.

9. The document generation method according to any one of claims 1 to 8, characterized in that: Combining the base image and the executed command to generate an image statement includes: Generate an image creation statement with the base image as the image source; Determining a successfully executed command from among the executed commands; If the successfully executed command is a target command for changing the environment state, the target command is converted into a corresponding mirror configuration statement.

10. The document generation method according to claim 9, characterized in that: Convert the target command into a corresponding image configuration statement, including: If the directory corresponding to the target command when it is executed is not the root directory, then generating a working directory setting statement based on the directory corresponding to the target command when it is executed, and generating a corresponding mirror configuration statement based on the target command; If the target command is an edit code command, executing the target command to obtain an edited target script; Generate a file addition statement for adding the target script; If the target command is to set a variable of the target environment, converting the target command into an environment variable setting statement; If the target command is a network port listening command, convert the target command into an expose port statement; If the target command is an external file access command, the target command is converted into a create data volume statement.

11. The document generation method according to claim 9, wherein: Determine the successful execution of commands from the executed commands, including: Obtaining the return code of the executed command; Determining whether the executed command was successfully executed using the return code; If yes, the executed command is determined as the successfully executed command.

12. A document generation device, characterized in that: include: An image running module is used to obtain a base image for a software development project and run the base image in a target environment; a configuration detection module, configured to determine a configuration list of the software development project using a large language model and perform dependency conflict verification on the configuration list; a mirror configuration module, configured to generate commands corresponding to the configuration list using the large language model when conflict verification passes, and execute the commands in the target environment to configure the software development project environment; An image statement generation module is used to generate an image statement by combining the base image and the executed command when the configuration is completed and the configuration test passes; The document generation module is used to generate an environment configuration document for automatically configuring the software development project environment using the mirror statement.

13. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the document generation method according to any one of claims 1 to 11 when executing the computer program.

14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the document generation method according to any one of claims 1 to 11.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the document generation method according to any one of claims 1 to 11 are implemented.

Citation Information

Patent Citations

  • Method for realizing cross compiling of Docker mirror image

    CN111309451A

  • Mirror image construction method, system and device and medium

    CN112363803A

  • Custom model publishing method and device, equipment and medium

    CN115599401A

  • Algorithm environment mirror image construction method and system based on automatic command line generation

    CN117348972A

  • Model operation environment determination method and device, storage medium and electronic equipment

    CN118227212A