大家好,我是每天给推荐优秀开源项目的小G,今天推荐的是一款强大的开源自动化浏览器智能体。
在做浏览器自动化脚本时,我们常常需要编写大量代码来处理复杂的网页交互,不仅耗时耗力,还难以调试和优化,要是出错更是难以精准定位问题所在。
项目简介
Index 是一款先进的开源浏览器代理,能够自主地在网络上执行复杂任务。
-
它由 Claude 3.7 Sonnet 驱动,具有扩展性思维。未来将支持更多模型。
-
Index 还提供托管 API 服务。
-
您还可以尝试通过托管 UI 或完全自托管 UI 来使用 Index。
-
支持由 Laminar 提供的先进浏览器代理可观察性。
Index API
Index API 可在 Laminar 平台上作为托管 API 使用。Index API 管理远程浏览器会话和代理基础设施。Index API 是运行 AI 浏览器自动化的最佳方式。要开始使用,请注册并创建项目 API 密钥。
安装 Laminar
pip install lmnr
通过 API 使用Infrc
Initialize the clientclient = AsyncLaminarClient(api_key="your_api_key")
通过 API 使用Index
from lmnr import Laminar, AsyncLaminarClient
# you can also set LMNR_PROJECT_API_KEY environment variable
# Initialize tracing
Laminar.initialize(project_api_key="your_api_key")
# Initialize the client
client = AsyncLaminarClient(api_key="your_api_key")
async def main():
# Run a task
response = await client.agent.run(
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"
)
# Print the result
print(response.result)
if __name__ == "__main__":
asyncio.run(main())
当您通过 API 调用 Index 时,您将自动在 Laminar 平台上获得完整的浏览器代理可观察性。了解更多关于 Index 浏览器可观察性的信息。
本地快速入门
安装依赖
pip install lmnr-index
Install playwright
playwright install chromium
运行代理
import asynciofrom index import Agent, AnthropicProviderasync def main():
# Initialize the LLM providerllm = AnthropicProvider(
model="claude-3-7-sonnet-20250219",
enable_thinking=True,
thinking_token_budget=2048)
# Create an agent with the LLMagent = Agent(llm=llm)
# Run the agent with a taskoutput = await agent.run(
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"
)
# Print the resultprint(output.result)
if name == "__main__":
asyncio.run(main())
直播代理的输出
from index import Agent, AnthropicProvideragent = Agent(llm=AnthropicProvider(model="claude-3-7-sonnet-20250219"))
Stream the agent's outputasync for chunk in agent.run_stream(
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"):
print(chunk)
启用浏览器代理可观察性
要追踪索引代理的动作并记录浏览器会话,您只需在运行代理之前初始化 Laminar 跟踪即可。
from lmnr import Laminar
Laminar.initialize(project_api_key="your_api_key")
然后,您将在 Laminar 平台上获得对代理动作的完整可观察性,并与浏览器会话同步。
运行远程 CDP URL
import asynciofrom index import Agent, AnthropicProvider, BrowserConfigasync def main():
# Configure browser to connect to an existing Chrome DevTools Protocol endpointbrowser_config = BrowserConfig(
cdp_url="<cdp_url>"
)
# Initialize the LLM providerllm = AnthropicProvider(model="claude-3-7-sonnet-20250219", enable_thinking=True, thinking_token_budget=2048)
# Create an agent with the LLM and browseragent = Agent(llm=llm, browser_config=browser_config)
# Run the agent with a taskoutput = await agent.run(
prompt="Navigate to news.ycombinator.com and find the top story"
)
# Print the resultprint(output.result)
if name == "__main__":
asyncio.run(main())
自定义浏览器窗口大小
import asynciofrom index import Agent, AnthropicProvider, BrowserConfigasync def main():
# Configure browser with custom viewport sizebrowser_config = BrowserConfig(
viewport_size={"width": 1200, "height": 900}
)
# Initialize the LLM providerllm = AnthropicProvider(model="claude-3-7-sonnet-20250219")
# Create an agent with the LLM and browseragent = Agent(llm=llm, browser_config=browser_config)
# Run the agent with a taskoutput = await agent.run(
"Navigate to a responsive website and capture how it looks in full HD resolution"
)
# Print the resultprint(output.result)
if name == "__main__":
asyncio.run(main())
项目链接
https://github.com/lmnr-ai/index
扫码加入技术交流群,备注「开发语言-城市-昵称」
(文:GitHubStore)