Code running environment construction method and system and related device
By analyzing the code repository to generate environment build files and test instructions using a large language model, the problem of incompatibility between the code runtime environment and the code repository is solved, achieving efficient and automated code runtime environment construction, which is suitable for a variety of projects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- IFLYTEK CO LTD
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-17
AI Technical Summary
Existing technologies have limitations in building code runtime environments, such as incompatibility between the runtime environment and the code repository, insufficient automation and adaptability, and limitations in handling complex dependencies and cross-language environment building.
By analyzing code repositories using large language models, environment build files and test instructions are generated. By building and testing the code runtime environment, an adapted code runtime environment is automatically generated.
It improves the efficiency and adaptability of automated code runtime environment building, can understand multiple programming languages and project structures, is suitable for various projects, and reduces computing resource consumption and build time.
Smart Images

Figure CN121879839A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer software technology, and in particular to a method, system and related apparatus for constructing a code runtime environment. Background Technology
[0002] In recent years, code repositories on open source platforms such as GitHub (a code repository contains the source code files of a project and related files for building, running, and testing the source code) have experienced explosive growth, and the massive number of code repositories has provided an unprecedented scale of data for training large models.
[0003] However, the current research paradigm for large-scale models has evolved from traditional static code analysis to dynamic code execution. Large-scale models' operations on code repositories are no longer limited to reading and writing, but have expanded to include running, debugging, and modifying. This technological evolution makes the code runtime environment a rigid infrastructure requirement for large-scale model research. Therefore, how to build a code runtime environment for code repositories is a problem that urgently needs to be solved. Summary of the Invention
[0004] In view of this, this application provides a method, system, and related apparatus for building a code runtime environment for a code repository, and the technical solution is as follows:
[0005] The first aspect of this application provides a method for building a code runtime environment, including:
[0006] Using a large language model, the code repository of the target project is analyzed to obtain information related to the construction of the code runtime environment. Based on the obtained information, the environment build file and environment test instructions of the target project are generated. The environment build file defines the construction process of the code runtime environment.
[0007] Based on the environment build file, construct the code execution environment;
[0008] If the code execution environment is successfully built, the code execution environment is tested by executing the environment test instructions within the code execution environment;
[0009] If the code execution environment passes the test, then the code execution environment is determined to be the target code execution environment corresponding to the code repository of the target project.
[0010] In one possible implementation, the use of a large language model involves analyzing the target project's code repository to obtain information related to the construction of the code runtime environment, including:
[0011] Obtain file directory information and project description file from the target project's code repository, wherein the project description file contains information related to the construction of the code runtime environment;
[0012] Using a large language model, based on the file directory information and the project description file, information related to the construction of the code runtime environment is collected from the code repository of the target project until the existing information is complete. The information related to the construction of the code runtime environment in the project description file and the collected information are taken as the final information related to the construction of the code runtime environment.
[0013] In one possible implementation, the use of a large language model, based on the file directory information and the project documentation, involves collecting information related to the code runtime environment setup from the target project's code repository, including:
[0014] Obtain tool descriptions for the toolset;
[0015] Using a large language model, based on the file directory information, the project documentation, and the tool description information of the toolset, the tools in the toolset are invoked to collect information related to the construction of the code runtime environment from the code repository of the target project.
[0016] In one possible implementation, the toolset includes a file content viewing tool for reading the full content of a file and a search tool for performing keyword searches;
[0017] The tools in the toolset are invoked to collect information related to the construction of the code runtime environment from the code repository of the target project, including:
[0018] The search tool is invoked to search for files or file content fragments related to the construction of the code runtime environment from the target code repository;
[0019] And / or, invoke the file content viewing tool to obtain all file content related to the code runtime environment construction from the target code repository.
[0020] In one possible implementation, a large language model is used to generate the environment build file for the target project based on the acquired information, including:
[0021] Using a large language model, based on the acquired information and referring to a pre-built environment build template, the environment build file for the target project is generated.
[0022] In one possible implementation, the acquired information includes software dependency information, which is information about the external software components required to run the target project;
[0023] The process of using a large language model, based on the acquired information and referencing a pre-built environment build template, to generate the environment build file for the target project includes:
[0024] Using a large language model, based on the software dependency information in the acquired information, the target base image version is determined from multiple preset base image versions, and the target dependency installation information is determined based on the acquired information, wherein the target dependency installation information is the installation information of external software components required to run the target project;
[0025] Referring to a pre-built environment build template, an environment build file containing the target base image version and the target dependency installation information is generated.
[0026] In one possible implementation, the acquired information includes test framework information, which is information about the test framework used by the target project.
[0027] Using a large language model, environmental test instructions are generated based on the acquired information, including:
[0028] Using a large language model, environmental test instructions are generated based on the test framework information obtained from the acquired information. These environmental test instructions are used to trigger the test framework to execute test tasks.
[0029] In one possible implementation, the code runtime environment construction method further includes:
[0030] If the code runtime environment fails to build, it is determined that there is a problem with the environment build file;
[0031] Using a large language model, the environment build file is modified based on the error information generated during the environment build process;
[0032] Rebuild the code runtime environment based on the modified environment build file.
[0033] In one possible implementation, the code runtime environment construction method further includes:
[0034] If the code runtime environment fails the test, the large language model is used to analyze the reasons for the failure of the code runtime environment based on the error information generated during the environment testing process, and the analysis results are obtained. The reasons for the failure of the code runtime environment are one of the following: there is a problem with the environment build file, there is a problem with the environment testing instructions, or there is a problem with the code repository of the target project.
[0035] If the analysis results indicate that there is a problem with the environment configuration file, then the environment configuration file is modified using a large language model; based on the modified environment configuration file, the code execution environment is rebuilt.
[0036] If the analysis results indicate that there is a problem with the environment testing instructions, then the environment testing instructions are modified using a large language model; the code execution environment is then retested by executing the modified environment testing instructions in the code execution environment.
[0037] If the analysis results indicate that there is a problem with the code repository of the target project, then it is determined that there is no problem with the code runtime environment.
[0038] A second aspect of this application provides a code runtime environment building system, comprising: an environment building data generation unit and a debugging decision control unit;
[0039] The environment building data generation unit is used to utilize a large language model to analyze the code repository of the target project, obtain information related to the construction of the code runtime environment, and generate the environment building file and environment testing instructions of the target project based on the obtained information. The environment building file defines the construction process of the code runtime environment.
[0040] The debugging decision control unit is used to build a code execution environment according to the environment build file. If the code execution environment is successfully built, the code execution environment is tested by executing the environment test command in the code execution environment. If the code execution environment passes the test, the code execution environment is determined as the target code execution environment corresponding to the code repository of the target project.
[0041] In one possible implementation, the debugging decision control unit is further configured to collect data generated during the environment building process and data generated during the environment testing process. If the code runtime environment building fails, the data generated during the environment building process is provided to the environment building data generation unit, enabling the environment building data generation unit to modify the environment build file based on the data generated during the environment building process. If the code runtime environment fails the test, a large language model is used to analyze the reasons for the failure based on the data generated during the environment testing process, obtaining analysis results. If the analysis results indicate a problem with the environment build file or a problem with the environment testing instructions, the analysis results are provided to the environment building data generation unit, enabling the environment building data generation unit to modify the environment build file or the environment testing instructions.
[0042] A third aspect of this application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0043] The memory is used to store computer programs;
[0044] The processor is used to execute the computer program so that the electronic device can implement any of the above-described code execution environment construction methods.
[0045] A fourth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement any of the above-described code execution environment construction methods.
[0046] The fifth aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement any of the above-described code execution environment construction methods.
[0047] By employing the above technical solution, the code runtime environment construction method provided in this application first utilizes a large language model to analyze the code repository of the target project, obtain information related to the construction of the code runtime environment, and generate environment build files and environment testing instructions for the target project based on the collected information. Then, the code runtime environment is constructed according to the environment build files. If the code runtime environment is successfully constructed, the environment testing instructions are executed in the code runtime environment to test it. If the code runtime environment passes the test, it is determined as the target code runtime environment corresponding to the code repository of the target project. The code runtime environment construction method provided in this application can construct a code runtime environment for the code repository of the target project. On the one hand, the code runtime environment construction method provided in this application utilizes a large language model to realize the construction of the code runtime environment, which has a high degree of automation and thus high environment construction efficiency. On the other hand, since the large language model can understand multiple programming languages and project structures, the code runtime environment construction method provided in this application can be applied to various different projects and has strong adaptability. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0049] Figure 1A flowchart illustrating the code runtime environment construction method provided in this application embodiment;
[0050] Figure 2 This is a schematic diagram illustrating the code runtime environment construction process provided in the embodiments of this application;
[0051] Figure 3 This application provides a flowchart illustrating how a large language model is used to analyze the code repository of a target project, obtain information related to the construction of the code runtime environment, and generate environment build files and environment test instructions for the target project based on the obtained information.
[0052] Figure 4 This application provides an embodiment of a large language model that analyzes the code repository of a target project to obtain information related to the construction of the code runtime environment, and then generates an environment construction file.
[0053] Figure 5 This is a schematic diagram of the structure of the code runtime environment building system provided in the embodiments of this application. Detailed Implementation
[0054] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0055] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0056] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0057] In the process of realizing this case, the inventors discovered that there are currently some code runtime environment construction schemes, which are mainly template-based configuration generation schemes and static analysis-based dependency inference schemes.
[0058] The template-based configuration generation scheme involves matching the closest code environment configuration template from the code environment configuration template library based on the project metadata of the code repository, and then generating the code runtime environment based on that template. This scheme requires open-source contributors to submit not only their code repositories to the open-source platform but also their code environment configuration templates to the code environment configuration template library.
[0059] For template-based configuration generation solutions, if the code environment configuration template is synchronized with the code repository, the generated runtime environment has high direct usability and reliability. However, in reality, the iteration speed of the code repository is much faster than the update frequency of its corresponding code environment configuration template. Many code environment templates are no longer maintained after submission, causing them to become out of touch with the latest code repository. Consequently, the runtime environment built based on outdated code environment configuration templates cannot meet the current runtime requirements of the code repository. In addition, template-based configuration generation solutions rely entirely on open-source contributors to manually update and maintain the code environment configuration templates, which brings additional and continuous overhead to open-source contributors that is unrelated to the development of core functions.
[0060] The dependency inference scheme based on static analysis uses a syntax tree to parse the code behavior in the project configuration file (such as setup.py) to extract the explicit dependency environment in the code execution, and constructs a directed acyclic graph of dependency packages, finally generating a minimal dependency list (such as requirements.txt), and then constructs the code execution environment based on the minimal dependency list.
[0061] However, dependency inference schemes based on static analysis have significant limitations: First, dependency coverage is incomplete. The inference heavily relies on explicit dependency declarations defined in the code and captured by static analysis, failing to effectively identify and infer implicit dependencies introduced at runtime or under specific conditions. This results in a large number of missing dependencies in the generated code's runtime environment, compromising its usability. Second, the code's runtime environment and version compatibility are weak. The scheme's package version parsing logic is relatively simple, making it difficult to handle complex version constraints and conflicts. Furthermore, its technical implementation is often deeply coupled to the ecosystem and toolchain of a specific language (such as Python), lacking cross-language and cross-build tool universality, and unable to build a unified environment for modern software projects involving multiple technology stacks. As the cornerstone of the environment building process, the accuracy and completeness of dependency inference directly determine the success or failure of the final environment. The inherent deficiencies of static analysis-based dependency inference schemes in implicit dependencies and cross-language support have become major bottlenecks hindering the development of automated environment building technologies.
[0062] Given the numerous shortcomings of the aforementioned code environment construction scheme, the inventors of this case conducted research and conceived a construction scheme based on large model optimization. Specifically, an environment construction template (Dockerfile template) is pre-built, comprising four major steps: base image version, runtime environment setup, repository code copying, and command execution. The code runtime environment is then built based on the environment construction template (Dockerfile template), tested, and the Dockerfile template is continuously modified based on the test feedback using a large model to obtain the final correct Dockerfile.
[0063] The inventors of this case studied the above-mentioned large model-based optimization build scheme and found that the pre-built Dockerfile template may not cover all project types, and the Dockerfile template may not be applicable. In addition, the above-mentioned large model-based build scheme often requires multiple modifications to the Dockerfile template, which in turn requires multiple builds and tests of the code runtime environment. This process is extremely time-consuming and consumes a lot of computing resources.
[0064] To address the problems of the aforementioned large-model-based construction schemes, the inventors of this application conducted further research and, through continuous investigation, ultimately proposed a more effective code runtime environment construction method that overcomes the shortcomings of the aforementioned schemes. The following embodiments will further illustrate the code runtime environment construction method provided in this application.
[0065] Please see Figure 1 The diagram illustrates a flowchart of a code runtime environment construction method provided in an embodiment of this application. This code runtime environment construction method may include:
[0066] Step S101: Using a large language model, analyze the code repository of the target project to obtain information related to the code runtime environment construction, and generate the environment build file and environment test instructions for the target project based on the obtained information.
[0067] The target project's code repository contains the target project's source code files and related files, such as files related to building, running, and testing the source code.
[0068] In this embodiment, as Figure 2 As shown, the code repository of the target project is analyzed to obtain information related to the construction of the code runtime environment, and then the environment build files and environment test instructions of the target project are generated based on the obtained information.
[0069] Information related to the code runtime environment construction obtained from the target project's code repository may include, but is not limited to: software dependency information (information on external software components required to run the target project), runtime configuration information (such as the target project's runtime instructions, environment variables required for runtime, etc.), code structure information, test-related information (such as test frameworks, test configurations, etc.), and other key information (such as the ports exposed by the target project, the working directory of the target project when running in a container, etc.).
[0070] In this embodiment, the environment build file (Dockerfile) of the target project is a file used to build the code runtime environment of the target project, which defines the build process of the code runtime environment of the target project.
[0071] Below is an example of an environment build file (Dockerfile):
[0072]
[0073] The Dockerfile described above defines the following code runtime environment build process:
[0074] 1. Base image selection → Python 3.9 slim;
[0075] 2. Working directory settings → / app;
[0076] 3. System-level dependency installation (system preparation) → Install compilation tools;
[0077] 4. Install application-level dependencies → Install Python packages;
[0078] 5. Code Deployment → Copy Application Code;
[0079] 6. Environment Configuration → Set Flask Environment Variables;
[0080] 7. Network preparation → Expose service ports.
[0081] The Dockerfile can include basic environment information, dependency installation information, application deployment information, and runtime configuration information. Basic environment information can include the base image version and working directory settings; dependency installation information can include system-level and application-level dependency installation information; application deployment information can include code deployment information; and runtime configuration information can include environment variable configuration information and network configuration information.
[0082] In this embodiment, the environment testing instructions are instructions used to test the code execution environment. They are determined according to the test framework of the target project. That is, the environment testing instructions in this embodiment are test instructions that are adapted to the test framework of the target project and used to test the code execution environment of the target project.
[0083] Step S102: Based on the environment build file, build the code execution environment.
[0084] After obtaining the environment build files, such as Figure 2 As shown, the code runtime environment is built based on the environment build file. Specifically, the process of building the code runtime environment based on the environment build file can include: building a container image based on the environment build file; and instantiating the container image to obtain the code runtime environment.
[0085] After obtaining the environment build file (Dockerfile), the text-based environment build file is first converted into a deployable container image containing all dependencies and code. Specifically, the Docker engine's build command (docker build) can be called to convert the environment build file (Dockerfile) into a container image. If the container image is successfully built, the Docker engine's run command (docker run) is called to instantiate the container image, resulting in a dynamic, running container instance, i.e., the code execution environment.
[0086] Step S103: If the code runtime environment is successfully built, test the code runtime environment by executing environment test commands within the code runtime environment.
[0087] like Figure 2 As shown, after successfully building the code runtime environment, the environment test command is executed in the built code runtime environment to test the code runtime environment and collect the test results.
[0088] When an environment test command is executed, it triggers the test framework to perform testing. It's important to note that the test framework is a software toolkit that defines how to write tests, how to organize tests, and provides the core capabilities to run tests.
[0089] Step S104: If the code execution environment passes the test, then the code execution environment is determined to be the target code execution environment corresponding to the code repository of the target project.
[0090] If the environment test command is executed successfully, the code runtime environment is determined to have passed the test, and the code runtime environment is then identified as the target code runtime environment corresponding to the code repository of the target project.
[0091] The code runtime environment construction method provided in this application first analyzes the code repository of the target project using a large language model to obtain information related to the construction of the code runtime environment. Based on the obtained information, it generates an environment build file and environment testing instructions for the target project. Then, it constructs the code runtime environment according to the environment build file. If the code runtime environment is successfully constructed, it is tested by executing the environment testing instructions within the code runtime environment. If the code runtime environment passes the test, it is determined as the target code runtime environment corresponding to the code repository of the target project. The code runtime environment construction method provided in this application can construct a code runtime environment for the code repository of a target project. On the one hand, the method utilizes a large language model to achieve a high degree of automation, resulting in high environment construction efficiency. On the other hand, since a large language model can understand multiple programming languages and project structures, the method provided in this application is applicable to various projects and has strong adaptability.
[0092] In some embodiments of this application, the process of "step S101: using a large language model, analyzing the code repository of the target project to obtain information related to the construction of the code runtime environment, and generating the environment build file and environment test instructions of the target project based on the obtained information" in the above embodiments is described.
[0093] In one possible implementation, such as Figure 3 As shown, the process of using a large language model to analyze the code repository of the target project, obtain information related to the code runtime environment construction, and generate environment build files and environment test instructions for the target project based on the obtained information may include:
[0094] Step S301: Obtain file directory information and project description files from the target project's code repository.
[0095] The file directory information refers to the directory information of the files contained in the code repository of the target project, which includes the relative paths of each file in the code repository.
[0096] The project description document (e.g., a README file) is a document that introduces the target project. It typically contains some or all of the following key information: project overview (basic project information), installation steps (how to install), running method (how to run), testing method (how to test), configuration requirements, and other information. The project overview, installation steps, running method, testing method, and configuration requirements are information related to building the runtime environment.
[0097] Step S302: Using the large language model, collect information related to the code runtime environment construction from the target project's code repository based on the file directory information and project description file until the existing information is complete, and generate environment construction files and environment testing instructions based on the information related to the code runtime environment construction in the project description file and the collected information.
[0098] It should be noted that the information in the project documentation may be incomplete or missing. Therefore, it is necessary to use a large language model to collect information related to the code runtime environment setup from the target project's code repository based on the file directory information and the project documentation.
[0099] Specifically, the tool description information of the toolset is obtained, and using the large language model, the tools in the toolset are invoked based on the file directory information, project documentation, and tool description information of the toolset. Information related to the construction of the code runtime environment is collected from the code repository of the target project.
[0100] The toolset contains several tools, and the tool description information in the toolset includes information such as the function of the tool and the calling convention.
[0101] In one possible implementation, the toolset may include a file content viewing tool (cat tool) for reading the complete content of a file and a search tool (grep tool) for performing keyword searches. When calling tools in the toolset to collect information related to the code runtime environment build from the target project's code repository, the search tool may be invoked to search for files or file content fragments related to the code runtime environment build from the target code repository, and / or the file content viewing tool may be invoked to obtain the complete file content of files related to the code runtime environment build from the target code repository.
[0102] In one possible implementation, a pre-configured prompt template can be obtained first. The prompt template contains file directory information slots, project description information slots, and tool information slots, as well as task prompt information. The task prompt information is used to instruct the large language model to call tools in the toolset based on the information in the file directory information slots, project description information slots, and tool information slots, collect information related to the code runtime environment construction from the target project's code repository, and generate environment build files and environment test instructions based on the existing information when it is complete. Then, the file directory information is filled into the file directory information slots in the prompt template, the information in the project description file is filled into the project description information slots in the prompt template, and the tool description information in the toolset is filled into the tool information slots in the prompt template to obtain the target prompt word. The target prompt word is then input into the large language model to obtain the environment build files and test instructions output by the large language model.
[0103] Below is an example of a prompt word template:
[0104] "Role: You are a senior code repository analysis expert, focusing on building standardized code runtime environments for software projects."
[0105] Core objective: To generate accurate Dockerfiles and test instructions through systematic analysis of code repositories.
[0106] Available toolset:
[0107] - cat<file_path> Read the complete contents of the specified file.
[0108] - grep " <pattern>"<file_path> Search for content in a file that matches a specified pattern.
[0109] - [Other related tools...]
[0110] Execution rules:
[0111] 1. Initial Analysis: First, carefully study the repository file directory information and project description documents to establish an overall understanding of the project;
[0112] 2. Information Gathering: Based on existing information, identify the key information gaps required for environment construction (including but not limited to: runtime environment, dependency management, startup method, testing framework, etc.).
[0113] 3. Tool Utilization: Select appropriate tools to obtain supplementary information, and integrate the new information after each utilization to update the understanding of the repository;
[0114] 4. Iterative optimization: Repeat steps 2-3 until you are confident that you have enough information to create a complete Dockerfile and test instructions;
[0115] 5. Result Generation: When the information is complete, generate and output the Dockerfile and test instructions based on the obtained information.
[0116] Initial information:
[0117] Repository file directory information: [File directory information slot]
[0118] Project Description Document: [Project Description Information Slot]
[0119] When collecting information, the large language model goes through a cycle of "thinking and analysis - action execution - termination judgment".
[0120] The analysis and consideration phase: The large language model "thinks" based on currently known information (file directory information, information in the README file, and the results of previous tool calls (this information will be available in the second loop)). For example, "Based on the directory structure and README, this appears to be a Python web application," "The existence of pom.xml indicates that this is a Maven-managed Java project," "This mentions the need for Python 3.9, but does not explicitly specify the dependency management method; we need to look up requirements.txt or pyproject.toml," "main.py in the pro directory is specified as the application entry point by the README; its implementation details need to be analyzed," "The README mentions the need for Python 3.9, but does not explicitly specify the dependency management method; we need to look up requirements.txt or pyproject.toml," "main.py in the src / directory is specified as the application entry point by the README; its implementation details need to be analyzed," "The structure of the test / directory suggests the possible use of the pytest framework; this needs to be verified," and so on. Figure 4 As shown, based on the above "thinking", the large language model will autonomously decide what needs to be done next and call the corresponding tools.
[0121] Action Execution Phase: Based on the conclusions of the analysis, the large language model autonomously selects and invokes appropriate tools to obtain information, and integrates the obtained information into its own context to update its understanding of the code repository. Specifically, for identified key files, the `cat` tool can be used to directly read the complete content; for uncertain information, the `grep` tool can be used for keyword matching searches. The results returned by the tools are then integrated into the analysis context to update the understanding of the code repository.
[0122] Termination Judgment Phase: The large language model autonomously assesses the completeness of the information. If the large language model determines that the information is complete, the loop terminates. The termination judgment is made autonomously by the large language model, and the judgment criteria may include: the programming language and version of the project have been identified, the dependency management mechanism and core dependencies have been identified, the project startup entry point and operation mode have been determined, the contents of key configuration files have been obtained, and special environmental requirements (ports, environment variables, etc.) have been discovered.
[0123] If the large language model determines that the information is incomplete, then a new round of thinking will continue.
[0124] Once no other unknown or confusing files are found that need to be explored, the large language model will generate environment build files and environment test instructions based on the information obtained.
[0125] In one possible implementation, when generating the environment build file using the large model and the acquired information, a pre-built environment build template (Dockerfile template) can be referenced. That is, the large model is used to generate the environment build file based on the collected information and the environment build template (Dockerfile template). In addition to file directory information slots, project description information slots, and tool information slots, the aforementioned prompt template may also include a reference environment build template information slot. Furthermore, the reference environment build template (Dockerfile template) is then populated into this reference environment build template information slot.
[0126] It should be noted that the environment build file needs to define the base image version and how the software dependencies (i.e., the external software components required to run the target project) will be installed.
[0127] In one possible implementation, a large language model is used to determine the target base image version from multiple preset base image versions based on the software dependency information obtained, and to determine the target dependency installation information (i.e., the installation method information of the external software components required to run the target project) based on the collected information. It should be noted that the above prompt template can provide several selectable base image versions and instruct the large language model to select the appropriate base image version from them.
[0128] In addition to utilizing a large language model to determine the target base image version and target dependency installation information based on the acquired information, other information that needs to be defined in the environment build file can also be determined based on the acquired information, such as environment variable configuration information, network configuration information, etc. Then, using the determined information, the environment build file (Dockerfile) is generated by referring to the environment build template (Dockerfile template).
[0129] The acquired information includes the target project's test framework information. When generating environment test commands, a large language model is used to generate environment test commands based on the collected test framework information. The target project's test framework information refers to the information about the test framework used by the target project.
[0130] After obtaining the environment build file and environment testing instructions, you can build the code running environment according to the environment build file.
[0131] Building a code runtime environment based on an environment build file can result in two outcomes: either the code runtime environment builds successfully, or it fails to build. As mentioned in the above embodiment, the process of building a code runtime environment based on an environment build file involves first building a container image based on the environment build file, and then instantiating the container image. The aforementioned failure to build the code runtime environment refers to the failure to successfully build the container image based on the environment build file.
[0132] If the code runtime environment is successfully built (the code runtime environment is successfully built according to the environment build file), then the environment test command is executed in the code runtime environment to test the code runtime environment. If the code runtime environment passes the test, then the code runtime environment that passes the test is determined as the target code runtime environment corresponding to the code repository of the target project.
[0133] In practical applications, the code runtime environment may not be successfully built on the first try, nor may it pass the test on the first try.
[0134] During the environment build phase (building the code runtime environment based on the environment build file), if the code runtime environment build fails (i.e., the code runtime environment is not successfully built based on the environment build file), then the environment build file is considered to have a problem. In this case, a large language model can be used to modify the environment build file based on the error information generated during the environment build process. That is, the environment build file and the error information generated during the construction of the code runtime environment based on the environment build file are provided to the large language model, allowing the large language model to modify the environment build file according to the error information generated during the environment build process. After obtaining the modified environment build file, the code runtime environment can be rebuilt and tested based on the modified environment build file.
[0135] During the environment testing phase (executing environment test commands in a successfully built code runtime environment), if the code runtime environment fails the test, the large language model can be used to analyze the reasons for the failure based on the error information generated during the test, and obtain the analysis results. The reasons for the failure of the code runtime environment are one of the following: problems with the environment build files, problems with the environment test commands, or problems with the target project's code repository.
[0136] If the analysis results indicate a problem with the environment configuration file, the environment configuration file is modified using a large language model. Specifically, based on the analysis results and error messages generated during testing, the environment configuration file is modified using the large language model. Then, the code runtime environment is rebuilt and tested using the modified environment configuration file. If the analysis results indicate a problem with the environment test commands, the environment test commands are modified using a large language model. Specifically, based on the analysis results and error messages generated during testing, the environment test commands are modified using the large language model. Then, the code runtime environment is retested by executing the modified environment test commands. If the analysis results indicate a problem with the target project's code repository, the code runtime environment is determined to be problem-free.
[0137] It should be noted that a preset threshold for the number of modifications can be set. If the total number of modifications made by the large language model to the environment build file and / or environment test instructions reaches the preset threshold and a code runtime environment that has passed the test is still not obtained, then the modification, environment build, and test operations will no longer be performed, and the current code runtime environment build process will end.
[0138] Considering that the environment build files and environment test instructions generated by the large language model may differ in different code runtime environment build processes, some code runtime environment build processes may fail to build a code runtime environment that passes the test, while others may succeed. Therefore, the above environment build process (collecting information → generating environment build files and environment test instructions → building and testing the code runtime environment → modifying the environment build files or environment test instructions based on error information generated during the build or test process → rebuilding and / or testing the code runtime environment....) can be executed multiple times (the maximum number of executions of the environment build process can be set, such as 50 times) for the target code repository in a parallel or serial manner.
[0139] The code runtime environment construction method provided in this application embodiment can automatically generate environment build files and environment testing instructions by analyzing the code repository of the target project using a large language model. Then, the code runtime environment can be built and tested according to the environment build files and environment testing instructions to obtain the target code runtime environment corresponding to the code repository of the target project. The code runtime environment construction method provided in this application embodiment has a high degree of automation. Furthermore, since the large language model can understand multiple programming languages and project structures, the code runtime environment construction method provided in this application embodiment can be applied to various different projects, i.e., it has strong adaptability. In addition, during the process of building and testing the code runtime environment according to the environment build files and environment testing instructions, the code runtime environment construction method provided in this application embodiment can also utilize the large language model to modify the environment build files or environment testing instructions based on error information generated during the building or testing process.
[0140] Compared to template-based configuration generation schemes, the code runtime environment construction method provided in this application does not require open-source contributors to provide and maintain environment configuration templates, and avoids the problem of incompatibility between the code runtime environment and the code repository. Compared to dependency inference schemes based on static analysis, the code runtime environment construction method provided in this application utilizes a large language model to generate environment build files. Since the large language model can understand the complex dependencies in the project, it can build more accurate environment build files, thereby building a usable code runtime environment. Compared to the build scheme based on large model optimization (i.e., pre-building a Dockerfile template and building according to the Dockerfile template), this method is more efficient. The code runtime environment is tested using a large model, and the Dockerfile template is continuously modified based on test feedback. Because the code runtime environment construction method provided in this application generates environment build files by analyzing the target project's code repository, and then modifies these files based on environment build or test feedback, rather than modifying an environment build template unrelated to the project, the number of modifications to the environment build files is significantly reduced. Consequently, the number of environment builds and tests is also greatly reduced, significantly decreasing time consumption and computational resource usage. Furthermore, the code runtime environment construction method provided in this application is applicable to various projects.
[0141] This application also provides a code runtime environment building system, such as... Figure 5 As shown, the code runtime environment building system may include: an environment building data generation unit 501 and a debugging decision control unit 502.
[0142] The environment building data generation unit 501 is used to utilize a large language model to analyze the code repository of the target project, obtain information related to the building of the code runtime environment, and generate the environment building file and environment testing instructions of the target project based on the obtained information. The environment building file defines the building process of the code runtime environment.
[0143] The debugging decision control unit 502 is used to build a code execution environment according to the environment build file. If the code execution environment is successfully built, the code execution environment is tested by executing the environment test command in the code execution environment. If the code execution environment passes the test, the code execution environment is determined as the target code execution environment corresponding to the code repository of the target project.
[0144] In one possible implementation, when the environment building data generation unit 501 uses a large language model to analyze the code repository of the target project and obtain information related to the code runtime environment building, it is specifically used for:
[0145] Obtain file directory information and project description file from the target project's code repository, wherein the project description file contains information related to the construction of the code runtime environment;
[0146] Using a large language model, based on the file directory information and the project description file, information related to the construction of the code runtime environment is collected from the code repository of the target project until the existing information is complete. The information related to the construction of the code runtime environment in the project description file and the collected information are taken as the final information related to the construction of the code runtime environment.
[0147] In one possible implementation, when the environment building data generation unit 501 collects information related to the code runtime environment building from the code repository of the target project using a large language model, based on the file directory information and the project specification file, it is specifically used for:
[0148] Obtain tool descriptions for the toolset;
[0149] Using a large language model, based on the file directory information, the project documentation, and the tool description information of the toolset, the tools in the toolset are invoked to collect information related to the construction of the code runtime environment from the code repository of the target project.
[0150] In one possible implementation, the toolset includes a file content viewer for reading the full content of a file and a search tool for performing keyword searches.
[0151] When the environment build data generation unit 501 calls the tools in the toolset to collect information related to the code runtime environment build from the code repository of the target project, it is specifically used for:
[0152] The search tool is invoked to search for files or file content fragments related to the construction of the code runtime environment from the target code repository;
[0153] And / or, invoke the file content viewing tool to obtain all file content related to the code runtime environment construction from the target code repository.
[0154] In one possible implementation, when the environment build data generation unit 501 generates the environment build file for the target project based on the acquired information using a large language model, it is specifically used for:
[0155] Using a large language model, based on the acquired information and referring to a pre-built environment build template, the environment build file for the target project is generated.
[0156] In one possible implementation, the acquired information includes software dependency information, which is information about the external software components required to run the target project;
[0157] In one possible implementation, when the environment build data generation unit 501 generates the environment build file for the target project using a large language model, based on the acquired information and referring to a pre-built environment build template, it is specifically used for:
[0158] Using a large language model, based on the software dependency information in the acquired information, the target base image version is determined from multiple preset base image versions, and the target dependency installation information is determined based on the acquired information, wherein the target dependency installation information is the installation information of external software components required to run the target project;
[0159] Referring to a pre-built environment build template, an environment build file containing the target base image version and the target dependency installation information is generated.
[0160] In one possible implementation, the environment building data generation unit 501 uses a large language model to analyze the code repository of the target project and obtain information related to the code runtime environment construction, including test framework information, which is the information of the test framework used by the target project.
[0161] When the environment building data generation unit 501 uses the large language model to generate environment test instructions based on the acquired information, it is specifically used for:
[0162] Using a large language model, environmental test instructions are generated based on the test framework information obtained from the acquired information. These environmental test instructions are used to trigger the test framework to execute test tasks.
[0163] In one possible implementation, the debug decision control unit 502 is also used for:
[0164] Collect data generated during the environment construction process and data generated during the environment testing process;
[0165] In the event that the code execution environment fails to be built, the data generated during the environment building process is provided to the environment building data generation unit 501 so that the environment building data generation unit 501 can modify the environment building file based on the data generated during the environment building process.
[0166] If the code runtime environment fails the test, the large language model is used to analyze the reasons for the failure of the code runtime environment based on the data generated during the environment testing process, and the analysis results are obtained.
[0167] If the analysis results indicate that there is a problem with the environment build file or the environment test instructions, the analysis results are provided to the environment build data generation unit 501 so that the environment build data generation unit 501 can modify the environment build file or the environment test instructions. If the analysis results indicate that there is a problem with the code repository of the target project, it is determined that there is no problem with the code running environment.
[0168] The code runtime environment construction system provided in this application first analyzes the code repository of the target project using a large language model to obtain information related to the construction of the code runtime environment. Based on the obtained information, it generates environment build files and environment testing instructions for the target project. Then, it constructs the code runtime environment according to the environment build files. If the code runtime environment is successfully constructed, it is tested by executing the environment testing instructions within the code runtime environment. If the code runtime environment passes the test, it is determined as the target code runtime environment corresponding to the code repository of the target project. The code runtime environment construction system provided in this application can construct a code runtime environment for the code repository of a target project. On the one hand, the system utilizes a large language model to construct the code runtime environment, resulting in a high degree of automation and thus high environment construction efficiency. On the other hand, since a large language model can understand multiple programming languages and project structures, the system is applicable to various projects and has strong adaptability.
[0169] This application also provides an electronic device, which may include at least one processor and a memory connected to the processor.
[0170] The processor may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application; the memory may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage.
[0171] The memory is used to store computer programs, and the processor is used to execute the computer programs, so that the electronic device can implement the code execution environment construction method provided in the above embodiments.
[0172] This application also provides a computer storage medium that carries one or more computer programs. When one or more computer programs are executed by an electronic device, the electronic device is able to implement the code execution environment construction method provided in the above embodiments.
[0173] This application also provides a computer program product, including computer-readable instructions, which, when executed on an electronic device, enable the electronic device to implement the code execution environment construction method provided in the above embodiments.
[0174] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0175] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0176] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0177] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).< / pattern>
Claims
1. A code runtime environment construction method characterized by comprising: include: Using a large language model, the code repository of the target project is analyzed to obtain information related to the construction of the code runtime environment. Based on the obtained information, the environment build file and environment test instructions of the target project are generated. The environment build file defines the construction process of the code runtime environment. Based on the environment build file, construct the code execution environment; If the code execution environment is successfully built, the code execution environment is tested by executing the environment test instructions within the code execution environment; If the code execution environment passes the test, then the code execution environment is determined to be the target code execution environment corresponding to the code repository of the target project.
2. The code execution environment construction method according to claim 1, characterized in that, The method utilizes a large language model to analyze the target project's code repository and obtain information related to the code runtime environment construction, including: Obtain file directory information and project description file from the target project's code repository, wherein the project description file contains information related to the construction of the code runtime environment; Using a large language model, based on the file directory information and the project description file, information related to the construction of the code runtime environment is collected from the code repository of the target project until the existing information is complete. The information related to the construction of the code runtime environment in the project description file and the collected information are taken as the final information related to the construction of the code runtime environment.
3. The code execution environment construction method according to claim 2, characterized in that, The method of utilizing a large language model, based on the file directory information and the project description file, collects information related to the code runtime environment construction from the code repository of the target project, including: Obtain tool descriptions for the toolset; Using a large language model, based on the file directory information, the project documentation, and the tool description information of the toolset, the tools in the toolset are invoked to collect information related to the construction of the code runtime environment from the code repository of the target project.
4. The code execution environment construction method according to claim 3, characterized in that, The toolset includes a file content viewing tool for reading the full content of a file and a search tool for performing keyword searches; The tools in the toolset are invoked to collect information related to the construction of the code runtime environment from the code repository of the target project, including: The search tool is invoked to search for files or file content fragments related to the construction of the code runtime environment from the target code repository; And / or, invoke the file content viewing tool to obtain all file content related to the code runtime environment construction from the target code repository.
5. The code execution environment construction method according to claim 1, characterized in that, Using a large language model, the environment build file for the target project is generated based on the acquired information, including: Using a large language model, based on the acquired information and referring to a pre-built environment build template, the environment build file for the target project is generated; The information obtained includes software dependency information, which is information about the external software components required to run the target project. The process of using a large language model, based on the acquired information and referencing a pre-built environment build template, to generate the environment build file for the target project includes: Using a large language model, based on the software dependency information in the acquired information, the target base image version is determined from multiple preset base image versions, and the target dependency installation information is determined based on the acquired information, wherein the target dependency installation information is the installation information of external software components required to run the target project; Referring to a pre-built environment build template, an environment build file containing the target base image version and the target dependency installation information is generated.
6. The code execution environment construction method according to claim 1, characterized in that, The information obtained includes test framework information, which is the information of the test framework used by the target project. Using a large language model, environmental test instructions are generated based on the acquired information, including: Using a large language model, environmental test instructions are generated based on the test framework information obtained from the acquired information. These environmental test instructions are used to trigger the test framework to execute test tasks.
7. The method for constructing a code execution environment according to any one of claims 1 to 6, characterized in that, Also includes: If the code runtime environment fails to build, it is determined that there is a problem with the environment build file; Using a large language model, the environment build file is modified based on the error information generated during the environment build process; Rebuild the code runtime environment based on the modified environment build file.
8. The method for constructing a code execution environment according to any one of claims 1 to 6, characterized in that, Also includes: If the code runtime environment fails the test, the large language model is used to analyze the reasons for the failure of the code runtime environment based on the error information generated during the environment testing process, and the analysis results are obtained. The reasons for the failure of the code runtime environment are one of the following: there is a problem with the environment build file, there is a problem with the environment testing instructions, or there is a problem with the code repository of the target project. If the analysis results indicate that there is a problem with the environment configuration file, then the environment configuration file is modified using a large language model; based on the modified environment configuration file, the code execution environment is rebuilt. If the analysis results indicate that there is a problem with the environment testing instructions, then the environment testing instructions are modified using a large language model; the code execution environment is then retested by executing the modified environment testing instructions in the code execution environment. If the analysis results indicate that there is a problem with the code repository of the target project, then it is determined that there is no problem with the code runtime environment.
9. A code runtime environment building system, characterized in that, include: Environment construction data generation unit and debugging decision control unit; The environment building data generation unit is used to utilize a large language model to analyze the code repository of the target project, obtain information related to the construction of the code runtime environment, and generate the environment building file and environment testing instructions of the target project based on the obtained information. The environment building file defines the construction process of the code runtime environment. The debugging decision control unit is used to build a code execution environment according to the environment build file. If the code execution environment is successfully built, the code execution environment is tested by executing the environment test command in the code execution environment. If the code execution environment passes the test, the code execution environment is determined as the target code execution environment corresponding to the code repository of the target project.
10. The code execution environment construction system according to claim 9, characterized in that, The debugging decision control unit is also used to collect data generated during the environment building process and data generated during the environment testing process. If the code execution environment fails to build, the unit provides the data generated during the environment building process to the environment building data generation unit, enabling the environment building data generation unit to modify the environment build file based on the data generated during the environment building process. If the code execution environment fails the test, the unit uses a large language model to analyze the reasons for the failure based on the data generated during the environment testing process, obtaining analysis results. If the analysis results indicate a problem with the environment build file or a problem with the environment testing instructions, the analysis results are provided to the environment building data generation unit, enabling the environment building data generation unit to modify the environment build file or the environment testing instructions.
11. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the code execution environment construction method as described in any one of claims 1 to 8.
12. A computer storage medium, characterized in that, The storage medium carries one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the code execution environment construction method as described in any one of claims 1 to 8.
13. A computer program product, characterized in that, It includes computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the code execution environment construction method as described in any one of claims 1 to 8.