Code generation method and apparatus based on large language model

CN122569908APending Publication Date: 2026-08-14BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-06
Publication Date
2026-08-14

AI Technical Summary

Benefits of technology

[0008]根据本公开的第五方面,提供了一种计算机程序产品,包括计算机程序,计算机程序在被处理器执行时实现如第一方面中任一实现方式描述的方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122569908A_ABST
    Figure CN122569908A_ABST
Patent Text Reader

Abstract

This disclosure provides a code generation method and apparatus based on a large language model, relating to the field of artificial intelligence technology, particularly natural language processing, computer vision, and large language models. The method includes: determining a target business scenario based on input requirement information; determining the target business data corresponding to the input requirement information; determining the target code skeleton corresponding to the target business scenario from a pre-generated code skeleton set; and filling the target business data into the target code skeleton to generate runnable target code. This disclosure improves both the efficiency and quality of code generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of artificial intelligence technology, particularly to the fields of natural language processing, computer vision, and large language models, and specifically to a code generation method and apparatus based on a large language model. Background Technology

[0002] Currently, digital transformation in the industrial sector is progressing steadily. Various business processes, such as production scheduling, logistics and distribution, and equipment condition monitoring, all rely on data visualization technology to present information intuitively. Front-end visualization frameworks are widely used, and combining them with artificial intelligence technology to automatically generate visualization code has become an important direction for improving page development and iteration efficiency. Summary of the Invention

[0003] This disclosure presents a code generation method, apparatus, electronic device, and storage medium based on a large language model.

[0004] According to a first aspect of this disclosure, a code generation method based on a large language model is provided, comprising: determining a target business scenario based on input requirement information; determining the target business data corresponding to the input requirement information; determining the target code skeleton corresponding to the target business scenario from a pre-generated code skeleton set; and filling the target business data into the target code skeleton to generate runnable target code.

[0005] According to a second aspect of this disclosure, a code generation apparatus based on a large language model is provided, comprising: a scenario determination module configured to determine a target business scenario based on input requirement information; a data determination module configured to determine target business data corresponding to the input requirement information; a skeleton determination module configured to determine a target code skeleton corresponding to the target business scenario from a pre-generated set of code skeletons; and a code generation module configured to fill the target business data into the target code skeleton to generate runnable target code.

[0006] According to a third aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform a method as described in any implementation of the first aspect.

[0007] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions for causing a computer to perform a method as described in any implementation of the first aspect.

[0008] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method as described in any implementation of the first aspect.

[0009] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0010] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein: Figure 1 This is an exemplary system architecture diagram to which this disclosure can be applied; Figure 2 This is a flowchart of a first embodiment of the code generation method based on a large language model according to the present disclosure; Figure 3 This is a flowchart of a second embodiment of the code generation method based on a large language model according to the present disclosure; Figure 4 yes Figure 3 The flowchart of the code skeleton generation process in step 304; Figure 5 This is a flowchart of a third embodiment of the code generation method based on a large language model according to the present disclosure; Figure 6 This is a flowchart of the fourth embodiment of the code generation method based on a large language model according to the present disclosure; Figure 7 This is a flowchart of the fifth embodiment of the code generation method based on a large language model according to the present disclosure; Figure 8 This is a flowchart of the sixth embodiment of the code generation method based on a large language model according to the present disclosure; Figure 9 This is a schematic diagram of the structure of an embodiment of the code generation apparatus based on a large language model according to the present disclosure; Figure 10 This is a block diagram of an electronic device used to implement the code generation method based on a large language model according to the embodiments of this disclosure. Detailed Implementation

[0011] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0012] It should be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0013] Figure 1 An exemplary system architecture 100 is shown, in which embodiments of the code generation method or apparatus based on the large language model of this disclosure can be applied.

[0014] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0015] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various applications for enabling information communication between the terminal devices 101, 102, and 103 and server 105 can be installed. These applications include cloud storage applications and instant messaging applications.

[0016] Terminal devices 101, 102, and 103 and server 105 can be either hardware or software. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices with displays, including but not limited to smartphones, tablets, laptops, and desktop computers. When terminal devices 101, 102, and 103 are software, they can be installed in the aforementioned electronic devices, and can be implemented as multiple software programs or software modules, or as a single software program or software module; no specific limitation is made here. When server 105 is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server. When server 105 is software, it can be implemented as multiple software programs or software modules, or as a single software program or software module; no specific limitation is made here.

[0017] Server 105 can provide various services through its built-in applications. For example, users can operate through applications on terminal devices 101, 102, and 103 and send code generation requests to server 105. Server 105 can receive and process these code generation requests, performing the following steps: determining the target business scenario based on the input requirement information; determining the target business data corresponding to the input requirement information; determining the target code skeleton corresponding to the target business scenario from a pre-generated set of code skeletons; and filling the target business data into the target code skeleton to generate executable target code.

[0018] It should be noted that the code generation method based on a large language model provided in this embodiment is generally executed by server 105, and correspondingly, the code generation device based on a large language model is generally located in server 105.

[0019] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0020] Continue to refer to Figure 2 This illustrates a flow 200 of a first embodiment of a code generation method based on a large language model according to the present disclosure. The code generation method based on a large language model includes the following steps: Step 201: Determine the target business scenario based on the input requirement information.

[0021] In this embodiment, after the user inputs the requirement information, the execution entity of the code generation method based on the large language model (e.g., Figure 1 The server 105 shown receives the user's input requirement information (i.e., input requirement information), and then performs word segmentation and semantic analysis on the acquired text content to extract the business object, core vocabulary, and business requirements. In this embodiment, industrial business scenarios such as scheduling, logistics and distribution, demand forecasting, and process optimization are preset, and a dedicated feature keyword library is configured for each scenario. The aforementioned execution entity compares and matches the parsed core vocabulary with the keyword libraries of each scenario one by one, and determines the corresponding business type based on the matching results, ultimately determining the target business scenario to which the current input requirement belongs. For example, when the input requirement information is "Help me analyze the scheduling delay situation this week," the aforementioned execution entity extracts keywords such as "this week," "scheduling," and "delay," and after matching, determines that the target business scenario is the scheduling scenario.

[0022] Step 202: Determine the target business data corresponding to the input requirement information.

[0023] In this embodiment, the execution entity first determines the target business scenario based on the input requirements, matches the corresponding data table in the database according to the business scenario, and then extracts the data fields to be obtained from the input requirement information, such as device number, time range, statistical indicators, filtering conditions and other retrieval fields, and converts them into database query statements to perform the retrieval.

[0024] Taking a scheduling scenario as an example, when the input request is "Help me analyze the scheduling delay situation this week," the aforementioned execution entity will first determine that the target business scenario is a scheduling scenario based on the user's input information, and match the corresponding scheduling record table in the database. Then, the execution entity will extract the search conditions from the input request information: the time range is this week, and the filter dimension is scheduling delay-related data. Based on the above conditions, a query rule will be constructed, and the scheduled execution time, actual completion time, delay duration, corresponding equipment, and process number of all processes this week will be retrieved from the scheduling record table. Invalid and redundant information will be removed, and the search results will be processed to finally obtain the target business data.

[0025] Step 203: Determine the target code skeleton corresponding to the target business scenario from the pre-generated code skeleton set.

[0026] In this embodiment, a unified, categorized, and persistently stored set of code skeletons has been pre-constructed. This set is divided and managed according to different industrial business scenarios. Each code skeleton within the set is assigned a unique scenario identification tag, serving as a unique identifier for retrieval and matching. Simultaneously, each code skeleton incorporates the visualization requirements of the corresponding scenario, pre-completing the overall page layout planning, the import and configuration of charts and third-party components, the writing of data receiving and parsing interfaces, and the definition of basic interactive events. It also embeds unified coding constraint rules, risk code avoidance logic, and differentiated functional modules adapted to different scenarios, thus distinguishing the skeleton structures of different scenarios. It should be noted that the code skeletons can be directly run and rendered correctly in a browser. When target code is generated by imitating the skeleton, it is guaranteed to be runnable. Therefore, this embodiment avoids code defects during the code generation stage.

[0027] The aforementioned execution entity will use the currently determined target business scenario as the search condition, traverse the scenario tags of all skeletons in the code skeleton set, compare and verify them one by one, and filter out the code skeletons whose tags match perfectly. The filtered code skeletons contain all the basic structures and general code logic required for visualization, data rendering, and human-computer interaction in that scenario, and can be directly used as templates for subsequent complete visualization code generation.

[0028] Step 204: Fill the target business data into the target code skeleton to generate runnable target code.

[0029] In this embodiment, the execution entity first performs structural analysis on the target code skeleton, identifying the preset data access areas, variable definition locations, chart initialization interfaces, and data rendering functions within the skeleton. Simultaneously, it outlines the skeleton's specifications for data format, field names, and array structures. Subsequently, the target business data is preprocessed, and according to the usage standards of the code skeleton and visualization components, field mapping, data type conversion, data reorganization, and format adaptation are completed to ensure a one-to-one correspondence between data fields, hierarchical structures, and code calling logic.

[0030] After data adaptation is complete, the aforementioned execution entity will traverse all data filling points in the code skeleton, sequentially writing the processed business data into specified variables, data arrays, and interface input parameter positions, replacing the placeholder content reserved within the skeleton. During the data filling process, the coding constraints and component calling rules embedded in the skeleton will be followed, without altering the original page layout, frame references, interactive events, communication logic, or risk avoidance code.

[0031] Once the data embedding is complete, the aforementioned execution entity will integrate and splice the overall code, perform syntax validation, and identify formatting issues arising from data integration. Ultimately, it will generate a structurally complete, grammatically compliant, and directly executable visual target code. This target code utilizes the existing framework to implement page layout, component loading, and interactive capabilities, and loads real business data to complete chart rendering. It can execute, run, display, and interact normally in a browser or headless browser.

[0032] The code generation method based on a large language model provided in this disclosure first determines the target business scenario based on input requirement information; then, it determines the target business data corresponding to the input requirement information; next, it determines the target code skeleton corresponding to the target business scenario from a pre-generated set of code skeletons; finally, it fills the target business data into the target code skeleton to generate runnable target code. This method matches a dedicated code skeleton according to the business scenario, reuses standardized page structures, component configurations, interaction logic, and coding standards, reduces repetitive coding work, and avoids common problems such as non-standard coding from the underlying level, thus improving code quality. Furthermore, by filling the corresponding business data into the code skeleton to generate complete and runnable code, it achieves automatic integration of data and code, eliminating the need for manual line-by-line writing and debugging, and improving the development and output efficiency of visual code and visual pages.

[0033] Furthermore, the collection, storage, use, processing, transmission, provision, and disclosure of any type of information, such as user personal information, involved in the technical solutions disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0034] Continue to refer to Figure 3 , Figure 3A flow 300 of a second embodiment of the code generation method based on a large language model according to this disclosure is shown. This code generation method based on a large language model includes the following steps: Step 301: Determine the target business scenario based on the input requirement information.

[0035] Step 302: Determine the target business data corresponding to the input requirement information.

[0036] Steps 301-302 are basically the same as steps 201-202 in the aforementioned embodiments. For specific implementation methods, please refer to the aforementioned description of steps 201-202, which will not be repeated here.

[0037] Step 303: Determine the scenario identifier for the target business scenario.

[0038] In this embodiment, the execution entity of the code generation method based on the large language model (e.g.) Figure 1 After determining the target business scenario, the server 105 shown will retrieve a pre-generated scenario identifier lookup table. This lookup table configures a unique and standardized scenario identifier for each type of industrial business scenario. The identifier format includes character encoding, name code, and other types.

[0039] Step 304: Determine the code skeleton corresponding to the scene identifier from the code skeleton set to obtain the target code skeleton.

[0040] In this embodiment, the execution entity uses the scene identifier as a search keyword to traverse the code skeleton set. All code skeletons in this set are pre-bound with corresponding scene identifiers, establishing a one-to-one correspondence between identifiers and skeletons. The execution entity compares the identifier information bound to each skeleton in the set and selects the code skeleton that is completely consistent with the current scene identifier. This skeleton pre-defines the page structure, component references, interaction logic, and coding standards for the corresponding scene, and matches the visualization requirements of the current business. The execution entity then identifies this skeleton as the target code skeleton.

[0041] Step 305: Fill the target business data into the target code skeleton to generate runnable target code.

[0042] Step 305 is basically the same as step 204 in the aforementioned embodiment. For the specific implementation method, please refer to the aforementioned description of step 204, which will not be repeated here.

[0043] from Figure 3 It can be seen from this that, with Figure 2Compared to the corresponding embodiments, the code generation method based on a large language model in this embodiment emphasizes the step of determining the target code skeleton. This method retrieves the code skeleton by matching the scene identifier, thereby achieving accurate association between the scene and the template. It completes rapid filtering based on the unique identifier, improving the efficiency of skeleton retrieval, while ensuring a high degree of adaptability between the selected skeleton and the business scenario.

[0044] Continue to refer to Figure 4 , Figure 4 It shows Figure 3 Step 304, the code skeleton generation process, is described in flowchart 400. The code skeleton generation process includes: Step 401: Identify fault code samples from the historical code repository.

[0045] The aforementioned execution entity will identify faulty code samples from the historical code repository. These faulty code samples are code samples that exhibit runtime errors. The execution entity will retrieve the historical code repository and identify faulty code samples from it. These faulty code samples are code samples that exhibit errors or malfunctions during production environment operation. These malfunctions can include browser console errors, rendering anomalies, or functional failures.

[0046] Step 402: Analyze the fault phenomena of the fault code sample and determine the root cause of the fault based on the analysis results.

[0047] The aforementioned execution entities will read each fault code sample one by one, and combine the runtime logs, error messages, and detection records to sort out the fault phenomena, including component call failures, abnormal chart rendering, interaction failures, and syntax warnings. Then, the execution entities will check the code structure, interface usage, and data integration logic layer by layer against coding standards and technical requirements to locate the underlying causes such as non-standard code writing, incorrect parameter configuration, and improper use of frameworks. Finally, they will identify the root cause of each type of fault and complete the classification and recording. The key to the attribution process is to identify the technical root cause of the defect rather than the appearance. For example, for the same code error, the root cause of the btoa (binary to ASCII, encoding binary strings into Base64 encoded strings) encoding failure should be the character encoding class, while the root cause of the onclick variable reference failure is the runtime scope class. The two have completely different constraints.

[0048] Step 403: Cluster all root causes of failures to generate multiple failure categories.

[0049] The aforementioned implementing entities will summarize all root causes of failures and cluster them according to the type of technical problem. For example, API (Application Programming Interface) call errors and abnormal component parameters will be classified as interface usage failures; non-standard syntax and incorrect formatting will be classified as encoding format failures; abnormal data parsing and mismatched fields will be classified as data integration failures; and disordered page layout and interaction failures will be classified as functional logic failures, ultimately resulting in multiple independent failure categories.

[0050] Please refer to Table 1, which shows the correspondence between fault categories, fault symptoms, and fault root causes: Table 1. Comparison of Fault Categories, Fault Symptoms, and Root Causes

[0051] As shown in Table 1, the fault categories include: 1) Character encoding class: When using btoa to encode SVG (Scalable Vector Graphics) content containing Chinese characters, an InvalidCharacterError is triggered. The root cause is that this method is only compatible with Latin1 single-byte encoding and cannot handle multi-byte characters such as Chinese characters.

[0052] 2) HTML (HyperText Markup Language) parsing class: The presence of the > symbol in inline event properties will cause property truncation and content exposure, because the HTML parser will misinterpret the symbol as a tag end character.

[0053] 3) JavaScript (JS) Syntax Class: Regular expression literals containing actual newline characters will result in a SyntaxError because JS syntax rules prohibit the direct use of newlines within regular expression literals.

[0054] 4) Runtime scope class: The onclick event references a closure variable and a ReferenceError occurs. This is a JavaScript reference error because the event has already left the original function scope when it is executed.

[0055] 5) Network environment issues: Using overseas CDN (Content Delivery Network) addresses causes resource loading failures, which is affected by domestic network access restrictions.

[0056] 6) Geographic accuracy: Directly connecting WGS84 coordinates to Baidu Maps results in a significant offset, while the actual map uses the BD09 coordinate system, which has a systematic offset due to the different coordinate systems used by the two.

[0057] 7) Misunderstandings about the framework API data model: Accessing params.data.xxx or params.itemStyle.color in the chart's custom rendering function results in TypeError: Cannot read properties of undefined. This is a JavaScript type error: Unable to read properties of an undefined object. This is because the system mistakenly assumes that the framework callback parameters carry the original data object. In the actual framework design, the parameters only contain coordinate / index information, and the data must be read through the framework's API (such as api.value(), api.style()).

[0058] The first six categories are coding errors (variables exist but are inaccessible or used improperly), while the seventh category is a misunderstanding of the framework's internal design, meaning the variable doesn't actually exist in the framework's design. These types of errors are difficult to completely avoid by reading the API documentation, because the documentation typically describes "how to call" rather than "the internal structure of the parameter object."

[0059] Step 404: Add the constraint rules corresponding to each fault category to the basic business skeleton corresponding to different business scenarios to obtain the code skeleton corresponding to different business scenarios.

[0060] The aforementioned implementing entity will transform the seven types of failure modes into formalized constraint rules, describing the "prohibited behaviors" and "correct alternatives" in the form of natural language and code examples, forming a structured specification document (SKILL.md). The specification document includes constraints such as: color system, font specifications, rendering strategies, rules for using external libraries, event attribute writing specifications, and geographic coordinate processing specifications.

[0061] The aforementioned constraints are then added to the business framework corresponding to each industrial scenario (e.g., scheduling, logistics, demand forecasting, process optimization), resulting in runnable HTML code frameworks for different business scenarios. These code frameworks can be directly run and verified in a browser, forming a two-way "constraint-implementation" mapping with the specification document: each constraint rule in the specification document has a corresponding concrete code implementation in the framework; the runnability of the framework serves as machine-verifiable proof of the specification's correctness.

[0062] In some optional implementations of this embodiment, step 404 includes: Step 4041: Determine the constraint rules corresponding to the fault category.

[0063] The aforementioned executing entity will determine the constraint rules corresponding to the fault categories. These constraint rules include natural language descriptions and code examples. Specifically, for each fault category, the executing entity will describe the "prohibited behaviors" and "correct alternative patterns" in the form of natural language and code examples, thus forming a structured specification document. The specification document may include constraints such as color systems, font specifications, rendering strategies, rules for using external libraries, event attribute writing specifications, and geographic coordinate processing specifications.

[0064] Step 4042: Add the constraint rules corresponding to each fault category to the basic business skeleton corresponding to different business scenarios to obtain the skeleton after addition for different business scenarios.

[0065] The aforementioned implementing entities will add the constraint rules from the aforementioned specification documents to the business basic skeleton corresponding to each type of industrial scenario, thereby obtaining the added skeletons for different business scenarios.

[0066] Step 4043: For each business scenario, in response to the determination that the added skeleton corresponding to the business scenario has passed the runnability verification, the added skeleton is determined as the code skeleton corresponding to the business scenario.

[0067] For each business scenario, the aforementioned execution entity will perform a runnability verification on the added skeleton corresponding to that business scenario. That is, it verifies whether the added skeleton is runnable. If its runnability is determined to pass the verification, the added skeleton is determined as the code skeleton corresponding to that business scenario. The code skeleton is a runnable HTML code skeleton, which can be directly run and verified in a browser. It forms a "constraint-implementation" bidirectional mapping with the specification document: that is, each constraint rule in the specification document has a corresponding specific code implementation in the skeleton. The runnability of the skeleton is a machine-verifiable proof of the correctness of the specification.

[0068] By first defining constraint rules for various faults, including textual descriptions and code examples, and then embedding these rules into the basic business framework, and finally finalizing them as standard code frameworks after operational verification, typical faults are intercepted at the architectural level, ensuring the stable operation of the framework itself. At the same time, constraint rules can guide code generation logic, reduce the error rate of subsequent code output, reduce debugging workload, and improve code quality and delivery efficiency in different business scenarios.

[0069] In some optional implementations of this embodiment, the business basic skeleton is generated through the following steps: for any business scenario, determine the business requirements of the business scenario, and construct the business module corresponding to the business scenario according to the business requirements; encapsulate the business module with the general code module to obtain the business basic skeleton corresponding to the business scenario; bind the scenario identifier of the business scenario to the business basic skeleton.

[0070] In this implementation, the executing entity first determines the business requirements, namely, to implement page chart rendering, vector graphics display, point geographic annotation, and interactive click functionality, supporting static resource loading and normal page interaction. Then, it sequentially builds a chart rendering module, an SVG graphics display module, a map point annotation module, and a page interaction event module, respectively implementing core capabilities such as chart drawing, vector graphics loading, coordinate positioning, and click response. Next, these business modules are integrated and encapsulated with common code modules such as HTML page structure, basic JS utility functions, and general styles to form a business-specific basic skeleton for this scenario. The generated business-specific basic skeleton includes a complete page structure, basic calling logic, and file reference structure. Finally, the executing entity associates and binds the scene identifier of the current business scenario with the generated business-specific basic skeleton for subsequent scene recognition and skeleton invocation. By building dedicated modules based on business requirements, encapsulating them into a basic skeleton with common code modules, and binding scene identifiers, the system aligns with business needs, improves code reusability, and reduces redundant development.

[0071] By first screening abnormal code samples, analyzing the fault phenomena and root causes layer by layer, then clustering them into standardized fault categories, and embedding the corresponding constraint rules into the skeleton of each business code, similar problems can be avoided from the source, code writing standards can be unified, the probability of generated code errors can be reduced, the running stability and scenario adaptability of industrial visualization code can be improved, and the cost of later debugging and repair can be reduced.

[0072] Continue to refer to Figure 5 , Figure 5 A flow 500 of a third embodiment of the code generation method based on a large language model according to this disclosure is shown. This code generation method based on a large language model includes the following steps: Step 501: Determine the target business scenario based on the input requirement information.

[0073] Step 502: Determine the target business data corresponding to the input requirement information.

[0074] Step 503: Determine the target code skeleton corresponding to the target business scenario from the pre-generated code skeleton set.

[0075] Steps 501-503 are basically the same as steps 201-203 in the aforementioned embodiments. For specific implementation methods, please refer to the aforementioned description of steps 201-203, which will not be repeated here.

[0076] Step 504: Input the target business data and the target code skeleton into the large model so that the large model fills the target business data into the data placeholder area of ​​the target code skeleton according to the preset field mapping rules, and outputs the filled code.

[0077] In this embodiment, the execution entity of the code generation method based on the large language model (e.g.) Figure 1 The server 105 shown will input the business data related to device operation statistics and the code skeleton of the visualization chart into the large model. The large model will replace the corresponding data placeholder areas in the code skeleton one by one with the title, numerical list and other content in the business data according to the preset field mapping rules, and finally output the complete chart code with data filling and can be run directly.

[0078] Furthermore, this embodiment establishes a closed-loop evolutionary process from runtime errors to standardized rules, consisting of the following steps: Step 1 (Defect Collection): Collect errors that occur when the large model generation code is run in the production environment, including browser console errors, rendering anomalies, and function failures.

[0079] Step 2 (Systematic Attribution Classification): Technicians or the system automatically classify the collected defects into a predefined seven-category failure mode classification system.

[0080] Step 3 (Rule Formalization): Transform the attributed root causes into formal constraint rules. Each rule contains three elements: (a) the specific wording of the prohibition and the reasons therefor; (b) the correct alternative implementation pattern; and (c) a code example that can be directly copied and used. The rules are written into the specification document in the form of natural language and code blocks.

[0081] Step 4 (Skeleton Synchronization Update): Synchronously write the correct implementation mode into the reference skeleton of the corresponding scenario, so that the skeleton always reflects the correct implementation of the latest constraint rules.

[0082] Step 5 (Injection Verification): Inject the updated specification document and skeleton into the LLM (Large Language Model) to generate a context and verify that the same type of defect no longer occurs.

[0083] Furthermore, the specification document in this embodiment has already accumulated multiple rules, corresponding to complete prevention coverage of seven types of failure modes. Representative examples of these rules are as follows: Rule 3 states: BootCDN should be used uniformly for CDN, Cloudflare is prohibited, and the source defect is: overseas CDN timeout, resulting in a blank chart; Rule 7 states that regular expressions should prevent actual line breaks by using \n. The source of the error is a SyntaxError, which prevents the code from executing. Rule 8 states: Tooltip should not be used for inline HTML; use data-tip instead. The source defect is: > truncation of attributes, causing text to be rendered on the page; Rule 12 (onclick section): The rule states that onclick should use numeric indexing and should not reference closure variables. The source defect is ReferenceError, and clicking will not respond. The map rules are as follows: prohibit btoa, use encodeURIComponent, the source defect is InvalidCharacterError, and the icon is not rendered.

[0084] Step 505: Determine the target rendering strategy based on the amount of target business data.

[0085] In this embodiment, the execution entity first determines the amount of target business data and then determines the corresponding rendering strategy based on that amount. For example, when the amount of target business data is less than 1000 records, the target rendering strategy is determined to be CSS (Cascading Style Sheets) / SVG rendering. This rendering method generates concise code that can directly manipulate the DOM (Document Object Model) and has no dependencies. When the amount of target business data is greater than or equal to 1000 records, the target rendering strategy is determined to be Canvas rendering + virtual scrolling. This avoids page lag caused by too many SVG nodes, and Canvas batch drawing offers superior performance. Thus, the rendering strategy decision is made autonomously based on the data amount during the code generation phase, rather than being dynamically determined at runtime.

[0086] Step 506: Add the target rendering strategy to the filled code to obtain the target code.

[0087] In this embodiment, the execution entity will add the determined target rendering strategy to the filled code to obtain the target code.

[0088] from Figure 5 It can be seen from this that, with Figure 2 Compared to the corresponding embodiments, the code generation method based on a large language model in this embodiment emphasizes the step of generating target code. This method combines a rendering strategy that matches the data volume and integrates it into the code. It can quickly generate usable code and optimize rendering performance in a targeted manner, avoiding page lag under large data volumes and improving the overall stability and adaptability of the code.

[0089] Continue to refer to Figure 6 , Figure 6 A flow 600 of a fourth embodiment of the code generation method based on a large language model according to the present disclosure is shown. This code generation method based on a large language model includes the following steps: Step 601: Determine the target business scenario based on the input requirement information.

[0090] Step 602: Determine the target business data corresponding to the input requirement information.

[0091] Step 603: Determine the target code skeleton corresponding to the target business scenario from the pre-generated code skeleton set.

[0092] Step 604: Input the target business data and the target code skeleton into the large model so that the large model fills the target business data into the data placeholder area of ​​the target code skeleton according to the preset field mapping rules, and outputs the filled code.

[0093] Step 605: Determine the target rendering strategy based on the amount of target business data.

[0094] Step 606: Add the target rendering strategy to the filled code to obtain the target code.

[0095] Steps 601-606 are basically the same as steps 501-506 in the previous embodiment. For specific implementation methods, please refer to the above description of steps 501-506, which will not be repeated here.

[0096] Step 607: Detect the code writing style of the target code according to the predefined regular expression rule library to obtain the static detection results.

[0097] In this embodiment, the execution entity of the code generation method based on the large language model (e.g.) Figure 1 The server 105 shown will scan the generated HTML source code through a predefined regular expression rule library to identify known error patterns and obtain static detection results.

[0098] The rule base includes the following categories: API misuse detection: Identify incorrect ways of calling framework APIs, such as BMapGL calling the non-existent setOpacity() method, and ECharts custom rendering functions incorrectly accessing params.data.xxx properties, etc. Framework convention detection: Identifies code that violates the framework's usage conventions, such as non-compliant CDN sources, incorrect script tag placement, and dependencies on external JSON (JavaScript Object Notation) files; Safe mode detection: Identifies code patterns that may cause runtime errors, such as SVG icons using btoa() encoding (causing Chinese character crashes) and HTML event attributes embedding JSON.stringify (quote truncation).

[0099] Static analysis is completed in milliseconds, covering all known, formalizable error patterns. When a violation is detected, an error description, the violating code snippet, and suggested fixes are output.

[0100] Step 608: Launch the headless browser to run the target code, detect the running status of the target code, and obtain dynamic detection results.

[0101] In this embodiment, the aforementioned execution entity uses a headless browser to actually run the generated HTML code to capture runtime errors that static detection cannot detect, thereby generating dynamic detection results. The specific detection process is as follows: Start a Playwright Chromium browser instance; load the HTML file via the file: / / protocol; register pageerror and console.error event listeners; continue listening for 3-5 seconds after the page has finished loading (DOM ContentLoaded) to capture asynchronous rendering errors; filter internal noise from third-party SDKs (such as internal errors in the BMapGL SDK, favicon loading failures, etc.); output a list of unfiltered runtime errors.

[0102] Dynamic detection can uncover runtime errors that static detection cannot cover, including but not limited to: JavaScript type errors (TypeError, ReferenceError), side effect errors caused by resource loading failures, asynchronous rendering timing issues, and abnormal internal framework states.

[0103] Step 609: In response to the determination that both the static detection result and the dynamic detection result are passed, the target code is rendered according to the target rendering strategy, a visualization result is generated, and the visualization result is displayed in the embedded window of the front-end page.

[0104] In this embodiment, after completing static code testing and dynamic runtime testing, and both results are deemed satisfactory, the execution entity will retrieve the selected slice rendering target strategy to render the target code. The code processes business data in batches according to rules, gradually draws graphical components, and finally generates complete industrial data visualization charts, vector graphics, geographic locations, and other visualization content. Subsequently, the execution entity will load the overall visualization screen and display it in a preset embedded independent window on the front-end page, allowing operators to intuitively view the final presentation effect.

[0105] Step 610: In response to determining that either the static detection result or the dynamic detection result is a failed detection, determine the abnormal information of the failed detection.

[0106] In this embodiment, when either the static detection result or the dynamic detection result fails the detection, that is, when any layer of detection fails, the execution entity will determine the abnormal information of the failed detection.

[0107] Step 611: Input the abnormal information into the large model so that the large model can repair the target code based on the abnormal information and output the repaired target code.

[0108] In this embodiment, the aforementioned execution entity returns error information and repair suggestions (if any) to the LLM, triggering code repair or regeneration, and outputting the repaired target code. When static detection generates an error, since it is a known error pattern, there will be corresponding repair suggestions. This forms an automated closed loop of "generation-detection-repair-re-detection," which continues to run until the detection passes or the maximum number of retries is reached.

[0109] This automatically captures static code style issues and runtime anomalies, sending the anomaly information into a large model to achieve intelligent code repair. This eliminates the need for manual troubleshooting and modification, shortens problem processing time, forms an automated error correction chain, and improves code qualification rate and overall generation efficiency.

[0110] from Figure 6 It can be seen from this that, with Figure 5 Compared to the corresponding embodiments, the code generation method based on a large language model in this embodiment emphasizes both static and dynamic detection of the target code. When both detections pass, a visual result is generated. This method utilizes a regular expression rule base for static code compliance detection and combines this with a headless browser for runtime dynamic detection, forming a dual verification mechanism. If all detections pass, rendering proceeds normally and the visual content is displayed in an embedded window on the front end. If any detection fails, the abnormal information is automatically extracted and handed over to the large model for intelligent code repair. This entire process achieves a closed loop of automatic code problem discovery, repair, and verification, reducing the cost of manual investigation and modification, ensuring compliant and stable output code, and improving automation efficiency.

[0111] Continue to refer to Figure 7 , Figure 7 A flow 700 of a fifth embodiment of the code generation method based on a large language model according to the present disclosure is shown. This code generation method based on a large language model includes the following steps: Step 701: Determine the target business scenario based on the input requirement information.

[0112] Step 702: Determine the target business data corresponding to the input requirement information.

[0113] Step 703: Determine the target code skeleton corresponding to the target business scenario from the pre-generated code skeleton set.

[0114] Step 704: Input the target business data and the target code skeleton into the large model so that the large model fills the target business data into the data placeholder area of ​​the target code skeleton according to the preset field mapping rules, and outputs the filled code.

[0115] Step 705: Determine the target rendering strategy based on the amount of target business data.

[0116] Step 706: Add the target rendering strategy to the filled code to obtain the target code.

[0117] Step 707: Detect the code writing style of the target code according to the predefined regular expression rule library to obtain the static detection result.

[0118] Step 708: Launch the headless browser to run the target code, detect the running status of the target code, and obtain dynamic detection results.

[0119] Step 709: In response to the determination that both the static detection result and the dynamic detection result are passed, the target code is rendered according to the target rendering strategy, a visualization result is generated, and the visualization result is displayed in the embedded window of the front-end page.

[0120] Steps 701-709 are basically the same as steps 601-609 in the aforementioned embodiments. For specific implementation methods, please refer to the aforementioned description of steps 601-609, which will not be repeated here.

[0121] Step 710: In response to detecting an interactive operation on the visualization result, determine the target element targeted by the interactive operation; generate a natural language message based on the attribute information of the target element, and display the natural language message in the dialog area of ​​the front-end page.

[0122] In this embodiment, after the industrial data visualization chart is displayed in the embedded window of the current page, the execution entity of the code generation method based on the large language model (e.g., Figure 1 The server 105 shown monitors page interactions in real time. When a user interaction with the visualization (e.g., clicking, dragging) is detected, the execution entity determines the target element of the interaction, such as the element clicked or dragged by the user. The execution entity then generates a natural language message based on the target element's attribute information and displays the message in the dialog box area of ​​the front-end page.

[0123] For example, when an industrial data visualization chart is displayed in an embedded window on the current page, and the user clicks on the bar chart element representing the load of Unit 2, the aforementioned execution entity will first locate the target graphic element corresponding to the interaction and retrieve its pre-bound attribute data, including equipment name, real-time load value, operating status, and collection time. Then, according to preset dialogue rules, it integrates the attribute information to generate a complete natural language message: "You have currently selected Unit 2, real-time load 86%, equipment is operating normally, data collection time: 2026-06-15 14:20". Finally, this message is pushed to a dedicated dialog area at the bottom of the page for display, allowing users to quickly read the detailed information corresponding to the interactive element.

[0124] If the user subsequently performs other interactive operations such as mouse hovering, point clicking, or area selection, the above-mentioned execution entity will repeat the above logic to accurately identify the corresponding target element, parse the attributes, generate prompt text, and update the content in the dialog box in real time.

[0125] In this embodiment, all visual HTML artifacts generated by LLM have a standardized Agent callback function embedded in the code generation stage. The callback function is automatically written by LLM during the generation stage, as required by the specification document, rather than being manually added by the developer afterwards (of course, manual writing by the user is also supported as an alternative implementation).

[0126] In the Agent callback function, the context field carries the complete structured context of the operated element (task ID, time range, load rate, process chain preceding / following nodes, status, and other machine-readable fields), and the message field is a natural language instruction automatically generated based on the operated element and operation type.

[0127] Referring to Table 2, which shows the standard format specifications for callback messages for various industrial scenarios: Table 2 Standard Format of Callback Messages for Various Industrial Scenarios

[0128] As shown in Table 2, different visualization chart scenarios, corresponding triggering operations, and preset message templates are used to automatically generate standardized natural language text during interaction, and to link with AI for subsequent processing such as analysis, optimization, and comparison. Specific explanations are as follows: Gantt Chart Task Bar: When you click on the task bar, it automatically extracts the task name, associated resource, time range, running status, and information on preceding tasks, and generates a prompt text requesting AI analysis of the task or suggesting a rescheduling.

[0129] Heatmap Overload Cells (≥90%): After clicking on a cell with a load exceeding 90%, the corresponding resource, time period, actual load, and warning threshold are retrieved, and a prompt text is generated to provide AI overload mitigation solutions.

[0130] Logistics route: Click the "Ask AI" button next to the route to retrieve the vehicle number, stops along the way, operating status, and total mileage, and generate a prompt text requesting AI analysis and optimization of the route.

[0131] Predicted data points: Click on a data point with a deviation exceeding 5% to obtain the corresponding dimension of the horizontal axis, the actual value, the deviation ratio, and generate a prompt text asking AI to analyze the cause of the data deviation.

[0132] Process Parameter Row: After clicking the parameter row, the parameter name, corresponding values ​​of Scheme A and Scheme B are read, and a comparison prompt text is generated to help the AI ​​judge the merits of the two schemes.

[0133] It should also be noted that when LLM generates HTML with dynamic data binding, the onclick attribute is subject to dual constraints: HTML parsing (quotes must match) and JavaScript scope (onclick executes after leaving the original function). Ordinary syntax will result in a ReferenceError or HTML parsing error. This embodiment uses a global index array for decoupling: dynamic data is stored in a global array, and onclick only passes a numeric index, thus resolving the dual constraint conflict unique to LLM code generation.

[0134] In some optional implementations of this embodiment, generating a natural language message based on the attribute information of the target element includes: extracting attribute information based on the element index of the target element, wherein the attribute information includes: spatiotemporal attribute information, state attribute information, and scene attribute information; determining the target interaction intent based on the target element and the target business scenario; and filling the attribute information into the speech template corresponding to the target interaction intent to generate a natural language message.

[0135] In this implementation, the aforementioned execution entity first accurately locates the interaction object using the unique index of the target element, and then extracts complete attribute data in three categories: spatiotemporal, state, and scenario. This comprehensively records the element's associated time, location, operational status, and the business scope it belongs to. Subsequently, the execution entity combines the element type with the overall business scenario to accurately identify the user's current interaction request and operational intent, and retrieves a standard script template specific to that intent. Finally, the acquired attribute information replaces the placeholder content in the template one by one, generating a semantically complete natural language message that fits the interaction requirements.

[0136] For example, the aforementioned execution entity locates the clicked overloaded cell in the heatmap using element indexing, extracts the corresponding spatiotemporal, state, and scenario attribute information, and combines this visualization element with the business scenario of equipment load monitoring to determine the user's interaction intent of wanting to obtain solutions to the overload problem. Then, the extracted attribute data is filled into the matching message template to finally generate a complete natural language message: "Workstation No. 1 has a load of 92% during the period from 08:00 to 10:00, exceeding the threshold of 90%. How to alleviate the overload?"

[0137] This allows for the extraction of multi-dimensional attributes through element indexing, accurate identification of interaction intent by combining elements with business scenarios, and then matching corresponding dialogue templates to generate natural language messages. The output content is standardized and consistent, automating the entire process of information extraction, intent determination, and message generation, reducing manual costs, and providing standardized output for subsequent processing of large models.

[0138] Step 711: In response to the detection of an acknowledgment operation for the natural language message, input the natural language message and the contextual business data of the target element into the large model, and output the new target code.

[0139] In this embodiment, if the aforementioned execution entity detects a confirmation operation for a natural language message—that is, when a user clicks the confirmation button on the front-end page—it will trigger a confirmation operation for the current natural language message. The execution entity will immediately collect two parts of data: first, the complete natural language message already generated on the interface; and second, the full contextual business data associated with the current interactive target element, including associated metrics, historical data, business rules, and parameters of similar elements. All data is then uniformly input into the large language model. The model, combining user requests, attribute information, and business logic, optimizes and rewrites the rendering rules, interaction logic, data calculation, and display logic of the original visualization code, ultimately generating and outputting a new version of the target code with updated functionality and performance.

[0140] It should be noted that the host web system listens for callback messages sent by the visual artifacts using `window.addEventListener('message',...)`, and supports two injection modes: Confirmation mode: The user fills in the input box and focuses on it, then manually sends the message after reviewing the content (to prevent accidental touches; this is the default mode); Automatic mode: The user directly calls `sendMsg()` to send the message, suitable for low-risk query scenarios. The choice between these two injection methods depends on the specific circumstances.

[0141] Step 712: Render the new target code and display the rendered result in the embedded window.

[0142] In this embodiment, the aforementioned execution entity loads the new version of the target code output by the large model and performs rendering. Following a preset rendering strategy, it completes data calculations, chart drawing, and interactive logic initialization, generating an updated visualization interface. Subsequently, the new display results are synchronously loaded into the embedded window of the front-end page, replacing the original content, allowing users to view the actual presentation effect after the code iteration.

[0143] from Figure 7 It can be seen from this that, with Figure 6 Compared to the corresponding embodiments, the code generation method based on the large language model in this embodiment emphasizes the steps of user interaction with the visualization results and automatically generating and rendering new target code based on the interaction. By injecting a standardized Agent callback interface into the generated code product, the visualization product has the dual ability to display and trigger the next round of Agent commands. This solves the problem in the prior art where users have to manually leave the visualization interface, return to the dialog box, describe what they see in natural language and ask questions after observing data anomalies, resulting in an interaction gap between the LLM product and user perception. This improves the user experience and operational efficiency.

[0144] Continue to refer to Figure 8 , Figure 8 A flow 800 of a sixth embodiment of the code generation method based on a large language model according to the present disclosure is shown. This code generation method based on a large language model includes the following steps: Step 801: Determine the business entity information based on the input requirement information.

[0145] In this embodiment, the execution entity of the code generation method based on the large language model (e.g.) Figure 1 The server 105 shown will parse the user's input requirements to extract business entity information and clarify the core objects and business scope. For example, if the user inputs "Optimize the workshop equipment heat map, investigate high-load periods and provide a scheduling plan", the above-mentioned execution entity will parse the requirements to extract business entity information such as workshop equipment, heat map, load data, and time period scheduling.

[0146] Step 802: Match the business entity information with the preset business scenarios, and determine the target business scenario based on the matching results.

[0147] In this embodiment, the aforementioned execution entity will match the extracted business entity information one by one with the keywords corresponding to the preset business scenario, and then determine the target business scenario based on the matching results. That is, if the business entity information is successfully matched with the keywords corresponding to the preset business scenario, the business scenario corresponding to the successfully matched keywords will be determined as the target business scenario.

[0148] By parsing the requirements to extract business entities and then matching them with preset scenarios, the corresponding business scenarios can be quickly and accurately located.

[0149] Step 803: Determine the target data table corresponding to the target business scenario from the pre-built business database.

[0150] In this embodiment, the execution entity determines the target data table corresponding to the target business scenario from a pre-built business database. The business database contains business data tables corresponding to all business scenarios. That is, the execution entity retrieves data from the business database based on the determined target business scenario, thereby matching and filtering out the data table specific to that scenario, and designating it as the target data table for subsequent data reading, processing, and display.

[0151] Step 804: Determine the data fields to be extracted based on the input requirements; retrieve the data corresponding to the data fields to be extracted from the target data table.

[0152] In this embodiment, the aforementioned execution entity deeply analyzes the user's input requirements, accurately breaks down business needs and analytical dimensions, and accordingly identifies all the core data fields to be extracted for the current business. Subsequently, the execution entity locates the matched target business data table, filters and batch retrieves the complete original business data corresponding to all fields to be extracted, completing accurate data collection and extraction.

[0153] Step 805: Perform data verification and cleaning on the acquired data to obtain the target business data.

[0154] In this embodiment, the aforementioned execution entity will conduct standardized verification and cleaning of the extracted raw data, checking the data integrity, field validity, numerical rationality, and time dimension consistency one by one, removing missing values, duplicate data, and abnormal dirty data, correcting non-standard format content, completing data regularization and noise reduction, and finally outputting standardized target business data.

[0155] This allows for matching and locating data tables based on the scenario, extracting data from specified fields as needed, and then filtering and cleaning to remove abnormal, missing, and duplicate content, ensuring the accuracy and standardization of the data.

[0156] Step 806: Determine the target code skeleton corresponding to the target business scenario from the pre-generated code skeleton set.

[0157] Step 807: Fill the target business data into the target code skeleton to generate runnable target code.

[0158] Steps 806-807 are basically the same as steps 203-204 in the aforementioned embodiments. For specific implementation methods, please refer to the aforementioned description of steps 203-204, which will not be repeated here.

[0159] from Figure 8 It can be seen from this that, with Figure 2 Compared to the corresponding embodiments, the code generation method based on a large language model in this embodiment emphasizes the steps of determining the target business scenario and the target business data, thereby realizing a standardized flow from requirement analysis to data output. By analyzing the requirements, the business entity and corresponding scenario are locked, the data table is located and field data is extracted as needed, and then the data is verified, cleaned and purified. The whole process is logically clear and targeted, which not only improves the efficiency of data retrieval but also ensures data quality.

[0160] For example, the complete interaction flow of a user using the above code generation method based on a large language model is as follows: (1) The user inputs an industrial scenario question into the Famou Agent: "Help me analyze the scheduling delay situation this week"; (2) The Agent calls the specification document and skeleton constraints to generate a visual HTML and writes it into the session workspace; (3) The host UI detects HTML artifacts and displays them below the dialogue message. <iframe>Inline rendering; (4) Users can directly observe and manipulate visual content within the iframe; If a user clicks on the Gantt chart task bar, a side panel pops up, displaying task details, preceding / following process chains, and a "Ask AI" button; If a user clicks on the overload cell (load ≥ 90%) on the heatmap, the overload will be automatically identified, and an analysis request containing the overload threshold and load rate will pop up. If a user clicks the "Ask AI" button for the logistics route, they can provide the complete route context (vehicle, stops, mileage, ETA, cargo). (5) When the user clicks the "Ask AI" button, the iframe sends a callback message to the parent window via postMessage; (6) The host UI receives the message, fills the automatically generated message text into the input box and focuses on it, and sends it after the user confirms; (7) The Agent receives the structured instructions, completes the analysis or rearrangement, generates a new visualization product, re-renders, and repeats the process until step 3.

[0161] As can be seen, users do not need to manually describe what they see. The structured context is automatically assembled by the product, achieving zero-loss transmission. Moreover, the confirmation mode retains the user's initiative and prevents accidental touches.

[0162] For example, in one application scenario, the application scenario is a factory scheduling delay scenario, that is, the background of the embodiment is: a certain injection molding factory has 3 machines (CNC-01, CNC-02, welding station), and there are 5 processes to be scheduled this week, of which process P-004 has a risk of delay, and P-002 is a VIP urgent order. The user wants to analyze the reasons and obtain rescheduling suggestions.The specific interaction process is as follows: Phase 1: LLM generates high-quality visualization outputs. Step 1: The user enters "Help me analyze this week's schedule, which processes are at risk of delay?"; Step 2: Before calling LLM to generate code, the system simultaneously injects the specification document (containing multiple constraint rules) and the reference skeleton of the Gantt heatmap scenario into the LLM context; Step 3: The LLM generates the HTML code file gantt_chart.html under the constraints; Step 4: The generated HTML file is written to the session's workspace; Phase Two: Host UI Rendering Outputs Step 5: The host UI detects that the artifacts field of the assistant message contains gantt_chart.html, and renders it below the message bubble; Step 6: The user sees that the P-004 task bar in the Gantt chart is orange (warning status) and the P-002 task bar is red (VIP); the heat map tab shows that the CNC-02 load reached 95% between 10:00 and 13:00, exceeding the overload threshold (90%). Phase 3: User actions trigger Agent callbacks; Step 7: When the user clicks the P-004 taskbar, the JavaScript within the iframe executes the click handling function, popping up the process chain side panel, which displays: Task P-004: CNC-02, 10:30~13:00, risk of delay; Pre-processing: P-003 (CNC-02, 08:00~10:30, completed); Subsequent procedures: None; Button: "Ask AI Analysis / Rearrangement"; Step 8: The user clicks the "Ask AI" button. The click handling function within the iframe automatically assembles the message as follows: Task 'P-004' is scheduled for CNC-02, time: 10:30~13:00, status: risk of delay.

[0163] Pre-process: P-003 (completed, ended at 10:30); no subsequent processes.

[0164] Please analyze whether this arrangement is reasonable, or suggest a rearrangement.

[0165] Step 9: The iframe sends a callback message to the parent window via window.parent.postMessage(); Step 10: The host UI's message event listener receives the message, writes the message field into the input box, and focuses it (confirmation mode). The user sees that the input box has been pre-filled with the analysis request, verifies the content, and presses Enter to send.

[0166] Phase 4: Agent Decision-making and New Round of Visualization:Step 11: The LLM Agent receives the structured instruction and analyzes that P-004 should be advanced to 08:00 - 10:30, and P-003 is moved to the afternoon. Generate a new gantt_chart.html after rearrangement (using the baseline_tasks field to overlay the original plan with a gray bottom bar)Step 12: The host UI renders a new Gantt chart iframe below the new round of assistant messages. The user can see the comparison effect and can continue to click on the task bars in the new chart for the next round of interaction.

[0167] Further referring to Figure 9, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a code generation device based on a large language model. This device embodiment corresponds to the method embodiment shown in Figure 2, and this device can be specifically applied to various electronic devices.

[0168] As shown in Figure 9, the code generation device 900 based on a large language model in this embodiment includes: a scenario determination module 901, a data determination module 902, a skeleton determination module 903, and a code generation module 904. Among them, the scenario determination module 901 is configured to determine the target business scenario according to the input requirement information; the data determination module 902 is configured to determine the target business data corresponding to the input requirement information; the skeleton determination module 903 is configured to determine the target code skeleton corresponding to the target business scenario from the pre-generated code skeleton set; the code generation module 904 is configured to fill the target business data into the target code skeleton to generate a runnable target code.

[0169] In this embodiment, in the code generation device 900 based on the large language model: for the specific processing of the scenario determination module 901, data determination module 902, skeleton determination module 903, and code generation module 904 and the technical effects brought by them, reference can be made to the relevant descriptions of steps 201-204 in the corresponding embodiment of Figure 2, which will not be elaborated here.

[0170] In some optional implementation manners of this embodiment, the above-mentioned code generation device 900 based on the large language model further includes a code skeleton generation module for generating the code skeletons in the code set. The code skeleton generation module includes: a fault sample determination sub-module configured to determine fault code samples from the historical code library, where the fault code samples are code samples that have faults during runtime; an analysis sub-module configured to analyze the fault phenomena of the fault code samples and determine the root causes of the faults according to the analysis results; a clustering and division sub-module configured to perform clustering and division on all the root causes of the faults to generate multiple fault categories; a rule addition sub-module configured to add the constraint rules corresponding to each fault category to the business basic skeletons corresponding to different business scenarios to obtain the code skeletons corresponding to different business scenarios.

[0171] In some optional implementation manners of this embodiment, the above-mentioned code generation device 900 based on the large language model further includes a basic skeleton generation module for generating business basic skeletons. The basic skeleton generation module is configured to: for any business scenario, determine the business requirements of the business scenario and construct the business modules corresponding to the business scenario according to the business requirements; encapsulate the business modules and the general code modules to obtain the business basic skeletons corresponding to the business scenario; bind the scenario identifier of the business scenario to the business basic skeletons.

[0172] In some optional implementation manners of this embodiment, the rule addition sub-module is further configured to: determine the constraint rules corresponding to the fault categories, where the constraint rules include: natural language descriptions and code examples; add the constraint rules corresponding to each fault category to the business basic skeletons corresponding to different business scenarios to obtain the added skeletons corresponding to different business scenarios; for each business scenario, in response to determining that the added skeleton corresponding to the business scenario passes the runnability verification, determine the added skeleton as the code skeleton corresponding to the business scenario.

[0173] In some optional implementations of this embodiment, the skeleton determination module is further configured to: determine the scene identifier of the target business scenario; determine the code skeleton corresponding to the scene identifier from the code skeleton set to obtain the target code skeleton.

[0174] In some optional implementations of this embodiment, the code generation module is further configured to: input the target business data and the target code skeleton into the large model, so that the large model fills the target business data into the data placeholder area of ​​the target code skeleton according to the preset field mapping rules, and outputs the filled code; determine the target rendering strategy according to the data volume of the target business data; add the target rendering strategy to the filled code to obtain the target code.

[0175] In some optional implementations of this embodiment, the above-mentioned code generation device 900 based on a large language model further includes: a visualization result display module, configured to: detect the code writing specifications of the target code according to a predefined regular rule library to obtain static detection results; start a headless browser to run the target code, detect the running status of the target code to obtain dynamic detection results; in response to determining that both the static detection results and the dynamic detection results are passed, render the target code according to the target rendering strategy, generate visualization results, and display the visualization results in an embedded window of the front-end page.

[0176] In some optional implementations of this embodiment, the above-mentioned code generation device 900 based on a large language model further includes: a code repair module, configured to: in response to determining that either the static detection result or the dynamic detection result is a failed detection, determine the abnormal information of the failed detection; input the abnormal information into the large model so that the large model repairs the target code according to the abnormal information and outputs the repaired target code.

[0177] In some optional implementations of this embodiment, the code generation device 900 based on the large language model further includes: an interaction module, comprising: an element determination submodule, configured to determine the target element of the interaction operation in response to detecting an interaction operation on the visualization result; a message generation submodule, configured to generate a natural language message based on the attribute information of the target element and display the natural language message in the dialog box area of ​​the front-end page; a code generation submodule, configured to input the natural language message and the contextual business data of the target element into the large model in response to detecting a confirmation operation on the natural language message and output new target code; and a rendering and display submodule, configured to render the new target code and display the rendered result in an embedded window.

[0178] In some optional implementation manners of this embodiment, the message generation sub-module is further configured to: extract attribute information according to the element index of the target element, where the attribute information includes: spatio-temporal attribute information, status attribute information, and scenario attribute information; determine the target interaction intention according to the target element and the target business scenario; fill the attribute information into the speech template corresponding to the target interaction intention to generate a natural language message.

[0179] In some optional implementation manners of this embodiment, the scenario determination module is further configured to: determine business entity information based on the input requirement information; match the business entity information with the preset business scenarios, and determine the target business scenario according to the matching result.

[0180] In some optional implementation manners of this embodiment, the data determination module is further configured to: determine the target data table corresponding to the target business scenario from the pre-constructed business database, where the business database contains business data tables corresponding to all business scenarios; determine the data fields to be extracted according to the input requirement information; obtain the data corresponding to the data fields to be extracted from the target data table; perform data verification and cleaning on the obtained data to obtain the target business data.

[0181] According to the embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0182] Figure 10 shows a schematic block diagram of an exemplary electronic device 1000 that can be used to implement the embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processors, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0183] Figure 10 shows a schematic block diagram of an exemplary electronic device 1000 that may be used to implement embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, a laptop computer, a desktop computer, a workbench, a personal digital assistant, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as, a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely exemplary and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0184] As shown in Figure 10, the electronic device 1000 includes a computing unit 1001 that can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the electronic device 1000 are also stored. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0185] A plurality of components in the electronic device 1000 are connected to the I / O interface 1005, including: an input unit 1006, such as a keyboard, a mouse, etc.; an output unit 1007, such as various types of displays, speakers, etc.; a storage unit 1008, such as a magnetic disk, an optical disc, etc.; and a communication unit 1009, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1009 allows the electronic device 1000 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0186] The computing unit 1001 may be various general and / or special processing components having processing and computing capabilities.Examples of computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Computing unit 1001 performs the various methods and processes described above, such as a code generation method based on a large language model. For example, in some embodiments, the code generation method based on a large language model may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 1000 via ROM 1002 and / or communication unit 1009. When the computer program is loaded into RAM 1003 and executed by computing unit 1001, one or more steps of the code generation method based on a large language model described above may be performed. Alternatively, in other embodiments, computing unit 1001 may be configured to perform the code generation method based on a large language model by any other suitable means (e.g., by means of firmware).

[0187] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SOCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0188] Program code for implementing the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus such that, when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0189] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0190] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0191] The systems and techniques described herein can be implemented in computing systems that include back-end components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with embodiments of the systems and techniques described herein), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0192] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps.For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this document does not impose any restrictions.

[0193] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.< / iframe>

Claims

1. A code generation method based on a large language model, comprising: Determine the target business scenario based on the input requirements information; Determine the target business data corresponding to the input requirement information; The target code skeleton corresponding to the target business scenario is determined from the pre-generated set of code skeletons; The target business data is filled into the target code skeleton to generate runnable target code.

2. The method according to claim 1, wherein, The code skeletons in the code skeleton set are generated through the following steps: Identify faulty code samples from the historical code repository, wherein the faulty code samples are code samples that fail during runtime; The fault symptoms of the fault code samples are analyzed, and the root cause of the fault is determined based on the analysis results. All root causes of failures are clustered and divided to generate multiple failure categories; The constraint rules corresponding to each fault category are added to the basic business skeleton corresponding to different business scenarios to obtain the code skeleton corresponding to different business scenarios.

3. The method according to claim 2, wherein, The basic business framework is generated through the following steps: For any given business scenario, determine the business requirements for that scenario, and construct the corresponding business module based on those requirements. The business module is encapsulated with the general code module to obtain the basic business skeleton corresponding to the business scenario; The scenario identifier of the business scenario is bound to the basic business framework.

4. The method according to claim 2, wherein, The step of adding the constraint rules corresponding to each fault category to the basic business skeleton corresponding to different business scenarios to obtain the code skeleton corresponding to different business scenarios includes: Determine the constraint rules corresponding to the fault category, wherein the constraint rules include: natural language description and code examples; Each fault category's corresponding constraint rules are added to the business basic skeleton corresponding to different business scenarios, resulting in the added skeletons for the different business scenarios. For each business scenario, in response to the determination that the added skeleton corresponding to the business scenario has passed the runnability verification, the added skeleton is determined as the code skeleton corresponding to the business scenario.

5. The method according to claim 3, wherein, Determining the target code skeleton corresponding to the target business scenario from a pre-generated set of code skeletons includes: Determine the scene identifier of the target business scenario; The target code skeleton is obtained by determining the code skeleton corresponding to the scene identifier from the set of code skeletons.

6. The method according to claim 1, wherein, The step of filling the target business data into the target code skeleton to generate runnable target code includes: The target business data and the target code skeleton are input into the large model, so that the large model fills the data placeholder area of ​​the target code skeleton with the target business data according to the preset field mapping rules, and outputs the filled code; The target rendering strategy is determined based on the amount of data in the target business data. The target rendering strategy is added to the filled code to obtain the target code.

7. The method according to claim 6, further comprising: The code writing style of the target code is detected based on a predefined regular expression rule library to obtain static detection results; Launch a headless browser to run the target code, detect the running status of the target code, and obtain dynamic detection results; In response to determining that both the static detection result and the dynamic detection result are passed, the target code is rendered according to the target rendering strategy, a visualization result is generated, and the visualization result is displayed in an embedded window of the front-end page.

8. The method according to claim 7, further comprising: In response to determining that either the static detection result or the dynamic detection result is a failed detection, an abnormal information for the failed detection is determined; The anomaly information is input into the large model so that the large model can repair the target code based on the anomaly information and output the repaired target code.

9. The method according to claim 7, further comprising: In response to detecting an interactive action on the visualization result, the target element targeted by the interactive action is determined; A natural language message is generated based on the attribute information of the target element, and the natural language message is displayed in the dialog box area of ​​the front-end page; In response to the detection of an acknowledgment operation for the natural language message, the natural language message and the contextual business data of the target element are input into the large model, and a new target code is output. The new target code is rendered, and the rendered result is displayed in the embedded window.

10. The method according to claim 9, wherein, The step of generating a natural language message based on the attribute information of the target element includes: The attribute information is extracted based on the element index of the target element, wherein the attribute information includes: spatiotemporal attribute information, state attribute information, and scene attribute information; Determine the target interaction intent based on the target element and the target business scenario; The attribute information is filled into the speech template corresponding to the target interaction intent to generate the natural language message.

11. The method according to claim 1, wherein, The step of determining the target business scenario based on input requirement information includes: Determine the business entity information based on the input requirement information; The business entity information is matched with a preset business scenario, and the target business scenario is determined based on the matching result.

12. The method according to claim 11, wherein, Determining the target business data corresponding to the input requirement information includes: The target data table corresponding to the target business scenario is determined from a pre-built business database, wherein the business database contains business data tables corresponding to all business scenarios; The data fields to be extracted are determined based on the input requirements information; Retrieve the data corresponding to the data field to be extracted from the target data table; The acquired data is validated and cleaned to obtain the target business data.

13. A code generation device based on a large language model, comprising: The scenario determination module is configured to determine the target business scenario based on the input requirement information; The data determination module is configured to determine the target business data corresponding to the input requirement information; The skeleton determination module is configured to determine the target code skeleton corresponding to the target business scenario from a pre-generated set of code skeletons; The code generation module is configured to fill the target business data into the target code skeleton to generate runnable target code.

14. An electronic device comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-12.

15. A non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-12.

16. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-12.