Skip to content
This repository was archived by the owner on Jul 3, 2025. It is now read-only.

Commit e192884

Browse files
authored
Merge pull request #45 from lmnr-ai/dev
extraction
2 parents cff5e68 + 50785eb commit e192884

File tree

11 files changed

+336
-219
lines changed

11 files changed

+336
-219
lines changed

README.md

Lines changed: 71 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
<a href="https://github.com/lmnr-ai/index">![GitHub stars](https://img.shields.io/github/stars/lmnr-ai/index?style=social)</a>
12
<a href="https://www.ycombinator.com/companies/laminar-ai">![Static Badge](https://img.shields.io/badge/Y%20Combinator-S24-orange)</a>
23
<a href="https://x.com/lmnrai">![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/lmnrai)</a>
34
<a href="https://discord.gg/nNFUUDAKub"> ![Static Badge](https://img.shields.io/badge/Join_Discord-464646?&logo=discord&logoColor=5865F2) </a>
45

6+
57
# Index
68

7-
Index is the SOTA open-source browser agent for autonomously executing complex tasks on the web.
9+
Index is a state-of-the-art open-source browser agent that autonomously executes complex web tasks. It turns any website into an accessible API and can be seamlessly integrated with just a few lines of code.
810

911
- [x] Powered by reasoning LLMs with vision capabilities.
1012
- [x] Gemini 2.5 Pro (really fast and accurate)
@@ -13,9 +15,10 @@ Index is the SOTA open-source browser agent for autonomously executing complex t
1315
- [x] Gemini 2.5 Flash (really fast, cheap, and good for less complex tasks)
1416
- [x] `pip install lmnr-index` and use it in your project
1517
- [x] `index run` to run the agent in the interactive CLI
16-
- [x] Index is also available as a [serverless API.](https://docs.lmnr.ai/laminar-index/introduction)
18+
- [x] Supports structured output via Pydantic schemas for reliable data extraction.
19+
- [x] Index is also available as a [serverless API.](https://docs.lmnr.ai/index-agent/api/getting-started)
1720
- [x] You can also try out Index via [Chat UI](https://lmnr.ai/chat).
18-
- [x] Supports advanced [browser agent observability](https://docs.lmnr.ai/laminar-index/observability) powered by open-source platform [Laminar](https://github.com/lmnr-ai/lmnr).
21+
- [x] Supports advanced [browser agent observability](https://docs.lmnr.ai/index-agent/tracing) powered by open-source platform [Laminar](https://github.com/lmnr-ai/lmnr).
1922

2023
prompt: go to ycombinator.com. summarize first 3 companies in the W25 batch and make new spreadsheet in google sheets.
2124

@@ -25,40 +28,11 @@ https://github.com/user-attachments/assets/2b46ee20-81b6-4188-92fb-4d97fe0b3d6a
2528

2629
Check out full documentation [here](https://docs.lmnr.ai/index-agent/getting-started)
2730

28-
## Index API
29-
30-
The easiest way to use Index in production is via the [serverless API](https://docs.lmnr.ai/laminar-index/introduction). Index API manages remote browser sessions, agent infrastructure and [browser observability](https://docs.lmnr.ai/laminar-index/tracing). To get started, [sign up](https://lmnr.ai/sign-in) and create project API key. Read the [docs](https://docs.lmnr.ai/laminar-index/introduction) to learn more.
31-
32-
### Install Laminar
33-
```bash
34-
pip install lmnr
35-
```
36-
37-
### Use Index via API
38-
```python
39-
from lmnr import Laminar, LaminarClient
40-
# you can also set LMNR_PROJECT_API_KEY environment variable
41-
42-
# Initialize tracing
43-
Laminar.initialize(project_api_key="your_api_key")
44-
45-
# Initialize the client
46-
client = LaminarClient(project_api_key="your_api_key")
47-
48-
for chunk in client.agent.run(
49-
stream=True,
50-
model_provider="gemini",
51-
model="gemini-2.5-pro-preview-03-25",
52-
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"
53-
):
54-
print(chunk)
55-
56-
```
57-
## Local Quick Start
31+
## Quickstart
5832

5933
### Install dependencies
6034
```bash
61-
pip install lmnr-index
35+
pip install lmnr-index 'lmnr[all]'
6236

6337
# Install playwright
6438
playwright install chromium
@@ -68,21 +42,57 @@ playwright install chromium
6842

6943
Setup your model API keys in `.env` file in your project root:
7044
```
71-
ANTHROPIC_API_KEY=
7245
GEMINI_API_KEY=
46+
ANTHROPIC_API_KEY=
7347
OPENAI_API_KEY=
48+
# Optional, to trace the agent's actions and record browser session
49+
LMNR_PROJECT_API_KEY=
7450
```
7551

52+
### Run Index with code
53+
```python
54+
import asyncio
55+
from index import Agent, GeminiProvider
56+
from pydantic import BaseModel
57+
from lmnr import Laminar
58+
import os
59+
60+
# to trace the agent's actions and record browser session
61+
Laminar.initialize()
7662

77-
### Run the agent with CLI
63+
# Define Pydantic schema for structured output
64+
class NewsSummary(BaseModel):
65+
title: str
66+
summary: str
7867

79-
You can run Index via interactive CLI. It features:
68+
async def main():
69+
70+
llm = GeminiProvider(model="gemini-2.5-pro-preview-05-06")
71+
agent = Agent(llm=llm)
72+
73+
# Example of getting structured output
74+
output = await agent.run(
75+
prompt="Navigate to news.ycombinator.com, find a post about AI, extract its title and provide a concise summary.",
76+
output_model=NewsSummary
77+
)
78+
79+
summary = NewsSummary.model_validate(output.result.content)
80+
print(f"Title: {summary.title}")
81+
print(f"Summary: {summary.summary}")
82+
83+
if __name__ == "__main__":
84+
asyncio.run(main())
85+
```
86+
87+
### Run Index with CLI
88+
89+
Index CLI features:
8090
- Browser state persistence between sessions
8191
- Follow-up messages with support for "give human control" action
8292
- Real-time streaming updates
8393
- Beautiful terminal UI using Textual
8494

85-
You can run the agent with the following command. Remember to set API key for the selected model in the `.env` file.
95+
You can run Index CLI with the following command.
8696
```bash
8797
index run
8898
```
@@ -115,176 +125,62 @@ Step 4: Scrolling back up to view pricing tiers
115125
Step 5: Provided concise summary of the three pricing tiers
116126
```
117127

118-
### Running with a personal Chrome instance
128+
### Running CLI with a personal Chrome instance
119129

120-
You can use Index with personal Chrome browser instance instead of launching a new browser. Main advantage is that all existing logged in sessions will be available.
130+
You can use Index with personal Chrome browser instance instead of launching a new browser. Main advantage is that all your existing logged-in sessions will be available.
121131

122132
```bash
123133
# Basic usage with default Chrome path
124134
index run --local-chrome
125-
126-
# With custom Chrome path and debugging port
127-
index run --local-chrome --chrome-path="/path/to/chrome" --port=9223
128135
```
129136

130-
This will launch Chrome with remote debugging enabled and connect Index to it.
131-
132-
#### OS-specific Chrome paths
137+
## Use Index via API
133138

134-
Default Chrome executable paths on different operating systems:
139+
The easiest way to use Index in production is with [serverless API](https://docs.lmnr.ai/index-agent/api/getting-started). Index API manages remote browser sessions, agent infrastructure and [browser observability](https://docs.lmnr.ai/index-agent/api/tracing). To get started, create a project API key in [Laminar](https://lmnr.ai).
135140

136-
**macOS**:
137-
```bash
138-
index run --local-chrome --chrome-path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
139-
```
140-
141-
**Windows**:
141+
### Install Laminar
142142
```bash
143-
index run --local-chrome --chrome-path="C:\Program Files\Google\Chrome\Application\chrome.exe"
143+
pip install lmnr
144144
```
145145

146-
#### Connecting to an already running Chrome instance
147-
148-
If you already have Chrome running with remote debugging enabled, you can connect to it:
149-
150-
1. Launch Chrome with debugging enabled:
151-
```bash
152-
# macOS
153-
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
154-
155-
# Windows
156-
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
157-
```
158-
159-
2. Then run Index with the same port:
160-
```bash
161-
index run --local-chrome --port=9222
162-
```
163-
164-
### Run the agent with code
146+
### Use Index via API
165147
```python
166-
import asyncio
167-
from index import Agent, AnthropicProvider
168-
169-
async def main():
170-
171-
llm = AnthropicProvider(
172-
model="claude-3-7-sonnet-20250219",
173-
enable_thinking=True,
174-
thinking_token_budget=2048)
175-
# llm = OpenAIProvider(model="o4-mini") you can also use OpenAI models
148+
from lmnr import Laminar, LaminarClient
149+
# you can also set LMNR_PROJECT_API_KEY environment variable
176150

177-
agent = Agent(llm=llm)
151+
# Initialize tracing
152+
Laminar.initialize(project_api_key="your_api_key")
178153

179-
output = await agent.run(
180-
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"
181-
)
182-
183-
print(output.result)
184-
185-
if __name__ == "__main__":
186-
asyncio.run(main())
187-
```
154+
# Initialize the client
155+
client = LaminarClient(project_api_key="your_api_key")
188156

189-
### Stream the agent's output
190-
```python
191-
async for chunk in agent.run_stream(
157+
for chunk in client.agent.run(
158+
stream=True,
159+
model_provider="gemini",
160+
model="gemini-2.5-pro-preview-05-06",
192161
prompt="Navigate to news.ycombinator.com, find a post about AI, and summarize it"
193162
):
194163
print(chunk)
195-
```
164+
165+
```
166+
196167

197-
### Enable browser agent observability
168+
## Browser agent observability
198169

199-
To trace Index agent's actions and record browser session you simply need to initialize Laminar tracing before running the agent.
170+
Both code run and API run provide advanced browser observability. To trace Index agent's actions and record browser session you simply need to initialize Laminar tracing before running the agent.
200171

201172
```python
202173
from lmnr import Laminar
203174

204175
Laminar.initialize(project_api_key="your_api_key")
205176
```
206177

207-
Then you will get full observability on the agent's actions synced with the browser session in the Laminar platform.
178+
Then you will get full observability on the agent's actions synced with the browser session in the Laminar platform. Learn more about browser agent observability in the [documentation](https://docs.lmnr.ai/index-agent/tracing).
208179

209180
<picture>
210181
<img src="./static/traces.png" alt="Index observability" width="800"/>
211182
</picture>
212183

213-
### Run with remote CDP url
214-
```python
215-
import asyncio
216-
from index import Agent, AnthropicProvider, BrowserConfig
217-
218-
async def main():
219-
# Configure browser to connect to an existing Chrome DevTools Protocol endpoint
220-
browser_config = BrowserConfig(
221-
cdp_url="<cdp_url>"
222-
)
223-
224-
llm = AnthropicProvider(model="claude-3-7-sonnet-20250219", enable_thinking=True, thinking_token_budget=2048)
225-
226-
agent = Agent(llm=llm, browser_config=browser_config)
227-
228-
output = await agent.run(
229-
prompt="Navigate to news.ycombinator.com and find the top story"
230-
)
231-
232-
print(output.result)
233-
234-
if __name__ == "__main__":
235-
asyncio.run(main())
236-
```
237-
238-
### Run with local Chrome instance (programmatically)
239-
```python
240-
import asyncio
241-
from index import Agent, AnthropicProvider, BrowserConfig
242-
243-
async def main():
244-
# Configure browser to connect to a local Chrome instance
245-
browser_config = BrowserConfig(
246-
cdp_url="http://localhost:9222"
247-
)
248-
249-
llm = AnthropicProvider(model="claude-3-7-sonnet-20250219", enable_thinking=True, thinking_token_budget=2048)
250-
251-
agent = Agent(llm=llm, browser_config=browser_config)
252-
253-
output = await agent.run(
254-
prompt="Navigate to news.ycombinator.com and find the top story"
255-
)
256-
257-
print(output.result)
258-
259-
if __name__ == "__main__":
260-
asyncio.run(main())
261-
```
262-
263-
### Customize browser window size
264-
```python
265-
import asyncio
266-
from index import Agent, AnthropicProvider, BrowserConfig
267-
268-
async def main():
269-
# Configure browser with custom viewport size
270-
browser_config = BrowserConfig(
271-
viewport_size={"width": 1200, "height": 900}
272-
)
273-
274-
llm = AnthropicProvider(model="claude-3-7-sonnet-20250219")
275-
276-
agent = Agent(llm=llm, browser_config=browser_config)
277-
278-
output = await agent.run(
279-
"Navigate to a responsive website and capture how it looks in full HD resolution"
280-
)
281-
282-
print(output.result)
283-
284-
if __name__ == "__main__":
285-
asyncio.run(main())
286-
```
287-
288184
---
289185

290186
Made with ❤️ by the [Laminar team](https://lmnr.ai)

0 commit comments

Comments
 (0)