Multi-agent based psychological counseling system, method, device and storage medium

By using a multi-agent psychological counseling system, users' emotions can be determined in real time and adaptive processing paths can be selected to generate a structured psychological analysis chain. This solves the problem of insufficient emotion reasoning mechanisms in existing technologies and enables efficient and professional mental health services.

CN122392825APending Publication Date: 2026-07-14JIAYING UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIAYING UNIV
Filing Date
2026-04-17
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing technologies in the field of mental health, such as automated psychological intervention tools and single large-scale language model solutions, lack deep emotional reasoning mechanisms and dynamic adaptability, making it difficult to cope with complex changes in users' psychological states. Furthermore, they lack stability when dealing with complex emotions and are not professional or interpretable.

Method used

A multi-agent-based psychological counseling system is adopted, including an emotion analysis module, a routing control module, a thinking and reasoning module, and a psychological counseling module. Through emotion analysis, the system determines the user's emotional state in real time, selects an adaptive processing path, and generates a structured psychological analysis chain and professional responses.

Benefits of technology

It enhances the ability to handle complex emotional states and improves system robustness, achieves real-time and smooth interaction, improves the interpretability and professionalism of the system's decision-making process, optimizes the allocation of computing resources, and provides reliable digital mental health services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122392825A_ABST
    Figure CN122392825A_ABST
Patent Text Reader

Abstract

The application provides a kind of psychological counseling system, method, equipment and storage medium based on multi-agent, system determines user emotional state in real time by emotion analysis module, and via routing control module, it is adaptively selected processing path according to the determination result of negative or non-negative, realizes the dynamic response and different processing to user emotion.When user emotion is non-negative, system directly calls psychological counseling module to carry out efficient response, ensures the immediacy and fluency of interaction;When emotion is negative, first call thinking reasoning module to generate structured psychological analysis chain, then output by psychological counseling module, so as to provide professional intervention with logical support for deep emotional problems.This design not only enhances the processing capacity and system robustness for complex emotional state, but also greatly improves the explainability and professionalism of system decision process by introducing structured intermediate analysis chain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a psychological counseling system, method, device and storage medium based on multi-agent systems. Background Technology

[0002] As artificial intelligence (AI) technology is increasingly applied in the field of mental health, existing technologies mainly fall into two categories: one is automated psychological intervention tools based on traditional natural language processing (NLP) technology, such as emotion analysis-driven psychological assessment systems or online question-and-answer platforms; the other is to directly use a single large-scale language model for psychological counseling, fine-tuning or optimizing it through instructions to enable it to recognize emotions and provide empathetic responses. However, both of these approaches have significant limitations. Traditional tools typically lack deep-level emotion reasoning mechanisms and dynamic adaptability, making it difficult to cope with the complex and potential changes in users' psychological states. While single-model approaches improve the fluency of language generation, they lack stability when handling complex emotions, the rhythm of the dialogue often does not conform to the phased characteristics of professional counseling, the reasoning process lacks coherence and interpretability, and the overall performance is that of a "black box" system, without constructing a collaborative workflow from emotion recognition to structured reasoning to professional feedback.

[0003] In summary, the problems existing in the current technology urgently need to be solved. Summary of the Invention

[0004] This invention provides a multi-agent-based psychological counseling system, method, device, and storage medium to address the shortcomings of existing technologies and enhance the ability to handle complex emotional states and the robustness of the system.

[0005] This invention provides a multi-agent-based psychological counseling system, comprising: The sentiment analysis module is used to receive text input by the user and output a sentiment category determination result, which is used to characterize whether the user is in a negative or non-negative state. A routing control module, connected to the sentiment analysis module, is used to select a processing path based on the sentiment category determination result; The reasoning module, connected to the routing control module, is used to generate a structured psychological analysis chain when the routing control module selects the first path based on the user's emotional category determination result in a negative state. The psychological counseling module, connected to the routing control module and the reasoning module, is used to generate the final counseling response; wherein, When the routing control module selects the second path based on the determination that the user is in a non-passive state, the psychological counseling module directly generates the final counseling response; When the routing control module selects the first path, the psychological counseling module generates the final counseling response based on the psychological analysis chain generated by the thinking and reasoning module.

[0006] According to the present invention, a multi-agent-based psychological counseling system is provided, wherein the emotion analysis module includes: A text encoding unit is used to encode the text input by the user based on a pre-trained language model to obtain a text feature vector; A classification and discrimination unit, connected to the text encoding unit, is used to calculate the probability that the user input belongs to the negative category based on the text feature vector, and generate the emotion category determination result based on a preset probability threshold.

[0007] According to a multi-agent-based psychological counseling system provided by the present invention, the emotion category determination result includes emotion category, confidence score and risk score; the routing control module is further used to select a path by combining the confidence score, the risk score and the emotion category.

[0008] According to a multi-agent-based psychological counseling system provided by the present invention, the routing control module is further configured to execute a preset intermediate path strategy when the probability output by the classification and discrimination unit is in a preset intermediate range. The intermediate path strategy includes at least one of the following: triggering lightweight reasoning, adding clarifying questions, or forcibly selecting the first path based on risk keywords.

[0009] According to a multi-agent-based psychological counseling system provided by the present invention, the structured psychological analysis chain generated by the thinking and reasoning module is organized in the form of a set of labeled fields, which includes at least: pattern recognition fields, psychological mechanism analysis fields, intervention structure fields, and crisis warning fields. The crisis warning fields are used to assess the user's risk level of self-harm or harm to others.

[0010] The psychological counseling system based on multi-agent provided by the present invention further includes a safety protocol execution module; when the risk level indicated by the crisis warning field exceeds a preset threshold, the safety protocol execution module is triggered and executes a safety protocol including outputting warning information, providing emergency contact suggestions, or guiding the dialogue to stabilization support.

[0011] According to the present invention, a multi-agent-based psychological counseling system is provided, wherein the psychological counseling module includes: The data receiving unit is used to receive and parse the structured psychological analysis chain generated by the thinking and reasoning module in response to the routing control module selecting the first path; A data reorganization unit is used to extract key information from the psychoanalysis chain and reorganize it into a dialogue format. The response generation unit is used to generate a response based on the text input by the user and the reconstructed information.

[0012] This invention also provides a multi-agent-based psychological counseling method, comprising: Receive text input from the user and output an emotion category determination result, which is used to characterize whether the user is in a negative or non-negative state. Select a processing path based on the emotion category determination result; When the first path is selected based on the user's negative emotion category, a structured psychological analysis chain is generated. Generate the final consultation response; among which, When the routing control module selects the second path based on the determination that the user is in a non-passive state, the psychological counseling module directly generates the final counseling response; When the routing control module selects the first path, the psychological counseling module generates the final counseling response based on the psychological analysis chain generated by the thinking and reasoning module.

[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the multi-agent-based psychological counseling system as described above.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the multi-agent-based psychological counseling system as described above.

[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements a multi-agent-based psychological counseling system as described above.

[0016] The multi-agent-based psychological counseling system, method, device, and storage medium provided by this invention effectively overcomes the shortcomings of existing technologies and brings significant benefits in many aspects by introducing emotion-driven dynamic routing and modular division of labor and cooperation mechanisms. First, the system determines the user's emotional state in real time through an emotion analysis module, and then adaptively selects a processing path based on whether the determination result is negative or non-negative, achieving dynamic response and differentiated processing of user emotions through a routing control module. When the user's emotion is non-negative, the system directly calls the psychological counseling module for efficient response, ensuring the immediacy and smoothness of the interaction; when the emotion is negative, it first calls the thinking and reasoning module to generate a structured psychological analysis chain, and then hands it over to the psychological counseling module for integration and output, thus providing logically supported professional intervention for deep emotional problems. This design not only enhances the ability to handle complex emotional states and the system's robustness, but also significantly improves the interpretability and professionalism of the system's decision-making process by introducing a structured intermediate analysis chain. Simultaneously, the multi-agent architecture, with each agent performing its own function, achieves a reasonable allocation of computing resources, optimizing the overall system's operating efficiency while ensuring the depth of psychological intervention. In summary, this invention constructs a systematic solution that closely integrates perception, reasoning, and feedback, laying a technological foundation for providing reliable, trustworthy, and efficient digital mental health services. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0018] Figure 1 This is a schematic diagram of the structure of the multi-agent-based psychological counseling system provided by the present invention; Figure 2 This is a flowchart of the multi-agent-based psychological counseling system provided by the present invention; Figure 3 This is a flowchart illustrating the multi-agent-based psychological counseling method provided by the present invention; Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0020] To address the problems in existing technologies, this invention proposes a multi-agent-based psychological counseling system to enhance the ability to handle complex emotional states and improve system robustness. The multi-agent-based psychological counseling system is described below, as follows: Figure 1 As shown, including but not limited to the following modules: The sentiment analysis module 110 is used to receive text input by the user and output a sentiment category determination result, which is used to characterize whether the user is in a negative or non-negative state. The sentiment analysis module 110 serves as the system's input terminal and perception unit, responsible for receiving text information input by users through clients (such as web pages, mobile applications, chat interfaces, etc.) and classifying their emotional states in real time.

[0021] In one specific embodiment, the implementation of the sentiment analysis module 110 includes the following steps: Text preprocessing: Cleaning the raw text input by the user, including removing irrelevant symbols, correcting spelling errors, and word segmentation.

[0022] Feature extraction: The text is converted into a high-dimensional feature vector using a pre-trained language model (such as BERT, RoBERTa, or variants thereof). This model can be pre-trained on general corpora and fine-tuned on labeled data in the field of psychological counseling to better capture emotion-related semantic features.

[0023] Classification: The obtained feature vector is input into a classifier (such as a fully connected neural network, support vector machine, etc.) to calculate the probability p that the text belongs to the "negative" category. neg .

[0024] Output: The emotion category is determined based on a preset threshold. For example, a threshold T is set. neg =0.6 and T nonneg =0.4: If p neg ≥T neg If so, the user's emotion is determined to be "negative"; If p neg ≤T nonneg If so, it is determined to be a "non-negative state" (including positive or neutral); If p neg The state between the two thresholds can be defined as an "uncertain state" and can be subject to specific policies by the routing control module 120 (see below).

[0025] The output of this module is typically a structured data object, which at least contains a sentiment category label (negative / non-negative) and can be expanded to include fields such as confidence score and raw probability value for use by downstream modules.

[0026] The routing control module 120 is connected to the sentiment analysis module and is used to select a processing path based on the sentiment category determination result. The routing control module 120, as the system's scheduling center, is directly connected to the sentiment analysis module 110, receives the sentiment category determination results output by the module, and decides the next information processing path accordingly.

[0027] In a preferred embodiment, the logic of the routing control module 120 is as follows: Path mapping: Establishing mapping rules between emotion categories and processing paths: If the result is "non-negative state", then select the second path (fast response path), and subsequent requests will be directly forwarded to the psychological counseling module 140.

[0028] If the result is "negative state", then the first path (deep analysis path) will be selected. Subsequently, the thinking and reasoning module 130 will be called first, followed by the psychological counseling module 140.

[0029] Dynamic Decision Making and State Management: Routing decisions are not made all at once, but independently for each round of user input. The module can maintain a session state machine and implement a delay mechanism based on historical judgment results. For example, it will only switch to the first path if two consecutive rounds are judged as "negative" to avoid frequent path jumps caused by slight emotional fluctuations.

[0030] Extended strategy: For "uncertain state", the module can execute a preset intermediate path strategy, such as: (a) generating a lightweight inference request (limiting the output length); (b) first generating an empathic response by the psychological counseling module 140 and adding a clarifying question; (c) if high-risk keywords are detected, directly process it as "negative state" and trigger the security protocol.

[0031] The reasoning module 130 is connected to the routing control module and is used to generate a structured psychological analysis chain when the routing control module selects the first path based on the user's emotional category determination result in a negative state. The reasoning module 130 is activated when the routing control module 120 selects the first path. Its core function is to conduct in-depth analysis of user input in a negative emotional state and generate a structured, interpretable psychological analysis chain to provide a basis for subsequent professional intervention.

[0032] In one specific embodiment, this module is built upon a large language model (such as the Qwen, LLaMA, GPT, and other related models): Model Training: The base model was supervisedly fine-tuned using a specially constructed "step-by-step reasoning dataset." This dataset contains a large number of counseling dialogues, and each sample includes not only user input and final response, but also manually labeled, step-by-step reasoning chains.

[0033] Inference Chain Structure: The trained model is designed to output a structured psychoanalytic chain. This chain is typically organized in JSON, XML, or specially marked text format and contains multiple well-defined fields, such as: Pattern recognition fields: Summarize the core triggering events, emotional expression patterns, and speech features in user statements.

[0034] Psychological mechanism analysis field: Analyzes the psychological mechanisms behind emotions, such as possible cognitive biases, irrational beliefs, and behavioral pattern cycles.

[0035] Intervention structure field: Consultation stages (such as listening, clarification, cognitive restructuring, and behavioral activation) and key techniques used in planning recommendations.

[0036] Crisis warning field (optional but important): Assess whether there are risk signals such as self-harm or harm to others in the current input, and give the risk level.

[0037] Workflow: The module receives the user's original text and / or conversation history as input, runs the fine-tuned model, and generates and outputs the structured analysis chain described above.

[0038] The psychological counseling module 140, connected to the routing control module and the reasoning module, is used to generate the final counseling response; wherein, When the routing control module selects the second path based on the determination that the user is in a non-passive state, the psychological counseling module directly generates the final counseling response; When the routing control module selects the first path, the psychological counseling module generates the final counseling response based on the psychological analysis chain generated by the thinking and reasoning module.

[0039] The psychological counseling module 140 is the terminal module that generates responses visible to the end user. Its behavior varies depending on the selection made by the routing control module 120, ensuring that the responses are both efficient and in-depth.

[0040] Its implementation methods include: Second path processing (non-passive state): When the routing control module 120 selects the second path, this module directly receives the user's input text. It quickly generates an empathetic and supportive response based on a large language model adapted to the psychological domain (which can be initially optimized through supervised fine-tuning), focusing on emotional recognition and general support to ensure the immediacy of the interaction.

[0041] First Path Processing (Negative State): When the first path is selected, the input to this module includes the user's original text and the structured psychoanalysis chain generated by the reasoning module 130. Its internal processing flow is as follows: Chain parsing and information extraction: Parse the received psychoanalysis chain, verify the integrity of key fields, and extract key summaries from the "pattern recognition" and "psychological mechanism analysis" fields.

[0042] Intervention plan integration: Convert the "Intervention Structure" field into a specific response outline or action plan.

[0043] Security Filtering and Content Generation: Combining security strategies (such as sensitive word filtering and high-risk content avoidance), the extracted information and plans are integrated into a natural conversational context to generate the final response. This process ensures that the response incorporates in-depth analysis and is presented to the user in a safe, professional, and easy-to-understand manner.

[0044] Model Alignment: To enhance the professionalism of responses and the appropriateness of the conversational pace, the large language model upon which this module is based can be further aligned through reinforcement learning. In one embodiment, the Group Relative Policy Optimization (GRPO) method is employed, utilizing a reward function that incorporates multiple dimensions such as phased questioning rate, empathic expression, and response length to optimize the model output and make it more consistent with the practical norms of professional psychological counseling.

[0045] like Figure 2 As shown, the workflow of this system begins with the user interface and ends with a professional psychological assessment model. It is a sequential intelligent decision-making and response process driven by sentiment analysis. The entire process can be summarized as: User Input → Sentiment Analysis → Core Decision and Routing → Reasoning (if needed) → Professional Response Generation.

[0046] Specific workflow example with reference to the attached diagram The following example of a typical user interaction will be used to illustrate the collaborative working mechanism of the various modules within the system.

[0047] Step 1: User Input and System Access User input: The user enters the text on the client interface (such as a chat window): "Hello counselor, I have been feeling very uncomfortable lately." Interface and Context Processing: As shown in the "User Interface Output" section of the attached diagram, the system verifies the user's identity through a single sign-on mechanism and outputs the user's identification information and available historical session context, establishing a personalized background for this interaction. The text entered by the user is sent to the backend sentiment analysis model.

[0048] Step Two: Sentiment Analysis Stage The text entered by the user is fed into the sentiment analysis model (corresponding to the sentiment analysis module 110 in the system) and processed as follows: The tokenizer breaks down the sentence "Hello counselor, I've been feeling very uncomfortable lately" into individual words or sub-words.

[0049] A text encoder (such as a pre-trained model based on the BERT architecture) transforms a segmented sequence into a high-dimensional semantic vector that captures the overall semantics and sentiment of the sentence.

[0050] The semantic vector is input into an MLP classifier (Multilayer Perceptron Classifier). The classifier analyzes the semantic features and outputs a sentiment prediction. For this example input, the model might output a judgment of "negative" state, accompanied by a high confidence score.

[0051] Step 3: Core Decision-Making and Routing Phase The sentiment prediction results (sentiment analysis results) are sent to the core decision logic (corresponding to the routing control module 120), which is a branch point in the system process.

[0052] Routing Decision: The decision logic reads the sentiment analysis results. Since this example is judged as "negative," the decision logic selects the first path (deep processing path) according to preset rules.

[0053] Activate deep reasoning: After selecting the first path, the decision logic calls the thinking reasoning module (corresponding to thinking reasoning module 130) and passes the user's original input to it.

[0054] Step Four: Thinking and Reasoning Stage (In-depth Analysis Path) Structured Analysis: As shown in the "Core Decision Logic" section of the attached diagram, the reasoning module initiates a multi-step analysis process (Step 1 to Step 5). This process is not a simple repetition, but rather a gradual and in-depth deconstruction of the user input: It is possible to initially extract the core demand ("feeling uncomfortable") and the emotional tone (negative).

[0055] Further pattern recognition and psychological mechanism analysis are then conducted. Ultimately, the module integrates the results of multiple analysis steps to generate multi-dimensional features and emotions—a structured psychological analysis chain. In this example, this chain might include: Superficial emotions: overall discomfort, underlying anxiety or depression.

[0056] Expression pattern: The user actively seeks help, using a general description such as "feeling very uncomfortable".

[0057] Preliminary inference: Further clarification is needed regarding the specific dimensions (such as emotions, physical sensations, and thoughts) and triggers of the "discomfort".

[0058] Step 5: Professional Response Generation Stage Information aggregation and model invocation: The core decision-making logic submits the user's original input and the structured analysis chain generated by the reasoning module to the psychological assessment model (corresponding to psychological counseling module 140). As shown at the bottom of the attached diagram, this model is the core that directly provides counseling services to the end user.

[0059] Generating a Professional Response: The psychological assessment model (a large language model fine-tuned and aligned with data from the field of psychological counseling) receives and integrates all information. Based on the principles of empathy, professional knowledge, and safety protocols, it generates a final response. In this example, the response might be: "Thank you for your trust in telling me you're feeling unwell. This general feeling of discomfort can indeed be very distressing. To better understand your situation, could you describe more specifically what this 'mental discomfort' feels like? Is it low mood, anxiety, or physical tension?" This response first demonstrates empathy and acceptance, and then, guided by the chain of reasoning ("the need for further clarification of specific dimensions"), transforms the general "discomfort" into several specific, explorable directions for questioning, which aligns with the initial techniques of "clarification" and "concretization" in psychological counseling.

[0060] Step Six: Loops and Iterations The system presents the above response to the user. Each subsequent input from the user (such as an answer to the above question) will serve as new input, re-triggering the entire process that started from step one (sentiment analysis), thereby achieving a dynamic, continuous, and context-aware multi-round psychological counseling dialogue.

[0061] Through the detailed process description above, combined with the accompanying drawings, it is clear that the system of this invention, through a rigorously modular pipeline design, achieves a complete closed loop from user emotion perception, intelligent routing decision-making, in-depth structured analysis to final professional response. The emotion analysis model serves as the perception entry point, the core decision-making logic is the intelligent scheduling center, and the reasoning module and psychological assessment model are collaboratively specialized processing units. This architecture ensures that the system possesses real-time responsiveness, analytical depth, professional standardization, and interpretable decision-making when handling psychological counseling tasks.

[0062] As a further optional embodiment, the sentiment analysis module includes: A text encoding unit is used to encode the text input by the user based on a pre-trained language model to obtain a text feature vector; A classification and discrimination unit, connected to the text encoding unit, is used to calculate the probability that the user input belongs to the negative category based on the text feature vector, and generate the emotion category determination result based on a preset probability threshold.

[0063] In this embodiment, the sentiment analysis module 110 may specifically include two core sub-units: a text encoding unit and a classification and discrimination unit. These two units work together to complete the conversion from raw text to sentiment category determination.

[0064] Text encoding unit Function: The core task of this unit is to transform the natural language text input by the user into a numerical representation that the machine can deeply understand, namely, a text feature vector.

[0065] Implementation: It is based on a pre-trained language model. This model has learned rich linguistic knowledge (such as syntax, semantics, and contextual relationships) on large-scale general corpora. In a specific implementation, a Transformer-based model can be used, such as BERT (Bidirectional Encoder Representations from Transformers) or its variants (such as RoBERTa, ERNIE, etc.). The workflow of this unit is as follows: Receive user input text that has undergone preliminary cleaning (such as removing special characters and standardization).

[0066] The encoder part of the pre-trained language model is invoked to process the input text.

[0067] Output a fixed-dimensional, dense text feature vector. This vector encapsulates the overall semantic and contextual information of the input sentence and forms the basis for subsequent classification tasks.

[0068] Classification and discrimination unit Function: This unit connects to the text encoding unit and is responsible for performing a specific sentiment binary classification task based on the semantic features provided upstream, and outputting a structured judgment result. Implementation: This unit typically consists of a lightweight classifier network. In a typical embodiment, a multilayer perceptron is used as the classifier.

[0069] Workflow: Probability Calculation: The text feature vector output by the text encoding unit is received and input into the MLP classifier. The MLP performs a series of nonlinear transformations and finally outputs a scalar probability value p (e.g., through a Sigmoid or Softmax activation function), which represents the probability that the current user input belongs to the "negative" category.

[0070] Threshold determination: The calculated probability p is compared with a preset probability threshold to generate the final emotion category determination result.

[0071] If p neg ≥T neg If so, the user's emotion is determined to be "negative"; If p neg ≤T nonneg If so, it is determined to be a "non-negative state" (including positive or neutral); If p neg The state between the two thresholds can be defined as an "uncertain state" and can be subject to specific policies by the routing control module 120.

[0072] Output results: The output of this unit not only includes the category label of "negative" or "non-negative", but can also be extended to include additional information such as confidence score (i.e., probability p itself or its transformed form) and risk score (calculated additionally through keyword matching, etc.), providing richer decision-making basis for downstream routing control modules.

[0073] Technical Results: By refining the sentiment analysis module into a two-level "encoding-discrimination" structure, this embodiment clearly defines the path to technical implementation. The use of a pre-trained language model ensures the depth and generalization ability of semantic understanding, while the subsequent lightweight MLP classifier achieves efficient and accurate binary classification of sentiment. This modular design facilitates individual optimization (such as fine-tuning the pre-trained model for psychological domain data, or adjusting the structure and thresholds of the MLP), thereby improving the accuracy and adaptability of the entire system's sentiment perception.

[0074] As a further optional embodiment, the emotion category determination result includes emotion category, confidence score, and risk score; the routing control module is also used to combine the confidence score, the risk score, and the emotion category to select a path.

[0075] Based on the above embodiments, this embodiment makes significant extensions to the output content of the sentiment analysis module and the decision logic of the routing control module to improve the granularity, robustness and security of the system's decision-making.

[0076] Extended output of the sentiment analysis module In this embodiment, the emotion category determination result generated by the emotion analysis module is designed as a structured data object containing multi-dimensional information, rather than just a simple category label. Specifically, it includes: Emotion Category: The core classification conclusion, indicating whether the user's current emotional state is "negative" or "non-negative".

[0077] Confidence score: Characterizes the degree of certainty that the sentiment analysis model is regarding the classification conclusion. This score is usually derived directly from the probability value output by the classifier (e.g., the probability for the "negative" category). A high score (e.g., 0.95) indicates that the model is very confident, while a low score (e.g., 0.55) indicates that the model's judgment has a large degree of uncertainty.

[0078] Risk Score: An independently calculated or assessed numerical value used to quantify the potential psychological or safety risks in user-input text. This score can be calculated based on various strategies, such as: Keyword matching: Checks whether the input contains preset high-risk words or phrases related to self-harm, harm to others, severe despair, etc., and assigns a weighted score based on the hit rate.

[0079] Intensity and contextual analysis: Risk level is assessed by combining the intensity of emotional polarity with the mode of expression (such as the use of absolute or extreme language).

[0080] Historical conversation association: Dynamically score users based on their risk trends in the current conversation history.

[0081] Enhanced decision logic of the routing control module The routing control module is configured to comprehensively utilize the three key pieces of information—emotion category, confidence score, and risk score—to execute a more refined and reliable path selection strategy. Its decision-making logic has been upgraded from a simple "if-else" rule to a multi-factor evaluation process.

[0082] In a specific implementation, this enhanced decision-making logic follows these principles: Standard routing under high confidence: When the confidence score is very high (e.g., above 0.85) and the risk score is very low, the routing decision is mainly based on the sentiment category. That is: non-negative -> second path (quick response); negative -> first path (deep reasoning).

[0083] Cautious handling at low confidence levels: When the confidence score is low (e.g., in the range of 0.4 to 0.6), it indicates that the model is uncertain about the sentiment classification. In this case, the routing control module may activate an intermediate path strategy or a conservative strategy. For example: Regardless of the category preference, a lightweight reasoning exercise (with limited output length) is triggered to obtain more analytical information to aid in the judgment.

[0084] Alternatively, a conservative approach (assuming a passive stance) can be prioritized to ensure that potential problems are not overlooked, while potentially reducing the intensity of interventions in subsequent responses.

[0085] Safety First in High-Risk Situations: Regardless of emotion category or confidence level, if the risk score exceeds the preset safety threshold, the routing control module will enforce the first path and immediately send a high-risk flag to the reasoning and psychological counseling modules. This ensures that any conversation that may involve a crisis is guided to a processing flow with in-depth analysis and security protocol enforcement capabilities, protecting user safety.

[0086] Comprehensive Weighting Decision: In a more complex implementation, a comprehensive scoring function can be designed to linearly or non-linearly combine the sentiment category tendency (mapped to a numerical value), confidence score, and risk score with different weights, and determine the path selection based on the interval in which the final comprehensive score falls. For example: The overall score is calculated as follows: W1 * sentiment tendency score + W2 * confidence score + W3 * risk score. Then, path mapping is performed based on the threshold of the overall score.

[0087] Technical Effects: This embodiment significantly improves the system's adaptability and reliability by enriching the output information dimensions of the sentiment analysis module and endowing the routing control module with more intelligent fusion decision-making capabilities. It enables the system to effectively handle the "fuzzy areas" of uncertain model predictions and establishes a robust "safety first" response mechanism, thereby making more professional, robust, and safe automated decisions when faced with complex and ever-changing real user input.

[0088] As a further optional embodiment, the routing control module is also configured to execute a preset intermediate path strategy when the probability output by the classification and discrimination unit is in a preset intermediate range. The intermediate path strategy includes at least one of the following: triggering lightweight inference, adding clarification questions, or forcibly selecting the first path based on risk keywords.

[0089] Building upon the above embodiments, this embodiment designs a specialized and refined processing strategy for the routing control module to address the uncertain intermediate states in sentiment analysis. This strategy aims to improve the system's decision-making quality and user experience when faced with fuzzy model predictions, and to strengthen the safety fallback mechanism.

[0090] 1. Definition and identification of intermediate intervals In this embodiment, the "preset intermediate interval" refers to the specific numerical range of the probability p, output by the classification and discrimination unit, representing the user input belonging to the "negative" category. This interval typically lies between the high-confidence interval for "non-negative" and the high-confidence interval for "negative". For example, if we set: When p≤0.40, it is clearly determined to be "non-passive"; When p ≥ 0.60, it is clearly judged as "negative"; The interval (0.40, 0.60) is then defined as the "middle interval".

[0091] When the probability p falls within this interval, the routing control module considers the sentiment analysis result to be uncertain and that the standard path should not be used directly.

[0092] 2. Preset intermediate path strategy When the probability is detected to be in the middle range, the routing control module no longer executes a simple binary choice route, but instead triggers a preset intermediate path strategy. This strategy is a set of options including multiple actions designed to gather more information, conduct initial probing, or prioritize security. Specifically, it includes at least one of the following actions: Strategy A: Trigger lightweight inference Operation: The routing control module initiates a lightweight inference request to the reasoning module. This request may include instruction constraints (e.g., limiting the length of the output analysis chain, requiring only preliminary pattern recognition), or specifying the use of a simplified inference model with lower computational overhead.

[0093] Objective: To obtain preliminary professional analysis at a low cost to help determine the severity of a user's condition. The output of lightweight inference can be used to revise or supplement the current sentiment assessment, thereby guiding the next round of more accurate routing decisions.

[0094] Strategy B: Ask additional clarifying questions Operation: The routing control module instructs the psychological counseling module (or its rapid response unit) to proactively add a clarifying question after generating a basic empathetic response (e.g., "It sounds like you're having some complicated feelings"). For example: "Would you like to describe in more detail what kind of 'uncomfortable' feeling you're experiencing? Is it some anxiety, low mood, or something else?" Objective: To obtain higher-quality new input text by guiding users to provide more specific and emotional descriptions. The next round of sentiment analysis based on this new input will likely yield more definitive results, thus helping the system overcome uncertainty.

[0095] Strategy C: Force selection of the first path based on risk keywords Operation: While performing intermediate state judgment, the routing control module initiates a rapid risk keyword scan in parallel (based on a preset risk keyword database). If one or more high-risk keywords (such as words clearly related to self-harm, suicide, serious injury, etc.) are detected in the current user input text, the intermediate state processing flow is immediately rejected, and the path selection is forcibly switched to the "first path" (i.e., the deep analysis path).

[0096] Objective: This strategy establishes the principle of absolute safety priority. Once a clear risk signal is detected, regardless of the confidence level of the sentiment model, the system will immediately initiate the highest level of processing (deep inference and security protocols) to ensure that potential crises are dealt with promptly and professionally.

[0097] 3. Strategy Combination and Execution The above strategies can be executed individually or in combination according to preset logic. For example: First execute strategy C (risk scan). If there is no risk, continue.

[0098] Execute strategy A (lightweight reasoning) to obtain preliminary analysis.

[0099] Based on the results of lightweight reasoning, a decision is made as to either proceed directly to the first path or execute strategy B (additional clarification) and wait for the user's next input.

[0100] Technical effect This embodiment significantly enhances the robustness and security of the system by designing a specialized intermediate path strategy for states of "uncertainty." It avoids the inefficiency or unprofessionalism that can result from arbitrarily adopting deep or fast paths when information is insufficient. Instead, through intelligent probing, clarification, and rigorous security filtering, the system can handle edge cases more smoothly and reliably. This reflects the human-centered and professional nature of the system design and is a key element in building a trustworthy AI-powered psychological counseling system.

[0101] As a further optional embodiment, the structured psychological analysis chain generated by the thinking and reasoning module is organized in the form of a set of labeled fields, which includes at least: pattern recognition fields, psychological mechanism analysis fields, intervention structure fields, and crisis warning fields, wherein the crisis warning fields are used to assess the user's risk level of self-harm or harm to others.

[0102] Based on the above system architecture, this embodiment provides a detailed explanation of the core output of the reasoning module—the structured psychological analysis chain. This analysis chain is the key carrier for the interpretability and professional depth of this system, and it is organized in a standardized format that is machine-parseable and human-understandable.

[0103] The Composition of a Structured Psychoanalytic Chain In this embodiment, the structured psychological analysis chain generated by the reasoning module is not a piece of free text, but a data structure organized as a set of clearly labeled fields. This organization ensures the hierarchy, completeness, and reusability of the analysis results. This set of fields includes at least the following four core parts: Pattern recognition fields Function: This field is designed to summarize and categorize users’ surface statements and extract identifiable expression patterns.

[0104] Example content: Describe the triggering events mentioned by the user (such as "work project deadline", "argument with family"), core emotional words (such as "anxiety", "despair", "loneliness"), and expression characteristics (such as the use of a lot of absolute words "always", "never", or somatization such as "can't eat"). For example, for the input "I have completely failed and can't do anything right", this field can be summarized as: "Triggering event: negative self-assessment of ability; Expression pattern: full negative statement ('can't do anything right'); Emotional tags: frustration, despair".

[0105] Psychological mechanism analysis fields Function: Based on pattern recognition, this field makes deeper psychological inferences, attempting to explain the underlying cognitive processes or motivations behind emotions or behaviors.

[0106] Example content: Analyze potential cognitive biases (such as "black and white thinking", "overgeneralization", "catastrophizing"), infer their core beliefs (such as "I must be perfect to be accepted"), or outline the emotion-behavior-thought cycle. Continuing from the previous example, this field might be analyzed as: "Potential cognitive biases: overgeneralization (generalizing a single event's failure to an overall personal failure); possible core beliefs: self-worth is based on absolute success."

[0107] Intervention structure field Function: Based on the first two analyses, this field plans the initial direction and optional techniques for professional intervention, providing an action blueprint for the downstream psychological counseling module.

[0108] Example content: Suggest the main goals of the current response (e.g., "empathic acceptance," "cognitive clarification," "behavioral activation"), recommended counseling techniques or stages (e.g., "Socratic questioning to challenge irrational beliefs," "guided mindfulness practice," "assigning small behavioral experiments"), and precautions. Following the previous example, this field might be planned as: "Stage goal: Cognitive restructuring; Suggested techniques: Guide users to distinguish between 'not doing something well' and 'a complete failure' through questioning; Precautions: Avoid vague reassurances, focus on specific examples."

[0109] Crisis warning field Functionality: This is a key safety feature field specifically designed to assess whether there is a direct or indirect risk of self-harm or harm to others in the user's input.

[0110] Content and Output: The output of this field is a risk assessment level (e.g., "No Risk", "Low Risk", "Medium Risk", "High Risk"), which may be accompanied by a brief triggering reason (e.g., "The statement contains an explicit expression of 'I don't want to live anymore'" or "Expresses a strong sense of hopelessness accompanied by descriptions of social isolation"). The assessment of this field is independent of the emotion classification and is the direct basis for triggering system safety protocols.

[0111] Generation and usage process The reasoning module (such as a model fine-tuned based on Qwen2.5-7B-Instruct) is trained to receive user input and generate corresponding structured content according to the requirements of the four dimensions mentioned above. These fields can be output in JSON, XML, or text format with specific delimiters.

[0112] Upon receiving this analysis chain, the downstream psychological counseling module first parses these fields: Key information is extracted from fields using pattern recognition and psychological mechanism analysis to form internal prompts.

[0113] Transform the intervention structure fields into specific response strategies and scripts.

[0114] Crucially: Immediately check the crisis warning field. If the risk level exceeds the preset threshold (such as "medium risk" or "high risk"), the psychological counseling module must invoke or follow the instructions of the safety protocol execution module before generating a response to ensure that the response includes necessary risk intervention measures (such as expressing concern, providing emergency resource information, and avoiding reinforcing harmful thoughts), rather than just providing routine psychological counseling.

[0115] Technical effect This embodiment achieves the following by normalizing the output of reasoning into a structured chain containing the four core fields mentioned above: Deep standardization: making the AI ​​analysis process conform to the thinking framework of professional psychological counseling.

[0116] Highly explainable: Every decision is supported by a structured reason, breaking the "black box".

[0117] Embedded security: By incorporating crisis early warning as one of the core analytical dimensions, security assurance is no longer an afterthought function, but is deeply integrated into the analytical logic.

[0118] Downstream friendly: It provides clear, structured, and actionable guidance for the psychological counseling module, greatly improving the professionalism and security of the final response.

[0119] This structured analytical chain is a key bridge connecting perception (emotional analysis), deep cognition (thinking and reasoning), and professional action (psychological counseling), and is one of the core innovations of this system in achieving professional and reliable psychological counseling.

[0120] As a further optional embodiment, a security protocol execution module is also included; when the risk level indicated by the crisis warning field exceeds a preset threshold, the security protocol execution module is triggered and executes a security protocol including outputting warning information, providing emergency contact suggestions, or guiding the dialogue to stabilization support.

[0121] To address potential crisis situations during psychological counseling, this embodiment introduces an independent security protocol execution module based on the aforementioned multi-agent collaborative system, deeply integrating it into the system workflow. This module acts as the system's "security guardian," specifically handling high-risk situations identified by upstream analysis, ensuring that user safety receives the highest priority protection under all circumstances.

[0122] 1. Module triggering mechanism The activation of the security protocol execution module depends strictly on the crisis warning field in the structured psychological analysis chain output by the reasoning module. The risk assessment level of this field is the core trigger.

[0123] Triggering condition: When the risk level indicated by the crisis warning field (e.g., "high risk") exceeds the system's preset safety threshold (e.g., "medium risk" and above), the routing control module or the psychological counseling module will immediately send a trigger signal to the security protocol execution module.

[0124] Additional triggering: In some embodiments, to enhance response speed, the security protocol execution module can also be configured to accept direct input from the sentiment analysis module. For example, when the sentiment analysis module independently detects extreme risk words (such as specific suicide methods, time and location plans, etc.) through real-time keyword scanning, the security protocol execution module can be triggered directly in parallel even if the reasoning module has not yet run.

[0125] 2. Specific implementation details of the security protocol Once triggered, the security protocol execution module will interrupt or take over parts of the normal dialogue flow and execute a series of predefined, progressively escalating security protocols. These protocols are designed to provide immediate intervention, offer practical resources, and attempt to guide the dialogue to a stable state. Specifically, this includes, but is not limited to, combinations of the following operations: Protocol A: Output standardized alerts and empathy messages The module controls the output interface, sending users fixed-format messages that are highly relevant, empathetic, and clearly directed. For example: “I hear you are suffering greatly and even have thoughts of ending your life, which worries me greatly. Your life is very important, please give yourself a chance to get help.” The message was professionally worded to express deep concern, affirm the value of life, break down feelings of loneliness, and pave the way for subsequent assistance, while avoiding language that could have negative implications.

[0126] Agreement B: Provide emergency contact advice and direct resources The module dynamically provides localized emergency assistance resources based on user registration information (such as geographical location) or IP address. For example: "You urgently need to speak with a professional mental health counselor or crisis interventionist. You can immediately call the following 24-hour toll-free mental health crisis intervention hotline: [Insert the number that matches your region, such as Hope Hotline 400-161-9995]. Alternatively, please go directly to the nearest hospital emergency department." The information provided should be clear and actionable, and should prioritize channels that enable instant interpersonal connections (such as telephone) rather than plain text resources.

[0127] Agreement C: Guiding Dialogue Towards Stabilization Support and Risk Mitigation The module intervenes in the subsequent dialogue generation logic, forcing the dialogue topic to shift from potentially in-depth discussions of negative emotions or event details to real-time security assessment and stabilization technology.

[0128] For example, it might guide a psychological counseling model to generate questions like the following: Before you contact a professional, I'd like to confirm: Are you alone right now? Do you have any trusted friends or family members who can come and be with you immediately? Or provide simple and stable grounding techniques: "If you'd like, we can do a simple breathing exercise together to help you calm down a bit: Slowly inhale for 4 seconds, hold your breath for 4 seconds, then slowly exhale for 6 seconds, and repeat a few times. Would you like to try it?" Protocol D: Initiate system-side security logging and early warning. While performing user intervention, the module will automatically generate high-risk event logs in the system backend, recording the trigger time, risk level, keywords, and system response actions.

[0129] Based on preset rules and legal requirements, and with the user's consent or in compliance with legal exemptions, the module may automatically send alert notifications to the system's designated security administrator or emergency contact (as specified by the user in the settings).

[0130] 3. System status management after protocol execution After the security protocol is executed, the system will enter a temporary "high-risk intervention mode." In this mode: The routing control module may be "locked," forcing the path to the psychological counseling module, which integrates security policies, in subsequent rounds of dialogue, regardless of the sentiment analysis results.

[0131] The generation strategy for the psychological counseling module will be modified, with the "safety and compliance" weight in its reward function being increased to the highest level. This will ensure that all subsequent responses prioritize risk mitigation and stabilization, avoiding triggering deeper emotional exploration or providing inappropriate advice.

[0132] This mode will continue until the reasoning module clearly outputs a lower risk level in subsequent analysis, or is manually deactivated by a human administrator.

[0133] Technical effect By introducing a dedicated security protocol execution module and defining its explicit triggering logic and execution protocol, this embodiment establishes a crucial safety baseline for the AI-based psychological counseling system. It elevates crisis intervention from a passive, potentially overlooked text-generating constraint to a proactive, structured, resource-linked, and standardized emergency response process. This not only significantly enhances the system's reliability and social responsibility but also makes it more compliant with professional ethical standards, providing a key safeguard for the responsible deployment of artificial intelligence technology in high-risk areas.

[0134] As a further optional embodiment, the psychological counseling module includes: The data receiving unit is used to receive and parse the structured psychological analysis chain generated by the thinking and reasoning module in response to the routing control module selecting the first path; A data reorganization unit is used to extract key information from the psychoanalysis chain and reorganize it into a dialogue format. The response generation unit is used to generate a response based on the text input by the user and the reconstructed information.

[0135] Based on the above system architecture, this embodiment refines the internal structure of the psychological counseling module, revealing how it transforms upstream information (user input and optional deep analysis chains) into a professional, safe, and natural final response. This module is key to achieving professionalism and fluency in human-computer interaction, and it can be internally divided into three clearly defined, sequentially cooperating sub-units.

[0136] The psychological counseling module specifically includes: a data receiving unit, a data reorganization unit, and a response generation unit. The functions and collaborative processes of each unit are explained in detail below.

[0137] 1. Data receiving unit Core Function: This unit serves as the "information portal" for the psychological counseling module, responsible for receiving and initially processing all input data from upstream sources. Its behavior is determined by the path selected by the routing control module 120.

[0138] Work mode: Mode 1 (Second Path Response): When the routing control module 120 selects the second path (fast response path) based on a "non-passive" decision, the data receiving unit only receives the user's original input text. At this time, its main task is to perform basic validation and formatting of the text, and then directly pass it to the response generation unit.

[0139] Mode Two (First Path Response - Core Function): When the routing control module selects the first path (deep analysis path) based on a "negative" decision, the data receiving unit will simultaneously receive the user's original input text and the structured psychological analysis chain generated by the reasoning module 130. At this time, its core task is to parse this analysis chain: Format validation: Verify the integrity and standardization of the analysis chain (such as JSON format) to ensure that required fields exist.

[0140] Field Extraction and Initial Security Screening: Extracting the raw content of fields such as "Pattern Recognition," "Psychological Mechanism Analysis," and "Intervention Structure." Crucially, it must immediately check the "Crisis Warning" field. If the risk level exceeds the threshold, it will immediately trigger or notify the security protocol execution module to intervene, and mark the high-risk status in subsequent processing within this unit.

[0141] Information summarization: Transforming lengthy analytical content (such as complex descriptions of psychological mechanisms) into concise key points or keywords to form summarized prompts for use in the next unit.

[0142] 2. Data Reassembly Unit Core Function: This unit is the module's "strategy converter," responsible for transforming upstream, analysis-oriented "machine language" into "action plans" that are dialogue-logical and geared towards response generation.

[0143] Workflow: Input integration: Receives summarized prompts from the data receiving unit (from the analysis chain) and raw user input text.

[0144] Intervention plan transformation: Transform the "intervention structure" field in the analysis chain (such as "suggest using Socratic questioning for cognitive clarification") into specific, actionable response strategies. For example, this strategy could be transformed into: "This round of response should first express empathy, then pose an open-ended question to guide the user to reflect on the evidence behind their thoughts." Security Filtering and Content Reorganization: Based on a pre-defined security policy library, all information to be used is filtered. For example, details in the analysis chain that may cause secondary harm to the user (such as specific descriptions of self-harm methods) are filtered out, or replaced with more general and safer expressions. At the same time, the filtered key information points (such as "the user has a 'black and white' mentality") are integrated with the transformed response strategy and reorganized into a structured and secure dialogue generation instruction set.

[0145] 3. Response Generation Unit Core Function: This unit is the "final executor" of the module. Based on a professionally aligned large language model, it generates a natural, fluent, and professional final consultation response from all the information processed by the preceding units.

[0146] Workflow: Model Invocation: This unit can either build in or invoke a large language model that has been supervised fine-tuned (SFT) and aligned with reinforcement learning (such as GRPO) (e.g., the psychological counseling-specific version of Qwen2.5-7B-Instruct).

[0147] Prompt Engineering and Generation: The user input text and the dialogue generation instruction set provided by the data recombination unit 142 are combined to construct a prompt that the model can understand, and then input it into the model.

[0148] Generation and Output: Based on the prompt, the model generates the final text response. This response naturally blends empathy (addressing the user's original emotions), professionalism (derived from deep insights from the analytics chain), and safety (filtered by the reorganization unit). Finally, the response is sent to the user interface, completing this round of interaction.

[0149] Example: Following the aforementioned "work feels meaningless" case, the response generation unit might receive the following instruction set: "Express empathy for the 'stress and sense of meaninglessness'; ask a clarifying question to guide the user to specify the source of the 'sense of meaninglessness'." Based on this, the model generates: "It sounds like you're under immense work pressure, even starting to doubt the value of things. This feeling must be very heavy. If we analyze it together, what specific aspects of your work do you feel this 'meaninglessness' refers to?" Technical effect By subdividing the psychological counseling module into three clearly defined sub-units—"receiving and analyzing," "reorganizing and planning," and "generating and outputting"—this embodiment achieves a highly controllable, safe, reliable, and professional response generation process. This design ensures that: Clarity and controllability of information flow: Every step of the transformation from raw data to final response is traceable and auditable.

[0150] Deep integration of security: Security filtering is placed at the core of the generation process, rather than as a post-processing remedy.

[0151] Effective injection of expertise: The structured analysis chain is accurately transformed into dialogue strategies through standardized processes, avoiding the "loss" or "distortion" of professional knowledge.

[0152] Model focus: The response generation unit can focus on the quality and humanization of language generation, while complex logical judgments and strategy formulation are completed by the upstream unit, improving overall efficiency and effectiveness.

[0153] The following describes the multi-agent-based psychological counseling method provided by this invention, such as... Figure 3 As shown, the multi-agent-based psychological counseling method described below can be referred to in correspondence with the multi-agent-based psychological counseling system described above.

[0154] A multi-agent-based psychological counseling method includes: Step 310: Receive the text input by the user and output the emotion category determination result, which is used to characterize whether the user is in a negative or non-negative state. Step 320: Select a processing path based on the emotion category determination result; Step 330: When the first path is selected based on the user's emotional category judgment result of being in a negative state, a structured psychological analysis chain is generated; Step 340: Generate the final consultation response; among which, When the routing control module selects the second path based on the determination that the user is in a non-passive state, the psychological counseling module directly generates the final counseling response; When the routing control module selects the first path, the psychological counseling module generates the final counseling response based on the psychological analysis chain generated by the thinking and reasoning module.

[0155] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communications interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute a multi-agent-based psychological counseling system, the method of which includes: Receive text input from the user and output an emotion category determination result, which is used to characterize whether the user is in a negative or non-negative state. Select a processing path based on the emotion category determination result; When the first path is selected based on the user's negative emotion category, a structured psychological analysis chain is generated. Generate the final consultation response; among which, When the routing control module selects the second path based on the determination that the user is in a non-passive state, the psychological counseling module directly generates the final counseling response; When the routing control module selects the first path, the psychological counseling module generates the final counseling response based on the psychological analysis chain generated by the thinking and reasoning module.

[0156] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a 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 several 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 described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0157] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is able to execute the multi-agent-based psychological counseling system provided by the above methods, the method comprising: Receive text input from the user and output an emotion category determination result, which is used to characterize whether the user is in a negative or non-negative state. Select a processing path based on the emotion category determination result; When the first path is selected based on the user's negative emotion category, a structured psychological analysis chain is generated. Generate the final consultation response; among which, When the routing control module selects the second path based on the determination that the user is in a non-passive state, the psychological counseling module directly generates the final counseling response; When the routing control module selects the first path, the psychological counseling module generates the final counseling response based on the psychological analysis chain generated by the thinking and reasoning module.

[0158] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the multi-agent-based psychological counseling system provided by the methods described above, the method comprising: Receive text input from the user and output an emotion category determination result, which is used to characterize whether the user is in a negative or non-negative state. Select a processing path based on the emotion category determination result; When the first path is selected based on the user's negative emotion category, a structured psychological analysis chain is generated. Generate the final consultation response; among which, When the routing control module selects the second path based on the determination that the user is in a non-passive state, the psychological counseling module directly generates the final counseling response; When the routing control module selects the first path, the psychological counseling module generates the final counseling response based on the psychological analysis chain generated by the thinking and reasoning module.

[0159] 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.

[0160] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0161] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to 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 the present invention.

Claims

1. A multi-agent collaborative system for psychological counseling, characterized in that, include: The sentiment analysis module is used to receive text input by the user and output a sentiment category determination result, which is used to characterize whether the user is in a negative or non-negative state. A routing control module, connected to the sentiment analysis module, is used to select a processing path based on the sentiment category determination result; The reasoning module, connected to the routing control module, is used to generate a structured psychological analysis chain when the routing control module selects the first path based on the user's emotional category determination result in a negative state. The psychological counseling module, connected to the routing control module and the reasoning module, is used to generate the final counseling response; wherein, When the routing control module selects the second path based on the determination that the user is in a non-passive state, the psychological counseling module directly generates the final counseling response; When the routing control module selects the first path, the psychological counseling module generates the final counseling response based on the psychological analysis chain generated by the thinking and reasoning module.

2. The multi-agent collaborative system for psychological counseling according to claim 1, characterized in that, The sentiment analysis module includes: A text encoding unit is used to encode the text input by the user based on a pre-trained language model to obtain a text feature vector; A classification and discrimination unit, connected to the text encoding unit, is used to calculate the probability that the user input belongs to the negative category based on the text feature vector, and generate the emotion category determination result based on a preset probability threshold.

3. The multi-agent collaborative system for psychological counseling according to claim 2, characterized in that, The emotion category determination result includes emotion category, confidence score, and risk score; the routing control module is also used to select a path by combining the confidence score, the risk score, and the emotion category.

4. The multi-agent collaborative system for psychological counseling according to claim 3, characterized in that, The routing control module is further configured to execute a preset intermediate path strategy when the probability output by the classification and discrimination unit is in a preset intermediate range. The intermediate path strategy includes at least one of the following: triggering lightweight inference, adding clarification questions, or forcibly selecting the first path based on risk keywords.

5. The multi-agent collaborative system for psychological counseling according to claim 1, characterized in that, The structured psychological analysis chain generated by the reasoning module is organized in the form of a set of labeled fields, which includes at least: pattern recognition fields, psychological mechanism analysis fields, intervention structure fields, and crisis warning fields. The crisis warning fields are used to assess the user's risk level of self-harm or harm to others.

6. The multi-agent collaborative system for psychological counseling according to claim 1, characterized in that, It also includes a security protocol execution module; when the risk level indicated by the crisis warning field exceeds a preset threshold, the security protocol execution module is triggered and executes security protocols including outputting warning information, providing emergency contact suggestions, or guiding the dialogue to stabilization support.

7. The multi-agent collaborative system for psychological counseling according to claim 1, characterized in that, The psychological counseling module includes: The data receiving unit is used to receive and parse the structured psychological analysis chain generated by the thinking and reasoning module in response to the routing control module selecting the first path; A data reorganization unit is used to extract key information from the psychoanalysis chain and reorganize it into a dialogue format. The response generation unit is used to generate a response based on the text input by the user and the reconstructed information.

8. A multi-agent collaborative method for psychological counseling, characterized in that, include: Receive text input from the user and output an emotion category determination result, which is used to characterize whether the user is in a negative or non-negative state. Select a processing path based on the emotion category determination result; When the first path is selected based on the user's negative emotion category, a structured psychological analysis chain is generated. Generate the final consultation response; among which, When the routing control module selects the second path based on the determination that the user is in a non-passive state, the psychological counseling module directly generates the final counseling response; When the routing control module selects the first path, the psychological counseling module generates the final counseling response based on the psychological analysis chain generated by the thinking and reasoning module.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the multi-agent-based psychological counseling system as described in claim 8.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the multi-agent-based psychological counseling system as described in claim 8.