License to Bill🍸💸:MCP Agents 和 Bedrock Budget Protocol

发布: (2026年1月18日 GMT+8 18:05)
2 min read
原文: Dev.to

Source: Dev.to

前置条件

  • ✅ 一个已激活的 AWS 账户
  • 🧠 对基础模型(FMs)和 Amazon Bedrock 的基本了解
  • 💻 已安装并配置凭证的 AWS 命令行界面(CLI)
  • 🐍 Python 3.11 或更高版本
  • 🛠️ 已安装 AWS 云开发工具包(CDK)CLI
  • 🤖 已在 Amazon Bedrock 中启用对 Anthropic 的 Claude 3.5 Sonnet v2 的模型访问权限
  • 🔐 将 AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY 设置为环境变量,以进行服务器身份验证

示例:InlineAgent Hello World

from bedrock_agents.agent import InlineAgent

InlineAgent(
    foundationModel="us.anthropic.claude-3-5-haiku-20241022-v1:0",
    instruction="You are a friendly assistant that is supposed to say hello to everything.",
    userInput=True,
    agentName="hello-world-agent",
).invoke("Hi how are you? What can you do for me?")

示例输出

SessionId: 99c0924d-d5ae-4080-9f59-8b8dc501977e
2025-04-04 17:34:11,438 - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials
Input Tokens: 600 Output Tokens: 137
Thought: The user has greeted me and asked about my capabilities. I'll respond in a friendly manner and use the user interaction tool to engage with them.
Hello there! I'm doing great, thank you for asking. I'm a friendly assistant who loves to say hello to everything! What would you like help with today? I'm ready to assist you with any questions or tasks you might have.
Agent made a total of 1 LLM calls, using 737 tokens (in: 600, out: 137), and took 4.7 total seconds
Back to Blog

相关文章

阅读更多 »

了解网络设备:初学者指南

基本网络流程 Internet → Modem → Router → Switch → 您的设备 Modem - 它的作用:将来自 ISP 的信号转换为您的设备可以使用的数据。 - Ana...