Front-end API (Application Program Interface) service code generation method and device, equipment and storage medium

By splitting and organizing the front-end API documents of low-code platforms and calling large language models, code answers are generated, and the problem of difficult to combine multiple component APIs and configure complex code execution processes in the existing technology is solved, achieving efficient and accurate Front-end API business code generation.

CN119415100APending Publication Date: 2025-02-11SUPCON TECH CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411408885.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

When existing low-code platforms assist in generating front-end API business code, it is difficult to combine APIs of multiple components, and users need to be familiar with the functions of each logic point and the in-parameter parameters and the configuration code execution process is complicated.

Method used

By splitting and organizing the front-end API documents of low-code platforms, API documents are obtained, and the questions received by the front-end interface are combined with the questions of receiving user input, and a large language model is called to generate code answers, and displayed on the front-end interface.

Benefits of technology

It realizes the generation of effective low-code front-end codes on the business scenario and front-end APIs, and can combine multiple front-end APIs to realize code generation in complex business scenarios, improving the efficiency and accuracy of code generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415100A_ABST
    Figure CN119415100A_ABST
Patent Text Reader

Abstract

The invention provides a front-end API service code generation method and device, equipment and a storage medium, and the method comprises the steps: carrying out the splitting and arrangement of a low-code platform front-end API document, and obtaining API document slices and keywords corresponding to the API document slices; receiving a question input by a user through the front-end interface; calling a large language model, and generating a code answer according to the question input by the user, the API document slice and the keyword corresponding to the API document slice; and displaying a code answer generated by the large language model on a front-end interface. Therefore, the effective low-code platform front-end codes can be generated according to the business scene and the front-end APIs, and a plurality of front-end APIs can be combined to generate complex business scene codes. In addition, a specific business scene code can be generated based on the combination of the general code generation capability of the large language model and a front-end API (Application Program Interface).
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device, equipment and storage medium for generating front-end API business code. Background Art

[0002] With the development of industrial Internet and enterprise digitalization, more and more companies have chosen low-code platforms to develop enterprise digital systems. Because these complex systems contain more logic, they require a large amount of business code to be implemented on the front-end page.

[0003] There are two main types of existing solutions for assisting low-code platform business code generation:

[0004] The first type provides a full-text retrieval system for the front-end application program interface (API) of the low-code platform. Based on the retrieval of keywords in specific business scenarios, specific component API documents or examples are obtained for reference in writing specific business codes. The disadvantage of this type of solution is that it can only retrieve keyword-related APIs, and it cannot combine multiple APIs of multiple components to assist in code generation.

[0005] The second type is to generate specific business logic code through visual process orchestration through the front-end logic orchestration function. The disadvantage of this solution is that you need to be familiar with the functions of each logic point, input and output parameters in advance, and you need to strictly follow the process configuration code execution process. When there is no logic node that meets the business characteristics, you still need to write code to implement it. Summary of the invention

[0006] In view of the defects in the prior art, the purpose of the present invention is to provide a method, device, equipment and storage medium for generating front-end API business code.

[0007] In a first aspect, an embodiment of the present application provides a method for generating a front-end API business code, including:

[0008] Split and organize the low-code platform front-end API documents to obtain API document slices and keywords corresponding to API document slices;

[0009] Receive user input through the front-end interface;

[0010] Call the large language model to generate code answers based on the user's input question, API document slices, and keywords corresponding to the API document slices;

[0011] The code answers generated by the large language model are displayed on the front-end interface.

[0012] Optionally, the low-code platform front-end API document is split and sorted to obtain API document slices, and keywords corresponding to the API document slices include:

[0013] Get complete front-end API documentation from the low-code platform;

[0014] Slice the front-end API document according to the components to which the API belongs, and obtain API document slices corresponding to each component;

[0015] Based on the API document slices corresponding to each component, organize the keywords corresponding to the API document slices, wherein the keywords include: table control, data display table, data table, table view, data grid, data list, any one of data display table, or a combination of any two or more;

[0016] A target file is formed according to the API document slices and the keywords corresponding to the API document slices, wherein the target file is used to store key-value pairs consisting of components and keywords and is input into the large language model.

[0017] Optionally, organizing keywords corresponding to the API document slices based on the API document slices corresponding to each component includes any of the following methods:

[0018] Method 1: Store the API document slices corresponding to the component as a full-text search database, locate the relevance of the question, and obtain the keywords corresponding to the API document slices;

[0019] Method 2: Input the API document slice corresponding to the component into the large language model, which converts it into the corresponding vector value, and performs relevance matching based on the vector value of the question to obtain the keywords corresponding to the API document slice;

[0020] Method 3: Artificially organize the API document slices corresponding to the components to obtain the keywords corresponding to the API document slices.

[0021] Optionally, the front-end interface includes: a historical question and answer area, an API answer area, an answer evaluation area, and a question input area; wherein:

[0022] The historical question and answer area is used to display the questions previously entered by the user and the corresponding code answers;

[0023] API answer area, used to display code answers generated based on questions;

[0024] The answer evaluation area is used to receive users' evaluation of the code answers;

[0025] The question input area is used to receive questions input by users.

[0026] Optionally, the calling of the large language model generates a code answer according to the question input by the user, the API document slice, and the keywords corresponding to the API document slice, including:

[0027] Organize keyword prompts based on the questions entered by the user;

[0028] Based on the keyword prompts, API document slices, and the keywords corresponding to the API document slices, organize and identify the prompts of the components contained in the question, call the large language model, generate the first question and answer, and determine the components contained in the question;

[0029] According to the contained component information, the corresponding API document slices are loaded to form code generation context prompt words;

[0030] Sending the code generation prompt word to a large language model;

[0031] The large language model is called to generate a code answer according to the code generation prompt word.

[0032] Optionally, displaying the code answer generated by the large language model on the front-end interface includes:

[0033] The code answer of the large language model is fed back to the front end through the organization streaming interface, and the code answer is displayed on the front end interface.

[0034] Optionally, after displaying the code answer generated by the large language model on the front-end interface, the method further includes:

[0035] Receive the user's comments on the code answer entered in the front-end interface;

[0036] Generate corresponding improvement strategies based on the comments submitted by users, and optimize the generated code answers through the improvement strategies; wherein the improvement strategies include: improving the completeness of the front-end API documentation, modifying the prompt words, upgrading the called large language model, or introducing a new large language model.

[0037] In a second aspect, an embodiment of the present application provides a device for generating a front-end API business code, including:

[0038] The document splitting module is used to split and organize the low-code platform front-end API documents to obtain API document slices and keywords corresponding to the API document slices;

[0039] A question input module is used to receive questions input by users through the front-end interface;

[0040] The processing module is used to call the large language model to generate code answers based on the questions entered by the user, the API document slices, and the keywords corresponding to the API document slices;

[0041] The display module is used to display the code answers generated by the large language model on the front-end interface.

[0042] Optionally, the document splitting module is specifically used to:

[0043] Get complete front-end API documentation from the low-code platform;

[0044] Slice the front-end API document according to the components to which the API belongs, and obtain API document slices corresponding to each component;

[0045] Based on the API document slices corresponding to each component, organize the keywords corresponding to the API document slices, wherein the keywords include: table control, data display table, data table, table view, data grid, data list, any one of data display table, or a combination of any two or more;

[0046] A target file is formed according to the API document slices and the keywords corresponding to the API document slices, wherein the target file is used to store key-value pairs consisting of components and keywords and is input into the large language model.

[0047] Optionally, organizing keywords corresponding to the API document slices based on the API document slices corresponding to each component includes any of the following methods:

[0048] Method 1: Store the API document slices corresponding to the component as a full-text search database, locate the relevance of the question, and obtain the keywords corresponding to the API document slices;

[0049] Method 2: Input the API document slice corresponding to the component into the large language model, which converts it into the corresponding vector value, and performs relevance matching based on the vector value of the question to obtain the keywords corresponding to the API document slice;

[0050] Method 3: Artificially organize the API document slices corresponding to the components to obtain the keywords corresponding to the API document slices.

[0051] Optionally, the front-end interface includes: a historical question and answer area, an API answer area, an answer evaluation area, and a question input area; wherein:

[0052] The historical question and answer area is used to display the questions previously entered by the user and the corresponding code answers;

[0053] API answer area, used to display code answers generated based on questions;

[0054] The answer evaluation area is used to receive users' evaluation of the code answers;

[0055] The question input area is used to receive questions input by users.

[0056] Optionally, the processing module is specifically used to: organize keyword prompt words according to the question input by the user;

[0057] Based on the keyword prompts, API document slices, and the keywords corresponding to the API document slices, organize and identify the prompts of the components contained in the question, call the large language model, generate the first question and answer, and determine the components contained in the question;

[0058] According to the contained component information, the corresponding API document slices are loaded to form code generation context prompt words;

[0059] Sending the code generation prompt word to a large language model;

[0060] The large language model is called to generate a code answer according to the code generation prompt word.

[0061] Optionally, the display module is specifically used to: feed back the code answer of the large language model to the front end through the organization streaming interface, and display the code answer on the front end interface.

[0062] Optionally, the above device may further include:

[0063] A receiving module is used to receive the evaluation of the code answer entered by the user on the front-end interface;

[0064] The iterative optimization module is used to generate corresponding improvement strategies based on the evaluations submitted by users, and optimize the generated code answers through the improvement strategies; wherein the improvement strategies include: improving the completeness of the front-end API documentation, modifying the prompt words, upgrading the called large language model, or introducing a new large language model.

[0065] In a third aspect, an embodiment of the present application provides a device for generating a front-end API business code, including: a processor and a memory, wherein the memory stores executable program instructions, and when the processor calls the program instructions in the memory, the processor is used to:

[0066] Execute the steps of the method for generating the front-end API business code as described in any one of the first aspects.

[0067] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium for storing a program, which, when executed, implements the steps of the method for generating a front-end API business code as described in any one of the first aspects.

[0068] Compared with the prior art, the present invention has the following beneficial effects:

[0069] In this application, the front-end API documents of the low-code platform are split and sorted to obtain API document slices and keywords corresponding to the API document slices; questions input by users are received through the front-end interface; the large language model is called to generate code answers based on the questions input by users, API document slices, and keywords corresponding to the API document slices; the code answers generated by the large language model are displayed on the front-end interface. In this way, effective low-code platform front-end code can be generated according to business scenarios and front-end APIs, and multiple front-end APIs can be combined to achieve complex business scenario code generation. In addition, specific business scenario code can be generated based on the general code generation capabilities of the large language model and the front-end API. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings in the following descriptions are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work. By reading the detailed description of the non-limiting embodiments with reference to the following drawings, other features, purposes and advantages of the present invention will become more obvious:

[0071] Figure 1 A schematic diagram of the architecture of a method for generating front-end API business code provided in an embodiment of the present application;

[0072] Figure 2 A flowchart of a method for generating a front-end API service code provided in an embodiment of the present application;

[0073] Figure 3 A schematic diagram of a slice structure provided in an embodiment of the present application;

[0074] Figure 4 A schematic diagram of the front-end interface of the question-answering system provided in an embodiment of the present application;

[0075] Figure 5 Schematic diagram of the front-end and back-end interaction of the question-answering system provided in the embodiment of the present application

[0076] Figure 6 A schematic diagram of the interaction between various terminals in the large language model call processing process provided in an embodiment of the present application;

[0077] Figure 7 A schematic diagram of an iterative cycle flow of question-answer evaluation provided in an embodiment of the present application;

[0078] Figure 8 This is a structural diagram of a device for generating front-end API business code provided in an embodiment of the present application. DETAILED DESCRIPTION

[0079] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0080] It should be noted that when a component is said to be "fixed to" another component, it can be directly on the other component or there can be a central component. When a component is said to be "connected to" another component, it can be directly connected to the other component or there can be a central component at the same time.

[0081] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0082] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein, for example, can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0083] The following specific embodiments are used to describe in detail the technical solution of the present invention and how the technical solution of the present application solves the above technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0084] In order to facilitate the understanding of the various technical solutions provided in the embodiments of the present application, a brief description of the professional terms appearing below is given:

[0085] 1) Low-code platform: refers to a development platform that can quickly develop application systems without writing code or with a small amount of code. Through the application development method of visual configuration pages, developers with different experience levels can create web pages and mobile applications through a graphical user interface, using drag-and-drop web components and data model-driven methods.

[0086] 2) Large Language Model: (LLM) refers to a deep learning model trained with a large amount of text data, which can be used to generate natural language text or understand the meaning of language text. Large language models can handle a variety of natural language tasks, such as text classification, question answering, dialogue, code generation, etc., and are an important path to artificial intelligence.

[0087] 3) Low-code platform front-end API: refers to the page component API provided by the low-code platform, which is used to implement specific business logic in the front-end page. These APIs can be called through JAVASCRIPT to implement business scenario codes. It is a common method for low-code platforms to implement advanced functions.

[0088] 4) Business code: refers to the code that completes specific system business logic in the low-code platform. These codes are often used to complete advanced and complex functions to improve the capabilities of the low-code platform.

[0089] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0090] For example, Figure 1 A schematic diagram of the architecture of a method for generating a front-end API business code provided in an embodiment of the present application, such as Figure 1As shown, it may include a low-code platform, a front-end function of a question-and-answer system, a large model call processing, and a three-party universal large language model. First, the low-code platform completes the organization of the front-end API documents (such as document slicing, keyword organization), and obtains document slices and keywords corresponding to the slices. The front-end function of the question-and-answer system is mainly to present an interface for inputting questions to the user, to ask questions to the large model, and to present the code answers fed back by the large model. The large model call processing is mainly based on document slices and keywords corresponding to the slices, as well as the questions entered by the user, to locate the key API document slices, and to identify the effective logic of the questions, and finally to organize the prompt words and record the question-and-answer process. Among them, the three-party universal large language model (Large Language Model, LLM for short) refers to a deep learning model trained using a large amount of text data, which can be used to generate natural language text or understand the meaning of language text. The large language model can handle a variety of natural language tasks, such as text classification, question and answer, dialogue, code generation, etc., and is an important way to artificial intelligence. In an embodiment of the present application, the large language model is used to generate code answers by question and answer.

[0091] The method in this embodiment implements the enterprise development of complex page logic through a low-code front-end intelligent API process in the question-and-answer process, and can quickly implement calls to specific function APIs through natural language to improve the efficiency of page development.

[0092] For example, Figure 2 A flowchart of a method for generating a front-end API service code provided in an embodiment of the present application, such as Figure 2 As shown, the method in this embodiment can be applied to Figure 1 In the architecture shown, the following steps are specifically included:

[0093] Step 201, split and organize the low-code platform front-end API document to obtain API document slices and keywords corresponding to the API document slices.

[0094] In this embodiment, the front-end page of the low-code platform usually provides a large number of encapsulated APIs based on components and functions for business developers to call when writing business codes. For example, a general low-code platform will provide a complete document to describe how to call these APIs, including input and output parameters. Assuming there are 50 page components, each component has an average of 20 API methods. If a single article is 1,000 words, then the text described in these API documents will exceed 100,000 words. For a general large language model, if the entire document is used as the context for related questions and answers, it will far exceed the 8K context limit of the current large model. Therefore, it is first necessary to reasonably split and slice the entire API question and answer, and according to the relevance of the questions asked, only the relevant slices are used as large model context prompts, so as to reasonably adapt to the restrictions of the large model.

[0095] For example, Table 1 is a description of an API.

[0096] Table 1

[0097]

[0098] In this embodiment, the general description of "an API for obtaining selected rows of a table component" is shown in Table 1. Among them, "belonging component" identifies the component to which this API belongs, which is the table component here; "API name" is the name of the current API defined by the low-code system; "API description" details the function of the current API, as well as the parameters that need to be passed in when calling the current API and the content returned after the call; "API example" is for better use of the API, and the document also provides a complete example to fully illustrate the usage scenario; "version requirements" means that with the iteration of the low-code platform version, the API will continue to increase, and you need to pay attention to the limitations of the current version when using it.

[0099] Furthermore, after the front-end API is initially understood, in order to break down the large document into slices and effectively organize the large model context according to the slices, the embodiment of the present application slices the document according to the component to which the API belongs, so that the API document of a component is independent into a file. For example, the slice structure is as follows: Figure 3 shown.

[0100] For example, the identification of relevant API slice text in the user question can be based on the following methods:

[0101] Store the slices as a full-text search database to locate the relevance of the problem;

[0102] The slices are “embedded” into a large model and converted into vector data, and then relevance matching is performed based on the vector value of the question.

[0103] In one of the optional implementations, keywords for each slice can be manually organized, and then the API slice keywords and questions can be organized into a context for slice identification. In the API document organization part, keywords for each slice also need to be organized. For example, the keywords for the table are as follows: "table control; data display table; data table; table view; data grid; data list; data display table; Table; DataGrid;". Other component slices are similar, and eventually a keyword.txt file is formed, in which the keyword.txt file contains key-value pairs of components and keywords.

[0104] Step 202: receiving questions input by the user through the front-end page.

[0105] In this embodiment, in order to realize code generation, a front-end page is provided, which is used to support users to ask questions and view code answers fed back by the system.

[0106] For example, Figure 4 A schematic diagram of the front-end interface of the question-answering system provided in the embodiment of the present application, such as Figure 4 As shown, it may include: historical questions and answers, smart API answer area, answer evaluation area, and question input area. Among them, historical questions and answers are used to display the questions previously entered by the user and the corresponding system answers; the smart API answer area is used to display the code answers generated by the system based on the questions entered by the user; the question input area is used to provide user question input and send it to the back-end server. In this embodiment, the answer display and answer evaluation area of ​​the smart API answer area will display the complete API code generation in the form of a streaming interface, and the user can perform a closed-loop evaluation on the answer (non-compliant, basically compliant, well compliant, fully compliant, etc.), and the historical questions and answers will record the situation of each question and answer.

[0107] For example, Figure 5 The diagram of the front-end and back-end interaction of the question-answering system is shown in Figure 1. Taking the interaction between the browser and the solution server as an example, the following steps can be included:

[0108] Step 1: Enter the front-end problem through the browser and send the problem to the solution server.

[0109] Step 2: The solution server processes the received question, generates the answer by calling the big model, and sends it to the browser.

[0110] In this embodiment, a streaming request interface is used for question processing, large model calling, and returning to the browser side, and the text formatting of the question answer uses "showdown.js" for display in a MarkDown format. The streaming request interface refers to: a special http request method that allows data to be divided into smaller chunks during network transmission, each chunk has its own length information, and is sent to the client one by one. This method is implemented based on the Chunked encoding of the HTTP protocol, in which the Transfer-Encoding field in the HTTP header is set to "chunked". In this way, the sender can divide the data into smaller chunks and then send them one by one without waiting for the integrity of the entire entity. This makes it easy to complete the answer step by step, giving the questioner an experience that is close to a real question and answer. The MarkDown format display uses the "showdown.js" library to facilitate the actual effect of the display code in the browser.

[0111] Step 3: The browser formats the received answer.

[0112] Step 4: The browser displays the formatted answer.

[0113] Step 5: The browser sends the question evaluation entered by the user to the solution server and archives the history.

[0114] Step 6: The solution server generates a problem evaluation.

[0115] Step 203, calling the large language model to generate a code answer based on the question input by the user, the API document slice, and the keywords corresponding to the API document slice.

[0116] For example, Figure 6 The diagram below shows the interaction between the various terminals in the large model call processing process. Taking the interaction between the browser terminal and the solution server terminal as an example, the following steps can be included:

[0117] Step a: The server receives the question sent by the browser, organizes keyword prompts for the question, and obtains the components contained in the question.

[0118] Step b: Call the large model to generate the first answer based on the components contained in the question.

[0119] Step c: The server analyzes the answer to the first answer and generates prompt words based on the code generated by the analysis result.

[0120] In step c, if the component is recognized, the local component API document is read and the code generation prompt words are organized; if the component is not recognized, the general code generation prompt words are organized; and the generated prompt words are sent to the large model.

[0121] Step d: Call the large model to generate prompt words based on the code, or generate code answers based on the general code generation prompt words.

[0122] Step e: The server feeds the code answer back to the browser through the organization streaming interface and displays the API question and answer answer in the browser.

[0123] For example, the user's questions and all the component keyword key value files (keywork.txt) prepared in advance are used to ask the big model questions by organizing prompt words separately, and the big model is required to answer the recognized component array in a certain format. The core prompt word format is as follows:

[0124] "Suppose you are a senior front-end engineer and have developed a xxx low-code system. At the same time, the low-code provides a large number of front-end APIs with xxx functions. I will provide a document of components and component keywords, and provide you with a question: {}. You need to identify which components are included in the question and answer it in the form of an array. If no components are identified, undefined will be returned."

[0125] Exemplarily, after identifying the valid API slices in combination with the problem, the server will get a valid component array or undefined feedback. If there are valid components, the local slices will be organized to organize the code generation prompt words. If undefined is returned, the prompt words of the general problem will be organized.

[0126] Exemplarily, a method for organizing prompt words for identifying effective component scenarios is described below, which may include the following steps:

[0127] 1) Identity assumption: First, it is assumed that this is a front-end logic writing scenario of a low-code platform, so the identity assumption is mainly based on a senior front-end development engineer.

[0128] 2) System function description: mainly generates business logic code based on the front-end API of a specific low-code platform page. It is necessary to clearly describe how the low-code platform encapsulates the API, the characteristics of these APIs, how to use them, and in what scenarios they are used.

[0129] 3) Specific examples: In order to help the big model better understand the problem itself, 1-2 simple scenario questions and answers are required.

[0130] 4) Provide component API documentation: The large model needs to call the API of a specific component to generate code. Based on the problem API identification, the API documentation that has been obtained needs to be provided to the large model, and the internal organization method must be introduced in detail.

[0131] 5) Explanation of answer requirements: Since the embodiment of this application is to assist in generating valid code, the returned format is mainly code. Therefore, it is necessary to clearly indicate the return format in the prompt word. In order to further determine the API call status, it is necessary to let the large model add the API usage of this answer and the API version restrictions at the end of the answer.

[0132] For example, when calling a large model, the general method of "OpenAI" can be used. For details, please refer to the OpenAI general interface specification.

[0133] Step 204: Display the code answer generated by the large language model on the front-end interface.

[0134] In this embodiment, the answer of the large language model is fed back to the front end through the organization streaming interface, and the API question and answer answer is displayed on the front end interface.

[0135] In this embodiment, the front-end API documents of the low-code platform are split and sorted to obtain API document slices and keywords corresponding to the API document slices; questions input by users are received through the front-end interface; the large language model is called to generate code answers based on the questions input by users, API document slices, and keywords corresponding to the API document slices; the code answers generated by the large language model are displayed on the front-end interface. In this way, effective low-code platform front-end code can be generated according to business scenarios and front-end APIs, and multiple front-end APIs can be combined to realize complex business scenario code generation. In addition, specific business scenario code can also be generated based on the general code generation capabilities of the large model and the front-end API.

[0136] Exemplarily, the above method embodiment may further include the following steps:

[0137] Step 205, receiving the evaluation of the code answer input by the user in the front-end interface.

[0138] In this embodiment, the evaluation of the code answer mainly includes the following categories:

[0139] Non-compliant: The question and answer are not relevant, or the API used is not provided by a valid component.

[0140] Basically compliant: The answer has identified a valid API and basically used the API, but there could be better ways to call or organize the code in actual writing.

[0141] Good compliance: The answer has identified the valid API and well organized the API calling process. However, the writing of individual APIs is not rigorous enough and needs fine-tuning in actual operation.

[0142] Perfect fit: The answer accurately identifies the API and is logically organized to be the most appropriate, running directly on the actual page.

[0143] Step 206, generating a corresponding improvement strategy based on the evaluation submitted by the user, and optimizing the generated code answer through the improvement strategy.

[0144] Among them, the improvement strategies include: improving the completeness of the front-end API documentation, modifying the prompt words, upgrading the called large language model, or introducing a new large language model.

[0145] In this embodiment, through the analysis of the "non-compliance" and "basic compliance" problems, the improvement measures that can be adopted include: improvement of the completeness of the front-end API documentation, modification of prompt words, and upgrading and introducing large models. The improvement of API documentation mainly refers to the inability to effectively generate questions using input and output parameters of the API in API slicing; the modification of prompt words is mainly aimed at the lack of reasonable answers when the large model answers or the lack of necessary links in the answers; the upgrade of the large model mainly refers to the continuous upgrading of the large language model in the embodiment of this application as the capabilities of the general large language model are improved.

[0146] For example, Figure 7 The iterative cycle process of question and answer evaluation is demonstrated in the figure. By analyzing a large number of questions and answers, the accuracy of the questions and answers in the embodiment of the present application can be improved in a closed loop.

[0147] The embodiment of the present application adopts a closed-loop iterative design to implement quality feedback records based on a single question and answer, which is convenient for identifying the accuracy of the system questions and answers in a large number of question samples. After getting the answer, the user can evaluate the quality of the question, thereby continuously improving the auxiliary code generation process.

[0148] For example, Figure 8 This is a schematic diagram of the structure of a device for generating a front-end API business code provided in an embodiment of the present application, such as Figure 8 As shown, the device in this embodiment may include: a document splitting module 801, a question input module 802, a processing module 803 and a display module 804, wherein:

[0149] The document splitting module 801 is used to split and organize the low-code platform front-end API documents to obtain API document slices and keywords corresponding to the API document slices;

[0150] The question input module 802 is used to receive questions input by the user through the front-end interface;

[0151] The processing module 803 is used to call the large language model to generate a code answer according to the question input by the user, the API document slice, and the keywords corresponding to the API document slice;

[0152] The display module 804 is used to display the code answers generated by the large language model on the front-end interface.

[0153] Optionally, the document splitting module 801 is specifically used to: obtain a complete front-end API document from a low-code platform; slice the front-end API document according to the components to which the API belongs to obtain API document slices corresponding to each component; organize keywords corresponding to the API document slices based on the API document slices corresponding to each component, wherein the keywords include: table controls, data display tables, data tables, table views, data grids, data lists, any one of data display tables, or a combination of any two or more; form a target file based on the API document slices and the keywords corresponding to the API document slices, wherein the target file is used to store key-value pairs consisting of components and keywords, and is input into a large language model.

[0154] Optionally, organizing keywords corresponding to the API document slices based on the API document slices corresponding to each component includes any of the following methods:

[0155] Method 1: Store the API document slices corresponding to the component as a full-text search database, locate the relevance of the question, and obtain the keywords corresponding to the API document slices;

[0156] Method 2: Input the API document slice corresponding to the component into the large language model, which converts it into the corresponding vector value, and performs relevance matching based on the vector value of the question to obtain the keywords corresponding to the API document slice;

[0157] Method 3: Artificially organize the API document slices corresponding to the components to obtain the keywords corresponding to the API document slices.

[0158] Optionally, the front-end interface includes: a historical Q&A area, an API answer area, an answer evaluation area, and a question input area; wherein: the historical Q&A area is used to display questions previously input by users and the corresponding code answers; the API answer area is used to display code answers generated based on the questions; the answer evaluation area is used to receive users' evaluations of the code answers; and the question input area is used to receive questions input by users.

[0159] Optionally, the processing module 803 is specifically used to: organize keyword prompts according to the question input by the user; organize prompts for identifying components contained in the question according to the keyword prompts, API document slices, and keywords corresponding to the API document slices, call the large language model, generate a first answer, and determine the components contained in the question; load the corresponding API document slices according to the contained component information to form code generation context prompts; send the code generation prompts to the large language model; call the large language model to generate a code answer according to the code generation prompts.

[0160] Optionally, the display module 804 is specifically used to: feed back the code answer of the large language model to the front end through the organization flow interface, and display the code answer on the front end interface.

[0161] Optionally, the above device may further include:

[0162] The receiving module 805 is used to receive the evaluation of the code answer input by the user in the front-end interface;

[0163] Iterative optimization module 806 is used to generate corresponding improvement strategies based on the comments submitted by users, and optimize the generated code answers through the improvement strategies; wherein the improvement strategies include: improving the completeness of the front-end API document, modifying the prompt words, upgrading the called large language model, or introducing a new large language model.

[0164] An embodiment of the present application provides a device (or system) for generating a front-end API business code, including: a processor and a memory, wherein the memory stores executable program instructions, and when the processor calls the program instructions in the memory, the processor is used to: execute the steps of the method for generating a front-end API business code as in the above-mentioned embodiments.

[0165] It should be noted that those skilled in the art will appreciate that various aspects of the present invention may be implemented as systems, methods or program products. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "platform" herein.

[0166] In addition, an embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When at least one processor of a user device executes the computer-executable instructions, the user device executes the above-mentioned various possible methods. Among them, the computer-readable medium includes a computer storage medium and a communication medium, wherein the communication medium includes any medium that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in a user device. Of course, the processor and the storage medium can also exist in a communication device as discrete components.

[0167] The present application also provides a program product, which includes a computer program. The computer program is stored in a readable storage medium. At least one processor of the server can read the computer program from the readable storage medium. At least one processor executes the computer program so that the server implements any method of the above-mentioned embodiments of the present invention.

[0168] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0169] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art may make various modifications or variations within the scope of the claims, which do not affect the essence of the present invention.

Claims

1. A method for generating a front-end API business code, characterized in that: include: Split and organize the low-code platform front-end API documents to obtain API document slices and keywords corresponding to API document slices; Receive user input through the front-end interface; Call the large language model to generate code answers based on the user's input question, API document slices, and keywords corresponding to the API document slices; The code answers generated by the large language model are displayed on the front-end interface.

2. The method for generating a front-end API business code according to claim 1, characterized in that: The low-code platform front-end API document is split and sorted to obtain API document slices and keywords corresponding to the API document slices, including: Get complete front-end API documentation from the low-code platform; Slice the front-end API document according to the components to which the API belongs, and obtain API document slices corresponding to each component; Based on the API document slices corresponding to each component, organize the keywords corresponding to the API document slices, wherein the keywords include: table control, data display table, data table, table view, data grid, data list, any one of data display table, or a combination of any two or more; A target file is formed according to the API document slices and the keywords corresponding to the API document slices, wherein the target file is used to store key-value pairs consisting of components and keywords and is input into the large language model.

3. The method for generating a front-end API business code according to claim 2, characterized in that: The organizing of keywords corresponding to the API document slices based on the API document slices corresponding to each component includes any of the following methods: Method 1: Store the API document slices corresponding to the component as a full-text search database, locate the relevance of the question, and obtain the keywords corresponding to the API document slices; Method 2: Input the API document slice corresponding to the component into the large language model, which converts it into the corresponding vector value, and performs relevance matching based on the vector value of the question to obtain the keywords corresponding to the API document slice; Method 3: Artificially organize the API document slices corresponding to the components to obtain the keywords corresponding to the API document slices.

4. The method for generating a front-end API service code according to claim 1, characterized in that: The front-end interface includes: a historical question and answer area, an API answer area, an answer evaluation area, and a question input area; wherein: The historical question and answer area is used to display the questions previously entered by the user and the corresponding code answers; API answer area, used to display code answers generated based on questions; The answer evaluation area is used to receive users' evaluation of the code answers; The question input area is used to receive questions input by users.

5. The method for generating a front-end API business code according to claim 1, characterized in that: The calling of the large language model generates code answers based on the question input by the user, the API document slice, and the keywords corresponding to the API document slice, including: Organize keyword prompts based on the questions entered by the user; According to the keyword prompts, API document slices, and the keywords corresponding to the API document slices, organize and identify the prompts of the components contained in the question, call the large language model, generate the first answer, and determine the components contained in the question; According to the component information, the corresponding API document slices are loaded to form code generation context prompt words; Sending the code generation prompt word to a large language model; The large language model is called to generate a code answer according to the code generation prompt word.

6. The method for generating a front-end API service code according to claim 1, characterized in that: The code answer generated by the large language model is displayed on the front-end interface, including: The code answer of the large language model is fed back to the front end through the organization streaming interface, and the code answer is displayed on the front end interface.

7. The method for generating a front-end API service code according to any one of claims 1 to 6, characterized in that: After displaying the code answer generated by the large language model on the front-end interface, the method further includes: Receive the user's comments on the code answer entered in the front-end interface; Generate corresponding improvement strategies based on the comments submitted by users, and optimize the generated code answers through the improvement strategies; wherein the improvement strategies include: improving the completeness of the front-end API documentation, modifying the prompt words, upgrading the called large language model, or introducing a new large language model.

8. A device for generating a front-end API business code, characterized in that: include: The document splitting module is used to split and organize the low-code platform front-end API documents to obtain API document slices and keywords corresponding to the API document slices; A question input module is used to receive questions input by users through the front-end interface; The processing module is used to call the large language model to generate code answers based on the questions entered by the user, the API document slices, and the keywords corresponding to the API document slices; The display module is used to display the code answers generated by the large language model on the front-end interface.

9. A device for generating front-end API business code, characterized in that: include: A processor and a memory, wherein the memory stores executable program instructions, and when the processor calls the program instructions in the memory, the processor is used to: Execute the steps of the method for generating the front-end API business code as described in any one of claims 1 to 7.

10. A computer-readable storage medium for storing a program, characterized in that: When the program is executed, the steps of the method for generating the front-end API business code according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Question and answer pair generation method and device based on API document, equipment and storage medium

    CN119739755A

  • Method, apparatus, device, and storage medium for generating question-and-answer pairs based on API documentation

    CN119739755B

  • Code generation method and device, medium and equipment

    CN119847532A

  • Meteorological data access code generation method based on language large model

    CN121326317A