Form generation method, form generation system, storage medium, and program product

CN121680850BActive Publication Date: 2026-09-25NEXCHIP SEMICON CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202610203763.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-02-12
Publication Date
2026-09-25
Estimated Expiration
2046-02-12

AI Technical Summary

Technical Problem

[0004]然而,针对半导体制造等内部生产管理流程较为精密复杂的企业环境,在将大语言模型应用于表单开发的过程中,研究人员发现,大语言模型直接输出的表单实现代码或直接生成的表单难以满足企业生产管理的实际要求,需要耗费大量人力成本和时间成本对大语言模型的输出进行二次开发和适配修改,导致表单开发效率降低

Benefits of technology

[0016]在本申请提供的多个实施例中,基于获取的表单生成指令,调用大语言模型执行上下文推理,从表单知识库中抽取与表单生成指令相匹配的前端组件和后端服务信息作为上下文数据,接着基于表单生成指令、前次上下文推理输出的上下文数据和表单知识库,调用大语言模型执行开发规范推理,确定表单开发规范,随后基于上下文数据和前次开发规范推理输出的表单开发规范,调用大语言模型执行表单生成需求转换推理,将表单生成指令转换为表单生成提示词,最终将前次表单生成需求转换推理输出的表单生成提示词输入大语言模型,调用其执行代码生成推理,生成包含对应前端组件的前端代码、对应后端服务信息的后端代码以及用于关联前端代码和后端代码且符合表单开发规范的连接代码的表单代码,实现的意想不到的效果包括:由于以表单知识库作为大语言模型推理的基础,在每次推理过程中采用思维链提升大语言模型的推理能力,并且,除上下文推理外,大语言模型执行的每次推理的输入至少包括前次推理的输出,使得大语言模型的输出更贴近企业实际表单需求,从而减少了针对大语言模型的输出进行人工修改的工作量,提升了表单开发效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121680850B_ABST
    Figure CN121680850B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a form generation method, a form generation system, a storage medium and a program product. The form generation method comprises the following steps: based on the obtained form generation instruction, calling a large language model to perform context reasoning, and extracting context data related to the form generation instruction from a form knowledge base; based on the form generation instruction, the context data and the form knowledge base, calling the large language model to perform development specification reasoning, and determining a form development specification matched with the form generation instruction; based on the context data and the form development specification, calling the large language model to perform form generation requirement conversion reasoning, and converting the form generation instruction into a form generation prompt word; inputting the form generation prompt word into the large language model, calling the large language model to perform code generation reasoning, and generating a form code used for realizing the function described by the form generation instruction. Through the embodiment of the application, the form development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments in this application relate to the field of artificial intelligence technology, specifically to a form generation method, a form generation system, a storage medium, and a program product. Background Technology

[0002] With the digital and intelligent transformation and upgrading of the semiconductor manufacturing industry, forms, as a core tool for semiconductor device production management, directly impact the production and operational efficiency of semiconductor device manufacturers. Because form functionality is closely related to an enterprise's internal production, operational, and management processes, form development faces multiple challenges, including high complexity, high flexibility, and strong confidentiality requirements.

[0003] To address these challenges and reduce form development costs, researchers have attempted to leverage Large Language Models (LLMs) to assist in form development tasks. By utilizing the natural language understanding and coding capabilities of LLMs, the form development process can be simplified, reliance on manual coding can be reduced, and the form development speed can be accelerated.

[0004] However, in enterprise environments with sophisticated and complex internal production management processes, such as semiconductor manufacturing, researchers have found that when applying large language models to form development, the form implementation code directly output by the large language models or the forms directly generated are difficult to meet the actual requirements of enterprise production management. A lot of manpower and time costs are required to carry out secondary development and adaptation modifications to the output of the large language models, resulting in reduced form development efficiency. Summary of the Invention

[0005] In view of this, several embodiments of this application provide a form generation method, a form generation system, a storage medium, and a program product to improve the matching degree between the forms or code directly output by the large language model and the actual needs of enterprises, and to improve the efficiency of form development.

[0006] In one aspect, an embodiment of this application provides a form generation method, comprising: based on an acquired form generation instruction, invoking a large language model to perform contextual reasoning, extracting contextual data related to the form generation instruction from a form knowledge base; wherein the contextual data includes front-end component and back-end service information matching the form generation instruction; based on the form generation instruction, the contextual data, and the form knowledge base, invoking the large language model to perform development specification reasoning, determining a form development specification matching the form generation instruction; based on the contextual data and the form development specification, invoking the large language model to perform form generation requirement transformation reasoning, converting the form generation instruction into a form generation prompt; inputting the form generation prompt into the large language model, invoking the large language model to perform code generation reasoning, generating form code for implementing the function described by the form generation instruction; wherein the form code includes front-end code corresponding to the front-end component, back-end code corresponding to the back-end service information, and connection code for associating the front-end code and the back-end code and conforming to the form development specification.

[0007] Optionally, the form knowledge base stores historical form code; wherein the historical form code includes historical front-end component code, historical back-end service code, and historical form development framework code; the form generation method further includes: performing code preference analysis and semantic analysis on the historical form code based on an abstract syntax tree parsing algorithm to obtain the code dependency relationships between the historical front-end component code, the historical back-end service code, and the historical form development framework code; constructing a directed acyclic graph of the code dependency relationships; performing topological sorting on the directed acyclic graph based on an improved Kahn algorithm to obtain the topological order of the code dependency relationships; and storing the directed acyclic graph and the topological order of the code dependency relationships into the form knowledge base.

[0008] Optionally, the code dependencies include implementation dependencies, contract dependencies, and definition dependencies.

[0009] Optionally, the historical front-end component code includes historical front-end component implementation code and historical front-end component description code; the historical form development framework code includes historical form development template code and historical form development implementation code; based on the abstract syntax tree parsing algorithm, code preference analysis and semantic analysis are performed on the historical form code, including: using the historical form development template code as input, executing the abstract syntax tree parsing algorithm to achieve the code preference analysis; using the historical front-end component description code as input, executing the abstract syntax tree parsing algorithm to achieve the semantic analysis.

[0010] Optionally, the step of invoking a large language model to perform contextual reasoning based on the acquired form generation instruction and extracting contextual data related to the form generation instruction from the form knowledge base includes: retrieving multiple retrieval contextual data from the form knowledge base according to similarity retrieval rules based on the form generation instruction; filtering candidate contextual data from the multiple retrieval contextual data according to the directed acyclic graph; recalling dependent contextual data that have code dependencies on the candidate contextual data from the form knowledge base according to the directed acyclic graph; and sorting the candidate contextual data and the dependent contextual data according to the topological order of the code dependencies to obtain the contextual data.

[0011] Optionally, the form generation method further includes: receiving form development requirement data input by a user; wherein the form development requirement data includes unstructured data or semi-structured data; extracting content from the form development requirement data to obtain form function description data; inputting the form function description data into a pre-trained named entity recognition model, and calling the named entity recognition model to output the form generation instruction; wherein the form generation instruction is structured data; and pre-training the named entity recognition model using data in the form knowledge base.

[0012] Optionally, after generating the form code, the form generation method further includes: repeatedly executing the following sub-steps until the form code passes evaluation; the sub-steps include: based on the form generation instruction, the context data, and the form development specification, calling the large language model to perform code evaluation reasoning, performing functional evaluation on the form code, and obtaining an evaluation result; if the evaluation result does not meet the pass evaluation conditions, based on the evaluation result, calling the large language model to generate a correction instruction for the form code; based on the correction instruction, calling the large language model to re-execute at least one of the context reasoning, the development specification reasoning, the form generation requirement transformation reasoning, and the code generation reasoning, and updating the form code.

[0013] In another aspect, one embodiment of this application provides a form generation system, comprising: a context extraction layer, configured to extract context data related to the form generation instruction from a form knowledge base by invoking a large language model based on an acquired form generation instruction; the context data includes front-end components and back-end service information matching the form generation instruction; a development specification determination layer, configured to determine a form development specification matching the form generation instruction by invoking the large language model based on the form generation instruction, the context data, and the form knowledge base; a prompt word conversion layer, configured to convert the form generation instruction into a form generation prompt word by invoking the large language model based on the context data and the form development specification; and a code generation layer, configured to input the form generation prompt word into the large language model and invoking the large language model to generate form code for implementing the function described by the form generation instruction; wherein the form code includes front-end code corresponding to the front-end component, back-end code corresponding to the back-end service information, and connection code for associating the front-end component and the back-end service information and conforming to the form development specification.

[0014] In another aspect, one embodiment of this application provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the form generation method or form generation system as described in the above embodiments.

[0015] In another aspect, one embodiment of this application provides a computer program product including a computer program or computer executable instructions, which, when executed by a processor in an electronic device, implement the form generation method or form generation system as described in the above embodiments.

[0016] In several embodiments provided in this application, based on the acquired form generation instructions, a large language model is invoked to perform contextual reasoning. Front-end component and back-end service information matching the form generation instructions is extracted from the form knowledge base as context data. Then, based on the form generation instructions, the context data output from the previous contextual reasoning, and the form knowledge base, the large language model is invoked to perform development specification reasoning to determine the form development specifications. Subsequently, based on the context data and the form development specifications output from the previous development specification reasoning, the large language model is invoked to perform form generation requirement transformation reasoning, converting the form generation instructions into form generation prompts. Finally, the form generation prompts output from the previous form generation requirement transformation reasoning are input into the large language model. The model calls its execution code to generate inference, producing form code containing front-end code for corresponding front-end components, back-end code for corresponding back-end service information, and connection code that associates the front-end and back-end code and conforms to form development specifications. Unexpected effects include: using a form knowledge base as the basis for the large language model's inference; employing thought chains to enhance the large language model's inference capabilities during each inference process; and ensuring that, in addition to contextual inference, each inference performed by the large language model includes at least the output of the previous inference, making the large language model's output closer to the actual form requirements of enterprises. This reduces the workload of manually modifying the large language model's output and improves form development efficiency. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in describing the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 A flowchart illustrating the execution process of manually developing forms for related technologies.

[0019] Figure 2 This is a schematic diagram illustrating the execution flow of the large language model-assisted form development process provided in the embodiments of this application.

[0020] Figure 3 This is a flowchart illustrating the form generation method provided in an embodiment of this application.

[0021] Figure 4 This is a schematic diagram of the architecture of the form knowledge base provided in the embodiments of this application.

[0022] Figure 5 This is a schematic diagram illustrating the process of storing a directed acyclic graph of code dependencies and topological order into a form knowledge base, as provided in an embodiment of this application.

[0023] Figure 6 This is a flowchart illustrating the process of converting user-inputted form development requirement data into form generation instructions, as provided in an embodiment of this application.

[0024] Figure 7 This is a schematic diagram illustrating the process of calling a large language model to perform contextual reasoning and extracting contextual data related to form generation instructions from a form knowledge base, as provided in an embodiment of this application.

[0025] Figure 8 This is a schematic diagram illustrating the process of evaluating the form code output by a large language model, as provided in an embodiment of this application.

[0026] Figure 9 This is a schematic diagram illustrating the implementation process of the form generation method provided in this application embodiment.

[0027] Figure 10 This is a schematic diagram of a form generation system provided in an embodiment of this application. Detailed Implementation

[0028] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.

[0029] The accompanying drawings provided in this application are only schematic illustrations of the basic concept of this application. The drawings only show the components related to this application and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the shape, quantity and proportion of each component may be changed, and the layout of the components may also be more complex.

[0030] In the description of the embodiments of this application, it should be understood that the terms "upper," "lower," "left," "right," "vertical," "horizontal," "inner," "outer," "center," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this application, and do not indicate or imply that the device or component referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first" and "second" may explicitly or implicitly include one or more of the stated features.

[0031] In related technologies, due to limitations of early development technologies, the technical frameworks upon which forms in some enterprise internal management systems are based have low compatibility and face the risk of technological obsolescence. For example, most forms currently used by some enterprises are developed based on the .NET 2.0 framework. These forms are only compatible with Internet Explorer browsers and have difficulty being compatible with browsers such as Microsoft Edge, Google Chrome, Mozilla, and Firefox. With technological iterations, the compatibility mode of Internet Explorer browsers will soon be discontinued. To maintain enterprise production and operation management, these forms need to be redeveloped to adapt to the current technical framework.

[0032] Please see Figure 1 In related technologies, the specific execution process for manually redeveloping forms is as follows.

[0033] First, form designers, based on the functions of the rewritten form and the needs of the enterprise's internal production, operation, and management, formulate form development requirements, including form design documents and user interface (UI) prototypes, and provide these requirements to form developers.

[0034] After receiving the form development requirements, the form developers, with the assistance of the code development system, generate form code that implements the functions described in the form development requirements, and then provide the generated form code to the form testers.

[0035] Upon receiving the form code, form testers perform unit function testing and overall function testing. If the form code passes the tests, it is deployed to the enterprise's internal management system for use. If the form code fails the tests, the test results are fed back to the form developers, who then modify and adjust the form code based on the results. The form testers then test the modified form code again, and this process is repeated until the form code passes the tests.

[0036] Redeveloping forms through the aforementioned manual process results in low overall development efficiency, with each form requiring significant manpower and time costs. For example, if 114 forms need to be redeveloped, and the average manpower cost per form from redevelopment to successful deployment is 30 person-days, then the company would need to pay a total cost of 3420 person-days for form redevelopment.

[0037] To improve form development efficiency, researchers have attempted to introduce large language models to assist in generating form code, thereby leveraging the semantic understanding and coding capabilities of large language models to reduce the time required for form developers.

[0038] Please see Figure 2 The main difference between the execution process of form redevelopment assisted by a large language model and that of manual form redevelopment lies in the form code generation stage. Specifically, the large language model can first generate basic form code based on the form development requirements, which can basically achieve the functions described in the form development requirements. Then, form developers modify and complete the basic form code according to the company's internal coding style and standards, forming the final form code. This significantly reduces the workload of form developers during the form redevelopment process.

[0039] However, after researchers applied the large language model to the form redevelopment process, they found that the initial form code output by the large language model was difficult to adapt to the enterprise's internal management system, and the improvement in form development efficiency was relatively limited.

[0040] Further investigation reveals that large language models are typically used as general-purpose code generation tools. However, in the process of outputting basic form code using large language models, these models lack understanding and application of front-end and back-end knowledge data, such as user interface components and Application Programming Interfaces (APIs), as well as internal coding standards data from historical enterprise forms. Furthermore, researchers struggle to effectively control the output of large language models, forcing form developers to spend considerable time refining and integrating the basic form code directly output by the model to ensure it passes code testing.

[0041] Therefore, it is necessary to provide a form generation method and system that controls a large language model to directly output form code adapted to the enterprise's internal management system based on the enterprise's historical front-end and back-end knowledge data and internal code specification data, thereby improving form development efficiency.

[0042] Please see Figure 3 One embodiment of this application provides a form generation method. The form generation method may include steps S110, S120, S130, and S140.

[0043] S110: Based on the obtained form generation instructions, call the large language model to perform contextual reasoning and extract contextual data related to the form generation instructions from the form knowledge base.

[0044] To anchor the attention of the large language model within the scope of the form knowledge base that has been manually checked and verified, and to generate form code based on knowledge data (rather than general code) that conforms to the enterprise's internal coding standards, thereby improving the adaptability of the form code to the enterprise's internal management system, the large language model can be called to extract relevant contextual data from the form knowledge base based on the form generation instructions. This data can then be directly "reused" and "assembled" in the subsequent form code generation process.

[0045] In this embodiment, the form generation instruction can be a natural language statement or a structured command used to describe the form's functionality. Specifically, the form generation instruction may include a prototype diagram of the form's user interface and a form design file describing the functions of each interface component in the prototype diagram and the associated data of the interface components. Alternatively, the form generation instruction may only include a natural language description of the form's functionality. For example, the form generation instruction could be "Create a form for crystal boat loading registration, which needs to implement the following functions: display work order number, select equipment, and fill in operator signature."

[0046] In this embodiment, the large language model can be an artificial intelligence model that has been pre-trained on a large corpus, possesses deep learning capabilities, and is capable of understanding and generating natural language and program code. Specifically, before executing the form generation method, a form knowledge base can be provided to the general large language model for learning. That is, the general large language model is fine-tuned based on the form knowledge base to obtain the large language model, thereby leveraging the semantic understanding, analysis, reasoning, and code generation capabilities of the large language model to assist in generating form code.

[0047] To enhance the confidentiality of internal enterprise information, in this embodiment, the large language model can be deployed on a local server, and tasks can be executed by calling the general large language model through a local interface. For example, the general large language model deployed on the local server can be at least one of DeepSeek R1 671B, Qwen3 480B, and Devstral-Small-2507 24B.

[0048] In this embodiment, contextual reasoning can be the thought process of a large language model analyzing the knowledge data stored in the form knowledge base based on the input form generation instruction, following the "Chain of Thought (CoT)" logic of "question-thinking process-answer", and retrieving and filtering the knowledge data to determine the set of knowledge data most relevant to the form generation task indicated by the form generation instruction.

[0049] Please see Figure 4In this embodiment, the form knowledge base can store structured or unstructured knowledge data related to enterprise form development. Specifically, the form knowledge base can store two parts of knowledge data: historical form code and code dependency relationships. The specific content of each part of the knowledge data is as follows.

[0050] In this embodiment, historical form code can be a collection of source code corresponding to forms that have been developed and deployed in the enterprise's internal management system. Specifically, historical form code can include historical front-end component code, historical back-end service code, and historical form development framework code.

[0051] In this embodiment, the historical front-end component code can be the portion of historical form code used to implement user interface interaction functions. Specifically, the historical front-end component code can include historical front-end component implementation code and historical front-end component description code.

[0052] In this embodiment, the implementation code of the historical front-end components can be the source code files that constitute the main functionalities of the components in the historical form interface and can be directly executed or compiled. Specifically, the implementation code of the historical front-end components can be used to define the specific structure, style, behavioral logic, and lifecycle of the components. For example, for the "selection dropdown" component, the implementation code of the historical front-end components can be a Vue single-file component, containing... <template>Hypertext Markup Language (HTML) templates within tags <script>标签内用于数据获取和用户交互的JavaScript / TypeScript逻辑,以及<style>标签内的层叠样式表(Cascading Style Sheets,CSS)样式。

[0053] 在本实施例中,历史前端组件描述代码可以为描述历史表单界面中组件的元数据、接口契约或配置信息的代码。具体的,历史前端组件描述代码不用于直接实现组件功能,而可以用于声明组件的属性、事件、依赖关系及使用约束等特性。例如,针对"选择下拉框”组件,历史前端组件描述代码可以为JSON代码,定义了该组件需要接收的属性、会触发的事件以及其内部依赖的其他子组件或工具库。

[0054] 在本实施例中,历史后端服务代码可以为历史表单代码中用于提供数据处理、业务逻辑和数据存取的应用程序编程接口的部分代码。具体的,历史后端服务代码可以包括描述应用程序编程接口功能、调用方式与数据格式的接口契约代码。例如,针对"创建晶圆加工工单”服务,接口契约代码可以为采用C#语言编写的Swagger / OpenAPI规范描述或接口定义,以规定应用程序编程接口的路径、所需的输入参数以及成功或失败时的返回数据格式。此外,历史后端服务代码还可以包括实现上述接口契约所描述功能的业务逻辑实现代码。业务逻辑实现代码可以包括完成特定业务操作的所有算法、数据处理、数据库访问及与其他系统交互的指令。例如,同样针对"创建晶圆加工工单”服务,业务逻辑实现代码可以为实现对应接口的C#类,包含验证输入参数、在制造执行系统(Manufacturing ExecutionSystem,MES)中创建的工单记录、以及返回创建结果的具体程序逻辑等。

[0055] 在本实施例中,历史表单开发框架代码可以为企业为规范表单开发而定义的公共基础代码。具体的,历史表单开发框架代码可以为历史表单开发所依赖的、用于提供基础运行环境和通用能力的底层代码库或脚手架代码。历史表单开发框架代码可以包括历史表单开发模板代码和历史表单开发实现代码。例如,历史表单开发框架代码可以基于.NET 8架构实现,包括所有历史表单界面的基础布局模板、统一的数据状态管理库或封装有通用验证逻辑的基类。

[0056] 在本实施例中,历史表单开发模板代码可以为预定义的、用于快速初始化表单或表单模块的标准化代码结构和样式文件。具体的,历史表单开发模板代码可以为表单开发提供"填空式”开发的起点。例如,历史表单开发模板代码可以为基于Vue 3和Element Plus的"数据查询表单”的脚手架模板,其中包含有预设的目录结构、基础的表单页面组件、与后端的标准数据交互方法以及通用的样式文件。

[0057] 在本实施例中,历史表单开发实现代码可以为应用特定历史表单开发模板代码,且集成有具体业务逻辑与界面组件所形成的完整的、可运行的表单应用程序源代码。例如,历史表单开发实现代码可以为已上线运行的"数据查询表单”的完整前端代码和完整后端服务代码。

[0058] 在相关技术中,由于大语言模型的训练数据主要源于公开、通用的代码库,缺乏对企业内部知识资产(如历史表单组件、服务接口等)及隐性架构约束(如组件间的调用顺序、服务依赖等)的深度学习和理解,导致大语言模型直接输出的表单代码难以直接适配于企业内部管理系统,出现组件缺失、接口不匹配或组件调用逻辑顺序错误。

[0059] 请参阅图5。为对企业历史表单代码中隐含的、散乱的代码结构与代码依赖关系进行显式提炼,并实现显式提炼结果的结构化存储,从而为后续大语言模型的推理过程提供精准指引,提升大语言模型直接输出的表单代码的可用性,在一些实施例中,表单生成方法还可以包括步骤S101、S102和S103。

[0060] S101:基于抽象语法树解析算法,对历史表单代码进行代码偏好分析和语义分析,得到历史前端组件代码、历史后端服务代码以及历史表单开发框架代码之间的代码依赖关系。

[0061] 在本实施例中,抽象语法树(Abstract Syntax Tree,AST)解析算法可以用于将历史表单代码转换为树状数据结构,并对该树状数据结构进行分析以理解历史表单代码的语法和语义。

[0062] 为使得大语言模型能够基于历史表单代码各部分之间的替换关系、继承关系等特定依赖关系执行上下文推理过程,从而提升大语言模型从表单知识库中抽取的上下文数据在后续表单代码生成过程中的可用程度,减少表单开发人员的工作量,在本实施例中,代码依赖关系可以包括实现依赖关系、契约依赖关系和定义依赖关系。

[0063] 在本实施例中,实现依赖关系可以为代码模块或代码单元之间的类型依赖。具体的,类型依赖可以为代码模块或代码单元由于声明或使用了另一个具体类型,如类、结构体等,而产生的依赖。例如,在采用C#语言编写的代码中,若类FormA的成员变量类型声明为ServiceB,或者,类FormA的方法中创建了ServiceB的实例,则抽象语法树解析算法可以捕获此种具体类型的引用或实例化操作,并将此种引用或实例化操作标记为FormA对ServiceB的实现依赖关系,从而明确生成的表单代码中必须引用的具体实现类,使得表单代码在编译和运行过程中能够确定所有被使用的类型定义,实现各代码模块或代码单元之间的准确"组装”。

[0064] 在本实施例中,契约依赖关系可以为代码模块或代码单元之间的接口依赖。具体的,契约依赖关系可以为代码模块或代码单元由于实现或声明使用了某个接口而产生的依赖。例如,在采用C#语言编写的代码中,若类FormA实现了接口IDataValidator,则抽象语法树解析算法可以将其标记为FormA对IDataValidator的契约依赖关系,从而揭示代码模块或代码单元所需遵循的协议,增强表单代码生成的灵活性与可复用性。

[0065] 在本实施例中,定义依赖关系可以为代码模块或代码单元之间的继承关系。具体的,定义依赖关系可以为由于一个类通过继承机制派生自另一个类(基类 / 父类)而产生的依赖。例如,在采用C#语言编写的代码中,若类FormA声明其继承类FormB,则抽象语法树解析算法可以将其标记为FormA对FormB的定义依赖关系,从而确定不同代码模块或代码单元之间的层次化结构关系,提升了大语言模型生成的表单代码与历史表单代码之间的代码风格一致性与代码架构统一性。

[0066] 为提升代码依赖关系的准确性与丰富性,更好地支持表单代码生成过程中对包括历史表单代码在内的企业知识资产的"复用”,提升大语言模型直接输出的表单代码与企业内部管理系统的适配程度,在一些实施例中,基于抽象语法树解析算法,对历史表单代码进行代码偏好分析和语义分析,可以包括:以历史表单开发模板代码作为输入,执行抽象语法树解析算法,实现代码偏好分析;以历史前端组件描述代码作为输入,执行抽象语法树解析算法,实现语义分析。

[0067] 在本实施例中,代码偏好分析可以用于对代码的编写风格、命名习惯、结构模式等非功能性特征进行分析,以归纳和提取出编写历史表单代码实践中的习惯性选择与倾向。例如,代码偏好分析可以从历史表单代码中识别出使用"驼峰命名法”命名变量的倾向,或者,在表单提交前进行"双重确认”的代码风格。

[0068] 在本实施例中,代码偏好分析可以通过以下过程实现:利用抽象语法树算法将多个历史表单对应的历史表单开发模板代码解析为表单开发模板树,遍历和分析该表单开发模板树,统计和识别出多个历史表单开发模板代码在文件组织、引入依赖方式、界面结构和界面组件布局等方面的一致性特征。例如,识别出历史表单代码编码实践中倾向的界面头部(Header)和底部(Footer)的统一定义方式。

[0069] 在本实施例中,语义分析可以用于对代码中标识符的命名、注释的内容以及代码结构所表达的意图进行分析,归纳和提取出各个代码片段所表达的业务逻辑、数据流和组件间配合关系等含义。例如,语义分析可以从历史表单代码中识别出"设备选择下拉框”组件在业务逻辑中关联于"设备状态查询”的应用程序编程接口。

[0070] 在本实施例中,语义分析可以通过以下过程实现:利用抽象语法树算法将多个历史表单对应的历史前端组件描述代码解析为前端组件描述树,遍历该前端组件描述树,分析该前端组件描述树中的注释文本、接口定义、类型声明等节点,提取各个前端组件在业务逻辑中的角色、功能以及与其它组件的交互。例如,提取出"设备状态查询”、"设备状态更新”等业务逻辑语义,并明确与这些业务逻辑语义相关联的前端组件的输入输出参数的数据结构。

[0071] S102:构建代码依赖关系的有向无环图。

[0072] 为将上述利用抽象语法树算法分析得到的历史表单代码中各部分代码之间离散的、交错的代码依赖关系转化为无冲突的、可序列化的逻辑模型,可以构建代码依赖关系的有向无环图,从而能够显式地揭示各部分代码之间的层级与次序约束,并且,使得大语言模型在执行上下文推理的过程中,能够依据有向无环图判断抽取出的上下文内容是否满足代码依赖关系、排列顺序是否合理,从而提高上下文数据的可复用性。

[0073] 在本实施例中,有向无环图(Directed Acyclic Graph,DAG)可以为由顶点和有向边构成、且不存在任何循环路径的图数据结构。具体的,顶点可以表征代码模块或代码单元,有向边可以表征代码依赖关系,从而可以由顶点和有向边示出历史表单代码中各部分代码之间的代码依赖网络。

[0074] S103:基于改进Kahn算法对有向无环图进行拓扑排序,得到代码依赖关系的拓扑顺序,将有向无环图和代码依赖关系的拓扑顺序存入表单知识库。

[0075] 为提升大语言模型在后续推理过程中对上下文数据编排的准确性,可以对示出代码依赖关系的有向无环图进行拓扑排序,得到不存在逻辑冲突的"代码组装顺序表”,并将该"代码组装顺序表”作为元数据存入表单知识库,为后续大语言模型的推理过程提供遵循依据,减少大语言模型直接输出的表单代码中的循环依赖错误或逻辑顺序错误。

[0076] 在本实施例中,改进Kahn算法可以为对经典Kahn拓扑排序算法的优化算法变体,以提升算法计算效率或使算法适应特定应用场景。具体的,例如,可以从并行处理或基于优先级的队列管理等方向对经典Kahn拓扑排序算法进行优化。

[0077] 在本实施例中,代码依赖关系的拓扑顺序可以为各个代码模块或代码单元之间的线性序列。具体的,该线性序列可以用于指示代码模块或代码单元之间的依赖顺序,即,在生成表单代码的过程中,定义或处理不同代码单元或代码模块的执行顺序。

[0078] 在本实施例中,可以通过以下过程对有向无环图进行拓扑排序:根据有向边的方向,利用改进Kahn算法生成图中各个顶点的线性序列,使得对于该有向无环图中的每一条有向边,有向边的起点在线性序列中均位于有向边的终点之前。

[0079] 在一些实施例中,本实施例的改进Kahn算法可以为:在经典Kahn算法"入度计算—零入度队列—出队—更新入度”的主流程基础上,引入跨阶段上下文传播机制,使得每一顶点出队时触发与该顶点对应的上下文数据编排与增强生成,从而使下游顶点能够获取并利用上游顶点的生成结果作为推理依据。

[0080] 具体的,在本实施例中,改进Kahn算法可以将拓扑排序的节点组织方式由"单一文件”调整为面向"代码模块或代码单元”的组织方式,并且,所述代码模块或代码单元可以按照预设分类维度进行归类;所述预设分类维度用于表征所述代码模块或代码单元在企业级多层架构中的功能类别,所述预设分类维度可以对应实体类、数据传输对象、服务接口、服务实现类、控制器、枚举类、工作流配置以及工作流服务中的至少两者,从而在企业级多层架构代码生成场景下形成稳定的拓扑序约束。

[0081] 进一步地,在一些实施例中,改进Kahn算法在每一顶点出队时,还可以联动执行"生成—解析—注入”的处理流程,以实现拓扑排序与大语言模型的上下文推理过程之间的闭环衔接:(1)依赖代码收集:在当前顶点出队后,从上下文传播表中检索与当前顶点存在入边关系的上游顶点对应的生成结果,并依据所述预设分类维度进行归集,得到依赖代码集合;所述依赖代码集合用于表征下游代码模块或代码单元在生成过程中需要引用的类型定义、接口契约或继承关系信息。(2)代码结构解析:对所述依赖代码集合中的源代码内容执行结构化解析,提取命名空间声明、引用语句列表、类或接口声明、属性列表以及方法签名列表中的至少一者,得到结构化元数据;所述结构化元数据用于作为上下文数据的一部分,以约束后续生成代码的类型引用一致性、方法签名一致性以及命名空间一致性。(3)上下文增强生成:将所述结构化元数据与当前顶点对应的业务需求描述进行组装,形成大语言模型的输入提示,使大语言模型基于所述输入提示生成当前顶点对应的代码模块或代码单元;从而使生成的代码模块或代码单元在类型引用、命名空间引用以及属性访问上与上游已生成的代码模块或代码单元保持一致,以提升生成的表单代码在企业内部管理系统中的可编译性与可运行性。

[0082] 在一些实施例中,上述上下文传播表可以用于记录各顶点处理完成后的生成结果;所述生成结果可以包括已生成文件的文件路径、文件内容以及与所述预设分类维度对应的类别信息;并且,所述上下文传播表在拓扑排序过程中被持续更新,使得当某一目标顶点的入度更新为零并入队时,能够基于所述上下文传播表直接获取其上游依赖顶点对应的生成结果作为推理上下文,从而提升从表单知识库抽取的上下文数据的完整性与一致性。

[0083] 此外,在一些实施例中,改进Kahn算法还可以引入关键节点熔断判定机制:将与预设分类维度中至少一种关键类别对应的顶点确定为关键顶点;当所述关键顶点对应的代码模块或代码单元在生成过程中发生错误时,停止生成所有依赖该关键顶点的下游顶点,并记录错误信息;从而避免在关键依赖缺失的情况下继续传播不一致上下文导致的级联编译错误,进一步提升生成结果的稳定性与可用性。

[0084] 请参阅图6。为将用户以自然语言或设计文件等非结构化形式表达的表单开发需求,转化为用于大语言模型执行推理的准确、无歧义的输入指令,提升表单代码生成过程的智能化程度和大语言模型直接输出的表单代码与用户实际需求的接近程度,在一些实施例中,表单生成方法还可以包括步骤S201、S202和S203。

[0085] S201:接收用户输入的表单开发需求数据。

[0086] 在本实施例中,表单开发需求数据可以用于描述需要开发的表单的业务功能、界面布局或交互逻辑。具体的,表单开发需求数据可以包括非结构化数据或半结构化数据。例如,表单开发需求数据中的非结构化数据可以为表单设计人员绘制的表单视觉效果图或使用专业设计工具生成的专有格式源文件。表单开发需求数据中的半结构化数据可以为描述表单界面组件及其属性的JSON(JavaScript Object Notation,JavaScript对象表示法)、XML(Extensible Markup Language,可扩展标记语言)等格式的文件。

[0087] S202:对表单开发需求数据进行内容提取,得到表单功能描述数据。

[0088] 为将非结构化或半结构化的表单开发需求数据转化为能够被大语言模型解析和处理的标准化输入,减少由于表单开发需求数据的数据格式复杂或数据含义模糊导致的大语言模型输出偏差,可以先将表单开发需求数据转换为语义明确的中间数据。

[0089] 在本实施例中,表单功能描述数据可以用于以统一文本形式描述表单界面组件与业务逻辑之间的关联。具体的,表单功能描述数据可以包括对表单界面组件及各组件属性、组件间布局关系、表单可实现的用户交互行为以及各种交互行为所涉及的后端服务数据操作的描述。例如,表单功能描述数据可以为一段自然语言文本,内容为:"该表单用于晶舟入料登记。表单界面顶部显示标题‘晶舟入料单’。表单中间区域包含以下字段:工单号(文本输入框,必填)、设备ID(下拉选择框,选项需从企业内部管理系统动态获取)、批次号(文本输入框)、操作员(文本输入框,默认值为当前登录用户)。表单界面底部包含一个‘提交’按钮,点击后需调用后端‘CreateLot’接口并传递上述表单数据”。

[0090] 在本实施例中,针对不同结构化程度的表单开发需求数据,可以采用不同的内容提取方法。具体的,针对非结构化的表单开发需求数据,可以利用计算机视觉识别算法对图像类数据进行界面元素检测与光学字符识别,或者,调用专用解析库读取设计工具专有格式文件,获取其内部的图层与组件树等信息。针对半结构化的表单开发需求数据,可以通过解析JSON、XML等格式文件的语法结构,遍历节点,并提取文件中定义的组件类型、属性键值对、嵌套关系以及文本标签等信息。例如,在表单开发需求数据为表单视觉效果图的情况下,可以通过目标检测算法识别出图中的输入框、按钮等界面元素,并通过光学字符识别读取界面元素旁的标注文本,生成用于描述各界面元素特性及功能的表单功能描述数据。

[0091] S203:将表单功能描述数据输入预训练的命名实体识别模型,调用命名实体识别模型输出表单生成指令。

[0092] 为提供大语言模型执行上下文推理、开发规范推理、表单生成需求转换推理等推理过程的无歧义输入,提升对大语言模型输出的控制能力,提高大语言模型直接输出的表单代码的准确性和可用性,可以对表单功能描述数据进行命名实体识别,获得表单生成指令。

[0093] 在本实施例中,预训练的命名实体识别模型可以为已经过表单知识库中的知识数据预训练、能够从表单知识库存储的知识数据中识别并进行指定类型的实体分类的机器学习模型。具体的,可以对表单知识库中存储的知识数据进行标注,并将标注后的知识数据作为通用命名实体识别模型的训练样本,调整通用命名实体识别模型的模型参数,提高通用命名实体识别模型对企业表单开发领域内特定实体的识别能力,得到预训练的命名实体识别模型。

[0094] 在本实施例中,表单生成指令可以为命名实体识别模型输出的结构化数据。具体的,表单生成指令可以为预训练的命名实体识别模型对表单功能描述数据进行分析后所识别出的实体及其类型的结构化结果。例如,表单生成指令可以为JSON对象,具体包含"业务对象:工单号”、"界面组件:下拉选择框(属性:数据源=设备列表)”、"后端服务:调用CreateJob接口”等键值对。

[0095] 请参阅图7。在将代码依赖关系的有向无环图和拓扑顺序存入表单知识库后,为将检索增强生成(Retrieval-Augmented Generation,RAG)技术引入大语言模型生成表单代码的过程中,提升大语言模型执行上下文推理过程中所依据的数据的引导性,减少大语言模型直接输出的表单代码中因依赖关系缺失或混乱导致的错误,在本实施例中,基于获取的表单生成指令,调用大语言模型执行上下文推理,从表单知识库中抽取与表单生成指令相关的上下文数据的步骤,可以包括子步骤S111、S112、S113和S114。

[0096] S111:基于表单生成指令,按照相似度检索规则从表单知识库中检索出多个检索上下文数据。

[0097] 为在后续推理过程中为大语言模型提供充分且相关的企业内部知识数据,使得后续筛选和召回的知识数据能够覆盖表单知识库中尽可能广泛的范围,且与表单生成指令具有较强相关性,降低由于上下文数据信息不足而导致大语言模型直接输出的表单代码不完整或不可用的风险,可以先基于"查全”原则检索表单知识库。

[0098] 在本实施例中,相似度检索规则可以用于衡量并比较表单生成指令与表单知识库中存储的知识数据之间的关联程度。具体的,相似度检索规则可以基于语义相似度确定,或者,相似度检索规则可以基于余弦相似度、关键词匹配、编辑距离等多种相似度计算方法确定。

[0099] 在本实施例中,检索上下文数据可以为基于相似度检索规则,从表单知识库中初步查找出的知识数据集合。具体的,以相似度检索规则基于语义相似度确定为例,可以对表单生成指令和表单知识库中存储的知识数据进行向量化,得到表单生成指令向量和知识数据向量,计算二者之间的余弦相似度,将与表单生成指令向量的余弦相似度大于或等于指定阈值的知识数据向量对应的知识数据作为检索上下文数据。

[0100] S112:根据有向无环图,调用大语言模型从多个检索上下文数据中筛选出候选上下文数据。

[0101] 为从初步检索出的大量检索上下文数据中确定在逻辑上能够被正确组装和集成的知识数据,可以基于有向无环图表征的代码依赖关系,利用大语言模型评估各检索上下文数据与其他知识数据之间的依赖关系的兼容性与完整性,滤除其中依赖关系缺失或存在冲突的数据。

[0102] 在本实施例中,候选上下文数据可以为在所实现功能和代码间依赖关系方面能够作为表单代码核心组成部分的知识数据集合。具体的,候选上下文数据为检索上下文数据的子集。

[0103] 在本实施例中,根据有向无环图,调用大语言模型进行筛选的具体过程可以如下。

[0104] 首先,可以将多个检索上下文数据与有向无环图关联,从有向无环图中提取出每个检索上下文数据所代表的节点,以及该节点的直接依赖节点集合和被依赖节点集合,形成每个检索上下文数据的"依赖关系画像”。

[0105] 随后,可以将"依赖关系画像”和数据筛选指令输入给大语言模型。该数据筛选指令可以包含以下关键信息:(1)任务:基于表单生成指令,从给定的检索上下文数据中筛选出最可能被成功组装和使用的数据;(2)约束:每个检索上下文数据的"依赖关系画像”;(3)要求:筛选的业务背景为表单生成指令的关键意图;(4)输出:筛选出的候选上下文数据,并简要说明每个候选上下文数据被保留的理由。

[0106] 接着,调用大语言模型基于"依赖关系画像”和数据筛选指令执行推理。利用大语言模型的逻辑能力针对每个检索上下文数据进行分析,具体分析内容可以包括:检索上下文数据的依赖数据是否也为检索上下文数据、检索上下文数据自身是否为多个其他检索上下文数据的关键依赖、不同检索上下文数据之间的依赖关系与表单生成指令的匹配度。

[0107] 最后,将大语言模型完成推理后输出的筛选结果作为候选上下文数据。

[0108] S113:根据有向无环图,调用大语言模型从表单知识库中召回与候选上下文数据存在代码依赖关系的依赖上下文数据。

[0109] 为提升大语言模型直接输出的表单代码的功能完整性与结构正确性,减少由于缺失必要依赖数据导致的中间态代码无法直接编译或运行的错误,可以利用大语言模型主动从表单知识库中识别出与候选上下文数据存在代码依赖关系的其他知识数据,降低表单开发人员手动补充依赖代码的工作量。

[0110] 在本实施例中,依赖上下文数据可以为与候选上下文数据存在直接或间接的代码依赖关系的知识数据集合。具体的,依赖上下文数据可以包括存储于表单知识库内、为实现候选上下文数据的正确实现或调用所必需的配套知识数据。

[0111] 在本实施例中,根据有向无环图,调用大语言模型召回依赖上下文数据的具体过程与上述根据有向无环图,调用大语言模型进行筛选的具体过程类似,此处不再赘述。

[0112] S114:按照代码依赖关系的拓扑顺序,调用大语言模型对候选上下文数据和依赖上下文数据进行排序,得到上下文数据。

[0113] 为在大语言模型执行代码生成推理的过程中,引导大语言模型以正确的代码依赖顺序编排和生成"连接代码”,使得大语言模型直接输出的表单代码在代码结构和调用关系上更接近于历史表单代码,减少由于代码模块或代码单元的编排顺序错误而导致的代码编译失败或逻辑缺陷,可以调用大语言模型基于代码依赖关系的拓扑顺序对从表单知识库中选出的知识数据进行排序。

[0114] 在本实施例中,可以向大语言模型输入候选上下文数据、依赖上下文数据、代码依赖关系的拓扑顺序以及排序指令,调用大语言模型基于输入数据执行推理。利用大语言模型的逻辑能力针对每个候选上下文数据以及该候选上下文数据的依赖上下文数据进行分析,将候选上下文数据、依赖上下文数据按照代码依赖关系的拓扑顺序所规定的先后关系重新排列组合,将大语言模型完成推理后输出的排序结果作为上下文数据。具体的,上下文数据可以包括与表单生成指令相匹配的前端组件和后端服务信息。其中,前端组件可以为前端界面组件标识和前端界面组件标识对应的历史前端组件代码。后端服务信息可以为与前端界面组件标识相匹配的后端服务应用程序编程接口以及接口参数。

[0115] S120:基于表单生成指令、上下文数据和表单知识库,调用大语言模型执行开发规范推理,确定与表单生成指令相匹配的表单开发规范。

[0116] 请继续参阅图3。为将匹配于企业内部管理系统的编码标准、代码架构模式等作为结构化约束引入大语言模型生成表单代码的过程中,使得大语言模型直接输出的表单代码在组织结构、命名约定和代码设计模式等方面能够与企业内部的代码质量要求对齐,减少由于代码风格混杂、架构不一致所引起的集成调试与人工重构工作量,可以将表单生成指令、表单知识库以及前次大语言模型执行上下文推理输出的上下文数据共同输入大语言模型,调用其执行推理,确定表单开发规范。

[0117] 在本实施例中,表单开发规范可以为表单代码为匹配企业内部管理系统而需要遵循的规则和模式。具体的,表单开发规范可以为表单开发的规范说明书(SpecificationDocument,SD),即,规范化设计文档。例如,表单开发规范可以包括前端界面组件的命名前缀规则、后端应用程序编程接口的异常处理统一范式、特定类型业务表单的固定代码文件结构,以及数据验证逻辑的封装方式等。

[0118] 在本实施例中,开发规范推理可以为大语言模型基于输入的表单生成指令和前次推理输出的上下文数据,按照"问题-思考过程-答案”的"思维链”逻辑,分析表单知识库中存储的知识数据,确定后续生成的表单代码需要遵循的代码编写约束和代码架构模式的思维过程。

[0119] S130:基于上下文数据和表单开发规范,调用大语言模型执行表单生成需求转换推理,将表单生成指令转换为表单生成提示词。

[0120] 为提升大语言模型直接输出的表单代码的准确性与规范性,并弥补表单生成指令与可被大语言模执行的代码生成指令之间的语义差距,可以调用大语言模型执行推理,对表单生成指令进行解析和翻译,将表单生成指令转换为融合有可复用的历史表单代码及生成表单代码需遵循的表单开发规范的表单生成提示词,从而减少由于需求理解偏差或规范缺失导致的表单代码可用性降低。

[0121] 在本实施例中,表单生成提示词可以为输入给大语言模型调用其生成表单代码的指令。具体的,表单生成提示词可以包含表单开发需求、大语言模型执行上下文推理输出的上下文数据、上下文数据之间的代码依赖关系以及大语言模型执行开发规范推理输出的表单开发规范等信息。例如,表单生成提示词的内容可以包括:"(1)任务:创建设备点检表单;(2)可用上下文数据:EquipmentDropdown(属性:api=‘ / api / devices’)、InspectionDatePicker(属性:format=‘YYYY-MM-DD’);(3)表单开发规范:继承BaseInspection-Form类、提交按钮需调用ValidationUtil.runCheck()、界面组件按垂直顺序排列。请生成完整的Vue单文件组件及对应的C# API控制器代码。”在本实施例中,表单生成需求转换推理可以为大语言模型基于上下文推理输出的上下文数据和前次推理输出的表单开发规范,按照"问题-思考过程-答案”的"思维链”逻辑,分析表单知识库中存储的知识数据,将结构化的表单生成指令转换为可执行指令的思维过程。

[0122] S140:将表单生成提示词输入大语言模型,调用大语言模型执行代码生成推理,生成用于实现表单生成指令所描述的功能的表单代码。

[0123] 在大语言模型分层次多次执行"思维链”逻辑推理后,输出的表单生成提示词已包含用户意图、表单知识库中的知识数据、表单代码需要遵循的代码规范等各方面信息,此时,再次调用大语言模型基于表单生成提示词执行推理,使得生成的表单代码能够贴近用户的实际表单开发需求,并匹配企业内部管理系统,以提升表单开发效率。

[0124] 在本实施例中,表单代码可以为能够实现表单生成指令所描述的功能的计算机程序代码。具体的,表单代码可以包括对应前端组件的前端代码、对应后端服务信息的后端代码和用于关联前端代码和后端代码且符合表单开发规范的连接代码。其中,前端代码可以为实现表单生成指令所描述的用户界面交互逻辑的源代码。后端代码可以为实现表单数据处理与存储逻辑的源代码。连接代码可以为在前端代码与后端代码之间建立通信、数据转换与调用关系,使表单代码整体逻辑符合表单开发规范的"胶水”代码。例如,前端代码可以为上下文数据中包括的前端界面组件标识和前端界面组件标识对应的历史前端组件代码,或者,前端代码可以为基于Vue 3框架对该历史前端组件代码进行微调形成的前端组件代码。后端代码可以为上下文数据中包括的与前端界面组件标识相匹配的后端服务应用程序编程接口以及接口参数,或者,后端代码可以为基于.NET 8框架对该后端服务应用程序编程接口和接口参数进行微调形成的后端服务代码。连接代码可以包括前端发起应用程序编程接口调用的函数、后端接口的封装代码及数据模型转换逻辑等。

[0125] 在本实施例中,根据表单生成提示词内容,除表单代码外,大语言模型执行代码生成推理还可以生成用于配置前端组件、采用JSON、XML等机器可读且易于解析的数据交换格式保存的配置文件。以及,大语言模型执行代码生成推理还可以生成用于快速定义表单界面与业务逻辑的低代码描述。其中,低代码描述可以采用特定领域语言(Domain-SpecificLanguage,DSL)、根据可视化操作生成的元数据或简化的声明式语法编写。

[0126] 在本实施例中,代码生成推理可以通过向大语言模型输入前次推理输出的表单生成提示词,调用大语言模型按照"问题-思考过程-答案”的"思维链”逻辑,结合表单生成提示词中的具体指令,分析表单知识库中存储的知识数据,生成对应表单生成提示词的表单代码的思维过程。

[0127] 请参阅图8。为验证表单代码对表单生成指令所描述的功能的实现能力,并减少表单代码测试阶段对人工代码审查与手动调试的依赖,提升表单代码的可靠性和表单开发整体流程的智能化程度,在一些实施例中,在生成表单代码之后,表单生成方法还可以包括:重复执行以下子步骤,直至表单代码通过评估。子步骤可以包括S151、S152和S153。

[0128] S151:基于表单生成指令、上下文数据和表单开发规范,调用大语言模型执行代码评估推理,对表单代码进行功能评估,得到评估结果。

[0129] 为利用大语言模型的语义理解能力识别表单代码与表单开发需求及表单开发规范之间可能存在的偏差,为表单代码的修正提供决策依据,可以在大语言模型输出表单代码后,利用大语言模型对其自身的输出进行闭环验证。

[0130] 在本实施例中,评估结果可以为大语言模型对表单代码的质量判定信息。具体的,评估结果可以为结构化数据或半结构化数据。评估结果的内容可以包括评估结论以及支持该评估结论的具体分析。其中,评估结论可以表示表单代码是否满足通过评估条件的总体状态判断。例如,评估结论可以为"通过评估条件”、"未通过评估条件”或"有条件通过评估条件”。具体分析可以包括从一个或多个维度对评估结论进行的解释。例如,在评估结论为"未通过”的情况下,具体分析可以包括表单代码目前存在的问题数量、问题类型、问题位置、问题描述以及问题严重性等级等。

[0131] 在本实施例中,评估条件可以为用于判定表单代码是否达到可交付质量的预设技术准则集合。具体的,评估条件可以包括功能一致性条件、规范符合性条件、依赖完整性条件以及可执行性条件。其中,基于功能一致性条件可以判定表单代码是否能够完整且正确地实现表单生成指令所描述的全部表单功能。基于规范符合性条件可以判定表单代码的结构、命名、代码风格是否与表单开发规范保持一致。基于依赖完整性条件可以判定表单代码所调用的前端组件、后端服务信息是否在表单知识库中均有明确定义且可访问。基于可执行性条件可以判定表单代码是否存在语法错误、类型错误等基础编译错误,以及表单各业务逻辑路径是否通畅。

[0132] 在本实施例中,代码评估推理可以通过向大语言模型输入表单生成指令以及此前多次推理输出的上下文数据、表单开发规范和表单代码,调用大语言模型按照"问题-思考过程-答案”的"思维链”逻辑,结合表单生成指令中所描述的表单功能和表单开发规范中所记录的代码约束,分析表单代码对表单功能的实现能力以及对代码约束的满足情况,生成表单代码功能评估结果的思维过程。

[0133] S152:在评估结果未满足通过评估条件的情况下,基于评估结果调用大语言模型生成对表单代码的修正指令。

[0134] 为实现表单代码的自动修正,在大语言模型对直接输出的表单代码的评估结果为"未满足通过评估条件”的情况下,可以调用大语言模型基于评估结果,将执行代码评估推理输出的表单代码存在的具体问题转化为可执行的修正指令,减少为人工修正代码缺陷的工作量。

[0135] 在本实施例中,修正指令可以为针对大语言模型输出的表单代码中存在的问题的修改操作建议。具体的,修正指令的内容与评估结果中的具体分析直接相关。例如,修正指令可以包括语法修正指令、组件依赖修正指令、逻辑补全修正指令、应用程序编程接口调用修正指令等。

[0136] 在本实施例中,基于评估结果调用大语言模型生成修正指令的过程与调用大语言模型执行代码评估推理的过程类似,此处不再赘述。

[0137] S153:基于修正指令,调用大语言模型重新执行上下文推理、开发规范推理、表单生成需求转换推理、代码生成推理中的至少一个,更新表单代码。

[0138] 为提升大语言模型最终输出的表单代码的准确性与可用性,在利用大语言模型输出针对表单代码的修正指令后,可以根据修正指令所定位的表单代码中存在的具体问题和修正策略,调用大语言模型重新执行分层次"思维链”推理中的至少一个推理过程,从而对表单代码进行迭代优化,在提升表单代码的代码质量的同时提升表单开发效率。

[0139] 请参阅图9。综上,本申请的一个实施例提供的表单生成方法可以通过以下过程实现。

[0140] 首先,通过对历史表单代码进行代码偏好分析和语义分析,得到代码依赖关系,并将历史表单代码和代码依赖关系共同存入表单知识库。并且,对表单开发需求数据进行内容提取,得到表单功能描述数据,再将表单功能描述数据输入命名实体识别模型,将命名实体识别模型的输出作为表单生成指令。

[0141] 随后,将表单生成指令和表单知识库输入给大语言模型,调用其依次执行上下文推理、开发规范推理、表单生成需求转换推理、代码生成推理和代码评估推理五个层次的"思维链”推理过程。其中,在后推理过程的输入至少包括在前推理过程的输出。多层次"思维链”推理过程具体如下。

[0142] 第一,调用大语言模型执行上下文推理从表单知识库中抽取出上下文数据。

[0143] 第二,将表单知识库、上下文数据和表单生成指令共同输入大语言模型,调用其执行开发规范推理,输出表单开发规范。

[0144] 第三,将上下文数据和表单开发规范输入大语言模型,调用其执行表单生成需求转换推理,将表单生成指令转换为表单生成提示词。

[0145] 第四,将表单生成提示词输入大语言模型,调用其执行代码生成推理,生成表单代码。

[0146] 第五,将表单生成指令、上下文数据、表单开发规范和代码生成推理输出的表单代码输入大语言模型,调用其执行代码评估推理,根据代码评估推理输出的评估结果对表单代码进行迭代优化,最终输出包括前端代码、连接代码、后端代码的表单代码。

[0147] 通过上述多层次"思维链”推理过程,可以减少大语言模型输出的"AI幻觉”,使得大语言模型输出的表单代码与企业内部管理系统之间存在较高匹配度,从而在提升表单开发效率的同时降低了表单开发的技术壁垒。

[0148] 请参阅图10。本申请的另一个实施例提供一种表单生成系统。该表单生成系统可以包括上下文抽取层、开发规范确定层、提示词转换层、代码生成层四个层级。

[0149] 在本实施例中,上下文抽取层可以用于基于获取的表单生成指令,调用大语言模型从表单知识库中抽取与表单生成指令相关的上下文数据。其中,上下文数据可以包括与表单生成指令相匹配的前端组件和后端服务信息。

[0150] 在本实施例中,开发规范确定层可以用于基于表单生成指令、上下文数据和表单知识库,调用大语言模型确定与表单生成指令相匹配的表单开发规范。

[0151] 在本实施例中,提示词转换层可以用于基于上下文数据和表单开发规范,调用大语言模型将表单生成指令转换为表单生成提示词。

[0152] 在本实施例中,代码生成层可以用于将表单生成提示词输入大语言模型,调用大语言模型生成用于实现表单生成指令所描述的功能的表单代码。其中,表单代码可以包括对应前端组件的前端代码、对应后端服务信息的后端代码以及用于关联前端组件和后端服务信息且符合表单开发规范的连接代码。

[0153] 本申请的又一个实施例提供一种计算机可读存储介质,其上可以存储有计算机程序,该计算机程序被处理器执行时可以实现如上述实施例所述的表单生成方法或表单生成系统。

[0154] 本申请的又一个实施例提供一种计算机程序产品,包括计算机程序或计算机可执行指令,该计算机程序或计算机可执行指令被电子设备中的处理器执行时可以实现如上述实施例所述的表单生成方法或表单生成系统。

[0155] 关于上述实施例所述的表单生成系统、计算机可读存储介质、计算机程序产品具有的其它技术效果,可以参照本申请其他实施例对照解释,在此不再赘述。

[0156] 在本申请实施例提供的表单生成方法和表单生成系统中,基于获取的表单生成指令和表单知识库,依次调用大语言模型执行上下文推理、开发规范推理、表单生成需求转换推理和代码生成推理,生成包含对应前端组件的前端代码、对应后端服务信息的后端代码以及符合表单开发规范的连接代码的表单代码,在此基础上,基于表单代码调用大语言模型执行代码评估推理,对表单代码进行迭代优化并最终输出,实现的意想不到的效果包括:由于除上下文推理外,大语言模型执行的每次推理的输入至少包括前次推理的输出,因此,在利用大语言模型输出表单代码的过程中,通过"分层思维链”的思维过程提升了对大语言模型输出的控制能力,降低了大语言模型直接输出的表单代码中的"AI幻觉”,使得大语言模型的输出更贴近企业实际表单需求,从而减少了针对大语言模型的输出进行人工修改的工作量,提升了表单开发效率,降低了表单开发的技术门槛。

[0157] 可以理解,本申请中的具体的示例只是为了帮助本领域技术人员更好地理解本申请实施例,而非限制本申请的范围。

[0158] 可以理解,在本申请中的各种实施例中,各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程组成任何限定。

[0159] 可以理解,本申请中描述的各种实施例,既可以单独实施,也可以组合实施,本申请实施例对此并不限定。

[0160] 除非另有说明,本申请实施例所使用的所有技术和科学术语与本申请的技术领域的技术人员通常理解的含义相同。本申请中所使用的术语只是为了描述具体的实施例的目的,不是旨在限制本申请的范围。本申请所使用的术语"和 / 或”包括一个或多个相关的所列项的任意的和所有的组合。在本申请实施例和所附权利要求书中所使用的单数形式的"一种”、"上述”和"该”也旨在包括多数形式,除非上下文清楚地表示其他含义。

[0161] 在本申请所提供的几个实施例中,应所述理解到,所揭露的表单开发系统、计算机可读存储介质、计算机程序产品可以通过其它的方式实现。例如,以上所描述的表单开发系统、计算机可读存储介质、计算机程序产品的实施例仅仅是示意性的。

[0162] 以上所述,仅为本申请的具体实施例,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。< / script> < / template>

Claims

1. A form generation method, characterized in that, include: Based on the acquired form generation instructions, a large language model is invoked to perform contextual reasoning, extracting contextual data related to the form generation instructions from the form knowledge base. The form knowledge base stores historical form code, a directed acyclic graph of code dependencies obtained from the historical form code, and the topological order of the code dependencies. Vertices in the directed acyclic graph represent code modules or code units, and directed edges represent code dependencies. The contextual data includes front-end components and back-end service information matching the form generation instructions. Based on the form generation instruction, the context data, and the form knowledge base, the large language model is invoked to perform development specification reasoning to determine the form development specification that matches the form generation instruction. The form development specification indicates the code writing constraints and code architecture patterns that the generated form code must follow. Based on the context data and the form development specifications, the large language model is invoked to perform form generation requirement transformation reasoning, and the form generation instructions are converted into form generation prompts. The form generation prompts indicate the form development requirements, the context data, the code dependencies between the context data, and the form development specifications. The topological order of the code dependencies is used to define or process the execution order of different code units or code modules during the generation of the form code. The form generation prompt is input into the large language model, and the large language model is invoked to perform code generation inference to generate form code for implementing the function described by the form generation instruction. The form code includes front-end code corresponding to the front-end component, back-end code corresponding to the back-end service information, and connection code for associating the front-end code and the back-end code and conforming to the form development specification. The connection code is used to establish communication, data conversion, and calling relationships between the front-end code and the back-end code. The connection code includes at least one of the following: a function for the front-end to initiate an application programming interface call, encapsulation code for the back-end interface, and data model conversion logic. The step of generating form code to implement the functionality described by the form generation instruction includes: Based on the topological sorting of the directed acyclic graph according to the code dependency relationship, after the current vertex is dequeued, the generation results corresponding to the upstream vertices that have an incoming edge relationship with the current vertex are retrieved from the context propagation table, and the results are collected according to the preset classification dimension to obtain the dependent code set. Perform structured parsing on the source code content in the dependent code set to extract at least one of the namespace declarations, reference statement lists, class or interface declarations, attribute lists, and method signature lists to obtain structured metadata; The structured metadata is assembled with the business requirement description corresponding to the current vertex to form the input prompt of the large language model, which then generates the code module or code unit corresponding to the current vertex based on the input prompt.

2. The form generation method according to claim 1, characterized in that, The form knowledge base stores historical form code; wherein, the historical form code includes historical front-end component code, historical back-end service code, and historical form development framework code; the form generation method further includes: Based on the abstract syntax tree parsing algorithm, code preference analysis and semantic analysis are performed on the historical form code to obtain the code dependency relationships between the historical front-end component code, the historical back-end service code, and the historical form development framework code. Construct a directed acyclic graph of the code dependencies; The directed acyclic graph is topologically sorted based on the improved Kahn algorithm to obtain the topological order of the code dependencies. The directed acyclic graph and the topological order of the code dependencies are then stored in the form knowledge base.

3. The form generation method according to claim 2, characterized in that, The code dependencies include implementation dependencies, contract dependencies, and definition dependencies.

4. The form generation method according to claim 2 or 3, characterized in that, The historical front-end component code includes historical front-end component implementation code and historical front-end component description code; the historical form development framework code includes historical form development template code and historical form development implementation code. Based on the abstract syntax tree parsing algorithm, code preference analysis and semantic analysis are performed on the historical form code, including: Using the historical form development template code as input, the abstract syntax tree parsing algorithm is executed to achieve the code preference analysis; Using the historical front-end component description code as input, the abstract syntax tree parsing algorithm is executed to achieve the semantic analysis.

5. The form generation method according to claim 2 or 3, characterized in that, Based on the acquired form generation instructions, the steps of invoking a large language model to perform contextual reasoning and extracting contextual data related to the form generation instructions from the form knowledge base include: Based on the form generation instruction, multiple search context data are retrieved from the form knowledge base according to the similarity retrieval rules; Based on the directed acyclic graph, the large language model is invoked to filter candidate context data from the multiple retrieval context data; Based on the directed acyclic graph, the large language model is invoked to retrieve dependent context data that has a code dependency relationship with the candidate context data from the form knowledge base; According to the topological order of the code dependencies, the large language model is invoked to sort the candidate context data and the dependency context data to obtain the context data.

6. The form generation method according to claim 1, characterized in that, The form generation method also includes: Receive form development requirement data input by the user; wherein, the form development requirement data includes unstructured data or semi-structured data; Extract content from the form development requirement data to obtain form function description data; The form function description data is input into a pre-trained named entity recognition model, and the named entity recognition model is invoked to output the form generation instruction; wherein, the form generation instruction is structured data; the named entity recognition model is pre-trained using data in the form knowledge base.

7. The form generation method according to claim 1, characterized in that, After generating the form code, the form generation method further includes: Repeat the following sub-steps until the form code passes evaluation; the sub-steps include: Based on the form generation instruction, the context data, and the form development specification, the large language model is invoked to perform code evaluation reasoning, and the form code is functionally evaluated to obtain the evaluation result. If the evaluation result does not meet the evaluation criteria, the large language model is invoked based on the evaluation result to generate correction instructions for the form code; Based on the correction instruction, the large language model is invoked to re-execute at least one of the context reasoning, the development specification reasoning, the form generation requirement transformation reasoning, and the code generation reasoning, and the form code is updated.

8. A form generation system, characterized in that, include: The context extraction layer is used to perform context reasoning by calling a large language model based on the acquired form generation instructions, and to extract context data related to the form generation instructions from the form knowledge base. The form knowledge base stores historical form code, a directed acyclic graph of code dependencies obtained based on the historical form code, and the topological order of the code dependencies. Vertices in the directed acyclic graph represent code modules or code units, and directed edges represent code dependencies. The context data includes front-end components and back-end service information matching the form generation instructions. The development specification determination layer is used to determine the form development specification that matches the form generation instruction by calling the large language model based on the form generation instruction, the context data, and the form knowledge base. The form development specification indicates the code writing constraints and code architecture patterns that need to be followed when generating form code. The prompt conversion layer is used to call the large language model to convert the form generation instructions into form generation prompts based on the context data and the form development specifications. The form generation prompts indicate the form development requirements, the context data, the code dependencies between the context data, and the form development specifications. The topological order of the code dependencies is used to define or process the execution order of different code units or code modules during the generation of the form code. A code generation layer is used to input the form generation prompts into the large language model, call the large language model to perform code generation inference, and generate form code to implement the function described by the form generation instructions; wherein, the form code includes front-end code corresponding to the front-end component, back-end code corresponding to the back-end service information, and connection code for associating the front-end component and the back-end service information and conforming to the form development specifications. The connection code is used to establish communication, data conversion, and calling relationships between the front-end code and the back-end code. The connection code includes at least one of the following: a function for the front-end to initiate an application programming interface call, encapsulation code for the back-end interface, and data model conversion logic. The code generation layer is further configured to: perform topological sorting of the directed acyclic graph based on the code dependencies; after the current vertex is dequeued, retrieve the generation results corresponding to upstream vertices with incoming edges to the current vertex from the context propagation table, and aggregate them according to a preset classification dimension to obtain a dependency code set; perform structured parsing on the source code content in the dependency code set, extract at least one of the namespace declarations, reference statement lists, class or interface declarations, attribute lists, and method signature lists to obtain structured metadata; assemble the structured metadata with the business requirement description corresponding to the current vertex to form the input prompt of the large language model, enabling the large language model to generate the code module or code unit corresponding to the current vertex based on the input prompt.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the form generation method as described in any one of claims 1 to 7, or implements the form generation system as described in claim 8.

10. A computer program product comprising a computer program or computer-executable instructions, characterized in that, When the computer program or computer-executable instructions are executed by a processor in an electronic device, they implement the form generation method as described in any one of claims 1 to 7, or the form generation system as described in claim 8.

Citation Information

Patent Citations

  • Business code generation method and device fusing code specification detection

    CN120803465A

  • Form code generation method and device, equipment, storage medium and program product

    CN121092148A

  • Front-end and back-end code generation and deployment system based on text AI model

    CN121277485A

  • Private intelligent code collaborative optimization method and system based on graph retrieval

    CN121326348A