轻量级开源框架专用于 AI Agent 开发,提供任务编排和工作流能力,直接降低 Agent 应用开发成本。
Index 是一个最先进的开源浏览器 agent,能够自主执行复杂的网页任务。它将任何网站转变为可访问的 API,可以仅用几行代码无缝集成。
由具有视觉能力的推理 LLM 驱动。Gemini 2.5 Pro(速度快且准确度高)Claude 3.7 Sonnet with extended thinking(可靠准确)OpenAI o4-mini(根据推理努力程度,在速度、成本和准确度之间提供良好平衡)Gemini 2.5 Flash(速度快、成本低,适合较简单的任务)
通过 pip install lmnr-index 在你的项目中使用它
运行 index run 在交互式 CLI 中运行 agent
示例提示词:访问 ycombinator.com。总结 W25 batch 中前 3 家公司,并在 Google Sheets 中创建新的电子表格。
查看完整文档。
pip install lmnr-index 'lmnr[all]'
# Install playwright
playwright install chromium
在项目根目录的 .env 文件中设置你的模型 API 密钥:
GEMINI_API_KEY=
ANTHROPIC_API_KEY=
OPENAI_API_KEY=
# Optional, to trace the agent's actions and record browser session
LMNR_PROJECT_API_KEY=
import asyncio
from index import Agent, GeminiProvider
from pydantic import BaseModel
from lmnr import Laminar
import os
# to trace the agent's actions and record browser session
Laminar.initialize()
# Define Pydantic schema for structured output
class NewsSummary(BaseModel):
title: str
summary: str
async def main():
llm = GeminiProvider(model="gemini-2.5-pro-preview-05-06")
agent = Agent(llm=llm)
# Example of getting structured output
output = await agent.run(
prompt="Navigate to news.ycombinator.com, find a post about AI, extract its title and provide a concise summary.",
output_model=NewsSummary
)
summary = NewsSummary.model_validate(output.result.content)
print(f"Title: {summary.title}")
print(f"Summary: {summary.summary}")
if __name__ == "__main__":
asyncio.run(main())
你可以通过以下命令运行 Index CLI。
index run
输出看起来像这样:
Loaded existing browser state
╭───────────────────── Interactive Mode ─────────────────────╮
│ Index Browser Agent Interactive Mode │
│ Type your message and press Enter. The agent will respond. │
│ Press Ctrl+C to exit. │
╰────────────────────────────────────────────────────────────╯
Choose an LLM model:
1. Gemini 2.5 Flash
2. Claude 3.7 Sonnet
3. OpenAI o4-mini
Select model [1/2] (1): 3
Using OpenAI model: o4-mini
Loaded existing browser state
Your message: go to lmnr.ai, summarize pricing page
Agent is working...
Step 1: Opening lmnr.ai
Step 2: Opening Pricing page
Step 3: Scrolling for more pricing details
Step 4: Scrolling back up to view pricing tiers
Step 5: Provided concise summary of the three pricing tiers
你可以用个人 Chrome 浏览器实例运行 Index,而不是启动新浏览器。主要优势是所有已登录的会话都会可用。
# Basic usage with default Chrome path
index run --local-chrome
在生产环境中使用 Index 最简单的方式是通过无服务器 API。Index API 管理远程浏览器会话、agent 基础设施和浏览器可观测性。开始前,在 Laminar 中创建一个项目 API 密钥。
pip install lmnr
from lmnr import Laminar, LaminarClient
# you can also set LMNR_PROJECT_API_KEY environment variable
# Initialize tracing
Laminar.initialize(project_api_key="your_api_key")
# Initialize the client
client = LaminarClient(project_api_key="your_api_key")
for chunk in client.agent.run(
stream=True,
model_provider="gemini",
model="gemini-2.5-pro-preview-05-06",
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"
):
print(chunk)
代码运行和 API 运行都提供高级浏览器可观测性。要追踪 Index agent 的操作并记录浏览器会话,你只需在运行 agent 前初始化 Laminar 追踪。
from lmnr import Laminar
Laminar.initialize(project_api_key="your_api_key")
然后你将在 Laminar 平台上获得完整的 agent 操作可观测性,与浏览器会话同步。在文档中了解更多关于浏览器 agent 可观测性的信息。
由 Laminar 团队用 ❤️ 制作