Skip to content

Commit d6d4c93

Browse files
committed
refactor(notte): simplify integration guide with minimal code
1 parent e40de50 commit d6d4c93

File tree

1 file changed

+14
-37
lines changed

1 file changed

+14
-37
lines changed

integrations/notte.mdx

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,12 @@ Import the libraries and create a cloud browser session:
2121
```python
2222
from kernel import Kernel
2323
from notte_sdk import NotteClient
24-
import os
25-
from dotenv import load_dotenv
26-
27-
# Load environment variables from .env file
28-
load_dotenv()
2924

3025
# Initialize clients
31-
kernel_api_key = os.getenv("KERNEL_API_KEY")
32-
notte_api_key = os.getenv("NOTTE_API_KEY")
33-
34-
if not kernel_api_key:
35-
raise ValueError("KERNEL_API_KEY not found in environment variables")
36-
if not notte_api_key:
37-
raise ValueError("NOTTE_API_KEY not found in environment variables")
38-
39-
kernel_client = Kernel(api_key=kernel_api_key)
40-
notte_client = NotteClient(api_key=notte_api_key)
26+
kernel_client = Kernel(api_key="your-kernel-api-key")
27+
notte_client = NotteClient(api_key="your-notte-api-key")
4128

42-
# Create a headful browser on Kernel
43-
print("Creating browser session on Kernel...")
29+
# Create a browser on Kernel
4430
kernel_browser = kernel_client.browsers.create(headless=False)
4531
```
4632

@@ -49,33 +35,24 @@ kernel_browser = kernel_client.browsers.create(headless=False)
4935
Use Kernel's CDP WebSocket URL to create a Notte session:
5036

5137
```python
52-
try:
53-
# Connect Notte to Kernel's browser via CDP
54-
print("Connecting Notte to Kernel browser...")
55-
with notte_client.Session(cdp_url=kernel_browser.cdp_ws_url) as session:
56-
# Create an agent with a task
57-
agent = notte_client.Agent(session=session, max_steps=10)
58-
59-
# Run your automation task
60-
result = agent.run(
61-
task="extract pricing plans from https://www.notte.cc"
62-
)
63-
64-
print(f"Task completed: {result.answer}")
65-
66-
except Exception as e:
67-
print(f"Error during automation: {e}")
38+
# Connect Notte to Kernel's browser via CDP
39+
with notte_client.Session(cdp_url=kernel_browser.cdp_ws_url) as session:
40+
# Create an agent with a task
41+
agent = notte_client.Agent(session=session, max_steps=10)
42+
43+
# Run your automation task
44+
result = agent.run(
45+
task="extract pricing plans from https://www.notte.cc"
46+
)
6847
```
6948

7049
### 4. Clean up the browser session
7150

7251
After your automation completes, tear down the Kernel browser:
7352

7453
```python
75-
finally:
76-
# Always clean up the browser session
77-
kernel_client.browsers.delete_by_id(kernel_browser.session_id)
78-
print("Browser session cleaned up")
54+
# Clean up the browser session
55+
kernel_client.browsers.delete_by_id(kernel_browser.session_id)
7956
```
8057

8158
## Complete example script

0 commit comments

Comments
 (0)