An AI client-based cross-process chart rendering method and system

CN122653744APending Publication Date: 2026-08-28SCI & TECH INFORMATION INST ZHEJIANG PROV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611150769.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-31
Publication Date
2026-08-28

AI Technical Summary

Technical Problem

[0006](1)系统稳定性不足

Benefits of technology

[0044] (1) Improve system stability: The master-slave process architecture isolates the chart rendering service from the business communication process. The crash or abnormality of any rendering process will not affect the normal communication and control of the master process, thereby significantly improving the stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122653744A_ABST
    Figure CN122653744A_ABST
Patent Text Reader

Abstract

The present disclosure provides an AI client-based cross-process chart rendering method and system, the method comprising: receiving chart configuration information sent by an AI client through a main process, the chart configuration information containing a chart type identifier and to-be-rendered data; passing the chart configuration information to a rendering process running independently of the main process; the rendering process allocating an idle browser instance from a browser instance pool, obtaining a corresponding preloaded resource file from a global cache according to the chart type identifier, and calling a headless browser environment of the browser instance, using the preloaded resource file to perform chart rendering, performing screenshot processing on the rendered chart, returning the screenshot as a chart result to the main process, and returning the chart result to the AI client by the main process, thereby achieving stable and fast chart rendering display in an AI agent scenario.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data visualization, specifically to a cross-process chart rendering method and system based on an AI client. Background Technology

[0002] With the development of Large Language Model (LLM) technology, AI agents are increasingly being applied to scenarios such as automated data analysis, business intelligence report generation, and enterprise knowledge systems. In these applications, AI agents typically generate charts automatically based on natural language instructions to visually display the analysis results.

[0003] In existing technologies, chart generation typically employs the following two methods.

[0004] The first approach involves generating Python plotting code using a large language model, such as calling Matplotlib or Seaborn libraries to create charts, which are then executed by a backend program to generate the images. While this method is simple to implement, the resulting charts have a relatively basic visual effect and are insufficient to meet the display requirements of enterprise-level data reports.

[0005] The second method involves rendering charts using a front-end charting library, such as ECharts or D3.js, and then rendering the webpage as an image using a headless browser. This method can generate charts with better visual effects, but it still has the following problems in practical use:

[0006] (1) Insufficient system stability

[0007] Existing chart rendering services typically run in a single process. When a script exception or memory overflow occurs during browser rendering, it may cause the entire service process to crash, thereby affecting the stable operation of the business system.

[0008] (2) Low resource utilization efficiency

[0009] Some systems launch a new browser instance for each chart rendering request, and the browser startup time is usually much longer than the actual chart rendering time, resulting in high system response latency.

[0010] (3) Chart configuration errors are difficult to automatically repair.

[0011] Since chart configurations are typically generated automatically by large language models, the generated results may contain syntax errors, data format errors, or configuration conflicts. Existing systems usually only return error messages, requiring manual correction, which interrupts the automated process.

[0012] Therefore, there is a need to provide a chart rendering method that can achieve stable and fast rendering in AI agent scenarios. Summary of the Invention

[0013] In response, this disclosure provides a cross-process graph rendering method and system based on an AI client.

[0014] Firstly, this disclosure provides a cross-process chart rendering method based on an AI client, including:

[0015] The main process receives chart configuration information sent by the AI ​​client, which includes chart type identifier and data to be rendered.

[0016] Pass the chart configuration information to the rendering process that runs independently of the main process;

[0017] The rendering process allocates an idle browser instance from the browser instance pool, retrieves the corresponding preloaded resource file from the global cache according to the chart type identifier, and calls the headless browser environment of the browser instance to perform chart rendering using the preloaded resource file. The preloaded resource file includes at least the chart core engine resources.

[0018] The rendered chart is captured and returned to the main process as the chart result. The main process then returns the chart result to the AI ​​client.

[0019] In some embodiments, the AI ​​client has a built-in large language model, and the chart configuration information is automatically generated by the large language model based on natural language instructions.

[0020] In some embodiments, the method further includes:

[0021] When the rendering process captures a rendering exception, it reports the exception to the main process. The main process performs semantic classification on the exception and determines whether it can be automatically corrected based on the classification result. If it is a type that cannot be automatically corrected, it is directly downgraded to the basic chart. If it is a type that can be automatically corrected, a correction configuration is generated and the rendering is retried. If the number of failed retryes exceeds the threshold, it is downgraded to the basic chart. Finally, the corrected or downgraded chart result is returned to the main process and replaced with the original result returned to the AI ​​client.

[0022] In some embodiments, the method further includes:

[0023] When the system starts, browser instances are pre-created and stored in the instance pool. The resource dependency mapping table is queried according to the chart type identifier to determine the minimum set of resources required for rendering different chart types. The resource files in the minimum set of resources are pre-loaded, and resource reuse between instances is achieved through global caching.

[0024] In some embodiments, the semantic classification of anomalies includes:

[0025] Obtain the original exception information corresponding to the rendering exception;

[0026] By performing pattern matching on the character content of the original exception information using regular expressions, the rendering exception is classified into at least one of the following types: syntax error, data format error, configuration logic conflict, runtime error, or memory overflow.

[0027] In some embodiments, determining whether automatic correction is possible based on the classification results includes:

[0028] When rendering exceptions are classified as syntax errors, data format errors, or configuration logic conflicts, they are automatically correctable types, and corresponding maximum retry thresholds are configured for each.

[0029] When a rendering exception is classified as a runtime error or memory overflow, it is considered a non-automatically correctable type.

[0030] In some embodiments, if the type is automatically correctable, a corrected configuration is generated and rendering is retried; if the number of failed retries exceeds a threshold, the system is downgraded to a base chart. Specifically:

[0031] If it is an autocorrectable type, construct a prompt message containing information about each exception and the original chart configuration, call the large language model to generate the corrected chart configuration, and retry rendering. If the number of failed retries exceeds the threshold, it will be downgraded to the basic chart.

[0032] In some embodiments, the method further includes:

[0033] The main process periodically sends heartbeat requests to the rendering process to monitor the running health status of the rendering process;

[0034] If no response is received from the rendering process multiple times in a row, the rendering process is determined to be abnormal, and the main process will perform a rendering process reconstruction operation. The reconstruction operation will not affect the continuous operation of the main process.

[0035] In some embodiments, the method further includes:

[0036] Set the initial number of instances, the maximum number of instances, and the instance lifecycle threshold for the browser instance pool;

[0037] When the number of idle instances is below the lower limit, a new instance is created. When the number of instances exceeds the maximum number of instances, excess instances are reclaimed. When the number of renderings or the idle time of an instance reaches the instance lifecycle threshold, the instance is reclaimed.

[0038] Secondly, this disclosure provides a cross-process chart rendering system (100) based on an AI client for running the aforementioned cross-process chart rendering method based on an AI client, including:

[0039] The configuration receiving module is used to receive chart configuration information sent by the AI ​​client through the main process. The chart configuration information includes the chart type identifier and the data to be rendered.

[0040] The transmission module is used to pass chart configuration information to the rendering process that runs independently of the main process;

[0041] The rendering execution module is used to allocate idle browser instances from the browser instance pool, obtain the corresponding preloaded resource files from the global cache according to the chart type identifier, and call the headless browser environment of the browser instance to perform chart rendering using the preloaded resource files. The preloaded resource files include at least the chart core engine resources.

[0042] The rendering result return module is used to take a screenshot of the rendered chart, return the screenshot as the chart result to the main process, and then the main process returns the chart result to the AI ​​client.

[0043] The beneficial effects of this disclosure are that, compared with the prior art, this disclosure has the following advantages:

[0044] (1) Improve system stability: The master-slave process architecture isolates the chart rendering service from the business communication process. The crash or abnormality of any rendering process will not affect the normal communication and control of the master process, thereby significantly improving the stability of the system.

[0045] (2) Improve rendering response efficiency: Compared with the real-time loading mode of "creating instances and loading resources temporarily after the request arrives", the browser instance pool is pre-created to preload the minimum set of resources required for rendering different chart types, and the resource reuse between instances is achieved through global caching. When the request arrives, the system first checks whether the resource is in the global resource cache and can directly use the preloaded resources, thereby accelerating the rendering response.

[0046] (3) Achieve automated fault tolerance: Based on error semantic classification and large language model adaptive correction mechanism, realize automatic repair of configuration errors and improve the stability of automated data analysis system. Attached Figure Description

[0047] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0048] Figure 1A schematic diagram of a cross-process chart rendering method based on an AI client provided in this embodiment of the disclosure;

[0049] Figure 2 A schematic diagram of a cross-process graph rendering device based on an AI client, provided for a disclosed embodiment;

[0050] Figure 3 An example of a fishbone diagram illustrating the various links in the industrial robot industry chain provided in this embodiment of the disclosure;

[0051] Figure 4 A schematic diagram illustrating an example method for an automatic error semantic correction mechanism provided in this disclosure embodiment;

[0052] Figure 5 This is a schematic diagram of the structure of a cross-process graph rendering system based on an AI client, provided as a public embodiment.

[0053] The accompanying drawings have illustrated specific embodiments of this disclosure, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concepts of this disclosure to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0054] The present disclosure will be further described below with reference to the accompanying drawings. The following embodiments are only used to illustrate the technical solutions of the present disclosure more clearly, and should not be used to limit the scope of protection of the present disclosure.

[0055] Figure 1 This is a general flowchart of a cross-process graph rendering method based on an AI client, provided as an embodiment of this disclosure. See also... Figure 1 The following is a detailed discussion of each step in conjunction with this embodiment.

[0056] S101 receives chart configuration information sent by the AI ​​client through the main process. The chart configuration information includes chart type identifier and data to be rendered.

[0057] In this embodiment, the chart configuration information includes chart type identifier, data to be rendered, and may further include output path, etc.

[0058] Different chart type identifiers indicate different chart types, which may include histograms, line charts, pie charts, fishbone diagrams, tree diagrams, etc.

[0059] The main process establishes a communication connection with the external AI client through the standard input / output interface and uses the JSON-RPC protocol to transmit chart configuration information, that is, the chart configuration information is in JSON format.

[0060] Optionally, the AI ​​client has a built-in large language model, and the chart configuration information is automatically generated by the large language model based on natural language instructions.

[0061] S102, pass the chart configuration information to the rendering process that runs independently of the main process;

[0062] S103, the rendering process allocates an idle browser instance from the browser instance pool, retrieves the corresponding preloaded resource file from the global cache according to the chart type identifier, and calls the headless browser environment of the browser instance to perform chart rendering using the preloaded resource file, wherein the preloaded resource file includes at least the chart core engine resources;

[0063] In this embodiment, the preloaded resource files include at least the core chart engine resources (such as echarts.js, Highcharts, D3.js, Chart.js, etc.), and may selectively include one or more extended resources as needed, such as chart extension component resources (such as datazoom.js), chart theme style resources (such as dark_theme.js), and chart data resource files (such as china_geo.json). The headless browser environment is built based on the Puppeteer framework.

[0064] S104: Take a screenshot of the rendered chart, return the screenshot as the chart result to the main process, and then the main process returns the chart result to the AI ​​client.

[0065] The user inputs a natural language command into the AI ​​client: "Generate a fishbone diagram of each link in the industrial robot supply chain using mcp_servers.graph." The AI ​​client's built-in large language model parses the command and generates structured chart configuration information (such as JSON format), which is sent to the main process via JSON-RPC. The main process forwards the configuration information across processes to the independently running rendering process. The rendering process allocates a pre-initialized headless browser instance from the browser instance pool, queries resources (such as d3.js, fishbone_layout.js) based on the chart type identifier, executes the fishbone diagram drawing using pre-loaded resources in the global cache, and returns the result to the main process, which then sends it back to the AI ​​client interface for display, such as... Figure 3 As shown in the diagram. This solution improves the efficiency and stability of cross-process chart rendering by isolating the main process and the rendering process, combined with instance pooling and resource caching mechanisms.

[0066] In one alternative implementation, the method further includes:

[0067] S105, when the rendering process captures a rendering exception, it reports the exception to the main process; the main process performs semantic classification of the exception and determines whether it can be automatically corrected based on the classification result. If it is a type that cannot be automatically corrected, it is directly downgraded to the basic chart. If it is a type that can be automatically corrected, a correction configuration is generated and the rendering is retried. If the number of failed retryes exceeds the threshold, it is downgraded to the basic chart. Finally, the corrected or downgraded chart result is returned to the main process and replaced with the original result returned to the AI ​​client.

[0068] In practical applications, the rendering engine uses the try-catch mechanism to catch JavaScript execution exceptions. Exception information includes error identifiers, error messages, and stack traces.

[0069] When the rendering process encounters a rendering exception during chart rendering, it performs semantic classification on the exception and determines whether it belongs to the type that can be automatically corrected based on the classification results:

[0070] If the correction strategy is a non-automatic correction type, then a downgrade process is performed to generate a preset base chart; if the correction strategy is an automatic correction type, then a corrected chart configuration is generated based on the rendering error and the original chart configuration, and the chart rendering is re-executed using the corrected chart configuration; if the number of automatic correction failures exceeds a preset threshold, then a downgrade process is performed to generate a preset base chart.

[0071] The chart result obtained through re-rendering or the base chart obtained through degradation is returned to the main process to replace the original rendering result returned to the AI ​​client.

[0072] Understandably, the basic chart is a predefined, simple rendered chart that retains only the core basic elements of the chart (such as basic axes, basic line / bar charts, and default styles). It uses the degraded fixed chart configuration items and does not involve too much data transformation or complex style configuration, ensuring stable generation in the rendering environment.

[0073] In one optional implementation, the semantic classification of anomalies includes:

[0074] Obtain the original exception information corresponding to the rendering exception;

[0075] By performing pattern matching on the character content of the original exception information using regular expressions, the rendering exception is classified into at least one of the following types: syntax error, data format error, configuration logic conflict, runtime error, or memory overflow.

[0076] In one optional implementation, the step of determining whether automatic correction is possible based on the classification result includes:

[0077] When rendering exceptions are classified as syntax errors, data format errors, or configuration logic conflicts, they are automatically correctable types, and corresponding maximum retry thresholds are configured for each.

[0078] When a rendering exception is classified as a runtime error or memory overflow, it is considered a non-automatically correctable type.

[0079] In one alternative implementation, if the type is automatically correctable, a corrected configuration is generated and rendering is retried; if the number of failed retries exceeds a threshold, the rendering is downgraded to the base chart. Specifically:

[0080] If it is an autocorrectable type, construct a prompt message containing information about each exception and the original chart configuration, call the large language model to generate the corrected chart configuration, and retry rendering. If the number of failed retries exceeds the threshold, it will be downgraded to the basic chart.

[0081] Preferably, if the type is automatically correctable, a prompt message containing all previous error information and the original chart configuration is constructed, and a large language model is called to generate the corrected chart configuration. The rendering is then retried. If the number of failed retries exceeds a threshold, the chart is downgraded to a basic chart. Specifically:

[0082] S1051, during the first correction, construct a prompt message containing the original exception information and the original chart configuration, call the large language model to generate the corrected chart configuration, and retry rendering;

[0083] S1052, if the first correction fails, the original chart configuration is vectorized, and the historical correction cache is queried through vector similarity retrieval. If a historical case with a similarity higher than the preset value is found, the corrected configuration of the historical case is obtained as a reference example and used together with the previous abnormal information and the original chart configuration as a prompt message. The large model is called to generate the corrected chart configuration and the rendering is retried until the number of failed retry exceeds the preset threshold. Then, the downgrade process is performed to generate the preset basic chart.

[0084] S1053 If no historical cases with similarity higher than the preset value are found, a prompt message containing information on previous anomalies and the original chart configuration is constructed, and a corrected chart configuration is generated by calling the large language model. The chart rendering is re-executed using the corrected configuration until the number of failed retries exceeds the preset threshold. Then, a downgrade process is performed to generate the preset basic chart.

[0085] like Figure 4 A specific embodiment of the provided automatic error semantic correction mechanism, which implements differentiated processing based on the semantic classification of service exception logs, includes the following steps:

[0086] S201, Rendering Error Capture. The rendering engine uses a try-catch mechanism to catch JavaScript execution exceptions. Exception information includes the error identifier, error message, and stack trace.

[0087] S202, Error Semantic Classification. Based on regular expressions, pattern matching is performed on the original exception information content to classify rendering exceptions into the following four types:

[0088] Type A (Syntax Error): Matches any of the keywords SyntaxError, Unexpected token, or JSON.parse error;

[0089] Type B (Data Format Error): Matches any of the keywords in TypeError: Cannot read property or Invalid dataformat;

[0090] Type C (Logical Conflict): Matches any of the keywords in "Component series not exists" or "Coordinate system not found".

[0091] Type D (Runtime Error or Memory Overflow): Matches either Out of Memory or Maximum call stack size exceeded.

[0092] S203, Strategy Selection. Select a handling strategy based on the error type. For types A, B, and C, the retry process is executed first, with a maximum of 2, 2, and 1 retries respectively. For type D, if there is a runtime error or memory overflow, directly jump to step S207 to execute the degradation process.

[0093] S204, initial correction. Construct a structured Prompt containing the original exception information, original configuration, and correction instructions, and send it to the LLM requesting correction. For example, using a JSON syntax error, the Prompt template configuration is as follows:

[0094] {

[0095] [Error Type] JSON Syntax Error

[0096] [Error location] Elements of the series.data array

[0097] [Revision Suggestion] Check and complete any missing right parentheses.

[0098] [Original Configuration] { ...}

[0099] Please output the corrected, complete JSON configuration, ensuring the syntax is correct.

[0100] }

[0101] S205, Historical Repair Cache Query. If the initial repair fails, the original chart configuration is vectorized, and the historical repair cache is queried through vector similarity search. The cache structure is a Map.<Config, CorrectedConfig> If a historical case with a similarity higher than the preset value is found, the corrected configuration of the historical case is obtained as a reference example and used together with the previous abnormal information and the original chart configuration as a prompt message. The large model is called to generate the corrected chart configuration and the rendering is retried until the number of failed retry exceeds the preset threshold. Then, the process proceeds to step S207 to execute the downgrade process.

[0102] In this embodiment, the historical scheme is constructed as follows: when a correction is successful, the system calculates the feature vector of the original configuration used when the previous failure occurred as the key, and stores the successfully corrected configuration (or its vector) as the value in the historical correction cache (which can be a vector database or a Map structure that supports vector retrieval).

[0103] When encountering similar original configuration failures in the future, the corresponding corrected configuration can be directly retrieved from the Map as a reference example, and then the model can be further guided to generate the corrected configuration based on the reference example information.

[0104] S206, Retry determination. If no historical cases with similarity higher than the preset value are found, a prompt message containing information on previous anomalies and the original chart configuration is constructed, and the large language model is called to generate a corrected chart configuration. The chart rendering is re-executed using the corrected configuration until the number of failed retries exceeds the preset threshold, at which point the process proceeds to step S207 to execute the downgrade process.

[0105] S207, Degradation Processing. Return to a preset safety chart (such as a basic bar chart), record detailed error logs for manual analysis, and ensure that the main process is not interrupted.

[0106] This method enables automatic fault tolerance in chart rendering: when the browser instance is running normally, the rendering engine obtains the chart rendering result; when rendering is abnormal, the error is automatically captured, the error semantics are automatically corrected, and the browser instance is called again for rendering until the correct chart result is obtained or a downgrade is performed. By automatically repairing configuration errors, the stability of the automated data analysis system is improved.

[0107] In one alternative implementation, the method further includes:

[0108] The main process periodically sends heartbeat requests to the rendering process to monitor the running health status of the rendering process;

[0109] If no response is received from the rendering process multiple times in a row, the rendering process is determined to be abnormal, and the main process will perform a rendering process reconstruction operation. The reconstruction operation will not affect the continuous operation of the main process.

[0110] In this embodiment, in order to detect abnormalities in the rendering process (such as crashes or blockages) in real time, the module sends a heartbeat request to the rendering process every preset period (e.g., 30 seconds) to obtain the health status of the downstream rendering process. If no response is received multiple times in a row, the rendering process is determined to be abnormal, and the abnormal information is sent to the main process.

[0111] In one optional implementation, prior to step S101, the method further includes:

[0112] When the system starts, browser instances are pre-created and stored in the instance pool. The resource dependency mapping table is queried according to the chart type identifier to determine the minimum set of resources required for rendering different chart types. The resource files in the minimum set of resources are pre-loaded, and resource reuse between instances is achieved through global caching. The resource dependency mapping table defines the mapping relationship between chart type identifier and minimum set of resources.

[0113] For example, the minimum resource set for a regular line chart or bar chart only includes the chart core engine echarts.js, while the minimum resource set for a fishbone chart includes the chart core engine D3.js and the chart extension component resource fishbone_layout.js. When a request arrives, the system first checks if the resource is in the global resource cache. If so, the preloaded resource can be used directly, accelerating the rendering response.

[0114] In one alternative implementation, the method further includes:

[0115] Set the initial number of instances, the maximum number of instances, and the instance lifecycle threshold for the browser instance pool;

[0116] When the number of idle instances is below the lower limit, a new instance is created. When the number of instances exceeds the maximum number of instances, excess instances are reclaimed. When the number of renderings or the idle time of an instance reaches the instance lifecycle threshold, the instance is reclaimed.

[0117] For example, the pooling parameters are: initial number of instances 2, maximum number of instances 10, and maximum idle time of a single instance 30 minutes.

[0118] like Figure 2 As shown, this disclosure provides a cross-process graph rendering device based on an AI client, employing a four-layer architecture design and achieving loosely coupled communication across languages ​​and processes through standardized protocols, specifically including:

[0119] The AI ​​client layer, acting as an external system, is responsible for natural language command processing, intent recognition, and parameter structuring. The AI ​​client establishes a persistent connection with this system via standard input / output (Stdio) and sends chart generation requests using the JSON-RPC 2.0 protocol. Request parameters include chart type identifier, structured data, and output path.

[0120] The communication control layer, implemented in Python, serves as the core control hub of the entire chart rendering device and runs within the main process. The communication control layer comprises the following four functional modules:

[0121] 1) Protocol processing module: Implements the parsing and encapsulation of the JSON-RPC 2.0 protocol, maintains the long-term connection session state with the AI ​​client, and is responsible for receiving chart generation requests and converting them into internal structured chart configurations.

[0122] 2) Heartbeat Monitoring Module: Periodically sends heartbeat requests to downstream rendering services to monitor the health status of downstream rendering processes. In this embodiment, the heartbeat period is set to 30 seconds. If no response is received multiple times consecutively, the rendering process is determined to be abnormal, and the abnormal information is sent to the process management module.

[0123] 3) Process Management Module: Maintains the normal operation of the rendering process. When an exception is received in the rendering process, it performs a rendering process reconstruction operation (e.g., destroying the exception process and starting a new process). This reconstruction process does not affect the continuous operation of the main communication control process.

[0124] 4) Semantic error handling module: It is responsible for receiving rendering error information reported from downstream and deciding on the subsequent processing flow based on the error type (such as syntax error, data format error, logical conflict, runtime error, etc.), including calling the large language model for automatic correction, retrying rendering, or performing degradation processing.

[0125] The resource management layer, implemented in Node.js, runs in a separate rendering process isolated from the main process. It is responsible for the browser instance's lifecycle management and rendering resource scheduling. The resource management layer comprises two functional modules:

[0126] 1) Rendering Engine Module: This module receives structured chart configuration information from the communication control layer and invokes the browser instance's rendering environment to perform chart rendering operations. Simultaneously, this module receives rendering exceptions reported by the browser instance, invokes the semantic error handling module (via inter-process communication) to automatically correct the configuration, and re-renders.

[0127] 2) Instance Pool Management Module: Responsible for maintaining the creation, allocation, recycling, and destruction of browser instances. In this embodiment, the pooling parameters are defined as follows: initial number of instances: 2; maximum number of instances: 10; maximum idle time per instance: 30 minutes. Browser instances are pre-created at system startup and uniformly stored in the instance pool. Based on the chart type identifier, the resource dependency mapping table is queried to determine the minimum resource set required for rendering different chart types. Resource files in the minimum resource set are pre-loaded, and resource reuse between instances is achieved through global caching. The resource dependency mapping table defines the mapping relationship between chart type identifiers and the minimum resource set.

[0128] The browser core layer is a specific Chromium browser instance. It receives control from the upper layer through the DevTools Protocol and implements headless browser control based on the Puppeteer library, performing operations such as page creation, script injection, rendering, and waiting.

[0129] Through the above four-layer architecture, this embodiment realizes a cross-process chart rendering device, in which the communication control layer (main process) and the resource management layer (rendering process) are isolated from each other and run independently. The crash or abnormality of any rendering process will not affect the normal communication and control of the main process, thereby significantly improving the stability and resource utilization efficiency of the system.

[0130] Figure 5 This disclosure provides a structural diagram of a cross-process chart rendering system based on an AI client, wherein the chart rendering system 100 is used to run the aforementioned cross-process chart rendering method based on an AI client, specifically including:

[0131] The configuration receiving module 101 is used to receive chart configuration information sent by the AI ​​client through the main process. The chart configuration information includes chart type identifier and data to be rendered.

[0132] The transmission module 102 is used to transmit the chart configuration information to the rendering process that runs independently of the main process;

[0133] The rendering execution module 103 is used for the rendering process to allocate an idle browser instance from the browser instance pool, obtain the corresponding preloaded resource file from the global cache according to the chart type identifier, and call the headless browser environment of the browser instance to perform chart rendering using the preloaded resource file. The preloaded resource file includes at least the chart core engine resource.

[0134] The rendering result return module 104 is used to take a screenshot of the rendered chart, return the screenshot as the chart result to the main process, and then the main process returns the chart result to the AI ​​client.

[0135] In one alternative implementation, the system further includes:

[0136] The exception correction module 105 is used to report the exception to the main process when the rendering process captures a rendering exception. The main process performs semantic classification on the exception and determines whether it can be automatically corrected based on the classification result. If it is a type that cannot be automatically corrected, it is directly downgraded to the basic chart. If it is a type that can be automatically corrected, a correction configuration is generated and the rendering is retried. If the number of failed retry exceeds the threshold, it is downgraded to the basic chart. Finally, the corrected or downgraded chart result is returned to the main process and replaced with the original result returned to the AI ​​client.

[0137] This disclosure provides an electronic device, including: a memory for storing computer programs;

[0138] A processor is used to execute a program stored in memory to implement the steps of the above method embodiments.

[0139] For details on the specific implementation of each step and related explanations, please refer to the aforementioned method embodiment, which will not be repeated here.

[0140] This disclosure also proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above method embodiments. For specific implementation details and explanations of each step, please refer to the foregoing method embodiments; further elaboration is not provided here.

[0141] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0142] It should be understood that the above embodiments are only used to illustrate the technical solutions of this disclosure, and not to limit them; although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure.

Claims

1. A cross-process chart rendering method based on an AI client, characterized in that, include: The main process receives chart configuration information sent by the AI ​​client, which includes chart type identifier and data to be rendered. Pass the chart configuration information to the rendering process that runs independently of the main process; The rendering process allocates an idle browser instance from the browser instance pool, retrieves the corresponding preloaded resource file from the global cache according to the chart type identifier, and calls the headless browser environment of the browser instance to perform chart rendering using the preloaded resource file. The preloaded resource file includes at least the chart core engine resources. The rendered chart is captured and returned to the main process as the chart result. The main process then returns the chart result to the AI ​​client.

2. The cross-process chart rendering method based on an AI client according to claim 1, characterized in that, The AI ​​client has a built-in large language model, and the chart configuration information is automatically generated by the large language model based on natural language instructions.

3. The cross-process chart rendering method based on an AI client according to claim 1, characterized in that, The method further includes: When the rendering process captures a rendering exception, it reports the exception to the main process. The main process performs semantic classification on the exception and determines whether it can be automatically corrected based on the classification result. If it is a type that cannot be automatically corrected, it is directly downgraded to the basic chart. If it is a type that can be automatically corrected, a correction configuration is generated and the rendering is retried. If the number of failed retryes exceeds the threshold, it is downgraded to the basic chart. Finally, the corrected or downgraded chart result is returned to the main process and replaced with the original result returned to the AI ​​client.

4. The cross-process chart rendering method based on an AI client according to claim 1, characterized in that, The method further includes: When the system starts, browser instances are pre-created and stored in the instance pool. The resource dependency mapping table is queried according to the chart type identifier to determine the minimum set of resources required for rendering different chart types. The resource files in the minimum set of resources are pre-loaded, and resource reuse between instances is achieved through global caching.

5. The cross-process chart rendering method based on an AI client according to claim 3, characterized in that, The semantic classification of anomalies includes: Obtain the original exception information corresponding to the rendering exception; By performing pattern matching on the character content of the original exception information using regular expressions, the rendering exception is classified into at least one of the following types: syntax error, data format error, configuration logic conflict, runtime error, or memory overflow.

6. The cross-process chart rendering method based on an AI client according to claim 3, characterized in that, The step of determining whether automatic correction is possible based on the classification results includes: When rendering exceptions are classified as syntax errors, data format errors, or configuration logic conflicts, they are automatically correctable types, and corresponding maximum retry thresholds are configured for each. When a rendering exception is classified as a runtime error or memory overflow, it is considered a non-automatically correctable type.

7. The cross-process chart rendering method based on an AI client according to claim 3, characterized in that, If the type is automatically correctable, a corrected configuration is generated and rendering is retried. If the number of failed retries exceeds a threshold, the rendering is downgraded to a basic chart. Specifically: If it is an autocorrectable type, construct a prompt message containing information about each exception and the original chart configuration, call the large language model to generate the corrected chart configuration, and retry rendering. If the number of failed retries exceeds the threshold, it will be downgraded to the basic chart.

8. The cross-process chart rendering method based on an AI client according to claim 1, characterized in that, The method further includes: The main process periodically sends heartbeat requests to the rendering process to monitor the running health status of the rendering process; If no response is received from the rendering process multiple times in a row, the rendering process is determined to be abnormal, and the main process will perform a rendering process reconstruction operation. The reconstruction operation will not affect the continuous operation of the main process.

9. The cross-process chart rendering method based on an AI client according to claim 4, characterized in that, The method further includes: Set the initial number of instances, the maximum number of instances, and the instance lifecycle threshold for the browser instance pool; When the number of idle instances is below the lower limit, a new instance is created. When the number of instances exceeds the maximum number of instances, excess instances are reclaimed. When the number of renderings or the idle time of an instance reaches the instance lifecycle threshold, the instance is reclaimed.

10. A cross-process chart rendering system (100) based on an AI client, used to run the cross-process chart rendering method based on an AI client as described in any one of claims 1-9, characterized in that, include: The configuration receiving module (101) is used to receive chart configuration information sent by the AI ​​client through the main process. The chart configuration information includes chart type identifier and data to be rendered. The transmission module (102) is used to transmit the chart configuration information to the rendering process that runs independently of the main process; The rendering execution module (103) is used to allocate an idle browser instance from the browser instance pool, obtain the corresponding preloaded resource file from the global cache according to the chart type identifier, and call the headless browser environment of the browser instance to perform chart rendering using the preloaded resource file. The preloaded resource file includes at least the chart core engine resource. The rendering result return module (104) is used to take a screenshot of the rendered chart, return the screenshot as the chart result to the main process, and then the main process returns the chart result to the AI ​​client.