接口封装
接口封装

Strands是AWS开源的Python SDK,用于构建和运行AI智能体。
Strands让开发团队无需从零搭建智能体框架,通过统一SDK快速实现AI自动化能力。支持本地到云端多种模型部署,内置丰富工具链降低开发门槛,多智能体协作模式可拆解复杂业务流程,帮助企业在客服、运维、数据分析等场景快速落地AI应用。
落地案例:某电商技术团队需构建自动处理退货申请的系统。使用Strands开发主智能体解析用户意图,协调库存查询、退款计算、邮件通知三个子智能体并行工作;通过装饰器封装内部ERP接口为自定义工具,2周内完成上线。运维阶段切换至本地Ollama模型降低成本,高峰期临时启用Bedrock弹性扩容。
安装SDK(推荐隔离安装):
pipx install strands-agents-builder
或直接安装:
pip install strands-agents strands-agents-tools
本地Ollama运行示例:
from strands import Agent
from strands.models.ollama import OllamaModel
model = OllamaModel("http://localhost:11434", model_id="qwen3:latest")
agent = Agent(model=model)
result = agent("What is the capital of France?")
AWS Bedrock默认运行(无需指定模型):
from strands import Agent
agent = Agent() # 默认使用us-west-2的Claude Sonnet 4
result = agent("Explain quantum computing")
自定义工具开发:
from strands import Agent, tool
@tool
def read_file(path: str) -> str:
"""Read contents of a file."""
with open(path) as f:
return f.read()
agent = Agent(model=model, tools=[read_file])
见下方输入与输出表格。
| 项目 | 内容 |
|---|---|
| 输入 | 自然语言指令;可选模型配置(Ollama/Bedrock/Anthropic/OpenAI);自定义工具函数;MCP服务器连接信息 |
| 输出 | 智能体响应文本;工具执行结果;状态更新数据 |
| 适用人群 | Python开发者、自动化工程师、多智能体系统研究者、需要本地部署的企业用户 |
| 不包含 | 图形化开发界面、模型训练能力、商业托管服务、JavaScript/Go等其他语言SDK |
原始链接:https://github.com/openclaw/skills/tree/main/skills/trippingkelsea/strands/SKILL.md
来源类型:GitHub仓库