View a markdown version of this page

配置内置策略 - Amazon Bedrock AgentCore

配置内置策略

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/'] } } ] )

语义的

S emantic (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/'] } } ] )

会话摘要

话摘要 (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}/'] } } ] )

情节性的

节 (EpisodicStrategy) 记忆策略将互动捕获为结构化的情节,包括场景、意图、想法、采取的行动、结果和工件。通过这种策略,还可以在剧集中进行reflections,以提取更广泛的见解,让代理人从以前的互动中学习成功的模式并将其应用于新的互动。

  • 用例示例:客户支持代理将互动记录为剧集。该系统会捕获哪些短语和动作可以成功进行互动

配置示例:

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}/'] } } } ] )