Code flow chart generation method and device, equipment and medium
By deploying a plugin in IDEA to call an AI model cluster to generate flowcharts, the problem of fragmented tools and insufficient dynamic analysis in existing technologies is solved, achieving efficient and accurate code logic mapping and improving development efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-03-13
AI Technical Summary
Existing code flowchart generation tools lack effective integration, causing developers to frequently switch between development environments and tool interfaces, which is time-consuming and laborious, and lacks dynamic analysis and update capabilities, affecting development efficiency.
Deploy a plugin in the IDEA integrated development environment, and use the plugin to call the gateway to generate an interactive flowchart. Utilize an AI model cluster to dynamically analyze the code logic and generate an accurate flowchart.
It enables efficient and accurate generation of flowcharts within IDEA, reducing environment switching, improving development efficiency, ensuring consistency between the generated flowcharts and code logic, and has strong dynamic update capabilities.
Smart Images

Figure CN121658008A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer software technology, and in particular to a method, apparatus, device and medium for generating code flowcharts. Background Technology
[0002] In current software development scenarios, developers often rely on code flowcharts to aid understanding and communication when outlining code execution logic and communicating code structure to the team. However, existing technical solutions have significant shortcomings. On one hand, while existing technologies offer IDE (Integrated Development Environment) plugin development capabilities and independent flowchart generation tools, the two lack effective integration. Existing code visualization plugins can only display inter-class dependencies and cannot generate detailed flowcharts of code execution paths. Basic flowchart tools require developers to annotate code logic line by line and manually input flowchart description text, which is not only time-consuming and laborious but also prone to overlooking key code boundaries such as nested loops and exception handling due to manual operation, leading to discrepancies between the flowchart and the actual code logic. On the other hand, existing technologies generally suffer from tool fragmentation. Developers need to export code to third-party flowchart tools for operation, frequently switching between development environments and tool interfaces, disrupting the normal development process. At the same time, the lack of dynamic analysis and updating capabilities means that flowcharts cannot be dynamically generated based on the actual code execution path, severely impacting development efficiency. Summary of the Invention
[0003] In view of this, the purpose of this application is to provide a method, apparatus, device, and medium for generating code flowcharts. By deploying a plugin in IDEA, the plugin calls a gateway to ultimately generate an interactive flowchart, meeting the needs of efficient, accurate, and seamless development. The specific solution is as follows:
[0004] Firstly, this application provides a code flowchart generation method, applied to a target AI gateway on the server side, including:
[0005] Receive a target request sent by a target plugin in the user terminal; the target request includes user-configured flowchart generation preference data and a structured data object generated by the target plugin in the user terminal;
[0006] The flowchart generation preference data and the structured data object are filled into a pre-designed prompt word template to obtain the target prompt word. The target prompt word is sent to the target model matched from the model cluster according to the preset model routing strategy so that the target model returns the corresponding original flowchart code text.
[0007] Based on a predefined standardized data format, the original flowchart code text is converted into standardized response data, and the standardized response data is sent to the target plugin in the user terminal so that the target plugin in the user terminal can extract the flowchart code in the standardized response data and generate an interactive flowchart based on the flowchart code.
[0008] Optionally, the content of the pre-designed prompt template includes role definition, task description, output format requirements, and variable slots for dynamically populating the flowchart generation preference data and the structured data object;
[0009] Accordingly, after obtaining the target prompt word, the process also includes:
[0010] The target prompt word is length-checked. If the length of the target prompt word exceeds the context window limit of the target model, non-critical comments or redundant syntax elements in the target prompt word are removed to obtain an optimized target prompt word, which is then sent to the target model.
[0011] Optionally, sending the target prompt word to the target model matched from the model cluster according to a preset model routing strategy includes:
[0012] Based on a cost-first strategy, the target prompt words are sent to the model with the highest call cost-effectiveness matched from the model cluster;
[0013] Alternatively, based on a quality-first strategy, the target prompt word is sent to the highest-performing model matched from the model cluster;
[0014] Alternatively, based on a load balancing strategy, the model with the lightest load is selected according to the current request queue length of each model, and the target prompt is sent to the model with the lightest load.
[0015] Optionally, the code flowchart generation method further includes:
[0016] When the selected target model fails or times out, the target model that failed or times out is marked as unavailable, and a backup model of the same type is selected from the model cluster according to the model routing policy, so as to use the backup model for corresponding processing.
[0017] Send alarm information so that operation and maintenance personnel can handle the failure or timeout of the target model; the alarm information includes the name of the faulty model, the time of failure, and the number of tasks affected.
[0018] Secondly, this application provides a code flowchart generation method, applied to a target plugin in a user terminal, including:
[0019] The system receives flowchart generation preference data input by the user in a graphical interface; the flowchart generation preference data includes the level of detail in the flowchart.
[0020] Obtain the target code selected by the user, parse the target code to generate a structured data object based on the parsed data;
[0021] The flowchart generation preference data and the structured data object are encapsulated into a target request, and the target request is sent to the target AI gateway on the server side. The target AI gateway obtains the corresponding target prompt words based on the target request, sends the target prompt words to the target model matched from the model cluster according to the preset model routing strategy, and converts the original flowchart code text returned by the target model into standardized response data.
[0022] The system receives standardized response data returned by the target AI gateway on the server side, extracts flowchart code from the standardized response data, and generates an interactive flowchart based on the flowchart code.
[0023] Optionally, obtaining the target code selected by the user and parsing the target code to generate a structured data object based on the parsed data includes:
[0024] If the user directly selects the target code block, then the target code block will be parsed;
[0025] If the user places the cursor within a method or function without selecting it, the entire method or function body where the cursor is located will be automatically parsed.
[0026] A structured data object is generated based on the parsed data; the content of the structured data object includes class name, method name, parameters, method body, and control flow statements.
[0027] Optionally, the code flowchart generation method further includes:
[0028] Receive user's modification instructions for the generated flowchart, modify the flowchart according to the modification instructions and generate corresponding code adjustment suggestions, and update the corresponding flowchart code based on the code adjustment suggestions;
[0029] Accordingly, after generating an interactive flowchart based on the flowchart code, the process further includes:
[0030] The flowchart code corresponding to the flowchart is stored in a local cache. When it is detected that the flowchart code corresponding to the flowchart has been modified, a prompt is sent to the user terminal so that the user terminal can choose to quickly display the old flowchart using the cache or regenerate the new flowchart according to the prompt.
[0031] Thirdly, this application provides a code flowchart generation device, applied to a target AI gateway on the server side, comprising:
[0032] The request receiving module is used to receive a target request sent by the target plugin in the user terminal; the target request includes user-configured flowchart generation preference data and a structured data object generated by the target plugin in the user terminal;
[0033] The text acquisition module is used to fill the flowchart generation preference data and the structured data object into a pre-designed prompt word template to obtain the target prompt word. According to the preset model routing strategy, the target prompt word is sent to the target model matched from the model cluster so that the target model returns the corresponding original flowchart code text.
[0034] The flowchart generation module is used to convert the original flowchart code text into standardized response data based on a predefined standardized data format, and send the standardized response data to the target plugin in the user terminal, so that the target plugin in the user terminal can extract the flowchart code in the standardized response data and generate an interactive flowchart based on the flowchart code.
[0035] Fourthly, this application provides an electronic device, comprising:
[0036] Memory, used to store computer programs;
[0037] A processor is used to execute the computer program to implement the aforementioned code flowchart generation method.
[0038] Fifthly, this application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned code flowchart generation method.
[0039] In this application, a target request is received from a target plugin in a user terminal. The target request includes user-configured flowchart generation preference data and a structured data object generated by the target plugin in the user terminal. The flowchart generation preference data and the structured data object are filled into a pre-designed prompt word template to obtain a target prompt word. The target prompt word is sent to a target model matched from the model cluster according to a preset model routing strategy, so that the target model returns the corresponding original flowchart code text. The original flowchart code text is converted into standardized response data based on a predefined standardized data format. The standardized response data is sent to the target plugin in the user terminal, so that the target plugin in the user terminal can extract the flowchart code in the standardized response data and generate an interactive flowchart based on the flowchart code. As described above, this application populates the prompt word template with structured data objects and user-configured flowchart generation preference data to obtain target prompt words. These target prompt words are then sent to the target model matched from the model cluster. The AI model generates the corresponding original flowchart code text, resulting in an interactive flowchart. The AI model accurately identifies key boundaries such as nested loops and exception handling, ensuring the final generated flowchart is consistent with the actual code logic, replacing the inefficient "manual annotation + manual drawing" mode. Developers do not need to export code; they can directly configure preferences and initiate requests on the user side via a plugin. The standardized response data generated on the server side is directly returned to the plugin. The plugin does not rely on third-party tools and can independently complete flowchart code extraction and visualization generation, avoiding environment switching. The structured data object generated by the plugin on the user side is not a simple extraction of static code text, but a structured depiction of the actual code execution path. The server generates corresponding standardized response data based on this dynamic structured data object and sends it to the plugin on the user side to obtain an interactive flowchart. The flowchart content directly maps to the actual code execution path, rather than a static list of all branches, thus achieving "the actual code execution path..." Structured data The precise mapping of "dynamic flowcharts" solves the pain point of existing solutions lacking dynamic analysis capabilities. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0041] Figure 1 This application discloses a specific flowchart for generating code flowcharts.
[0042] Figure 2 This is a schematic diagram of a system architecture disclosed in this application;
[0043] Figure 3 This is a sequence diagram disclosed in this application;
[0044] Figure 4 A flowchart for another specific code flowchart generation method disclosed in this application;
[0045] Figure 5 This is a schematic diagram of the structure of a code flowchart generation device disclosed in this application;
[0046] Figure 6 This is a schematic diagram of the structure of an electronic device disclosed in this application. Detailed Implementation
[0047] The technical solutions of 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. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0048] Existing code flowchart generation methods suffer from drawbacks such as cumbersome manual operations, lack of dynamic analysis and updating capabilities, and disconnect from the development environment. To address these issues, this application provides a code flowchart generation method that deploys a plugin in IDEA. The plugin then calls a gateway to generate an interactive flowchart, meeting the needs for efficient, accurate, and seamless development.
[0049] See Figure 1 As shown in the figure, this application discloses a code flowchart generation method, applied to a target AI gateway on the server side, including:
[0050] Step S11: Receive a target request sent by the target plugin in the user terminal; the target request includes user-configured flowchart generation preference data and a structured data object generated by the target plugin in the user terminal.
[0051] In this embodiment, the target request sent by the target plugin in the user terminal is first received through the target AI (Artificial Intelligence) gateway in the server.
[0052] It should be noted that the target plugin in the user-side first receives flowchart generation preference data input by the user in the graphical interface; this preference data includes, but is not limited to, the flowchart's level of detail. Then, it obtains the target code selected by the user, parses the target code, and generates a structured data object based on the parsed data. This process of obtaining the user-selected target code and parsing it to generate a structured data object can include: if the user directly selects the target code block, then the target code block is parsed; if the user only places the cursor within a method or function body without selecting it, then the entire method or function body currently under the cursor is automatically parsed. Then, a structured data object is generated based on the parsed data; the content of the structured data object includes, but is not limited to, class name, method name, parameters, method body, and control flow statements.
[0053] For example, a user configures the API (Application Programming Interface) endpoint and key for the Dify (an open-source, large-scale language model application development platform) application in the IDEA (Integrated Development Environment) settings. The plugin in the user-side provides a UI (User Interface) for the user to select the level of detail in the flowchart, such as main flow only / including exception branches, output format, etc. The user selects code or places the cursor within a method. The plugin parses the selected code through the PSI (Program Structure Interface) to generate a structured JSON object containing key information such as class name, method name, parameters, method body, and control flow statements.
[0054] Furthermore, the target plugin in the user-side encapsulates the flowchart generation preference data and structured data objects into a target request, and sends the target request to the target AI gateway in the server-side. For example, the plugin sends a structured JSON object along with the flowchart generation preference data to the preset Dify application API via an HTTP (Hypertext Transfer Protocol) request.
[0055] Step S12: Fill the flowchart generation preference data and the structured data object into the pre-designed prompt word template to obtain the target prompt word. According to the preset model routing strategy, send the target prompt word to the target model matched from the model cluster so that the target model returns the corresponding original flowchart code text.
[0056] In this embodiment, after receiving the target request, the Dify platform injects the received data into a pre-designed prompt template. For example, the prompt template is designed as: "You are a coding expert. Please convert the code described in the following JSON into Mermaid flowchart code, with a detail level of {detail_level}...". The pre-designed prompt template includes, but is not limited to, role definitions, task descriptions, output format requirements, and variable slots for dynamically populating flowchart generation preference data and structured data objects.
[0057] After obtaining the target prompt, the process may further include: performing a length check on the target prompt; if the length of the target prompt exceeds the context window limit of the target model, removing non-critical comments or redundant syntactic elements from the target prompt to obtain an optimized target prompt, which is then sent to the target model.
[0058] Then, the target prompt can be sent to the target model matched from the model cluster according to the preset model routing strategy, including: a cost-first strategy, sending the target prompt to the model with the highest call cost-effectiveness matched from the model cluster, such as GLM (Generalized Linear Models); or a quality-first strategy, sending the target prompt to the model with the strongest performance matched from the model cluster, such as GPT-4 (Generative Pre-trained Transformer 4, the fourth generation of generative pre-trained models in the GPT series); or a load-balancing strategy, selecting the model with the lightest load according to the current request queue length of each model, and sending the target prompt to the model with the lightest load.
[0059] It should be noted that when the selected target model call fails or times out, the failed or timed-out target model can be marked as unavailable, and a backup model of the same type can be selected from the model cluster according to the model routing policy to utilize the backup model for appropriate processing. Simultaneously, an alarm message is sent so that operations and maintenance personnel can handle the faulty target model; the alarm message includes, but is not limited to, the name of the faulty model, the fault time, and the number of affected tasks.
[0060] Step S13: Based on a predefined standardized data format, the original flowchart code text is converted into standardized response data, and the standardized response data is sent to the target plugin in the user terminal so that the target plugin in the user terminal can extract the flowchart code in the standardized response data and generate an interactive flowchart based on the flowchart code.
[0061] In this embodiment, after receiving the raw flowchart code text returned by the AI model, which is typically Mermaid or PlantUML code, the Dify platform can convert the raw flowchart code text into a predefined JSON format based on a predefined standardized data format, for example: { "format": "mermaid", "content": "graph TD...", "success": true}. This ensures that subsequent plugins can handle responses in a consistent manner even when dealing with different models. It should be noted that the plugin does not need to be aware of which specific model is used, nor does it hold the model API key.
[0062] The Dify platform then sends the standardized response data to the target plugin in the user's client, allowing the plugin to extract the flowchart code from the standardized response data and generate an interactive flowchart based on it. For example, after receiving the standardized response data, the plugin extracts the flowchart code and uses the built-in Mermaid / PlantUML renderer or calls an external service to draw an interactive flowchart in the IDE's tool pane.
[0063] Furthermore, users can modify the flowchart and synchronize it back to the code via the target plugin. Specifically, this can include: the target plugin receiving user modification instructions for the generated flowchart, modifying the flowchart according to the instructions and generating corresponding code adjustment suggestions, and updating the corresponding flowchart code based on the code adjustment suggestions. Correspondingly, after generating an interactive flowchart from the flowchart code, it can also include: storing the flowchart code corresponding to the flowchart in a local cache; when it detects that the flowchart code corresponding to the flowchart has been modified, sending a prompt to the user, so that the user can choose to quickly display the old flowchart using the cache or regenerate the new flowchart.
[0064] The following is based on Figure 2 Using the system architecture diagram shown as an example, the technical solution in this embodiment will be explained.
[0065] 1. The IDEA plugin client includes:
[0066] User Interface: The plugin provides a visual entry point within IDEA, with toolbar buttons for users to click to generate flowcharts, and a settings panel for users to configure Dify's API endpoints and keys, and select the level of detail and output format for the flowcharts.
[0067] Code parsing engine: When the user selects code or places the cursor in a method, the engine calls the PSI interface to extract key information from the code and organizes this information into a structured JSON object. This avoids the AI parsing deviation caused by directly passing plain text code and is the foundation for achieving accurate flowchart generation.
[0068] Communication module: Sends structured JSON objects and user-configured generation preferences to the preset Dify API via HTTP requests, and receives standardized response data returned by Dify.
[0069] Rendering Engine: The plugin extracts flowchart code from Dify's standardized responses and uses the built-in Mermaid / PlantUML renderer to draw visual flowcharts in the IDEA tool pane, supporting user interaction.
[0070] 2. The Dify AI gateway layer includes:
[0071] API Gateway: Receives HTTP requests sent by user-side plugins, passes the request data to subsequent modules, and after the response is generated, returns the standardized response data to the plugins via HTTP.
[0072] Prompt template management: Inject the structured JSON object and generation preferences sent by the user into a pre-designed prompt template, and assemble it into a "final Prompt" that the AI model can understand.
[0073] Model routing and load balancing: Following preset strategies, such as prioritizing cost by calling GLM, prioritizing quality by calling GPT-4, and load balancing by calling idle models, the system matches the target model from the backend AI model cluster and sends the "final prompt" to that model. Failover is supported; if a model fails, it automatically switches to a backup model to ensure uninterrupted service.
[0074] Standardized response processing: Different AI models return results in different formats. The original flowchart code text returned by the model is cleaned up and then converted into JSON format that the plugin can uniformly recognize. This masks the output differences between different models and ensures the stable operation of the plugin.
[0075] 3. Backend AI model cluster:
[0076] The cluster contains different types of models, such as Model A (GPT-4), Model B (GLM-4), and Model C (ERNIE, Enhanced Representation through Knowledge Integration), each adapted to different needs. GPT-4 excels at accurately parsing complex code logic, GLM has lower costs, and ERNIE is better adapted to Chinese code. The models only receive the final prompt from Dify and generate the original flowchart code text, then return the result to the Dify gateway layer, without directly interacting with user-side plugins.
[0077] The following is based on Figure 3Using the timing diagram shown as an example, the technical solution in this embodiment will be explained.
[0078] In the IDEA development environment, users first select the code snippet to be analyzed, or position the cursor within the target method, and then click the "Generate Flowchart" button in the IDEA plugin toolbar to trigger the entire process. After receiving the user's "generate command," the IDEA plugin calls the IDEA platform's PSI interface to parse the selected code, organizes the parsed data into structured data, converts the structured data into JSON format, and packages the generation preferences configured by the user in the plugin settings. This is then sent to the preset Dify API via an HTTP request. Upon receiving the plugin's request, the Dify gateway injects the "structured JSON data + user generation preferences" into a preset prompt template, generating a "final Prompt" that the AI model can understand. Based on the preset model routing strategy, the target LLM (Large Language Model) model to be called is determined. The Dify gateway then sends the "final Prompt" to the target LLM model in the backend AI model cluster according to the routing strategy. The target LLM model then converts the structured code logic into flowchart description code. After the target LLM model completes the transformation from code logic to flowchart description code, it returns the generated raw response to the Dify gateway. Upon receiving the raw response, the Dify gateway performs format standardization. The Dify gateway then returns the standardized JSON data to the requesting IDEA plugin via an HTTP response. The plugin extracts the flowchart description code from the standardized JSON returned by Dify, and then calls its built-in renderer to convert the code into a visual flowchart within IDEA's tool pane. The entire rendering process is completed within the IDE, without the need for third-party tools. The plugin displays the rendered visual flowchart within IDEA and provides interactive features. Developers can drag and drop nodes to adjust their positions, double-click to modify node labels, and right-click to edit branch names. In some scenarios, changes to the flowchart's logic can be synchronized back to the code, achieving a seamless flow. The reverse linkage of "code".
[0079] As shown above, this embodiment proposes a method to parse complex code into structured data objects and use them, along with user configuration, as input to an AI gateway. The gateway then dynamically assembles and optimizes prompts, improving efficiency and accuracy. Simultaneously, by using Dify's standardized output, the differences in output from different models are masked, ensuring the stable operation of the plugin.
[0080] See Figure 4 As shown in the figure, this application discloses a code flowchart generation method, applied to a target plugin in a user terminal, including:
[0081] Step S21: Receive flowchart generation preference data input by the user in the graphical interface; the flowchart generation preference data includes the level of detail of the flowchart.
[0082] Step S22: Obtain the target code selected by the user, parse the target code to generate a structured data object based on the parsed data.
[0083] Step S23: Encapsulate the flowchart generation preference data and the structured data object into a target request, and send the target request to the target AI gateway on the server side, so that the target AI gateway can obtain the corresponding target prompt words based on the target request, send the target prompt words to the target model matched from the model cluster according to the preset model routing strategy, and convert the original flowchart code text returned by the target model into standardized response data.
[0084] Step S24: Receive standardized response data returned by the target AI gateway in the server, extract the flowchart code in the standardized response data, and generate an interactive flowchart based on the flowchart code.
[0085] The specific implementation process of steps S21, S22, S23 and S24 can be referred to the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0086] As shown above, this embodiment generates preference data by receiving user-defined flowcharts, which can accurately adapt to users' personalized needs and avoid the generated flowcharts not matching user expectations. By parsing the target code to generate structured data objects, it significantly reduces the deviation in code logic parsing on the subsequent AI gateway side and improves the accuracy of flowchart generation. The preference data and structured data are encapsulated and sent to the server-side AI gateway. The plugin does not need to directly connect to the model cluster or hold the model API key, which simplifies the functional complexity of the plugin itself and ensures the security of model calls. Finally, it receives standardized response data and renders an interactive flowchart. The standardized format shields the output differences of different AI models, ensuring the uniformity and stability of the plugin's processing logic. The interactive flowchart allows users to directly view and operate within the development environment without switching to third-party tools, effectively reducing development process interruptions and improving the overall development and code logic sorting efficiency.
[0087] See Figure 5 As shown in the illustration, this application also discloses a code flowchart generation device, applied to a target AI gateway on the server side, comprising:
[0088] The request receiving module 11 is used to receive a target request sent by a target plugin in the user terminal; the target request includes user-configured flowchart generation preference data and a structured data object generated by the target plugin in the user terminal;
[0089] The text acquisition module 12 is used to fill the flowchart generation preference data and the structured data object into a pre-designed prompt word template to obtain the target prompt word, and send the target prompt word to the target model matched from the model cluster according to the preset model routing strategy, so that the target model returns the corresponding original flowchart code text;
[0090] The flowchart generation module 13 is used to convert the original flowchart code text into standardized response data based on a predefined standardized data format, and send the standardized response data to the target plugin in the user terminal, so that the target plugin in the user terminal can extract the flowchart code in the standardized response data and generate an interactive flowchart based on the flowchart code.
[0091] In some specific implementations, the pre-designed prompt word template includes role definitions, task descriptions, output format requirements, and variable slots for dynamically populating the flowchart generation preference data and the structured data object.
[0092] Correspondingly, the text acquisition module 12 also includes:
[0093] An optimization unit is used to check the length of the target prompt word. If the length of the target prompt word exceeds the context window limit of the target model, non-critical comments or redundant syntax elements in the target prompt word are removed to obtain an optimized target prompt word, which is then sent to the target model.
[0094] In some specific embodiments, the text acquisition module 12 includes:
[0095] The first sending unit is used to send the target prompt word to the model with the highest calling cost efficiency matched from the model cluster, based on a cost-first strategy.
[0096] The second sending unit is used to send the target prompt word to the highest-performing model matched from the model cluster based on a quality-first strategy.
[0097] The third sending unit is used to select the lightest-loaded model based on the current request queue length of each model according to the load balancing strategy, and send the target prompt word to the lightest-loaded model.
[0098] In some specific embodiments, the code flowchart generation device further includes:
[0099] The model selection unit is used to mark the target model that failed or timed out as unavailable when the selected target model fails to be called, and to select a backup model of the same type from the model cluster according to the model routing policy, so as to use the backup model for corresponding processing.
[0100] The alarm unit is used to send alarm information so that operation and maintenance personnel can handle the failure or timeout of the target model; the alarm information includes the name of the faulty model, the time of failure, and the number of tasks affected.
[0101] Furthermore, embodiments of this application also disclose an electronic device, Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0102] Figure 6 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the code flowchart generation method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0103] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0104] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0105] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the code flowchart generation method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0106] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed code flowchart generation method. The specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0107] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0108] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0109] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0110] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0111] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for generating code flowcharts, characterized in that, The target AI gateway used in the server-side includes: Receive a target request sent by a target plugin in the user terminal; the target request includes user-configured flowchart generation preference data and a structured data object generated by the target plugin in the user terminal; The flowchart generation preference data and the structured data object are filled into a pre-designed prompt word template to obtain the target prompt word. The target prompt word is sent to the target model matched from the model cluster according to the preset model routing strategy so that the target model returns the corresponding original flowchart code text. Based on a predefined standardized data format, the original flowchart code text is converted into standardized response data, and the standardized response data is sent to the target plugin in the user terminal so that the target plugin in the user terminal can extract the flowchart code in the standardized response data and generate an interactive flowchart based on the flowchart code.
2. The code flowchart generation method according to claim 1, characterized in that, The pre-designed prompt template includes role definition, task description, output format requirements, and variable slots for dynamically filling the flowchart to generate preference data and the structured data object; Accordingly, after obtaining the target prompt word, the process also includes: The target prompt word is length-checked. If the length of the target prompt word exceeds the context window limit of the target model, non-critical comments or redundant syntax elements in the target prompt word are removed to obtain an optimized target prompt word, which is then sent to the target model.
3. The code flowchart generation method according to claim 1, characterized in that, The step of sending the target prompt word to the target model matched from the model cluster according to the preset model routing strategy includes: Based on a cost-first strategy, the target prompt words are sent to the model with the highest call cost-effectiveness matched from the model cluster; Alternatively, based on a quality-first strategy, the target prompt word is sent to the highest-performing model matched from the model cluster; Alternatively, based on a load balancing strategy, the model with the lightest load is selected according to the current request queue length of each model, and the target prompt is sent to the model with the lightest load.
4. The code flowchart generation method according to claim 1, characterized in that, Also includes: When the selected target model fails or times out, the target model that failed or times out is marked as unavailable, and a backup model of the same type is selected from the model cluster according to the model routing policy, so as to use the backup model for corresponding processing. Send alarm information so that operation and maintenance personnel can handle the failure or timeout of the target model; the alarm information includes the name of the faulty model, the time of failure, and the number of tasks affected.
5. A method for generating code flowcharts, characterized in that, Target plugins applied to the user end include: The system receives flowchart generation preference data input by the user in a graphical interface; the flowchart generation preference data includes the level of detail in the flowchart. Obtain the target code selected by the user, parse the target code to generate a structured data object based on the parsed data; The flowchart generation preference data and the structured data object are encapsulated into a target request, and the target request is sent to the target AI gateway on the server side. The target AI gateway obtains the corresponding target prompt words based on the target request, sends the target prompt words to the target model matched from the model cluster according to the preset model routing strategy, and converts the original flowchart code text returned by the target model into standardized response data. The system receives standardized response data returned by the target AI gateway on the server side, extracts flowchart code from the standardized response data, and generates an interactive flowchart based on the flowchart code.
6. The code flowchart generation method according to claim 5, characterized in that, The process of obtaining the target code selected by the user and parsing the target code to generate a structured data object based on the parsed data includes: If the user directly selects the target code block, then the target code block will be parsed; If the user places the cursor within a method or function without selecting it, the entire method or function body where the cursor is located will be automatically parsed. A structured data object is generated based on the parsed data; the content of the structured data object includes class name, method name, parameters, method body, and control flow statements.
7. The code flowchart generation method according to claim 5, characterized in that, Also includes: Receive user's modification instructions for the generated flowchart, modify the flowchart according to the modification instructions and generate corresponding code adjustment suggestions, and update the corresponding flowchart code based on the code adjustment suggestions; Accordingly, after generating an interactive flowchart based on the flowchart code, the process further includes: The flowchart code corresponding to the flowchart is stored in a local cache. When it is detected that the flowchart code corresponding to the flowchart has been modified, a prompt is sent to the user terminal so that the user terminal can choose to quickly display the old flowchart using the cache or regenerate the new flowchart according to the prompt.
8. A code flowchart generation device, characterized in that, The target AI gateway used in the server-side includes: The request receiving module is used to receive a target request sent by the target plugin in the user terminal; the target request includes user-configured flowchart generation preference data and a structured data object generated by the target plugin in the user terminal; The text acquisition module is used to fill the flowchart generation preference data and the structured data object into a pre-designed prompt word template to obtain the target prompt word. According to the preset model routing strategy, the target prompt word is sent to the target model matched from the model cluster so that the target model returns the corresponding original flowchart code text. The flowchart generation module is used to convert the original flowchart code text into standardized response data based on a predefined standardized data format, and send the standardized response data to the target plugin in the user terminal, so that the target plugin in the user terminal can extract the flowchart code in the standardized response data and generate an interactive flowchart based on the flowchart code.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the code flowchart generation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store computer programs, which, when executed by a processor, implement the code flowchart generation method as described in any one of claims 1 to 7.