A design method and related device for quickly accessing AI capabilities for the life service industry

By setting up an abstract base class for AI task processing in the life services industry, standardized processing from task triggering to result storage is achieved, solving the problems of repetitive development and management, ensuring system stability and cost control, and providing a unified method for accessing AI capabilities.

CN122111418APending Publication Date: 2026-05-29GUANGZHOU FAISCO INFORMATON TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGZHOU FAISCO INFORMATON TECH
Filing Date
2026-01-23
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In existing technologies, the life services industry faces issues such as redundant development, security and data consistency when integrating AI capabilities. Asynchronous task processing is unreliable, making it difficult to achieve unified management and cost control.

Method used

By setting up an abstract base class for AI task processing, standardized processing logic from task triggering to result storage is encapsulated, including parameter validation, quota checking, asynchronous task link management and status tracking, providing a unified interface and process to enable rapid access and management of AI capabilities.

Benefits of technology

It achieves unified abstraction and rapid access to AI capabilities, avoids redundant development, ensures consistent system behavior, and improves system stability and cost control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122111418A_ABST
    Figure CN122111418A_ABST
Patent Text Reader

Abstract

The application provides a design method and related equipment for quickly accessing AI capability for life service industry, and belongs to the technical field of artificial intelligence application integration and service arrangement. The application comprises: setting an abstract base class for AI task processing; in response to a business request, obtaining a task context according to the specification of the abstract base class; executing pre-processing logic defined by the abstract base class; if the pre-processing logic passes, triggering task execution according to the workflow interface of a third-party AI agent platform and starting an asynchronous task link; in the asynchronous task link, generating a task identifier for state tracking, sending a delay check message containing the task identifier to a message queue, and performing bottom processing for task execution exceptions; receiving a callback from the third-party AI agent platform, updating the execution result to business data and storing it in an audit log, and recording task flow at the same time. The application can abstract and unify AI capability, avoiding repeated development of each business line.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence application integration and service orchestration technology, and in particular to a design method and related equipment for the rapid access of AI capabilities to the life service industry. Background Technology

[0002] In related technologies, there is a problem of repetitive implementation of AI call, callback, and data entry logic across various business scenarios, making standardization difficult and prone to security, idempotency, and data consistency issues. Adding a new AI capability requires modifications to multiple layers, including the Web layer, service layer, message queue (MQ), and data access layer. For workflow tasks using an asynchronous callback-compensation model, issues such as task freezing, lost callbacks, and untraceable results can easily occur. The lack of a unified abstraction for quota / usage management hinders cost control and risk management.

[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the Invention

[0004] The main objective of this application is to propose a design method and related equipment for the rapid access of AI capabilities to the life service industry, which can abstract and unify AI capabilities, avoid redundant development across different business lines, and ensure consistent system behavior.

[0005] To achieve the above objectives, one aspect of this application proposes a design method for rapidly integrating AI capabilities into the life services industry, the method comprising the following steps:

[0006] Set up an abstract base class for AI task processing; the abstract base class encapsulates the standardized processing logic from task triggering to result storage; In response to a business request, the task context is obtained according to the specification of the abstract base class; the task context includes merchant identifier, store identifier, and input content. Based on the task context, preprocessing logic defined by the abstract base class is executed; the preprocessing logic includes parameter validation and quota checking. If the preprocessing logic passes, the workflow interface of the third-party AI intelligent agent platform is called according to the abstract base class to trigger task execution and start the asynchronous task chain; In the asynchronous task chain, a task identifier for status tracking is generated based on the task context, and a delay check message containing the task identifier is sent to the message queue to perform fallback handling for task execution anomalies. The system receives a callback of the task execution result from the third-party AI intelligent agent platform, updates the execution result to the business data and stores it in the audit log according to the rules defined by the abstract base class, and records the task flow.

[0007] In some embodiments, the standardized processing logic includes parameter verification steps, quota check steps, task creation steps, service invocation steps, asynchronous guarantee steps, and result processing steps; The parameter verification step includes verifying the basic parameters, business parameters, and functional permissions in the task context; The quota check step includes checking the AI ​​service usage quota based on the task context; The task creation steps include creating a master task record and business report, and generating task identifiers and report identifiers for tracking. The service invocation steps include encapsulating the business parameters into the inputs required by the third-party AI intelligent agent platform and invoking the asynchronous workflow interface; The asynchronous guarantee step includes returning the task identifier and report identifier to the front end, and sending a delay check message containing the identifier to the message queue; The result processing steps include receiving the results through the callback controller, pulling the complete workflow results, and updating the detection report, task status, and record quota flow.

[0008] In some embodiments, in the parameter verification step, the verification method for the business parameters is dynamically adapted according to a preset AI task type, wherein the AI ​​task type includes image analysis tasks. For image analysis tasks, the parameter verification step verifies whether the number and type of input images meet the preset requirements of the image analysis task. The image analysis tasks include scalp detection, skin detection, or traditional Chinese medicine tongue surface detection; the preset requirements include: The scalp detection task requires at least one scalp photo taken in a preset orientation; Skin analysis tasks require a facial photograph; The task of TCM tongue examination requires the submission of both tongue and facial photos.

[0009] In some embodiments, the consumption logic of the delayed check message sent in the asynchronous guarantee step includes: Check the status of the test report corresponding to the report identifier; If the status is in progress, then update the status to "generation timed out and failed"; If the status is already completed or failed, then the processing ends; Supports a retry mechanism and sends an alarm message after a retry fails; The result processing steps, when retrieving workflow results from the third-party AI agent platform, also include status determination and processing: If the retrieved task status is running, then determine whether the task creation time exceeds the preset time range; If the timeout occurs, the task will be marked as failed. If the timeout has not occurred, the message will be put back into the queue for later consumption.

[0010] In some embodiments, the execution of preprocessing logic defined by the abstract base class based on the task context includes: The parameter validation steps defined in the abstract base class are executed to validate the legality of the initiated task and the completeness of the business parameters based on the task context. If the parameter verification step passes, the quota check step defined in the abstract base class is executed to check whether the corresponding AI service usage quota is sufficient based on the merchant identifier in the task context.

[0011] In some embodiments, if the preprocessing logic passes, task execution is triggered by calling the workflow interface of a third-party AI agent platform based on the abstract base class, and an asynchronous task chain is started, including: Based on the business parameters contained in the task context, the method defined in the abstract base class is called and encapsulated into a workflow input that conforms to the specifications of the third-party AI agent platform. The unified interface encapsulated in the abstract base class is invoked to submit the workflow input to the third-party AI intelligent agent platform, triggering its workflow execution asynchronously. Upon receiving a successful acceptance response from the third-party AI agent platform for the asynchronous task, it is determined that the asynchronous task chain has been officially started.

[0012] In some embodiments, in the asynchronous task chain, generating a task identifier for state tracking based on the task context and sending a delay check message containing the task identifier to a message queue for fallback handling of task execution anomalies includes: After the preprocessing logic passes and before calling the third-party AI intelligent agent platform interface, a globally unique task identifier for state tracking is generated based on the task context, and the task identifier is bound to the task context and the business records created subsequently. After successfully triggering the workflow of the third-party AI intelligent agent platform, a delay check message is constructed, which carries the task identifier. The delay check message is then sent to a message queue and configured to be consumed after a predetermined delay time. The delay check message is configured to: when consumed, check the execution status of the corresponding task based on the task identifier carried; if the task is not completed as expected, execute the predefined timeout failure handling logic.

[0013] In some embodiments, the abstract base class includes a dialogue abstract base class for handling streaming dialogues, wherein the dialogue abstract base class executes the process of server-pushed event dialogues including: The method of the aforementioned dialogue abstract base class is used to call the streaming interface of the third-party AI agent platform and set the response mode to streaming. Incrementally return text fragments to the client in the form of server push events; If the streaming response times out, the message identifier is persisted, and the background asynchronous task fetches the complete result and sends a notification to the front end. After the streaming response is completed, the usage information is read from the metadata to record the credit limit, and the complete response JSON is stored in the rich text middleware platform.

[0014] In some embodiments, the design method for rapidly integrating AI capabilities into the life services industry further includes: When adding a new AI capability, perform the following steps: Create a new concrete implementation class that inherits from the abstract base class for AI task processing or the abstract base class for dialogue. Register new task types in the factory class; the factory class is used to route requests to concrete implementation classes that inherit from the abstract base class based on the task type; Add the Uniform Resource Locator and Key for the different third-party AI agent platforms in the Configuration Center.

[0015] To achieve the above objectives, another aspect of this application proposes a design apparatus for rapidly integrating AI capabilities into the life services industry, the apparatus comprising: The first module is used to set up an abstract base class for AI task processing; the abstract base class encapsulates the standardized processing logic from task triggering to result storage. The second module is used to respond to business requests and obtain the task context according to the specification of the abstract base class; the task context includes merchant identifier, store identifier and input content; The third module is used to execute preprocessing logic defined by the abstract base class based on the task context; the preprocessing logic includes parameter validation and quota checking; The fourth module is used to trigger task execution and start the asynchronous task chain by calling the workflow interface of the third-party AI intelligent agent platform according to the abstract base class if the preprocessing logic passes. The fifth module is used to generate a task identifier for state tracking based on the task context in the asynchronous task chain, and send a delay check message containing the task identifier to the message queue to perform fallback handling for task execution anomalies. The sixth module is used to receive the task execution result callback from the third-party AI intelligent agent platform, update the execution result to the business data and store it in the audit log according to the rules defined by the abstract base class, and record the task flow.

[0016] To achieve the above objectives, another aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described above.

[0017] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the methods described above.

[0018] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer program product, including a computer program that, when executed by a processor, implements the aforementioned method.

[0019] The embodiments of this application include at least the following beneficial effects: This application provides a design method, device, electronic device, storage medium, and program product for the rapid access of AI capabilities to the life service industry. This application includes: setting an abstract base class for AI task processing; responding to a business request and obtaining the task context according to the specification of the abstract base class; executing preprocessing logic defined by the abstract base class; if the preprocessing logic passes, triggering task execution by calling the workflow interface of a third-party AI agent platform according to the abstract base class, and starting an asynchronous task chain; in the asynchronous task chain, generating a task identifier for state tracking, and sending a delayed check message containing the task identifier to a message queue for fallback handling of task execution anomalies; receiving callbacks from the third-party AI agent platform, updating the execution results to business data and storing them in the audit log, while simultaneously recording the task flow. This application can abstract and unify AI capabilities, avoiding redundant development across different business lines. Attached Figure Description

[0020] Figure 1 This is a flowchart of a design method for quickly integrating AI capabilities into the life services industry, provided in an embodiment of this application. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.

[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0023] Before providing a detailed description of the embodiments of this application, some of the nouns and terms involved in the embodiments of this application will be explained first. The nouns and terms involved in the embodiments of this application are subject to the following interpretations.

[0024] 1) JSON, JavaScript Object Notation, is a lightweight data interchange format; 2) MQ, Message Queue, is a temporary, asynchronous "data transfer station". The sender (producer) can send messages into the queue and continue to do other things. The receiver (consumer) can "retrieve" messages from the queue and process them at its own pace. 3) Token: In large language models (LLM), a token is the basic unit after text is segmented. It can be a character, a word, or a punctuation mark. It is the basic unit for AI model to calculate workload and billing. 4) Dify, a third-party AI agent platform, is a low-code AI application development and deployment platform, such as Baidu Qianfan / Wenxin agent platform, deeply integrated OpenAI models (such as GPT-4) and Microsoft Azure AI Studio / Copilot Studio, etc.

[0025] Common integration methods for related technologies: 1. Direct API calls: Directly calling third-party AI APIs in business code leads to a high degree of coupling between AI logic and business logic, and the handling of callbacks, timeouts, and idempotency is scattered and chaotic; 2. Simple SDK encapsulation: Although it can trigger AI tasks, it lacks complete task management, billing records, failure fallback, and long-chain tracing mechanisms; 3. Asynchronous processing of message queues (MQ): Although it solves the time-consuming problem, it has low standardization in terms of message structure, business mapping, and callback specifications, and the development cost is high when adding new capabilities; 4. General AI platforms: such as OpenAI, whose APIs do not directly cover internal business entities of enterprises (such as task lists, detection reports, and billing and risk control at the store / member level).

[0026] Summary of related technical defects: 1. Duplicated development and lack of standardization: AI call, callback and data entry logic are repeatedly implemented in various business scenarios, which is difficult to unify and can easily lead to security, idempotency and data consistency issues; 2. Long development cycle and high error rate: Adding a new AI capability requires modifications to multiple parts, including the Web layer, service layer, message queue (MQ), and data access layer; 3. Unreliable asynchronous task processing: For workflow tasks in the "asynchronous-callback-compensation" mode, problems such as task freezing, lost callbacks, and untraceable results are prone to occur; 4. Difficulty in cost control: The lack of a unified abstraction for quota / usage management is not conducive to cost control and risk management.

[0027] In view of this, this application provides a design method and related equipment for the rapid access of AI capabilities to the life service industry. The solution defines a standardized process for the entire chain from task triggering to result storage, and provides a unified interface for "plug and play" AI capabilities.

[0028] This application provides a design method for rapidly accessing AI capabilities in the life services industry, relating to the field of artificial intelligence application integration and service orchestration technology. The design method for rapidly accessing AI capabilities in the life services industry provided in this application can be applied to terminals, servers, or software running on either terminal or server. In some embodiments, the terminal can be a smartphone, tablet, laptop, or desktop computer, but is not limited to these. The server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network. The software can be an application implementing the design method for rapidly accessing AI capabilities in the life services industry, but is not limited to the above forms.

[0029] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0030] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent will be obtained first. Furthermore, the collection, use, and processing of this data will comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user will be obtained through pop-ups or redirects to confirmation pages. Only after obtaining the user's separate permission or consent will the necessary user-related data for the normal operation of the embodiments of this application be obtained.

[0031] Figure 1 This is an optional flowchart of a design method for quickly integrating AI capabilities into the life services industry, provided in an embodiment of this application. Figure 1 The method may include, but is not limited to, steps S101 to S106.

[0032] Step S101: Set up an abstract base class for AI task processing; the abstract base class encapsulates the standardized processing logic from task triggering to result storage. Step S102: In response to the business request, obtain the task context according to the specification of the abstract base class; the task context includes merchant identifier, store identifier and input content; Step S103: Based on the task context, execute the preprocessing logic defined by the abstract base class; the preprocessing logic includes parameter validation and quota check; Step S104: If the preprocessing logic passes, the task execution is triggered by calling the workflow interface of the third-party AI intelligent agent platform based on the abstract base class, and the asynchronous task chain is started. Step S105: In the asynchronous task chain, a task identifier for status tracking is generated based on the task context, and a delayed check message containing the task identifier is sent to the message queue to handle task execution exceptions. Step S106: Receive the task execution result callback from the third-party AI intelligent agent platform, update the execution result to the business data and store it in the audit log according to the rules defined by the abstract base class, and record the task flow.

[0033] Steps S101 to S106, as illustrated in this embodiment, define the "standard" (standard interface and process) for all AI tasks through an abstract base class (S101). Any new AI capability (such as "skin detection" or "intelligent diagnosis") can be immediately recognized and used by the system as long as it implements the abstract method according to this standard. By executing a "standardized task processing flow" through a centralized "abstract base class," AI capabilities can be securely, reliably, cost-effectively, and rapidly integrated and governed within enterprise business systems. For example, by executing a complete pipeline of "parameter validation → quota control → asynchronous call → delay fallback → auditing and database entry" through the abstract base class (AIWorkflowAbstract), a skin detection request can be automatically transformed into a traceable, billable, auditable, and highly available service ticket.

[0034] As an optional implementation, this application takes an AI scalp health detection service as an example. Traditional scalp detection relies on consultants' visual observation, which is non-standard and difficult to retain. While there are concerns about introducing AI detection to provide objective reports, there are worries about high development costs, slow integration, unstable calls, and uncontrollable expenses. The method in this embodiment addresses these concerns. In step S101, the technical team does not write specific detection code but first defines an AIWorkflowAbstract base class. This class acts like a Standard Operating Procedure (SOP), specifying 14 standard procedures that an AI task must go through from start to finish (parameter verification, quota check, task storage, AI call, delay check, result processing, etc.). Industry data significance: This means that in the future, whether integrating "scalp detection," "skin analysis," or "body constitution identification," there will be no need to redesign the process. This saves on basic code development for all subsequent AI functions. In step S102, when member user B (memberId: 10001) of branch A (storedId: 101) initiates a scalp scan on the mini-program, the system generates a task order and automatically fills in: aid: Head Office ID; storedId: 101; mid: 10001; content: {“images”: [“front.jpg”, “top.jpg”, “left.jpg”, “right.jpg”, “back.jpg”]} (5 scalp photo IDs). This embodiment allows each AI call to be bound to a specific merchant, store, and member, laying a data foundation for subsequent accurate cost allocation (independent accounting for each store) and personalized services (tracking member historical reports). In step S103, parameter verification is performed: the system automatically checks: ① whether member user B is a valid member of branch A; ② whether 5 photos from compliant angles have been uploaded. Quota Check: The system queries the AI ​​service account of branch A and finds that there are still 985 free detection quotas available this month (headquarters pre-charges each store with 1000 quotas per month). This implementation automatically intercepts illegal requests (such as non-members or non-compliant images), reducing invalid calls and potential disputes. Once a store's quota is exhausted, the service will automatically pause, preventing "sky-high AI bills" caused by a lack of budget control. Enterprises can accurately calculate AI costs for each store, achieving cost transparency. In step S104, the system encapsulates 5 images into a request and calls the "scalp detection workflow" on the Dify platform. Since the analysis takes 30 seconds, the system immediately returns: taskId: TASK_20231027_101_10001_001. The business system and the time-consuming AI analysis are asynchronously decoupled, avoiding prolonged blocking of the Web service thread and ensuring overall system stability.In step S105, an identifier is generated and a delay is implemented. Before the call, the system generates a unique task identifier (taskId) as the "waybill number". After a successful call, the system immediately sends a "delay message" to the message queue, setting a check after 10 minutes. Assuming the AI ​​platform fails to respond within 30 seconds due to network jitter, the system will automatically detect that "the report status of member user B in branch A is still 'in progress'" after 10 minutes and automatically update it to "generation timeout failed", while notifying the technical team. This avoids "zombie tasks" where users are stuck waiting indefinitely due to a single failure. In step S106, callback processing and auditing are performed. In the scenario where the AI ​​platform completes the analysis and callback, business data is updated: the structured report generated by the AI ​​(e.g., sebum secretion index 3.2 / 5, sensitive area warning, recommendation to use shampoo containing XXX ingredient) is written into member user B's electronic profile, generating a visual detection report. Then, the data is stored in the audit log: all original information from this call (original image ID, request time, complete JSON returned by the AI, time consumed, and token consumption) is permanently archived in rich text format. The task log is also recorded: one call is deducted from branch A's credit account, and it is recorded that approximately 1500 tokens were consumed, at a cost of about 0.03 yuan. Each test generates a complete, traceable, and auditable digital profile. If member user B questions the test results, customer service can easily access the rich text audit log for this service, showing the original request and the AI's original output to quickly resolve the dispute.

[0035] In some embodiments, the standardized processing logic in step S101 includes S111 parameter verification step, S112 quota check step, S113 task creation step, S114 service call step, S115 asynchronous guarantee step and S116 result processing step. Step S111, the parameter verification step includes verifying the basic parameters, business parameters and function permissions in the task context; Step S112, the quota check step includes checking the quota used by the AI ​​service based on the task context; Step S113, the task creation step includes creating a master task record and business report, and generating task identifiers and report identifiers for tracking; Step S114, the service invocation step includes encapsulating the business parameters into the input required by the third-party AI intelligent agent platform, and invoking the asynchronous workflow interface; Step S115, the asynchronous guarantee step includes returning a task identifier and a report identifier to the front end, and sending a delay check message containing the identifier to the message queue; Step S116, the result processing steps include receiving the results through the callback controller, pulling the complete workflow results, and updating the detection report, task status, and record quota flow.

[0036] Steps S111 to S116, as illustrated in this embodiment, involve: Step S111 centralizing parameter checking and permission judgment logic, previously scattered across various business codes, into a unified framework layer for execution. This ensures all AI calls adhere to the same set of security and business rules, preventing security vulnerabilities and logical inconsistencies caused by development oversights. Step S112 checks and pre-deducts (or reserves) the available credit before a call, technically preventing overuse. This enables "budget-based" management of pay-as-you-go AI services within the enterprise, ensuring costs do not exceed preset limits. Step S113 creates unique task and report identifiers, which are subsequently returned to the front end in S115, providing users and operations personnel with a single entry point for real-time task status tracking. Each AI call has a clearly defined lifecycle and status nodes. Step S114 encapsulates business parameters into a standard format and calls asynchronous interfaces, freeing business code from concern with the API details, network communication, and long waiting times of third-party AI platforms. Business code only interacts with context objects, and technical complexity is isolated by the framework. Step S115 sends a delay check message, establishing a time-based proactive monitoring channel independent of third-party platform callbacks. This is a fundamental enhancement to the traditional "passive wait for callbacks" model, resolving the persistent problem of "task suspension" in distributed systems caused by network jitter or service provider failures. Step S116, within a transaction or reliable process, correlates and updates AI results, business status, credit limit transactions, and audit logs to ensure data consistency from technical calls to business impact and cost accounting, avoiding financial reconciliation or reporting status errors caused by data asynchrony.

[0037] In some embodiments, in the parameter verification step of step S111, the verification method of the business parameters is dynamically adapted according to the preset AI task type. The AI ​​task type includes image analysis tasks. Step S1111: For image analysis tasks, the parameter verification step verifies whether the number and type of input images meet the preset requirements of the image analysis task. Step S1112, image analysis tasks include scalp detection, skin detection, or traditional Chinese medicine tongue surface detection; preset requirements include: The scalp detection task requires at least one scalp photo taken in a preset orientation; Skin analysis tasks require a facial photograph; The task of TCM tongue examination requires the submission of both tongue and facial photos.

[0038] Steps S1111 to S1112, as illustrated in this embodiment, transform the "what image to upload" rule, which originally required manual reading of documents or experience-based judgment, into a logical judgment that can be automatically executed by code. The system can proactively reject requests with incorrect formats, rather than passing the problem to the AI ​​platform and causing processing failure or incorrect results, thus intercepting business errors before the call occurs.

[0039] In some embodiments, the consumption logic for the delayed check message sent in the asynchronous guarantee step of step S115 includes: Step S1151: Check the status of the test report corresponding to the report identifier; Step S1152: If the status is in progress, then update the status to "generation timeout failed". Step S1153: If the status is already completed or failed, then the process ends; Step S1154: Support a retry mechanism and send an alarm message after a retry fails; In step S116, the result processing step, when pulling workflow results from a third-party AI agent platform, also includes status determination and processing: Step S1161: If the retrieved task status is running, determine whether the task creation time exceeds the preset time range. Step S1162: If a timeout occurs, mark the task as failed. In step S1163, if the timeout has not occurred, the message is put back into the queue for later consumption.

[0040] Steps S1151 to S1154, as illustrated in this embodiment, do not rely on callbacks from third-party AI platforms to drive state transitions. Instead, they proactively probe based on their own time baseline. Even if a third-party service completely crashes or the network is completely interrupted, this system can still detect the anomaly after a timeout and perform closed-loop processing, achieving the capability of "self-determination upon disconnection." This transforms "timeout" from an abnormal event requiring special handling into a normal business process with a clear state (generating a timeout failure), a standard processing path (updating the state), and subsequent actions (which can trigger alarms, manual follow-up, or automatic retry). This makes fault handling standardized and predictable. The consumption logic consists of all the business code written within the message consumer method, defining the specific sequence of operations to be executed after a message is delivered to the consumer. The retry mechanism is an automatic message redelivery process implemented by the message middleware (an independent system software or service, such as RocketMQ) and the consumer's return status: When an exception occurs while the consumer is processing a message, it returns RECONSUME_LATER; upon receiving this signal, the message middleware does not immediately discard the message, but puts it back into the original queue, but increments its retry count by 1; after a short delay (such as 3 seconds, 10 seconds, or 30 seconds, configurable), the message will be delivered again to any instance within the same consumer group; this process repeats until consumption is successful or the preset maximum number of retries (such as 16 times) is reached.

[0041] Steps S1161 to S1163 shown in this embodiment of the application, wherein "re-placing the task in the queue for later consumption" is a type of "backoff retries". When it is found that the task is still running but has not timed out, instead of immediately pulling the task again (which would lead to frequent useless requests), the processing right is actively returned to the message queue, allowing it to be scheduled again after a period of time. This achieves adaptive pull frequency, reducing the pressure of meaningless calls to external APIs during task execution.

[0042] In some embodiments, step S103 may include, but is not limited to, steps S301 to S302: Step S301: Execute the parameter validation steps defined in the abstract base class, and validate the legality of the initiated task and the completeness of the business parameters based on the task context. Step S302: If the parameter verification step passes, the quota check step defined in the abstract base class is executed. Based on the merchant identifier in the task context, the corresponding AI service usage quota is checked to see if it is sufficient.

[0043] Steps S301 to S302, as illustrated in this embodiment, extract the verification rules (parameter rules, permission rules) from the scattered business code and encapsulate them uniformly in the standard methods defined by the abstract base class. This centralizes the modification, addition, deletion, and auditing of rules. For example, when a new permission rule needs to be added, only the verification logic of the framework layer needs to be modified, and all AI capabilities inheriting from this base class will automatically take effect, avoiding the risk and cost of modifying each business code individually. Placing the credit limit check (S302) immediately after the parameter verification (S301) as a necessary step before calling the AI ​​service ensures that the credit limit check is performed within the context of the request's legitimacy being confirmed. This allows credit limit deduction or reservation operations (usually in subsequent steps) to be performed based on a verified and valid merchant identifier, accurately determining cost attribution and preventing incorrect credit limit deductions due to identity theft or incorrect parameters.

[0044] In some embodiments, step S104 may include, but is not limited to, steps S401 to S403: Step S401: Based on the business parameters contained in the task context, call the method defined in the abstract base class to encapsulate it into a workflow input that conforms to the specifications of the third-party AI intelligent agent platform; Step S402: Call the unified interface encapsulated in the abstract base class to submit workflow input to the third-party AI intelligent agent platform and trigger its workflow execution in an asynchronous manner; Step S403: After receiving a successful acceptance response from the third-party AI intelligent agent platform for the asynchronous task, it is determined that the asynchronous task chain has been officially started.

[0045] Steps S401 to S403, as illustrated in this embodiment, automatically and accurately convert diverse internal business data (such as image IDs and text descriptions) into the specific format required by third-party platform APIs (such as Dify's inputs objects) through the encapsulation method in S401. This eliminates the risk of errors caused by manually concatenating request parameters, ensuring the correctness of API calls and forming the foundation for stable system operation. The "unified interface" called in S402 is an abstraction and encapsulation layer for APIs of different AI platforms. Business code and core frameworks do not directly perceive the specific API details of Dify, Azure AI, or Baidu Qianfan. When switching or adding AI platforms, only the specific implementation of this unified interface needs to be adapted or added, without modifying the upper-level business logic and process framework, thus improving the maintainability and scalability of the system. The "successful acceptance response" judgment in S403 sets a clear and unambiguous start signal for the entire asynchronous task chain. It means that the third-party platform has confirmed the receipt of the task, and the local system can safely enter the "waiting for result" state and safely execute subsequent actions (such as returning the taskId to the user and sending a delay check message).

[0046] In some embodiments, step S105 may include, but is not limited to, steps S501 to S503: Step S501: After the preprocessing logic passes and before calling the third-party AI intelligent agent platform interface, generate a globally unique task identifier for state tracking based on the task context, and bind the task identifier to the task context and the business records created subsequently. Step S502: After successfully triggering the workflow of the third-party AI intelligent agent platform, construct a delay check message, which carries a task identifier, and send the delay check message to the message queue and configure it to be consumed after a predetermined delay time. Step S503, the delayed check message is configured to: when consumed, check the execution status of the corresponding task based on the task identifier carried; if the task is not completed as expected, execute the predefined timeout failure handling logic.

[0047] In the embodiments of this application, steps S501 to S503 illustrate the following: Step S501 generates a globally unique task identifier (taskId), which provides a unique association key for all subsequent distributed operations (database records, MQ messages, third-party platform callbacks, logs). This allows operations personnel to quickly aggregate all relevant logs and statuses through the taskId in complex asynchronous chains, regardless of where the problem occurs (network, database, MQ, third-party services), enabling end-to-end tracing and diagnosis. Steps S502 and S503 together implement a "pre-set insurance" mechanism. Instead of passively waiting for a failure to occur, it proactively deploys a future checkpoint when the task starts. This design shifts the system's reliability from relying on the robustness of downstream services to relying on its own controllable scheduling and inspection capabilities, enhancing the system's autonomy and resilience.

[0048] In some embodiments, the abstract base class in step S101 includes a dialogue abstract base class for handling streaming dialogues. The process of the dialogue abstract base class executing server push event dialogues includes: Step S1011: Call the streaming interface of the third-party AI agent platform through the method of the dialogue abstract base class and set the response mode to streaming. Step S1012: Incrementally return text fragments to the client in the form of server push events; Step S1013: If the streaming response times out, persist the message flag, switch to a background asynchronous task to fetch the complete result, and send a notification to the front end. Step S1014: After the streaming response is completed, read the usage information from the metadata to record the credit limit flow, and store the complete response JSON in the rich text middleware platform.

[0049] The timeout handling mechanism in steps S1011 to S1014 of this embodiment resolves the fundamental contradiction between streaming interfaces (which typically have connection time limits) and long-running AI tasks. When a streaming response is interrupted due to a timeout, the system can automatically and smoothly downgrade from "real-time streaming mode" to "asynchronous task mode." Users will not receive a connection error but will instead receive a friendly notification that "results will be pushed later," ensuring an uninterrupted experience while concealing the technical complexity from the user.

[0050] In some embodiments, the design method for enabling the life services industry to quickly access AI capabilities also includes: Step S1070: When adding a new AI capability, perform the following steps: Step S1071: Create a concrete implementation class that inherits from the abstract base class of AI task processing or the abstract base class of dialogue; Step S1072: Register a new task type in the factory class; the factory class is used to route requests to concrete implementation classes that inherit from the abstract base class based on the task type. Step S1073: Add the Uniform Resource Locator and Key for different third-party AI agent platforms in the configuration center.

[0051] Steps S1070 to S1073, as illustrated in this embodiment, involve a factory registration mechanism that allows newly launched AI capabilities to be automatically discovered and routed by the system without restarting existing services. A Uniform Resource Locator (URL) and a Key / Secret are the "address" and "key" connecting the system to a third-party AI agent platform (such as Dify). A URL is a standard-formatted string used to uniquely identify and locate a resource (usually a service or file) on the internet. A Key is a secret string of letters and numbers used to prove the caller's identity and permissions to the API service provider. Without a valid Key, even if a request is sent to the correct URL, access will be denied by the server.

[0052] As an optional implementation method, the embodiments of this application belong to the field of artificial intelligence application integration and service orchestration, and are designed for the life service industry (such as beauty, medical aesthetics, health care, in-store services, etc.).

[0053] I. This application addresses how to achieve unified integration of a third-party AI agent platform (Dify) within an enterprise-level Web / microservice system, covering the following core aspects: Abstract Access: Provides a unified access layer; Asynchronous callback orchestration: Managing the callback logic for long-running tasks; Task-based operation: Treat each AI call as a traceable and manageable state task; Credit / Billing Management: Controlling the usage and cost of AI services; Rich text logging: Auditing and archiving the call process and results; Business-side processing: Integrating AI results with specific business logic (such as membership and stores).

[0054] II. Applicable objects of the technologies in the embodiments of this application: Merchant and member integration: The system needs to provide AI functionality for both the management backend and end-users. Rapid deployment of multiple AI capabilities: suitable for scenarios that require rapid integration of multiple AI services (such as workflow inspection and conversational content generation); Governance requirements for medium to large-scale systems: Systems that require auditing and logging of AI calls, usage statistics, and idempotency guarantees (such as message queue retries).

[0055] III. The solutions of the embodiments of the present invention will be described in detail and explained with reference to specific application examples: 3.1. Core Design: A closed loop from workflow triggering to result entry into the database.

[0056] 3.1.1. Triggering Phase (AIWorkflowAbstract.workflowRun): This stage is initiated by the business side to complete the initialization and invocation of the AI ​​task.

[0057] As an optional implementation, the following information is required to initiate the task: Input information includes: ① Basic context information (AITaskContext): aid, yid, storeId - Merchant and store identifiers; mid (Member ID) or sid (Employee ID) - Operator identifier; IP address, CLIId - Client information; content - Core input content, which is a JSON-formatted string containing specific business parameters.

[0058] ② The specific content of the "content" field (depending on the type of AI task): Scalp examination: You need to provide scalp photo file IDs from 5 directions (forehead, top of head, left side, right side, and back of the head). Skin analysis: A facial photo file ID is required; Traditional Chinese Medicine tongue examination: You need to provide a photo of your tongue and a photo of your face (file ID).

[0059] ③ Implementation method for rapid access: By inheriting the abstract class AIWorkflowAbstract, concrete subclasses (such as AiDetectionImpl) can be implemented.

[0060] Each subclass only needs to implement 8 abstract methods, and the framework will automatically handle common logic such as task management, asynchronous calls, and result processing.

[0061] Developers only need to focus on business-specific parameter validation and result parsing logic.

[0062] 3.1.1.1. Parameter Validation (checkArgs): Validate business parameters (such as the number of images, order, etc.) according to the specific detection type.

[0063] As an optional implementation, the verification types and processing methods in checkArgs are as follows: ① Basic parameter verification: For example, merchant parameters and member identification parameters cannot be empty.

[0064] ② Business parameter validation (based on task type), such as the industry intelligent agents that have already been integrated: Scalp examination: At least one image is required; Skin analysis: Facial images are required; Traditional Chinese Medicine tongue examination: Both tongue and facial images must be provided.

[0065] ③ Function permission verification: Check if the merchant has enabled the AI ​​function switch; Check if the store settings allow this function; Check the membership usage limit (if enabled).

[0066] ④ Handling method: Use a unified exception handling mechanism to throw a CommonExceptionDef exception; Each subclass implements its own specific parameter validation logic in the checkArgs() method; The framework provides a general permission check method, checkCanUse().

[0067] 3.1.1.2. Quota Check (AIUtil.checkQuota): Verifies whether the tenant's AI service quota is sufficient.

[0068] 3.1.1.3. Task storage (AIUtil.saveTask): Creates a main task record, generates a unique taskId, and associates it with core business elements such as aid (enterprise ID), yid (operator ID), storeId (store ID), and mid (member ID).

[0069] 3.1.1.4. Report Pre-creation (createDetectionReport): Create the main report table in the business module (such as member detection), with the status "in progress", and generate reportId.

[0070] 3.1.1.5. Request Encapsulation (parseChatMessageRequest): Encapsulate business parameters (such as images and variables) into the inputs format required by the AI ​​agent, and set user identifiers to isolate users on the Dify side.

[0071] 3.1.1.6. Trigger Workflow (YkAIDifyInput.workflowRunThenWaitCallback): Forcibly invokes the asynchronous workflow of the Dify platform.

[0072] 3.1.1.7. Front-end immediate response: Immediately return taskId and reportId to the front-end for the front-end to track task status.

[0073] 3.1.1.8. Send DelayCheckMessage: Sends a delayed message to MQ to be executed 10 minutes later, as a fallback for handling Dify callback exceptions or network interruptions.

[0074] As an optional implementation, a detailed explanation of the MQ mechanism of sendDelayCheckMessage: ① MQ (Message Queue) is a message queue used for asynchronous task processing. Here, a delayed message queue is used, which allows you to configure messages to be consumed only after a specified time.

[0075] ② The content included in the delay information: Param body = new Param(); body.setInt("aid", this.context.getAid()); / / Merchant ID body.setInt("yid", this.context.getYid()); / / Branch ID body.setInt("storeId", this.context.getStoreId()); / / Store ID body.setInt("taskId", taskId); / / Task ID body.setInt("reportId", reportId); / / Report ID body.setInt("type", taskType); / / Task type body.setBoolean("isMemberSubmit", isMemberSubmit); / / Whether to submit as a member / / ... other context information ③ Delay processing and response logic: Sending timing: Send immediately after the AI ​​task starts, with a 10-minute delay before execution.

[0076] ④ Consumption Logic (YkAIDetectionCheckConsumer): Check the status of the test report; If the status is not "in progress", it means that it has been completed and a success message will be returned directly. If it is still "in progress", it means there may be a problem with the AI ​​service. Change the status to "Generation timeout failed".

[0077] ⑤ Fault tolerance mechanism: Supports a retry mechanism, with a maximum of 5 retries; An alert will be sent to the WeChat group if the retry fails. Ensure that the task does not get stuck indefinitely in the "in progress" state.

[0078] 3.1.2. Callback and Result Processing Stage: This stage is triggered by a callback from the Dify platform, and is decoupled and processed by MQ for the final result.

[0079] 1. Dify callback reception: The controller (DifyCallbackController) receives callback requests containing parameters such as taskId and reportId, and writes them to the message queue (MQ).

[0080] 2. Consumer processing (YkAIDetectionConsumer): Construct the task context AITaskContext from the MQ message, keeping it consistent with the triggering side.

[0081] Call YkAIDifyInput.getWorkflowResult to retrieve the complete workflow execution result from Dify.

[0082] 3. Status Determination and Handling: In progress: If the task is still running, check if the creation time exceeds 10 minutes. If it times out, mark it as failed; otherwise, put the message back into the queue for later consumption (ReconsumeLater).

[0083] Success or failure: Regardless of the outcome, detailed results are written to the rich text platform to ensure that all calls are traceable.

[0084] 4. Business data import: Update Detection Report (saveDetectionReport): Writes the structured AI results into the member's detection report form.

[0085] Update Task Status (AIUtil.updateTaskSuccess): Updates the status of the main task table to "success" or "failure".

[0086] Record QuotaFlow: If successful, it will calculate token consumption, text length, etc., and record the quota flow.

[0087] Log Fdp: Records data tracking information used for data analysis.

[0088] 3.2. Core Design: Unified Encapsulation of the SSE (Side-Side Message) Link: For conversational scenarios, this application provides a standard streaming response encapsulation based on Server-Sent Events (SSE).

[0089] Key considerations for server-side design (AIChatAbstract.sseChat): Unified Process Abstraction: Solidify the SSE dialogue process into a standard template method. Parameter / quota verification → Save task → Call Dify streaming interface → Rich text logging → Record quota transaction history → Task completed → Tracking.

[0090] Request construction: When requesting Dify, set response_mode=streaming and select the target agent configuration via configKey.

[0091] SSE Response Specification: Header: Set Content-Type to text / event-stream and disable buffering for each proxy layer; Data frame: Each data frame is a structured JSON containing incremental text fragments (delta) and accumulated usage information (such as prompt_tokens, completion_tokens).

[0092] Timeout and Compensation: The Dify streaming interface has a timeout limit of approximately 3 minutes; If a timeout occurs, the server will persist key information such as message_id, switch to an asynchronous task in the background to retrieve the complete result, and send a "switched to asynchronous processing" message to the front end to ensure uninterrupted user experience.

[0093] Usage and Recording: After the stream ends, usage information is accurately read from metadata.usage and the transaction history is recorded. The raw response JSON is stored in a rich text platform for auditing support.

[0094] Concurrency and Context Management: Use asynchronous tools such as CompletableFuture to isolate the web request context and ensure that context information such as flow and cliId is correctly passed during thread switching.

[0095] Front-end conversational interaction design: Connections and Subscriptions: Subscribe to the server's SSE endpoint using the EventSource API.

[0096] Incremental rendering: parse the text fragments in data frame by frame and append them to the UI display area to achieve a typewriter effect.

[0097] Interruption and Retry: Provides the ability for users to manually interrupt (EventSource.close()) and supports exponential backoff reconnection in the event of network jitter.

[0098] Timeout rollback: If no end signal is received for an extended period, the frontend should prompt the user that "the result will be returned asynchronously," and the user can obtain the final result by polling the task status.

[0099] Security and User Experience: XSS filtering is applied to the returned text, and rich text formats such as Markdown are supported for rendering.

[0100] 3.3. Core Architecture: Configurable, Factory-like, and Minimal Integration Configuration and tenant isolation: By loading the URLs and SECRETs of different agents from the configuration center using configKey, isolation and hot switching of multiple agents and tenants are achieved, and configuration can be differentiated by industry, store, and environment.

[0101] Factory routing (AIFactory): Use AIFactory.getInstance(taskType, ...) to route different task types (taskType) to the corresponding concrete implementation class (such as AiDetectionImpl, AiShopRecommendImpl).

[0102] Minimize the integration process: When a new industry AI capability needs to be added, developers only need to: 1. Create a new implementation class that inherits from AIWorkflowAbstract or AIChatAbstract.

[0103] 2. Register a new taskType in AIFactory.

[0104] 3. Add the corresponding URL / SECRET for the new configKey in the configuration center.

[0105] The core business code requires no intrusive modifications, resulting in extremely low integration costs.

[0106] IV. Key points and areas to be protected in this application: 1. A general AI access paradigm driven by abstract base classes: Based on AIWorkflowAbstract / AIChatAbstract, a unified template method pattern of "validation → modeling → invocation → callback → database entry → record keeping → transaction log" is defined.

[0107] 2. Idempotency and compensation design for asynchronous closed-loop workflows: The robustness of long-chain tasks is ensured by a three-pronged mechanism of "retrying during operation, degradation for timeout failure, and delayed check MQ".

[0108] 3. Unified rich text tracking and credit limit management: By standardizing and persisting the inputs, outputs, tokens / prices, and other elements of AI calls, a unified foundation is provided for compliance auditing and cost management.

[0109] 4. Configurable multi-agent access and tenant isolation: The configKey enables dynamic binding and hot switching of AI capabilities, avoiding hard coding.

[0110] 5. Factory routing + task type governance: Using taskType as a unified identifier for industry capabilities, combined with factory routing, minimizes the scope of code changes required for new capabilities.

[0111] V. Summary of Technical Advantages (Comparison with Related Technologies): Greater consistency and reusability: By abstracting and unifying AI capabilities, redundant development across different business lines is avoided, ensuring consistent system behavior.

[0112] A more robust asynchronous callback chain: It supports runtime status determination, timeout degradation and latency compensation, which greatly reduces the risk of task suspension and data loss.

[0113] More comprehensive governance support: built-in limits, prices, token transaction records and rich text tracking to meet enterprise-level compliance and cost management needs.

[0114] Lower barrier to entry: Adding new AI capabilities only requires "configuration + factory registration + inheritance implementation", without changing the core business process.

[0115] Better observability and maintainability: Unified instrumentation, structured logs, and context (AITaskContext) make problem localization and performance optimization more efficient.

[0116] The design philosophy of the framework in this application embodiment is a combination of the template method pattern and the strategy pattern: 1. The abstract base class (AIWorkflowAbstract) defines the complete AI task processing flow; 2. The specific implementation class (such as AiDetectionImpl) only needs to focus on the business-specific logic; 3. Quick integration: Developers only need to implement 8 abstract methods to integrate a new AI function; 4. General functions: Task management, asynchronous processing, timeout checks, result saving, etc. are all handled uniformly by the framework.

[0117] This application embodiment also provides a design device for the rapid access of AI capabilities to the life service industry, which can implement the above-described method. The device includes: The first module is used to set up the abstract base class for AI task processing; the abstract base class encapsulates the standardized processing logic from task triggering to result storage. The second module is used to respond to business requests and obtain the task context according to the specification of the abstract base class; the task context includes merchant identifier, store identifier and input content; The third module is used to execute preprocessing logic defined by the abstract base class based on the task context; the preprocessing logic includes parameter validation and quota checking. The fourth module is used to trigger task execution and start the asynchronous task chain by calling the workflow interface of the third-party AI intelligent agent platform according to the abstract base class if the preprocessing logic passes. The fifth module is used to generate a task identifier for status tracking based on the task context in the asynchronous task chain, and send a delayed check message containing the task identifier to the message queue to handle task execution exceptions. The sixth module is used to receive task execution result callbacks from third-party AI intelligent agent platforms, update the execution results to business data and store them in the audit log according to the rules defined by the abstract base class, and record the task flow.

[0118] It is understood that the content of the above method embodiments is applicable to the present device embodiments. The specific functions implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0119] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.

[0120] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0121] Another embodiment of the hardware structure of the electronic device, the electronic device including: The processor can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to achieve the technical solutions provided in the embodiments of this application. The memory can be implemented in the form of read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory and called by the processor to execute the methods described in the embodiments of this application. Input / output interfaces are used to implement information input and output; The communication interface is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). A bus is used to transfer information between various components of a device, such as processors, memory, input / output interfaces, and communication interfaces. The processor, memory, input / output interfaces, and communication interfaces communicate with each other within the device via a bus.

[0122] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.

[0123] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0124] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0125] It is understood that the content of the above method embodiments is applicable to the embodiments of this program product. The specific functions implemented by the embodiments of this program product are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0126] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0127] This application provides a design method, device, electronic device, storage medium, and program product for the rapid access of AI capabilities to the life services industry. It solidifies, encapsulates, and reuses the complex technical logic (verification, quotas, asynchronous processing, callbacks, auditing) of AI service integration. This allows developers to focus solely on the business itself when developing new AI capabilities, without repeatedly solving common problems in distributed systems, thus reducing AI integration from a "complex project" to a "standard configuration."

[0128] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0129] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0130] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; 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.

[0131] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0132] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0133] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0134] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0135] The units described above 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 units can be selected to achieve the purpose of this embodiment according to actual needs.

[0136] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0137] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0138] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A design method for rapidly integrating AI capabilities into the life services industry, characterized in that, The method includes the following steps: Set up an abstract base class for AI task processing; the abstract base class encapsulates the standardized processing logic from task triggering to result storage; In response to a business request, the task context is obtained according to the specification of the abstract base class; the task context includes merchant identifier, store identifier, and input content. Based on the task context, preprocessing logic defined by the abstract base class is executed; the preprocessing logic includes parameter validation and quota checking. If the preprocessing logic passes, the workflow interface of the third-party AI intelligent agent platform is called according to the abstract base class to trigger task execution and start the asynchronous task chain; In the asynchronous task chain, a task identifier for status tracking is generated based on the task context, and a delay check message containing the task identifier is sent to the message queue to perform fallback handling for task execution anomalies. The system receives a callback of the task execution result from the third-party AI intelligent agent platform, updates the execution result to the business data and stores it in the audit log according to the rules defined by the abstract base class, and records the task flow.

2. The method according to claim 1, characterized in that, The standardized processing logic includes parameter verification steps, quota check steps, task creation steps, service invocation steps, asynchronous guarantee steps, and result processing steps. The parameter verification step includes verifying the basic parameters, business parameters, and functional permissions in the task context; The quota check step includes checking the AI ​​service usage quota based on the task context; The task creation steps include creating a master task record and business report, and generating task identifiers and report identifiers for tracking. The service invocation steps include encapsulating the business parameters into the inputs required by the third-party AI intelligent agent platform and invoking the asynchronous workflow interface; The asynchronous guarantee step includes returning the task identifier and report identifier to the front end, and sending a delay check message containing the identifier to the message queue; The result processing steps include receiving the results through the callback controller, pulling the complete workflow results, and updating the detection report, task status, and record quota flow.

3. The method according to claim 2, characterized in that, In the parameter verification step, the verification method for the business parameters is dynamically adapted according to the preset AI task type, which includes image analysis tasks. For image analysis tasks, the parameter verification step verifies whether the number and type of input images meet the preset requirements of the image analysis task. The image analysis tasks include scalp detection, skin detection, or traditional Chinese medicine tongue surface detection; the preset requirements include: The scalp detection task requires at least one scalp photo taken in a preset orientation; Skin analysis tasks require a facial photograph; The task of TCM tongue examination requires the submission of both tongue and facial photos.

4. The method according to claim 2, characterized in that, The delayed check message sent in the asynchronous guarantee step, and the consumption logic of the delayed check message include: Check the status of the test report corresponding to the report identifier; If the status is in progress, then update the status to "generation timed out and failed"; If the status is already completed or failed, then the processing ends; Supports a retry mechanism and sends an alarm message after a retry fails; The result processing steps, when retrieving workflow results from the third-party AI agent platform, also include status determination and processing: If the retrieved task status is running, then determine whether the task creation time exceeds the preset time range; If the timeout occurs, the task will be marked as failed. If the timeout has not occurred, the message will be put back into the queue for later consumption.

5. The method according to claim 1, characterized in that, The execution of preprocessing logic defined by the abstract base class based on the task context includes: The parameter validation steps defined in the abstract base class are executed to validate the legality of the initiated task and the completeness of the business parameters based on the task context. If the parameter verification step passes, the quota check step defined in the abstract base class is executed to check whether the corresponding AI service usage quota is sufficient based on the merchant identifier in the task context.

6. The method according to claim 1, characterized in that, If the preprocessing logic passes, the task execution is triggered by calling the workflow interface of the third-party AI agent platform based on the abstract base class, and the asynchronous task chain is started, including: Based on the business parameters contained in the task context, the method defined in the abstract base class is called and encapsulated into a workflow input that conforms to the specifications of the third-party AI agent platform. The unified interface encapsulated in the abstract base class is invoked to submit the workflow input to the third-party AI intelligent agent platform, triggering its workflow execution asynchronously. Upon receiving a successful acceptance response from the third-party AI agent platform for the asynchronous task, it is determined that the asynchronous task chain has been officially started.

7. The method according to claim 1, characterized in that, In the asynchronous task chain, a task identifier for state tracking is generated based on the task context, and a delay check message containing the task identifier is sent to the message queue for fallback handling of task execution anomalies, including: After the preprocessing logic passes and before calling the third-party AI intelligent agent platform interface, a globally unique task identifier for state tracking is generated based on the task context, and the task identifier is bound to the task context and the business records created subsequently. After successfully triggering the workflow of the third-party AI intelligent agent platform, a delay check message is constructed, which carries the task identifier. The delay check message is then sent to a message queue and configured to be consumed after a predetermined delay time. The delay check message is configured to: when consumed, check the execution status of the corresponding task based on the task identifier carried; if the task is not completed as expected, execute the predefined timeout failure handling logic.

8. The method according to claim 1, characterized in that, The abstract base class includes a dialogue abstract base class for handling streaming dialogues. The process of the dialogue abstract base class executing server-pushed event dialogues includes: The method of the aforementioned dialogue abstract base class is used to call the streaming interface of the third-party AI agent platform and set the response mode to streaming. Incrementally return text fragments to the client in the form of server push events; If the streaming response times out, the message identifier is persisted, and the background asynchronous task fetches the complete result and sends a notification to the front end. After the streaming response is completed, the usage information is read from the metadata to record the credit limit, and the complete response JSON is stored in the rich text middleware platform.

9. The method according to claim 1, characterized in that, The method further includes: When adding a new AI capability, perform the following steps: Create a new concrete implementation class that inherits from the abstract base class for AI task processing or the abstract base class for dialogue. Register new task types in the factory class; the factory class is used to route requests to concrete implementation classes that inherit from the abstract base class based on the task type; Add the Uniform Resource Locator and Key for the different third-party AI agent platforms in the Configuration Center.

10. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to any one of claims 1 to 9.