Intelligent agent interaction method, apparatus, system, and storage medium

CN122838591APending Publication Date: 2026-09-29DANGKANG DATA INTELLIGENCE TECHNOLOGY (GUANGDONG) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611343444.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-01
Publication Date
2026-09-29

AI Technical Summary

Technical Problem

[0003]然而,现有智能体通常采用手动会话管理、固定会话标识绑定、全量向量检索或滑动上下文窗口等方式管理会话,难以自动识别用户角色及会话主题的变化

Benefits of technology

[0009]在本申请中,通过识别客户端输入的会话信息,确定对应的会话角色类型,并获取该会话角色类型对应的角色画像、角色会话记忆和角色会话内容;将上述信息与会话信息进行上下文组装,得到目标提示词,并将目标提示词输入智能体以生成回复信息。该方法能够提高智能体回复的角色适配性、连贯性和准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122838591A_ABST
    Figure CN122838591A_ABST
Patent Text Reader

Abstract

The application discloses an agent interaction method, device, system and storage medium. The method comprises the following steps: receiving session information input by a client, determining a corresponding session role type according to the session information; determining a role image, role session memory and role session content corresponding to the session information according to the session role type; performing context assembly on the role image, the role session memory, the role session content and the session information to obtain a target prompt word; and inputting the target prompt word into an agent to generate reply information corresponding to the session information. According to the scheme, the role image, the role session memory and the role session content corresponding to the session role type are called and context assembly is performed, so that the agent can generate reply information in combination with the characteristics and historical sessions of different roles, and the role adaptability, context coherence and accuracy of the reply of the agent are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to an intelligent agent interaction method, device, system and storage medium. Background Technology

[0002] With the development of large language model technology, intelligent agents based on multi-turn dialogue have been widely used in scenarios such as office work, programming, customer service, and education.

[0003] However, existing intelligent agents typically manage sessions using methods such as manual session management, fixed session identifier binding, full vector retrieval, or sliding context windows, making it difficult to automatically identify changes in user roles and session topics. While some existing technologies can retrieve historical session content, they lack constraints at the role and session segment levels, easily leading to the mixing and injection of historical information from different roles or topics into the context. This results in context pollution or loss of key information, causing the agent's generated responses to mismatch with the current user role or session content, making it difficult to meet the needs of coherent, accurate, and personalized intelligent interaction in multi-role scenarios. Summary of the Invention

[0004] This application provides an intelligent agent interaction method, device, system, and storage medium. By identifying the conversation role type corresponding to the conversation information, and assembling the corresponding role profile, role conversation memory, role conversation content, and conversation information into a context, the method generates response information corresponding to the conversation information. It is applicable to multi-role recognition, historical conversation association, and personalized intelligent interaction scenarios.

[0005] Firstly, this application provides an intelligent agent interaction method, including: Receive session information input from the client and determine the corresponding session role type based on the session information; Determine the corresponding character profile, character conversation memory, and character conversation content based on the conversation character type; The target prompt words are obtained by assembling the character profile, the character conversation memory, the character conversation content, and the conversation information in context. The target prompt is input into the agent to generate the response information corresponding to the conversation information.

[0006] Secondly, this application provides an intelligent agent interaction device, comprising: The type determination module is configured to receive session information input by the client and determine the corresponding session role type based on the session information. The memory loading module is configured to determine the character profile, character conversation memory, and character conversation content corresponding to the conversation information based on the conversation role type. The context assembly module is configured to perform context assembly on the character profile, the character conversation memory, the character conversation content, and the conversation information to obtain target prompt words; The response generation module is configured to input the target prompt word into the agent to generate response information corresponding to the conversation information.

[0007] Thirdly, this application provides an intelligent agent interaction system, comprising: One or more processors; A memory that stores one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the agent interaction method as described in the first aspect.

[0008] Fourthly, this application provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the intelligent agent interaction method as described in the first aspect.

[0009] In this application, the corresponding conversation role type is determined by recognizing the conversation information input by the client, and the role profile, conversation memory, and conversation content corresponding to that role type are obtained. This information is then combined with the conversation information in context to obtain target prompt words, which are input into the agent to generate response information. This method improves the role-appropriateness, coherence, and accuracy of the agent's responses. Attached Figure Description

[0010] Figure 1 This is a flowchart of an intelligent agent interaction method provided in an embodiment of this application; Figure 2 This is a flowchart of the method for prior determination of session role type provided in an embodiment of this application; Figure 3 This is a flowchart of the prior role association calculation method provided in the embodiments of this application; Figure 4 This is a flowchart of the session role type association determination method provided in the embodiments of this application; Figure 5 This is a flowchart of the role memory extraction method provided in the embodiments of this application; Figure 6 This is a flowchart of the method for determining role-based conversation content provided in an embodiment of this application; Figure 7 This is a flowchart of the session segment proximate cause association method provided in the embodiments of this application; Figure 8 This is a flowchart of the session segment extension association method provided in the embodiments of this application; Figure 9This is a flowchart of the session segment association method provided in the embodiments of this application; Figure 10 This is a schematic diagram of the structure of the intelligent agent interaction device provided in the embodiments of this application; Figure 11 This is a schematic diagram of the structure of an intelligent agent interaction system provided in an embodiment of this application. Detailed Implementation

[0011] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as being processed sequentially, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. A process can be terminated when its operation is completed, but it may also have additional steps not included in the drawings. A process can correspond to a method, function, procedure, subroutine, subroutine, etc.

[0012] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and are not limited in number; for example, a first object can be one or more. Furthermore, "and / or" in the specification and claims indicates at least one of the connected objects.

[0013] In the application of large language models, conversation management is crucial for maintaining interactive coherence, associating historical information, and providing personalized responses. Users may play different roles in different scenarios and complete complex tasks through multi-turn dialogues. Therefore, accurately identifying conversation roles and rationally organizing role profiles, conversation memories, and historical conversation content has become an important research direction for intelligent agent interaction technology based on large language models.

[0014] Existing technologies typically manage sessions using methods such as manual session management, fixed session identifier binding, full vector retrieval, or sliding context windows. However, these methods still suffer from insufficient role recognition and context organization capabilities. Manual management increases the user's workload, fixed session binding struggles to identify topic changes, full vector retrieval is prone to incorporating historical information from different roles or topics, and sliding windows may lose important content, resulting in insufficient coherence and accuracy in agent responses. Therefore, there is an urgent need to provide an agent interaction scheme that can identify session roles and accurately associate role profiles, session memories, and historical session content.

[0015] Figure 1 This is a flowchart of an intelligent agent interaction method provided in an embodiment of this application. (Reference) Figure 1 The intelligent agent interaction method specifically includes: S110. Receive session information input by the client and determine the corresponding session role type based on the session information.

[0016] The conversation information can be interactive information in the form of text, voice or images entered by the user through the client, and the conversation role type can be the user's current interactive identity or role classification in the interactive scenario, such as programmer role type, investor role type or self-media creator role type.

[0017] In one embodiment, the method for receiving session information input by the client can be: receiving text information sent by the client through a session interaction interface, and determining the received text information as session information.

[0018] In another embodiment, the method of receiving the session information input by the client can also be: receiving the voice information input by the client, performing voice recognition processing on the voice information, and determining the recognized text information as session information.

[0019] In one embodiment, the method for determining the session role type can be as follows: calculate the correlation between the session information and multiple candidate role types, and determine the candidate role type with the highest correlation as the session role type. For example, when the session information contains content such as "Python," "code," or "test," the programmer role type can be determined as the corresponding session role type; when the session information contains content such as "stocks," "position," or "stop-loss," the investor role type can be determined as the corresponding session role type.

[0020] By following the steps above, the user role corresponding to the session information can be automatically identified, reducing mutual interference between session data of different role types.

[0021] Optionally, Figure 2 This is a flowchart of the method for prior determination of session role type provided in an embodiment of this application. (See reference) Figure 2 The method for prior determination of the session role type specifically includes: S1101. Obtain the prior role type corresponding to the previous session information input by the client, calculate the correlation between the session information and the prior role type, and obtain the prior role correlation.

[0022] Among them, the previous session information can be the session information most recently entered by the client before the current session information, the prior role type can be the session role type determined after role identification of the previous session information, and the prior role correlation degree can be the numerical value of the degree of correlation between the current session information and the prior role type.

[0023] In one embodiment, the prior role type can be obtained by: obtaining the user identifier corresponding to the client, using the user identifier to query the role type identifier corresponding to the previous session information from the session state cache, and determining the role type indicated by the role type identifier as the prior role type. For example, if the previous session information is a programming question and corresponds to the programmer role type, the programmer role type is determined as the prior role type.

[0024] In one embodiment, the method for calculating the prior role association degree can be as follows: input the current session information and the role description information corresponding to the prior role type into a pre-trained association degree calculation model, and output the association probability between the current session information and the prior role type by the association degree calculation model, and determine the association probability as the prior role association degree.

[0025] By following the steps above, we can first determine whether the current session information continues the role type corresponding to the previous session information.

[0026] Optionally, Figure 3 This is a flowchart of a prior role association calculation method provided in an embodiment of this application. (Reference) Figure 3 The prior role association calculation method specifically includes: S11011. Obtain the character profile, trigger keywords, and entity keywords corresponding to the prior character type.

[0027] In this context, the role profile can be profile data describing the identity attributes, behavioral preferences, and interaction preferences of a pre-existing role type; trigger keywords can be domain terms used to identify the corresponding role type; and entity keywords can be specific object names under the corresponding role type. For example, trigger keywords for the programmer role type could include "code," "architecture," "testing," and "algorithm," while entity keywords could include "Python," "FastAPI," "React," and "Kubernetes."

[0028] In one embodiment, the method for obtaining the character profile, trigger keyword, and entity keyword can be as follows: obtain the character type identifier corresponding to the prior character type, use the character type identifier to query the character profile library, read the profile data, trigger keyword list, and entity keyword list stored in association with the character type identifier, and determine them as the character profile, trigger keyword, and entity keyword, respectively.

[0029] Through the above steps, we can obtain semantic features, domain features, and entity features that describe the prior role type.

[0030] S11012. Calculate the cosine similarity between the conversation information and the character portrait.

[0031] Cosine similarity can be a numerical value representing the degree of semantic similarity between conversation information and character profile. The higher the cosine similarity, the higher the semantic relevance between the conversation information and the character profile.

[0032] In one embodiment, the cosine similarity can be calculated as follows: Convert the character profile data, such as identity attributes, behavioral preferences, and interaction preferences, into character profile text; input the conversation information and character profile text into a pre-trained text vector model to obtain the conversation feature vector corresponding to the conversation information and the profile feature vector corresponding to the character profile; and calculate the cosine similarity between the conversation feature vector and the profile feature vector. The specific calculation formula is shown below: in, For cosine similarity, For the session feature vector, For portrait feature vectors, The dot product of two eigenvectors. and These are the magnitudes of the two eigenvectors.

[0033] For example, when the user profile indicates that the user is a backend developer using Python and FastAPI, and the current session information is "Help me add unit tests for this interface", the two have a high semantic relevance in terms of programming development and testing, and thus a high cosine similarity can be obtained.

[0034] By following the steps above, we can quantify the correlation between conversation information and the corresponding character profile of the prior character type from an overall semantic perspective.

[0035] S11013. Calculate the trigger word matching degree and entity word matching degree between the session information and the trigger keyword and the entity keyword.

[0036] Among them, the trigger word matching degree can be a numerical value of the degree of matching between the session information and the trigger keyword corresponding to the prior role type, and the entity word matching degree can be a numerical value of the degree of matching between the session information and the entity keyword corresponding to the prior role type.

[0037] In one embodiment, the method for calculating the trigger word matching degree and entity word matching degree can be as follows: The session information is segmented and keywords are extracted to obtain multiple session keywords; these multiple session keywords are matched with the trigger keywords and entity keywords respectively, and the number of successfully matched trigger keywords and entity keywords is counted; the proportion of successfully matched trigger keywords to the total number of trigger keywords is calculated to obtain the trigger word matching degree; the proportion of successfully matched entity keywords to the total number of entity keywords is calculated to obtain the entity word matching degree. The specific calculation formula is shown below: in, To trigger word matching, The number of trigger keywords that are successfully matched. This represents the total number of trigger keywords corresponding to the existing character type.

[0038] in, For entity word matching degree, The number of successfully matched entity keywords, This represents the total number of entity keywords corresponding to the prior role type.

[0039] For example, if the initial role type is "programmer," the trigger keywords include "code," "test," and "deployment," and the entity keywords include "Python," "FastAPI," and "Redis." When the session information is "Help me test this FastAPI interface," "test" can be identified as a successfully matched trigger keyword, and "FastAPI" can be identified as a successfully matched entity keyword. The trigger keyword matching degree and entity keyword matching degree can then be calculated separately.

[0040] Through the above steps, the degree of matching between conversation information and prior role types can be quantified at both the domain terminology and specific entity levels.

[0041] S11014. The cosine similarity, the trigger word matching degree, and the entity word matching degree are weighted and fused to obtain the prior role association degree.

[0042] In one embodiment, the prior role relevance can be calculated as follows: Obtain the weights corresponding to cosine similarity, trigger word matching, and entity word matching, multiply each value by its corresponding weight, sum the products, and determine the sum as the prior role relevance. The specific calculation formula is shown below: in, For prior role relevance, For cosine similarity, To trigger word matching, For entity word matching degree, , and These are the corresponding weights, and For example, the weights for cosine similarity, trigger word matching, and entity word matching can be set to 0.5, 0.3, and 0.2, respectively.

[0043] By taking the above steps, we can integrate the overall semantic association between the conversation information and the prior role types, the domain word matching, and the specific entity matching, thereby reducing the role recognition bias caused by using a single matching indicator and improving the accuracy of prior role association.

[0044] S1102. If the prior role association degree is greater than or equal to the first association degree threshold, the prior role type is determined as the session role type corresponding to the session information.

[0045] The first correlation threshold can be a critical value used to determine whether the current session information continues the correlation of the previous role type. Its specific value can be preset in combination with the historical role recognition results, for example, it can be set to 0.85.

[0046] In one embodiment, the method for determining the session role type can be as follows: compare the prior role relevance with a first relevance threshold; when the prior role relevance is greater than or equal to the first relevance threshold, it is determined that the current session information has a high degree of relevance to the prior role type, and the role type identifier corresponding to the prior role type is assigned to the current session information, so that the prior role type is determined as the session role type corresponding to the current session information. For example, if the previous session information corresponds to the programmer role type, and the current session information is "add another parameter to the previous sorting function". When the calculated prior role relevance is 0.88 and the first relevance threshold is 0.85, it can be determined that the current session information continues the programmer role type, and the programmer role type is determined as the session role type corresponding to the current session information.

[0047] By following the steps above, when the role type corresponding to the current session information and the previous session information has a high degree of correlation, the previous role type can be directly used, reducing the amount of computation required to repeatedly match multiple candidate role types and maintaining the consistency of role type identification in continuous sessions.

[0048] S1103. If the prior role association degree is less than the first association degree threshold, calculate the association degree between the session information and multiple candidate role types to obtain multiple candidate role association degrees.

[0049] Among them, the candidate role type can be multiple role types that have been established for the current user, such as programmer role type, investor role type and self-media creator role type; the candidate role relevance can be a numerical value of the degree of correlation between the session information and the corresponding candidate role type.

[0050] In one embodiment, the method for determining multiple candidate role types may be as follows: when the prior role relevance is less than the first relevance threshold, obtain the user identifier corresponding to the client, use the user identifier to query the role profile library, and determine the multiple existing role types corresponding to the user identifier as multiple candidate role types.

[0051] In one embodiment, the method for calculating the candidate role relevance can be as follows: For each candidate role type, obtain the corresponding role profile, trigger keywords, and entity keywords; calculate the cosine similarity between the session information and the role profile, and calculate the trigger word matching degree and entity word matching degree between the session information and the trigger keywords and entity keywords; perform a weighted fusion of the cosine similarity, trigger word matching degree, and entity word matching degree to obtain the candidate role relevance corresponding to the candidate role type. The specific calculation formula is as follows: in, For the first The correlation between candidate roles for each candidate role type For session information and the first Cosine similarity between the character profiles corresponding to each candidate character type For the corresponding trigger word matching degree, For the corresponding entity word matching degree, , and These are the corresponding weights. For example, the first correlation threshold can be set to 0.85. , and They can be set to 0.5, 0.3, and 0.2 respectively.

[0052] In another embodiment, the method for calculating the relevance of multiple candidate roles can also be as follows: inputting the session information and the role profile summary, trigger keywords and entity keywords corresponding to multiple candidate role types into a pre-trained role matching model, and having the role matching model output the association probability between the session information and each candidate role type, and determining the multiple association probabilities as the relevance of multiple candidate roles respectively.

[0053] By following the steps above, when the current session information cannot directly use the previous role type, multiple existing role types of the user can be matched.

[0054] S1104. Determine the session role type corresponding to the session information based on the correlation of multiple candidate roles.

[0055] Optionally, Figure 4 This is a flowchart of the session role type association determination method provided in an embodiment of this application. (See reference) Figure 4 The method for determining the association between session role types specifically includes: S11041. Determine the target role type with the highest candidate role relevance and its corresponding target role relevance from the multiple candidate role types, as well as the second-highest candidate role type and its corresponding second-highest candidate role relevance.

[0056] Among them, the target role type can be the role type with the highest candidate role relevance among multiple candidate role types, and the target role relevance can be the candidate role relevance corresponding to the target role type; the secondary role type can be the role type with the second highest candidate role relevance after the target role type, and the secondary role relevance can be the candidate role relevance corresponding to the secondary role type.

[0057] In one embodiment, the method for determining the target role type, target role relevance, secondary role type, and secondary role relevance can be as follows: Multiple candidate role types are sorted in descending order of their relevance; the candidate role type ranked first is determined as the target role type, and its relevance is determined as the target role relevance; the candidate role type ranked second is determined as the secondary role type, and its relevance is determined as the secondary role relevance. For example, the candidate role relevances for the programmer role type, investor role type, and self-media creator role type are 0.86, 0.72, and 0.35, respectively. After sorting the candidate role relevances in descending order, the programmer and 0.86 are determined as the target role type and target role relevance, respectively, and the investor and 0.72 are determined as the secondary role type and secondary role relevance, respectively.

[0058] By following the steps above, we can filter out the two candidate role types and their correlation with the conversation information that are most relevant to the conversation information.

[0059] S11042. Calculate the difference between the correlation degree of the target role and the correlation degree of the secondary role to obtain the correlation degree difference.

[0060] The correlation difference is calculated by subtracting the correlation of the secondary role from the correlation of the target role, and it represents the degree of distinction between the target role type and the secondary role type. The larger the correlation difference, the more significant the matching advantage of the target role type compared to the secondary role type.

[0061] In one embodiment, the correlation difference can be calculated by subtracting the correlation of the second-choice role from the correlation of the target role.

[0062] The above steps can quantify the difference in correlation between the target role type and the secondary role type.

[0063] S11043. Determine the session role type corresponding to the session information based on the target role correlation degree and the correlation degree difference.

[0064] Optionally, determining the session role type corresponding to the session information based on the target role relevance and the relevance difference includes: If the target role relevance is greater than or equal to the second relevance threshold and the relevance difference is greater than or equal to the difference threshold, the target role type is determined as the session role type corresponding to the session information.

[0065] The second correlation threshold can be a correlation threshold used to determine whether the target role type and the conversation information have a high degree of correlation, and the difference threshold can be a difference threshold used to determine whether the target role type has a significant matching advantage over the secondary role type.

[0066] In one embodiment, determining the target role type as the session role type can be achieved by: if the target role relevance is greater than or equal to a second relevance threshold and the relevance difference is greater than or equal to a difference threshold, determining that the target role type has a high degree of relevance to the session information, and that there is sufficient distinguishability between the target role type and the secondary role type, then assigning the role type identifier corresponding to the target role type to the session information. For example, the second relevance threshold can be set to 0.80, and the difference threshold can be set to 0.05. When the target role relevance corresponding to the programmer role type is 0.86, and the secondary role relevance corresponding to the investor role type is 0.72, the relevance difference is 0.14. Since the target role relevance of 0.86 is greater than the second relevance threshold of 0.80, and the relevance difference of 0.14 is greater than the difference threshold of 0.05, the programmer role type is determined as the session role type corresponding to the session information.

[0067] By following the steps above, when the target role type is highly relevant to the conversation information and has a significant matching advantage over the secondary role type, the conversation role type can be directly determined, reducing unnecessary role disambiguation processing.

[0068] If the target role correlation is greater than or equal to the third correlation threshold and less than the second correlation threshold, or if the target role correlation is greater than or equal to the second correlation threshold and the correlation difference is less than the difference threshold, the agent determines the session role type corresponding to the session information from multiple candidate role types.

[0069] The third relevance threshold can be a critical value for determining whether the target role type has a basic relevance to the conversation information.

[0070] In one embodiment, the method for determining the conversation role type using an agent can be as follows: Obtain role profile summaries and recent conversation examples corresponding to multiple candidate role types; fill the conversation information, multiple role profile summaries, recent conversation examples, and candidate role type identifiers into a preset role disambiguation template to obtain role disambiguation prompts; input the role disambiguation prompts into the agent, instructing the agent to select the candidate role type that best matches the conversation information from multiple candidate role types; obtain the role type identifier output by the agent, and determine the candidate role type corresponding to the role type identifier as the conversation role type corresponding to the conversation information. For example, the second correlation threshold can be set to 0.80, the third correlation threshold can be set to 0.50, and the difference threshold can be set to 0.05. When the target role correlation is 0.68, since the target role correlation is greater than the third correlation threshold and less than the second correlation threshold, role disambiguation is performed using an agent. When the target role correlation is 0.86 and the correlation difference is 0.03, since the correlation difference between the target role type and the secondary role type is small, the conversation role type is also determined from multiple candidate role types using an agent.

[0071] By following the steps above, when the confidence level of the target role type is insufficient or there is ambiguity among multiple candidate role types, the agent can perform role disambiguation by comprehensively considering conversation semantics, role profiles, and recent conversation information, thereby improving the accuracy of conversation role type identification.

[0072] If the target role correlation is less than the third correlation threshold, a session role type corresponding to the session information is created.

[0073] In one embodiment, creating a conversation role type can be achieved by: semantically parsing the conversation information to extract interaction intents, domain keywords, and entity keywords; combining the interaction intents, domain keywords, and entity keywords to generate an initial role profile; configuring a role type identifier for the initial role profile; and storing the role type identifier and its corresponding initial role profile, domain keywords, and entity keywords in a role profile database to obtain a new conversation role type corresponding to the conversation information. For example, when the target role relevance is 0.42, it is determined that the conversation information has no basic relevance to any existing candidate role types. In this case, a new conversation role type can be created for the conversation information, with the initial confidence level of the new conversation role type set to 0.3, and its role profile marked as "to be improved".

[0074] By following the steps above, when the current session information cannot be categorized into an existing candidate role type, an independent session role type can be created for it, avoiding the incorrect association of new interaction scenarios with existing role types, and providing a data foundation for role recognition of subsequent similar session information.

[0075] S120. Determine the character profile, character conversation memory, and character conversation content corresponding to the conversation information based on the conversation character type.

[0076] The role profile can be user profile data based on their identity attributes, behavioral preferences, and interaction preferences under a corresponding session role type. The role session memory can be structured memory data extracted and stored from historical sessions of the corresponding session role type. The role session content can be the original text of historical sessions related to the current session information. For example, the role profile corresponding to the programmer role type can include information such as technology stack, development paradigm, coding preferences, and communication style. The role session memory can include information such as requirements, designs, test cases, and code implementations formed in historical sessions. The role session content can include historical session segments related to the current programming problem.

[0077] In one embodiment, the method for determining the character profile may be: using the character type identifier corresponding to the conversation character type as the search condition, retrieving the profile data stored in the character profile library that is associated with the character type identifier, and determining the retrieved profile data as the character profile corresponding to the conversation information.

[0078] In one embodiment, the method for determining a role's conversation memory may be: using the role type identifier to search in the conversation memory database, obtaining multiple contextualized memory data stored under the conversation role type, filtering memory data related to the conversation information from the multiple contextualized memory data, and determining the filtered memory data as the role's conversation memory.

[0079] In one embodiment, the method for determining the role's conversation content may be: retrieving a target conversation segment that matches the conversation information from multiple historical conversation segments corresponding to the conversation role type, extracting the original text of the historical conversation related to the conversation information from the target conversation segment, and determining the extracted original text of the historical conversation as the role's conversation content.

[0080] By following the steps above, long-term profile data, medium-term structured memory data, and short-term historical conversation content can be obtained within the scope of the conversation role type, and the cross-interference between historical information corresponding to different role types can be reduced.

[0081] Optionally, Figure 5 This is a flowchart of the role memory retrieval method provided in an embodiment of this application. (Reference) Figure 5 The specific methods for extracting the character's memories include: S1201. Retrieve the character image corresponding to the session character type from the character image database.

[0082] The character profile library can be a data set used to store user profiles under different conversational role types, with the character profiles corresponding to different conversational role types being independent of each other. Character profiles can include user identity attributes, behavioral preferences, and interaction preferences under the corresponding conversational role type.

[0083] In one embodiment, retrieving a role profile from the role profile library can be done by: obtaining the user identifier corresponding to the client and the role type identifier corresponding to the session role type; using the user identifier and role type identifier as combined search conditions, querying the profile data stored in the role profile library that is associated with the combined search conditions; and determining the retrieved profile data as the role profile corresponding to the session information. For example, when the user identifier is U001 and the session role type is programmer, the role profile of the user under the programmer role type can be retrieved from the role profile library. This role profile may include the identity attribute of "senior backend development engineer", the development paradigm of "test-driven development", the technology stack such as Python and FastAPI, coding preferences such as type annotations and unit test coverage, and the interaction preference of preferring structured output.

[0084] By following the steps above, the corresponding user role characteristics can be obtained within the scope of the session role type, avoiding the need to call profile data under other session role types.

[0085] S1202. Retrieve the role conversation memory corresponding to the conversation role type from the conversation memory bank.

[0086] The conversation memory bank can be a database that stores historical interaction memories categorized by conversation role type. Each conversation role type can be configured with a corresponding memory data structure, and the conversation memories of different conversation role types are isolated from each other.

[0087] In one embodiment, retrieving role-based session memories from the session memory bank can be done by: obtaining a role type identifier corresponding to the session role type; querying the session memory bank using the role type identifier; reading the structured memory data stored in association with the role type identifier; and identifying the read structured memory data as the role-based session memory corresponding to the session role type. For example, when the session role type is a programmer role type, the role type identifier corresponding to the programmer role type can be obtained, and structured memory data such as requirements, designs, test cases, and code implementations corresponding to that role type identifier can be retrieved from the session memory bank to obtain the role-based session memory corresponding to the programmer role type.

[0088] In another embodiment, the method of retrieving role conversation memories from the conversation memory bank can also be: using the role type identifier to query the hot data storage area and the warm data storage area respectively, and combining the recent structured memory data and the earlier structured memory data according to the generation time to obtain the role conversation memory corresponding to the conversation role type.

[0089] By following the steps above, we can retrieve the structured historical memories accumulated under the current conversation role type from the conversation memory bank, avoiding the retrieval of memory data corresponding to other conversation role types.

[0090] S1203. Determine the role conversation content corresponding to the conversation information based on the conversation information and the conversation role type.

[0091] In one embodiment, the method for determining the role conversation content may be: obtaining the most recent conversation segment corresponding to the conversation role type, calculating the conversation continuity between the conversation information and the most recent conversation segment; if the conversation continuity is greater than or equal to the continuity threshold, extracting the historical conversation original text related to the conversation information from the most recent conversation segment, and determining the extracted historical conversation original text as the role conversation content.

[0092] By following the steps above, we can determine the original text of the historical conversation related to the current conversation information within the scope of the conversation role type, and prevent the historical conversation content under other conversation role types from entering the current interaction context.

[0093] Optionally, Figure 6 This is a flowchart of a method for determining role-based conversation content provided in an embodiment of this application. (Reference) Figure 6 The specific methods for determining the content of the character's conversation include: S12031. Among the multiple historical session segments corresponding to the session role type, retrieve multiple candidate session segments corresponding to the session information.

[0094] Among them, the historical conversation segment can be a collection of conversation content formed by dividing the historical conversation content according to the conversation topic or the continuity of the conversation, and each historical conversation segment is associated with a corresponding role type identifier; the candidate conversation segment can be a historical conversation segment that is related to the conversation information in terms of semantics, entity or time within the scope of the conversation role type.

[0095] In one embodiment, the method for retrieving multiple candidate session segments may be as follows: obtain the role type identifier corresponding to the session role type, and use the role type identifier to filter multiple corresponding historical session segments from the session segment database; use vector recall, entity recall and proximate cause recall methods respectively to retrieve historical session segments related to session information from multiple historical session segments; merge and deduplicate the historical session segments obtained by different recall methods to obtain multiple candidate session segments.

[0096] In one embodiment, the vector recall method may be as follows: generate a session feature vector corresponding to the session information, calculate the vector similarity between the session feature vector and the session segment anchor vectors of multiple historical session segments respectively, and select the first number of historical session segments to be recalled in order of vector similarity from high to low.

[0097] In one embodiment, entity recall can be achieved by: extracting entity keywords from session information, calculating the entity matching degree between the extracted entity keywords and the corresponding entity keywords of each historical session segment, and selecting a second number of historical session segments to recall based on the entity matching degree.

[0098] In one embodiment, the proximate cause recall method can be: selecting the third number of historical session segments to recall, in order of session time from most recent to oldest.

[0099] For example, in the vector recall process, the five historical session segments with the highest vector similarity can be selected; in the entity recall process, the three historical session segments with the highest entity matching degree can be selected; and in the proximate cause recall process, the three historical session segments with the most recent session time can be selected. The historical session segments obtained by the three recall methods are merged and deduplicated to obtain multiple candidate session segments.

[0100] By following the steps above, the retrieval scope of historical conversation segments can be limited to the current conversation role type, and historical conversation segments related to conversation information can be recalled from multiple aspects such as semantics, entity, and time, thereby improving the recall accuracy of candidate conversation segments.

[0101] S12032. For each candidate session segment, calculate the session matching degree between the candidate session segment and the session information.

[0102] The session matching degree can be a numerical value used to characterize the comprehensive relevance between candidate session segments and session information in terms of semantics, entities, and time. The higher the session matching degree, the higher the relevance between the candidate session segment and the session information.

[0103] In one embodiment, the session matching degree can be calculated as follows: For each candidate session segment, calculate the cosine similarity between the session feature vector corresponding to the session information and the session segment anchor vector corresponding to the candidate session segment to obtain the semantic matching degree; calculate the intersection-union ratio (IUU) between the session entity set corresponding to the session information and the session entity set corresponding to the candidate session segment to obtain the entity matching degree; calculate the time matching degree using the time difference between the input time of the session information and the most recent session time of the candidate session segment; and perform a weighted fusion of the semantic matching degree, entity matching degree, and time matching degree to obtain the session matching degree corresponding to the candidate session segment. The specific calculation formula is shown below: in, For the first The session matching degree corresponding to each candidate session segment. For the first The semantic matching degree of each candidate session segment. For the first The entity matching degree corresponding to each candidate session segment For the first The time matching degree corresponding to each candidate session segment , and These represent the corresponding weights, and the sum of the three is 1.

[0104] in, For the first The entity matching degree corresponding to each candidate session segment This is the set of session entities corresponding to the session information. For the first The set of session segment entities corresponding to each candidate session segment.

[0105] in, For session information and the first Time difference between candidate session segments This represents the time decay parameter.

[0106] For example, , and The time decay parameter can be set to 0.6, 0.25, and 0.15 respectively. It can be set to 86400 seconds, which is 24 hours.

[0107] By taking the above steps, we can comprehensively consider the semantic relevance, entity overlap, and temporal proximity between candidate session segments and session information, and accurately quantify the degree of relevance between each candidate session segment and session information.

[0108] S12033. Determine the target session segment corresponding to the session information based on the session matching degree, and extract the role session content corresponding to the session information from the target session segment.

[0109] The target session segment can be the historical session segment that is most relevant to the session information among multiple candidate session segments.

[0110] In one embodiment, the target session segment can be determined by: sorting multiple candidate session segments in descending order of session matching degree, and determining the candidate session segment with the highest session matching degree as the initial selection session segment; if the session matching degree corresponding to the initial selection session segment is greater than or equal to the first session segment threshold, the initial selection session segment is determined as the target session segment.

[0111] In one embodiment, the method for extracting role-specific conversation content can be as follows: Obtain multiple historical conversation entries and their corresponding historical replies contained in the target conversation segment; calculate the semantic similarity between each historical conversation entry and the current conversation entry; filter relevant historical conversation entries and their historical replies from the target conversation segment according to semantic similarity, and arrange them according to conversation time to obtain the role-specific conversation content. For example, the threshold for the first conversation segment can be set to 0.85. When the conversation matching score of the candidate conversation segment with the highest matching score is 0.88, that candidate conversation segment is determined as the target conversation segment. If the current conversation information is "Add another parameter to the previous sorting function," then the historical conversation content such as the requirement description, parameter design, test cases, and code implementation of the sorting function can be extracted from the target conversation segment to obtain the role-specific conversation content.

[0112] In another embodiment, if the conversation matching degree corresponding to the initially selected conversation segment is greater than or equal to the second conversation segment threshold and less than the first conversation segment threshold, the conversation information, the conversation segment summaries of multiple candidate conversation segments, and the corresponding conversation matching degrees can be assembled into a conversation segment disambiguation prompt. This disambiguation prompt is then input into the agent. The agent selects the candidate conversation segment most relevant to the conversation information from among the multiple candidate conversation segments, identifies it as the target conversation segment, and extracts the corresponding role conversation content from the target conversation segment. For example, the first and second conversation segment thresholds can be set to 0.85 and 0.60, respectively.

[0113] In another embodiment, if the session matching degree corresponding to the initially selected session segment is less than the second session segment threshold, it is determined that multiple candidate session segments do not have sufficient relevance to the session information. A new session segment is then created, designated as the target session segment, and the session information is associated with this target session segment. Since the newly created target session segment does not contain any historical session text preceding the session information, the role session content can be set to empty. For example, if the session matching degree of the initially selected session segment is 0.48, since this matching degree is less than 0.60, a new session segment is created, with the current session information as the first message in the new session segment, and the role session content is set to empty. Subsequent reception of session information related to this new session segment can continue to associate it with this session segment, gradually forming the corresponding role session content.

[0114] By following the steps above, the target session segment related to the current session information can be identified from multiple candidate session segments, and the corresponding historical session text can be extracted.

[0115] S130. The character portrait, the character conversation memory, the character conversation content, and the conversation information are assembled in context to obtain target prompt words.

[0116] The target prompt can be structured prompt information used to input the intelligent agent, which may include user role characteristics, historical interaction information and current interaction requirements.

[0117] In one embodiment, the contextual assembly of role profile, role conversation memory, role conversation content, and conversation information can be performed as follows: A preset prompt word template is obtained; the role profile is filled into the role setting area of ​​the prompt word template; the role conversation memory is filled into the memory information area; the role conversation content is filled into the historical context area; and the conversation information is filled into the current question area to obtain the target prompt word. For example, when the conversation role type is programmer, the user's technology stack, development paradigm, and coding preferences can be used as role settings; historical requirements, technical solutions, and test cases can be used as role conversation memory; historical conversation text related to the current programming problem can be used as historical context; and the conversation information currently input by the client can be used as the current question. These are then assembled in a preset order to obtain the target prompt word.

[0118] Through the above steps, contextual information from different levels and related to the current conversational role type can be integrated into the target prompt word. This allows the target prompt word to simultaneously reflect the user's role characteristics, historical memory, recent conversational context, and current interaction needs, providing a complete context for the agent to generate response information that matches the current user's needs.

[0119] S140. Input the target prompt word into the agent to generate the response information corresponding to the conversation information.

[0120] The agent can be a large language model with natural language understanding and generation capabilities, and the response information can be generated by the agent combining the role profile in the target prompt, the role's conversation memory, the role's conversation content, and the current conversation information. The response information can take the form of text, code, tables, or operation instructions.

[0121] In one embodiment, generating response information can be achieved by having an agent call an interface to input target prompts into a pre-configured large language model. The large language model then performs semantic understanding and text generation processing on the target prompts, outputting response content corresponding to the conversation information. For example, if the conversation role type is programmer, the agent can combine the user's technology stack, coding preferences, historical technical solutions, and relevant historical conversation content in the target prompts to generate code or technical responses that conform to the user's coding habits. If the conversation role type is investor, the agent can combine the user's risk preferences, trading style, and historical analysis records to generate corresponding analytical responses.

[0122] Through the above steps, the agent can generate response information by integrating user characteristics, historical memory, and conversation context corresponding to the current conversation role type. This makes the response information more in line with the user's interaction needs and expression preferences under the current role, thereby improving the accuracy and coherence of the agent's response.

[0123] Optionally, Figure 7 This is a flowchart of the session segment proximate cause association method provided in an embodiment of this application. (Reference) Figure 7 The proximate correlation method for this session segment specifically includes: S141. Obtain the first preset number of first conversation contents in the most recent conversation segment corresponding to the conversation role type, and calculate the first semantic similarity between the conversation information and the first conversation content.

[0124] Among them, the most recent conversation segment can be the conversation segment whose conversation time is closest to the current time under the conversation role type, the first preset number can be the number of conversation content obtained from the most recent conversation segment, the first conversation content can be the conversation content of the most recent rounds selected from the most recent conversation segment, and the first semantic similarity can be a numerical value used to characterize the semantic continuity between the conversation information and the first conversation content.

[0125] In one embodiment, the method for obtaining the first session content may be: obtaining the role type identifier corresponding to the session role type, querying the current active session segment cache using the role type identifier, determining the queried current active session segment as the most recent session segment; selecting a first preset number of complete session rounds from the most recent session segments in order of session time from most recent to oldest, and determining the selected user session information and corresponding reply information as the first session content.

[0126] In one embodiment, the first semantic similarity can be calculated as follows: The first session content is arranged and concatenated according to session time to obtain the first session text; the current session information and the first session text are input into a pre-trained text vector model to obtain the current session vector corresponding to the current session information and the first content vector corresponding to the first session content; the cosine similarity between the current session vector and the first content vector is calculated to obtain the first semantic similarity. The specific calculation formula is as follows: in, The first semantic similarity, This is the current session vector corresponding to the session information. This is the first content vector corresponding to the content of the first session. and These are the magnitudes of the current session vector and the first content vector, respectively.

[0127] For example, the first preset quantity can be set to 3, that is, the most recent 3 rounds of complete conversations in the most recent conversation segment are taken as the first conversation content. When the conversation information is "add another parameter to the previous sorting function", the conversation information and the most recent 3 rounds of complete conversations can be converted into corresponding vectors respectively, and the cosine similarity between the two vectors can be calculated to obtain the first semantic similarity.

[0128] By following the steps above, we can use the recent conversation content in the recent conversation segment to determine whether the current conversation information continues the topic of the recent conversation.

[0129] S142. If the first semantic similarity is greater than or equal to the first similarity threshold, the session information is associated with the most recent session segment.

[0130] The first similarity threshold can be a critical value used to determine whether the session information and the most recent session segment have a high degree of semantic continuity.

[0131] In one embodiment, associating session information with the most recent session segment can be achieved by: if the first semantic similarity is greater than or equal to a first similarity threshold, determining that the session information continues the session topic corresponding to the most recent session segment, obtaining the session segment identifier corresponding to the most recent session segment, writing the session segment identifier into the message node corresponding to the session information, and adding the message node to the message node linked list corresponding to the most recent session segment. For example, the first similarity threshold can be set to 0.85. When the first semantic similarity between the session information and the most recent three complete sessions is 0.88, since the first semantic similarity is greater than the first similarity threshold, the session information is associated with the most recent session segment.

[0132] By following the steps above, when the conversation information has a high semantic continuity with the most recent conversation segment, the conversation information can be directly attributed to the most recent conversation segment, thus maintaining the continuity of conversation content across multiple rounds under the same conversation topic.

[0133] Optionally, Figure 8 This is a flowchart of the session segment extension association method provided in an embodiment of this application. (Reference) Figure 8 The specific methods for extending the association of this session segment include: S143. If the first semantic similarity is greater than or equal to the third similarity threshold and less than the first similarity threshold, obtain a second preset number of second session contents from the most recent session segment, wherein the second preset number is greater than the first preset number.

[0134] The third similarity threshold can be a critical similarity value used to determine whether the session information and the most recent session segment have basic semantic relevance, and the first similarity threshold is greater than the third similarity threshold. The second preset quantity can be the number of session rounds obtained when performing extended analysis on the most recent session segment, and the second session content can be the content of several recent rounds of session selected from the most recent session segment.

[0135] In one embodiment, the method for obtaining the second session content may be as follows: If the first semantic similarity is greater than or equal to a third similarity threshold but less than the first similarity threshold, it is determined that the session information cannot be directly judged from the most recent session segment using the first session content. Then, in order of session time from most recent to oldest, a second preset number of complete session rounds are selected from the most recent session segments, and these selected complete session rounds are determined as the second session content. For example, the first similarity threshold can be set to 0.85, the third similarity threshold can be set to 0.60, the first preset number can be set to 3, and the second preset number can be set to 10. When the first semantic similarity is 0.72, since the first semantic similarity is greater than the third similarity threshold but less than the first similarity threshold, the analysis scope is expanded from the most recent 3 rounds of complete sessions to the most recent 10 rounds of complete sessions, thus obtaining the second session content.

[0136] By following the steps above, when a small amount of recent conversation content is insufficient to clearly determine the continuity of a conversation, the analysis scope of the most recent conversation segment can be expanded, and more historical conversation content can be used to further determine whether the conversation information continues from the most recent conversation segment.

[0137] S144. Calculate the second semantic similarity between the session information and the second session content.

[0138] The second semantic similarity can be a numerical value representing the degree of semantic continuity between the session information and the expanded second session content. The higher the second semantic similarity, the greater the semantic relevance between the session information and the most recent session segment within the expanded session scope.

[0139] In one embodiment, the second semantic similarity can be calculated as follows: The second conversation content is arranged and concatenated according to conversation time to obtain the second conversation text; the second conversation text is input into a pre-trained text vector model to obtain the second content vector corresponding to the second conversation content; the cosine similarity between the current conversation vector corresponding to the conversation information and the second content vector is calculated, and the result is determined as the second semantic similarity. The specific calculation formula is as follows: in, For second semantic similarity, This is the current session vector corresponding to the session information. This is the second content vector corresponding to the second session content. and These are the magnitudes of the current session vector and the second content vector, respectively.

[0140] For example, the second preset quantity can be set to 10. The most recent 10 complete conversations in the most recent conversation segment can be arranged and concatenated according to the conversation time. The concatenated second conversation text is converted into a second content vector, and the cosine similarity between the second content vector and the current conversation vector is calculated to obtain the second semantic similarity.

[0141] By following the steps above, we can re-evaluate the semantic continuity between the expanded session content and the most recent session segments, thereby reducing session segment association errors caused by insufficient information in a small amount of recent session content.

[0142] S145. If the second semantic similarity is greater than or equal to the second similarity threshold, the session information is associated with the most recent session segment, where the first similarity threshold is greater than the second similarity threshold and the second similarity threshold is greater than the third similarity threshold.

[0143] The second similarity threshold can be a critical value used to determine whether the session information and the expanded second session content have semantic continuity. The first similarity threshold is greater than the second similarity threshold, and the second similarity threshold is greater than the third similarity threshold.

[0144] In one embodiment, associating session information with the most recent session segment can be achieved by: if the second semantic similarity is greater than or equal to the second similarity threshold, determining that the session information has semantic continuity with the most recent session segment within the extended session scope, obtaining the session segment identifier corresponding to the most recent session segment, configuring the session segment identifier as the attribution identifier of the session information, and adding the session information to the most recent session segment. For example, the first similarity threshold, the second similarity threshold, and the third similarity threshold can be set to 0.85, 0.80, and 0.60, respectively. When the first semantic similarity is 0.72 and the second semantic similarity is 0.83, since the first semantic similarity is between 0.60 and 0.85, the most recent 10 complete sessions are obtained for extended analysis; since the second semantic similarity of 0.83 is greater than the second similarity threshold of 0.80, the session information is associated with the most recent session segment.

[0145] By following the steps above, when the continuity of a conversation cannot be directly confirmed by a small amount of recent conversation content, the expanded conversation content can be used to make further judgments and accurately associate semantically continuous conversation information with the most recent conversation segment.

[0146] Optionally, Figure 9 This is a flowchart of the session segment association method provided in an embodiment of this application. (Reference) Figure 9 The specific methods for associating these session segments include: S146. If the first semantic similarity is less than the third similarity threshold or the second semantic similarity is less than the second similarity threshold, extract entity keywords from the session information and the most recent session segment respectively to obtain a session entity set and a session segment entity set.

[0147] The session entity set can be a set of multiple entity keywords extracted from the current session information; the session segment entity set can be a set of multiple entity keywords extracted from all the session content of the most recent session segment.

[0148] In one embodiment, entity keyword extraction can be performed as follows: If the first semantic similarity is less than a third similarity threshold, or the second semantic similarity is less than a second similarity threshold, the session information and all session content of the most recent session segment are input into a pre-trained named entity recognition model. The named entity recognition model identifies the entity words contained in each, and the identified entity words are deduplicated and standardized to obtain a session entity set and a session segment entity set, respectively. For example, the third similarity threshold can be set to 0.60, and the second similarity threshold can be set to 0.80. When the first semantic similarity is 0.52 or the second semantic similarity is 0.74, entity keyword extraction is initiated. If the session information is "The FastAPI interface still needs to connect to Redis," then "FastAPI" and "Redis" can be extracted to form the session entity set; if all session content of the most recent session segment contains "Python," "FastAPI," "PostgreSQL," and "Redis," then the above entity keywords can be used to form the session segment entity set.

[0149] By following the steps above, when semantic similarity is insufficient to determine session continuity, it is possible to further extract current session information and specific objects from the most recent session segment.

[0150] S147. Calculate the intersection-union ratio of the session entity set and the session segment entity set to obtain the entity overlap rate.

[0151] The entity overlap rate can be a numerical value representing the degree to which session information and the most recent session segment contain the same entity objects. A higher entity overlap rate indicates a greater degree of relevance between the session information and the most recent session segment in terms of entity objects.

[0152] In one embodiment, the entity overlap rate can be calculated as follows: The intersection of the session entity set and the session segment entity set is performed to obtain common entity keywords that exist in both sets; the union of the session entity set and the session segment entity set is performed to obtain all non-repeating entity keywords contained in both sets; the ratio between the number of common entity keywords and the number of all non-repeating entity keywords is calculated, and this ratio is determined as the entity overlap rate. The specific calculation formula is as follows: in, This refers to the entity overlap rate. Information for the current session. For the most recent session segment, The set of session entities extracted from the current session information. This is the set of session segment entities extracted from the most recent session segment.

[0153] For example, if the session entity set is {FastAPI, Redis} and the session segment entity set is {Python, FastAPI, PostgreSQL, Redis}, the intersection of the two entity sets is {FastAPI, Redis}, and the union is {Python, FastAPI, PostgreSQL, Redis}. Therefore, the entity overlap rate is: By using the above steps, we can quantify the degree of overlap between the session information and the proportion of shared entities in the most recent session segment to all entities at the specific object level.

[0154] S148. Calculate the time decay factor based on the time difference between the input time of the session information and the input time of the last session content in the most recent session segment.

[0155] Among them, the input time of the session information can be the time when the client sends the current session information, the input time of the last session content can be the record time corresponding to the user session information or reply information that is latest in the time sequence in the most recent session segment, the time difference can be the interval between two input times, and the time decay factor can be the value of the continuity between the session information and the most recent session segment in the time dimension.

[0156] In one embodiment, the time decay factor can be calculated as follows: The input time of the session information and the input time of the last session content in the most recent session segment are obtained; the input time of the session information is subtracted from the input time of the last session content to obtain the time difference; the time difference and a preset time decay parameter are substituted into the exponential decay function to obtain the time decay factor. The specific calculation formula is as follows: in, For the time difference, For the time of inputting session information, The input time of the last message in the most recent session segment. The time decay factor, For time decay parameters, It is an exponential function with the natural constant as its base.

[0157] For example, time decay parameter It can be set to 30 minutes. When the time difference between the input time of the session information and the input time of the last session content in the most recent session segment is 10 minutes, the time decay factor is: The above steps enable us to quantify the temporal proximity of the current session information to the most recent session segment.

[0158] S149. The first semantic similarity, the entity overlap rate, and the time decay factor are weighted and fused to obtain the session continuity.

[0159] Session continuity can be a numerical value that characterizes the degree of continuity between session information and the most recent session segment in terms of semantics, entities, and time.

[0160] In one embodiment, the session continuity can be calculated as follows: First, obtain the fusion weights corresponding to the first semantic similarity, entity overlap rate, and time decay factor; multiply the first semantic similarity, entity overlap rate, and time decay factor by their respective fusion weights; sum the resulting products, and determine the sum as the session continuity. The specific calculation formula is shown below: in, For session continuity, The first semantic similarity, This refers to the entity overlap rate. The time decay factor, , and These are the fusion weights corresponding to the first semantic similarity, entity overlap rate, and time decay factor, respectively. .

[0161] By taking the above steps, we can comprehensively consider the semantic relevance, entity overlap, and temporal proximity between the session information and the most recent session segments, thus avoiding misjudgments caused by using a single indicator to determine session continuity.

[0162] S150. If the session continuity is greater than or equal to the continuity threshold, associate the session information with the most recent session segment.

[0163] The continuity threshold can be a critical value used to determine whether the session information has session continuity with the most recent session segment.

[0164] In one embodiment, associating session information with the most recent session segment can be achieved by: comparing session continuity with a continuity threshold; if the session continuity is greater than or equal to the continuity threshold, determining that the session information and the most recent session segment are continuous in terms of semantics, entities, and time; obtaining the session segment identifier corresponding to the most recent session segment, writing the session segment identifier into the message node corresponding to the session information, and adding the message node to the message node linked list corresponding to the most recent session segment. For example, the continuity threshold can be set to 0.70. When the session continuity obtained by weighted fusion of the first semantic similarity, entity overlap rate, and time decay factor is 0.76, since the session continuity is greater than the continuity threshold, the session information is associated with the most recent session segment.

[0165] In one embodiment, if the session continuity is less than a continuity threshold, it is determined that the session information does not have session continuity with the most recent session segment. A new session segment is created under the session role type, a session segment identifier is configured for the new session segment, the session segment identifier is written to the message node corresponding to the session information, and this message node is used as the first message node of the new session segment. For example, the continuity threshold can be set to 0.70. When the session continuity obtained by weighted fusion of the first semantic similarity, entity overlap rate, and time decay factor is 0.58, since the session continuity is less than the continuity threshold, the session information is not associated with the most recent session segment. Instead, a new session segment is created under the current session role type, and the session information is associated with the new session segment. The new session segment still belongs to the current session role type and does not change the session role type corresponding to the session information.

[0166] Through the above steps, when semantic similarity cannot directly determine the continuity of a session, further judgment can be made by combining entity overlap and temporal proximity, and session information with session continuity can be accurately associated with the most recent session segment.

[0167] Based on the above embodiments, Figure 10 This is a schematic diagram of the structure of the intelligent agent interaction device provided in an embodiment of this application. (Reference) Figure 10 The intelligent agent interaction device provided in this embodiment specifically includes: a type determination module 11, a memory loading module 12, a context assembly module 13, and a response generation module 14.

[0168] The module 11 is configured to receive session information input from the client and determine the corresponding session role type based on the session information; the memory loading module 12 is configured to determine the role profile, role session memory, and role session content corresponding to the session information based on the session role type; the context assembly module 13 is configured to perform context assembly on the role profile, the role session memory, the role session content, and the session information to obtain the target prompt word; and the response generation module 14 is configured to input the target prompt word into the agent to generate the response information corresponding to the session information.

[0169] The intelligent agent interaction device provided in this application embodiment, through the coordinated operation of the type determination module 11, memory loading module 12, context assembly module 13, and response generation module 14, realizes the determination of conversation role type, loading of role information, context assembly, and response generation. The type determination module 11 is used to determine the corresponding conversation role type based on the conversation information input by the client; the memory loading module 12 is used to determine the role profile, role conversation memory, and role conversation content corresponding to the conversation role type; the context assembly module 13 is used to perform context assembly on the role profile, role conversation memory, role conversation content, and conversation information to obtain the target prompt word; the response generation module 14 is used to input the target prompt word into the intelligent agent to generate the response information corresponding to the conversation information. This embodiment can improve the accuracy of role recognition and context matching during intelligent agent interaction, thereby improving the relevance and coherence of the response information.

[0170] The intelligent agent interaction device provided in this application embodiment can be used to execute the intelligent agent interaction method provided in the above embodiment, and has corresponding functions and beneficial effects.

[0171] Figure 11 This is a schematic diagram of the structure of an intelligent agent interaction system provided in an embodiment of this application, with reference to... Figure 11 The intelligent agent interaction system includes a processor 21, a memory 22, a communication device 23, an input device 24, and an output device 25. The number of processors 21 and the number of memories 22 in the intelligent agent interaction system can be one or more. The processor 21, memory 22, communication device 23, input device 24, and output device 25 of the intelligent agent interaction system can be connected via a bus or other means.

[0172] The memory 22, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as program instructions / modules corresponding to the intelligent agent interaction method in any embodiment of this application (e.g., type determination module 11, memory loading module 12, context assembly module 13, and response generation module 14 in the intelligent agent interaction device). The memory 22 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created based on the use of the device, etc. Furthermore, the memory 22 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0173] The communication device 23 is used for data transmission.

[0174] The processor 21 executes various functional applications and data processing of the device by running software programs, instructions and modules stored in the memory 22, thereby realizing the above-mentioned intelligent agent interaction method.

[0175] Input device 24 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the device. Output device 25 may include display devices such as a display screen.

[0176] The intelligent agent interaction system provided above can be used to execute the intelligent agent interaction method provided in the above embodiments, and has corresponding functions and beneficial effects.

[0177] This application embodiment also provides a storage medium containing computer-executable instructions. When executed by a computer processor, the computer-executable instructions are used to execute an intelligent agent interaction method. The intelligent agent interaction method includes: receiving session information input by a client; determining a corresponding session role type based on the session information; determining a role profile, role session memory, and role session content corresponding to the session information based on the session role type; performing contextual assembly on the role profile, the role session memory, the role session content, and the session information to obtain a target prompt word; and inputting the target prompt word into the intelligent agent to generate response information corresponding to the session information.

[0178] Storage medium—any type of memory device or storage device. The term "storage medium" is intended to include: mounting media, such as CD-ROM, floppy disk, or magnetic tape devices; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, etc.; non-volatile memory, such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. Storage medium may also include other types of memory or combinations thereof. Furthermore, storage medium may reside in a first computer system in which a program is executed, or it may reside in a different second computer system connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media residing in different locations (e.g., in different computer systems connected via a network). Storage medium may store program instructions (e.g., specifically implemented as a computer program) executable by one or more processors.

[0179] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the intelligent agent interaction method described above, but can also execute related operations in the intelligent agent interaction method provided in any embodiment of this application.

[0180] The intelligent agent interaction device, storage medium, and intelligent agent interaction system provided in the above embodiments can execute the intelligent agent interaction method provided in any embodiment of this application. For technical details not described in detail in the above embodiments, please refer to the intelligent agent interaction method provided in any embodiment of this application.

[0181] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application. The scope of this application is determined by the scope of the claims.

Claims

1. A method for intelligent agent interaction, characterized in that, include: Receive session information input from the client and determine the corresponding session role type based on the session information; Determine the corresponding character profile, character conversation memory, and character conversation content based on the conversation character type; The target prompt words are obtained by assembling the character profile, the character conversation memory, the character conversation content, and the conversation information in context. The target prompt is input into the agent to generate the response information corresponding to the conversation information.

2. The intelligent agent interaction method according to claim 1, characterized in that, Determining the corresponding session role type based on the session information includes: Obtain the prior role type corresponding to the previous session information input by the client, calculate the correlation between the session information and the prior role type, and obtain the prior role correlation. If the prior role association degree is greater than or equal to the first association degree threshold, the prior role type is determined as the session role type corresponding to the session information; If the prior role association degree is less than the first association threshold, the association degree between the session information and multiple candidate role types is calculated to obtain multiple candidate role association degrees; The session role type corresponding to the session information is determined based on the correlation between multiple candidate roles.

3. The intelligent agent interaction method according to claim 2, characterized in that, The calculation of the correlation between the session information and the prior role type to obtain the prior role correlation includes: Obtain the character profile, trigger keywords, and entity keywords corresponding to the aforementioned character type; Calculate the cosine similarity between the conversation information and the character portrait; Calculate the trigger word matching degree and entity word matching degree between the session information and the trigger keyword and entity keyword; The cosine similarity, the trigger word matching degree, and the entity word matching degree are weighted and fused to obtain the prior role association degree.

4. The intelligent agent interaction method according to claim 2, characterized in that, The step of determining the session role type corresponding to the session information based on the association degree of multiple candidate roles includes: From the multiple candidate role types, determine the target role type with the highest candidate role relevance and its corresponding target role relevance, as well as the second-highest candidate role type and its corresponding second-highest candidate role relevance; Calculate the difference between the relevance of the target role and the relevance of the secondary role to obtain the relevance difference; The session role type corresponding to the session information is determined based on the target role relevance and the relevance difference.

5. The intelligent agent interaction method according to claim 4, characterized in that, The step of determining the session role type corresponding to the session information based on the target role relevance and the relevance difference includes: If the target role relevance is greater than or equal to the second relevance threshold and the relevance difference is greater than or equal to the difference threshold, the target role type is determined as the session role type corresponding to the session information; If the target role correlation is greater than or equal to the third correlation threshold and less than the second correlation threshold, or if the target role correlation is greater than or equal to the second correlation threshold and the correlation difference is less than the difference threshold, the agent determines the session role type corresponding to the session information from multiple candidate role types. If the target role correlation is less than the third correlation threshold, a session role type corresponding to the session information is created.

6. The intelligent agent interaction method according to claim 1, characterized in that, The step of determining the character profile, character conversation memory, and character conversation content corresponding to the conversation information based on the conversation character type includes: Retrieve the character profile corresponding to the session character type from the character profile database; Retrieve the role conversation memory corresponding to the stated role type from the conversation memory bank; The role-related session content corresponding to the session information is determined based on the session information and the session role type.

7. The intelligent agent interaction method according to claim 6, characterized in that, The step of determining the role-based session content corresponding to the session information based on the session information and the session role type includes: Retrieve multiple candidate session segments corresponding to the session information from multiple historical session segments corresponding to the session role type; For each candidate session segment, calculate the session matching degree between the candidate session segment and the session information; Based on the session matching degree, the target session segment corresponding to the session information is determined, and the role session content corresponding to the session information is extracted from the target session segment.

8. The intelligent agent interaction method according to claim 1, characterized in that, The intelligent agent interaction method further includes: Obtain a first preset number of first session contents from the most recent session segments corresponding to the session role type, and calculate the first semantic similarity between the session information and the first session contents; If the first semantic similarity is greater than or equal to the first similarity threshold, the session information is associated with the most recent session segment.

9. The intelligent agent interaction method according to claim 8, characterized in that, The intelligent agent interaction method further includes: If the first semantic similarity is greater than or equal to the third similarity threshold and less than the first similarity threshold, then a second preset number of second conversation contents in the most recent conversation segment are obtained, wherein the second preset number is greater than the first preset number. Calculate the second semantic similarity between the session information and the second session content; If the second semantic similarity is greater than or equal to the second similarity threshold, the session information is associated with the most recent session segment; Wherein, the first similarity threshold is greater than the second similarity threshold, and the second similarity threshold is greater than the third similarity threshold.

10. The intelligent agent interaction method according to claim 9, characterized in that, The intelligent agent interaction method further includes: If the first semantic similarity is less than the third similarity threshold or the second semantic similarity is less than the second similarity threshold, entity keywords are extracted from the session information and the most recent session segment respectively to obtain a session entity set and a session segment entity set. The entity overlap rate is obtained by calculating the intersection-union ratio of the session entity set and the session segment entity set; Calculate the time decay factor based on the time difference between the input time of the session information and the input time of the last session content in the most recent session segment; The first semantic similarity, the entity overlap rate, and the time decay factor are weighted and fused to obtain the session continuity. If the session continuity is greater than or equal to the continuity threshold, the session information is associated with the most recent session segment.

11. An intelligent agent interaction device, characterized in that, include: The type determination module is configured to receive session information input by the client and determine the corresponding session role type based on the session information. The memory loading module is configured to determine the character profile, character conversation memory, and character conversation content corresponding to the conversation information based on the conversation role type. The context assembly module is configured to perform context assembly on the character profile, the character conversation memory, the character conversation content, and the conversation information to obtain target prompt words; The response generation module is configured to input the target prompt word into the agent to generate response information corresponding to the conversation information.

12. An intelligent agent interaction system, characterized in that, include: One or more processors; A memory that stores one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the agent interaction method as described in any one of claims 1-10.

13. A storage medium containing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the intelligent agent interaction method as described in any one of claims 1-10.