本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
配置内置策略
AgentCore 内存为常见用例提供预先配置的内置内存策略。
用户偏好
用户偏好 (UserPreferenceMemoryStrategy) 策略旨在自动识别和提取对话中的用户偏好、选择和风格。这使您的代理可以为每个用户建立持久的个人资料,从而实现更加个性化和相关的互动。
-
示例用例:电子商务代理会记住用户最喜欢的品牌和首选尺寸,让其在以后的会议中提供量身定制的产品推荐。
配置示例:
import boto3 # Initialize the Boto3 client for control plane operations control_client = boto3.client('bedrock-agentcore-control', region_name='us-west-2') # Create memory resource with user preference strategy response = control_client.create_memory( name="ECommerceAgentMemory", memoryStrategies=[ { 'userPreferenceMemoryStrategy': { 'name': 'UserPreferenceExtractor', 'namespaceTemplates': ['/users/{actorId}/preferences/'] } } ] )
语义
Semantic (SemanticMemoryStrategy) 记忆策略旨在从对话数据中识别和提取关键的事实信息和情境知识。这使您的代理可以针对互动期间讨论的重要实体、事件和详细信息建立持久的知识库。
-
示例用例:客户支持代理记得订单号ABC-123 与特定的支持票证相关,因此用户在跟进时不必再次提供订单号。
配置示例:
import boto3 # Initialize the Boto3 client for control plane operations control_client = boto3.client('bedrock-agentcore-control', region_name='us-west-2') # Create memory resource with semantic strategy response = control_client.create_memory( name="SupportAgentFactMemory", memoryStrategies=[ { 'semanticMemoryStrategy': { 'name': 'FactExtractor', 'namespaceTemplates': ['/support_cases/{sessionId}/facts/'] } } ] )
会话摘要
s ession s ummaries (SummaryMemoryStrategy) 内存策略可以创建对话的简短摘要,就像对话发生在单个会话中一样。它捕捉了关键主题和决策,使代理可以快速回忆起长时间对话的背景,而无需重新处理整个历史记录。
-
示例用例:在 30 分钟的故障排除会话后,代理可以访问摘要,例如 “用户报告了软件 v2.1 的问题,尝试了重新启动,并获得了知识库文章的链接。”
配置示例:
import boto3 # Initialize the Boto3 client for control plane operations control_client = boto3.client('bedrock-agentcore-control', region_name='us-west-2') # Create memory resource with summary strategy response = control_client.create_memory( name="TroubleshootingAgentSummaryMemory", memoryStrategies=[ { 'summaryMemoryStrategy': { 'name': 'SessionSummarizer', 'namespaceTemplates': ['/summaries/{actorId}/{sessionId}/'] } } ] )
剧集
ep isodic (EpisodicStrategy) 记忆策略将互动捕捉为结构化情节,包括场景、意图、想法、采取的行动、结果和工件。通过这种策略,还可以在各个情节中进行反思,以获得更广泛的见解,从而使代理人学习和应用先前互动中的成功模式,并将其应用于新的互动。
-
示例用例:客户支持代理将互动记录为情节。该系统捕获哪些短语和动作会导致成功的互动
配置示例:
import boto3 # Initialize the Boto3 client for control plane operations control_client = boto3.client('bedrock-agentcore-control', region_name='us-west-2') # Create memory resource with episodic strategy response = control_client.create_memory( name="MyMemory", memoryStrategies=[ { 'episodicMemoryStrategy': { 'name': 'EpisodicStrategy', 'namespaceTemplates': ['/strategy/{memoryStrategyId}/actors/{actorId}/sessions/{sessionId}/'], 'reflection': { 'namespaceTemplates': ['strategy/{memoryStrategyId}/actors/{actorId}/'] } } } ] )