index: 自动化浏览器智能体

GitHubhttps://github.com/lmnr-ai/index

更多AI开源软件https://www.aiinn.cn/

在做浏览器自动化脚本时,我们常常需要编写大量代码来处理复杂的网页交互,不仅耗时耗力,还难以调试和优化,要是出错更是难以精准定位问题所在。

主要功能

Index 是一款先进的开源浏览器代理,能够自主地在网络上执行复杂任务。

  • 它由 Claude 3.7 Sonnet 驱动,具有扩展性思维。未来将支持更多模型。
  • Index 还提供托管 API 服务。
  • 您还可以尝试通过托管 UI 或完全自托管 UI 来使用 Index。
  • 支持由 Laminar 提供的先进浏览器代理可观察性。

安装和使用

安装 Laminar
复制代码
pip install lmnr
通过 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 asyncio
from index import Agent, AnthropicProvider

async def main():
    # Initialize the LLM provider
    llm = AnthropicProvider(
            model="claude-3-7-sonnet-20250219",
            enable_thinking=True, 
            thinking_token_budget=2048)
  
    # Create an agent with the LLM
    agent = Agent(llm=llm)
  
    # Run the agent with a task
    output = await agent.run(
        prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"
    )
  
    # Print the result
    print(output.result)
  
if __name__ == "__main__":
    asyncio.run(main())

实战演习

场景1:流式传输代理的输出
复制代码
from index import Agent, AnthropicProvider

agent = Agent(llm=AnthropicProvider(model="claude-3-7-sonnet-20250219"))  

# Stream the agent's output
async for chunk in agent.run_stream(
    prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"):
    print(chunk)
场景2:启用浏览器代理可观测性

要跟踪 Index 代理的作并记录浏览器会话,您只需在运行代理之前初始化 Laminar 跟踪。

复制代码
from lmnr import Laminar

Laminar.initialize(project_api_key="your_api_key")

然后,您将获得与 Laminar 平台中的浏览器会话同步的代理作的完全可观察性。

​​

场景3:使用远程 CDP URL 运行
复制代码
import asyncio
from index import Agent, AnthropicProvider, BrowserConfig

async def main():
    # Configure browser to connect to an existing Chrome DevTools Protocol endpoint
    browser_config = BrowserConfig(
        cdp_url="<cdp_url>"
    )
  
    # Initialize the LLM provider
    llm = AnthropicProvider(model="claude-3-7-sonnet-20250219", enable_thinking=True, thinking_token_budget=2048)
  
    # Create an agent with the LLM and browser
    agent = Agent(llm=llm, browser_config=browser_config)
  
    # Run the agent with a task
    output = await agent.run(
        prompt="Navigate to news.ycombinator.com and find the top story"
    )
  
    # Print the result
    print(output.result)
  
if __name__ == "__main__":
    asyncio.run(main())
场景4:自定义浏览器窗口大小
复制代码
import asyncio
from index import Agent, AnthropicProvider, BrowserConfig

async def main():
    # Configure browser with custom viewport size
    browser_config = BrowserConfig(
        viewport_size={"width": 1200, "height": 900}
    )
  
    # Initialize the LLM provider
    llm = AnthropicProvider(model="claude-3-7-sonnet-20250219")
  
    # Create an agent with the LLM and browser
    agent = Agent(llm=llm, browser_config=browser_config)
  
    # Run the agent with a task
    output = await agent.run(
        "Navigate to a responsive website and capture how it looks in full HD resolution"
    )
  
    # Print the result
    print(output.result)
  
if __name__ == "__main__":
    asyncio.run(main())
相关推荐
struggle20259 分钟前
ebook2audiobook开源程序使用动态 AI 模型和语音克隆将电子书转换为带有章节和元数据的有声读物。支持 1,107+ 种语言
人工智能·开源·自动化
深空数字孪生12 分钟前
AI+可视化:数据呈现的未来形态
人工智能·信息可视化
标贝科技26 分钟前
标贝科技:大模型领域数据标注的重要性与标注类型分享
数据库·人工智能
aminghhhh34 分钟前
多模态融合【十九】——MRFS: Mutually Reinforcing Image Fusion and Segmentation
人工智能·深度学习·学习·计算机视觉·多模态
格林威37 分钟前
Baumer工业相机堡盟工业相机的工业视觉是否可以在室外可以做视觉检测项目
c++·人工智能·数码相机·计算机视觉·视觉检测
陈苏同学1 小时前
MPC控制器从入门到进阶(小车动态避障变道仿真 - Python)
人工智能·python·机器学习·数学建模·机器人·自动驾驶
努力毕业的小土博^_^1 小时前
【深度学习|学习笔记】 Generalized additive model广义可加模型(GAM)详解,附代码
人工智能·笔记·深度学习·神经网络·学习
漫谈网络2 小时前
Telnet 类图解析
python·自动化·netdevops·telnetlib·网络自动化运维
小小鱼儿小小林2 小时前
用AI制作黑神话悟空质感教程,3D西游记裸眼效果,西游人物跳出书本
人工智能·3d·ai画图
浪淘沙jkp2 小时前
AI大模型学习二十、利用Dify+deepseekR1 使用知识库搭建初中英语学习智能客服机器人
人工智能·llm·embedding·agent·知识库·dify·deepseek