Skip to content

Commit bbd599e

Browse files
juecdrgarcia
andauthored
Python Computer Use Sample App Implementation (#12)
* Use kernel browser --------- Co-authored-by: Rafael Garcia <[email protected]>
1 parent ddd7d5d commit bbd599e

File tree

22 files changed

+3066
-1432
lines changed

22 files changed

+3066
-1432
lines changed

index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ const TEMPLATES: Record<TemplateKey, TemplateInfo> = {
6666
name: "Persistent Browser",
6767
description:
6868
"Implements a persistent browser that maintains state across invocations",
69-
languages: [LANGUAGE_TYPESCRIPT],
69+
languages: [LANGUAGE_TYPESCRIPT, LANGUAGE_PYTHON],
7070
},
7171
[TEMPLATE_COMPUTER_USE]: {
7272
name: "Computer Use",
7373
description: "Implements the Anthropic Computer Use SDK",
74-
languages: [LANGUAGE_TYPESCRIPT],
74+
languages: [LANGUAGE_TYPESCRIPT, LANGUAGE_PYTHON],
7575
},
7676
};
7777

@@ -96,6 +96,8 @@ const INVOKE_SAMPLES: Record<
9696
'kernel invoke python-bu bu-task --payload \'{"task": "Compare the price of gpt-4o and DeepSeek-V3"}\'',
9797
[TEMPLATE_PERSISTENT_BROWSER]:
9898
'kernel invoke python-persistent-browser persistent-browser-task --payload \'{"url": "https://news.ycombinator.com/"}\'',
99+
[TEMPLATE_COMPUTER_USE]:
100+
'kernel invoke python-cu cu-task --payload \'{"query": "Return the first url of a search result for NYC restaurant reviews Pete Wells"}\'',
99101
},
100102
};
101103

@@ -318,6 +320,8 @@ function printNextSteps(
318320
? "kernel deploy main.py"
319321
: language === LANGUAGE_PYTHON && template === TEMPLATE_BROWSER_USE
320322
? "kernel deploy main.py --env OPENAI_API_KEY=XXX"
323+
: language === LANGUAGE_PYTHON && template === TEMPLATE_COMPUTER_USE
324+
? "kernel deploy main.py --env ANTHROPIC_API_KEY=XXX"
321325
: "";
322326

323327
console.log(

templates/python/browser-use/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ async def bu_task(ctx: kernel.KernelContext, input_data: TaskInput):
3030

3131
kernel_browser = client.browsers.create(invocation_id=ctx.invocation_id, stealth=True)
3232
print("Kernel browser live view url: ", kernel_browser.browser_live_view_url)
33+
#######################################
34+
# Your Browser Use implementation here
35+
#######################################
3336
agent = Agent(
3437
#task="Compare the price of gpt-4o and DeepSeek-V3",
3538
task=input_data["task"],

templates/python/browser-use/uv.lock

Lines changed: 1427 additions & 1427 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Python
2+
**/__pycache__/
3+
**/*.py[cod]
4+
**/*$py.class
5+
*.so
6+
__init__.py.bak
7+
.Python
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
.eggs/
14+
lib/
15+
lib64/
16+
parts/
17+
sdist/
18+
var/
19+
wheels/
20+
**/*.egg-info/
21+
.installed.cfg
22+
*.egg
23+
24+
# Virtual Environment
25+
venv/
26+
env/
27+
ENV/
28+
.venv/
29+
30+
# IDE
31+
.idea/
32+
.vscode/
33+
*.swp
34+
*.swo
35+
36+
# Testing
37+
.coverage
38+
htmlcov/
39+
.pytest_cache/
40+
.tox/
41+
42+
# Distribution
43+
*.tar.gz
44+
*.zip
45+
46+
# Logs
47+
*.log
48+
49+
# Local development
50+
.env
51+
.env.local
52+
.env.*.local
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Kernel Python Sample App - Computer Use
2+
3+
This is a simple Kernel application that implements a prompt loop using Anthropic Computer Use.
4+
5+
It generally follows the [Anthropic Reference Implementation](https://github.com/anthropics/anthropic-quickstarts/tree/main/computer-use-demo) but replaces `xodotool` and `gnome-screenshot` with Playwright.
6+
7+
See the [docs](https://docs.onkernel.com/quickstart) for information.

0 commit comments

Comments
 (0)