? 2. Index 的核心亮点
? 3. 实战演示:一句话搞定复杂任务
想象一下,你只需要给 Index 一句话,比如:
"去 ycombinator.com,总结 W25 批次的前 3 家公司信息,并在 Google Sheets 里创建一个新的电子表格来记录。"
Index 就能自动打开浏览器,访问网站,找到信息,理解内容,然后打开 Google Sheets 并创建表格填入数据!
?️ 4. 快速上手指南
lmnr库:pipinstalllmnr
importasyncio
fromlmnrimportLaminar, AsyncLaminarClient
# 推荐设置环境变量 LMNR_PROJECT_API_KEY
# 或直接在代码中提供
Laminar.initialize(project_api_key="your_api_key")
client = AsyncLaminarClient(api_key="your_api_key")
asyncdefmain():
response =awaitclient.agent.run(
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"
)
print(response.result)
if__name__ =="__main__":
asyncio.run(main())当你使用API时,Laminar平台会自动提供强大的可观测性功能。pip install lmnr-index
# 安装 Playwright 浏览器驱动
playwright install chromiumimportasyncio
fromindeximportAgent, AnthropicProvider
# 设置你的 Anthropic API Key (推荐使用环境变量)
# export ANTHROPIC_API_KEY='your_key_here'
asyncdefmain():
# 初始化 LLM (使用 Claude 3.7 Sonnet)
llm = AnthropicProvider(
model="claude-3-7-sonnet-20250219",
enable_thinking=True,# 开启扩展思考
thinking_token_budget=2048# 思考预算
)
agent = Agent(llm=llm)# 创建 Agent
output =awaitagent.run(
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"
)
print(output.result)
if__name__ =="__main__":
asyncio.run(main())# ... (llm 初始化同上)
agent = Agent(llm=AnthropicProvider(model="claude-3-7-sonnet-20250219"))
asyncforchunkinagent.run_stream(
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"):
print(chunk)# 实时打印 Agent 的思考和动作fromlmnrimportLaminar
Laminar.initialize(project_api_key="your_api_key")
# ... 后续代码同上 ...这样你的本地运行过程也能在 Laminar 平台看到详细追踪记录了![此处可插入 Laminar 平台观测界面的截图]⚙️ 5. 更多高级玩法 (代码示例见GitHub)
? 6. 开源项目地址
? 7. 应用场景
Index 的能力可以应用在各种需要与网页交互的场景:
自动化网页操作方面的巨大潜力。它强大、开源、灵活,并且提供了优秀的可观测性支持,无论是用于实际工作提效,还是作为学习AI Agent的前沿项目,都非常有价值!
| 欢迎光临 链载Ai (https://www.lianzai.com/) | Powered by Discuz! X3.5 |