-
Notifications
You must be signed in to change notification settings - Fork 5
Replace Playwright with Kernel native API in OpenAI CUA templates #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rgarcia
wants to merge
1
commit into
main
Choose a base branch
from
rgarcia/cua-native-kernel-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| # Copy this file to .env and fill in your API key | ||
| # Copy this file to .env and fill in your API keys | ||
| OPENAI_API_KEY=your_openai_api_key_here | ||
| KERNEL_API_KEY=your_kernel_api_key_here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,24 @@ | ||
| # Kernel Python Sample App - OpenAI Computer Use | ||
|
|
||
| This is a Kernel application that demonstrates using the Computer Use Agent (CUA) from OpenAI. | ||
| This is a Kernel application that demonstrates using the Computer Use Agent (CUA) from OpenAI with Kernel's native browser control API. | ||
|
|
||
| It generally follows the [OpenAI CUA Sample App Reference](https://github.com/openai/openai-cua-sample-app) and uses Playwright via Kernel for browser automation. | ||
| It uses Kernel's computer control endpoints (screenshot, click, type, scroll, batch, etc.) instead of Playwright, and includes a `batch_computer_actions` tool that executes multiple actions in a single API call for lower latency. | ||
|
|
||
| See the [docs](https://www.kernel.sh/docs/quickstart) for more information. | ||
| ## Local testing | ||
|
|
||
| You can test against a remote Kernel browser without deploying: | ||
|
|
||
| ```bash | ||
| cp .env.example .env | ||
| # Fill in OPENAI_API_KEY and KERNEL_API_KEY in .env | ||
| uv run test_local.py | ||
| ``` | ||
|
|
||
| ## Deploy to Kernel | ||
|
|
||
| ```bash | ||
| kernel deploy main.py --env-file .env | ||
| kernel invoke python-openai-cua cua-task -p '{"task":"go to https://news.ycombinator.com and list top 5 articles"}' | ||
| ``` | ||
|
|
||
| See the [docs](https://www.kernel.sh/docs/quickstart) for more information. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 2 additions & 6 deletions
8
pkg/templates/python/openai-computer-use/computers/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,7 @@ | ||
| from . import default | ||
| from . import contrib | ||
| from .kernel_computer import KernelComputer | ||
| from .computer import Computer | ||
| from .config import computers_config | ||
|
|
||
| __all__ = [ | ||
| "default", | ||
| "contrib", | ||
| "KernelComputer", | ||
| "Computer", | ||
| "computers_config", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| from .default import * | ||
| from .contrib import * | ||
| from .kernel_computer import KernelComputer | ||
|
|
||
| computers_config = { | ||
| "local-playwright": LocalPlaywrightBrowser, | ||
| "kernel": KernelPlaywrightBrowser, | ||
| "kernel": KernelComputer, | ||
| } | ||
2 changes: 0 additions & 2 deletions
2
pkg/templates/python/openai-computer-use/computers/default/__init__.py
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
pkg/templates/python/openai-computer-use/computers/default/kernel.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
config.pyis now dead codeLow Severity
config.pywas updated in this PR to referenceKernelComputer, butcomputers/__init__.pyno longer imports or exportscomputers_config. No other file references it either, making this entire file dead code.