oagi 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. oagi-0.7.0/.github/workflows/ci.yml +45 -0
  2. oagi-0.7.0/.github/workflows/release.yml +48 -0
  3. oagi-0.7.0/.gitignore +208 -0
  4. oagi-0.7.0/.python-version +1 -0
  5. oagi-0.7.0/CONTRIBUTING.md +1 -0
  6. oagi-0.7.0/LICENSE +21 -0
  7. oagi-0.7.0/Makefile +31 -0
  8. oagi-0.7.0/PKG-INFO +163 -0
  9. oagi-0.7.0/README.md +129 -0
  10. oagi-0.7.0/examples/async_google_weather.py +23 -0
  11. oagi-0.7.0/examples/continued_session.py +53 -0
  12. oagi-0.7.0/examples/execute_task_auto.py +42 -0
  13. oagi-0.7.0/examples/execute_task_manual.py +98 -0
  14. oagi-0.7.0/examples/google_weather.py +15 -0
  15. oagi-0.7.0/examples/hotel_booking.py +52 -0
  16. oagi-0.7.0/examples/screenshot_with_config.py +94 -0
  17. oagi-0.7.0/examples/single_step.py +19 -0
  18. oagi-0.7.0/pyproject.toml +36 -0
  19. oagi-0.7.0/src/oagi/__init__.py +96 -0
  20. oagi-0.7.0/src/oagi/async_pyautogui_action_handler.py +44 -0
  21. oagi-0.7.0/src/oagi/async_screenshot_maker.py +47 -0
  22. oagi-0.7.0/src/oagi/async_single_step.py +85 -0
  23. oagi-0.7.0/src/oagi/client/__init__.py +12 -0
  24. oagi-0.7.0/src/oagi/client/async_.py +197 -0
  25. oagi-0.7.0/src/oagi/client/base.py +334 -0
  26. oagi-0.7.0/src/oagi/client/sync.py +201 -0
  27. oagi-0.7.0/src/oagi/exceptions.py +75 -0
  28. oagi-0.7.0/src/oagi/logging.py +45 -0
  29. oagi-0.7.0/src/oagi/pil_image.py +99 -0
  30. oagi-0.7.0/src/oagi/pyautogui_action_handler.py +265 -0
  31. oagi-0.7.0/src/oagi/screenshot_maker.py +41 -0
  32. oagi-0.7.0/src/oagi/single_step.py +87 -0
  33. oagi-0.7.0/src/oagi/task/__init__.py +14 -0
  34. oagi-0.7.0/src/oagi/task/async_.py +97 -0
  35. oagi-0.7.0/src/oagi/task/async_short.py +64 -0
  36. oagi-0.7.0/src/oagi/task/base.py +130 -0
  37. oagi-0.7.0/src/oagi/task/short.py +64 -0
  38. oagi-0.7.0/src/oagi/task/sync.py +97 -0
  39. oagi-0.7.0/src/oagi/types/__init__.py +26 -0
  40. oagi-0.7.0/src/oagi/types/action_handler.py +30 -0
  41. oagi-0.7.0/src/oagi/types/async_action_handler.py +30 -0
  42. oagi-0.7.0/src/oagi/types/async_image_provider.py +37 -0
  43. oagi-0.7.0/src/oagi/types/image.py +17 -0
  44. oagi-0.7.0/src/oagi/types/image_provider.py +34 -0
  45. oagi-0.7.0/src/oagi/types/models/__init__.py +24 -0
  46. oagi-0.7.0/src/oagi/types/models/action.py +33 -0
  47. oagi-0.7.0/src/oagi/types/models/client.py +55 -0
  48. oagi-0.7.0/src/oagi/types/models/image_config.py +47 -0
  49. oagi-0.7.0/src/oagi/types/models/step.py +17 -0
  50. oagi-0.7.0/tests/__init__.py +9 -0
  51. oagi-0.7.0/tests/conftest.py +285 -0
  52. oagi-0.7.0/tests/test_async_client.py +359 -0
  53. oagi-0.7.0/tests/test_async_handlers.py +222 -0
  54. oagi-0.7.0/tests/test_async_task.py +239 -0
  55. oagi-0.7.0/tests/test_logging.py +362 -0
  56. oagi-0.7.0/tests/test_pil_image.py +236 -0
  57. oagi-0.7.0/tests/test_pyautogui_action_handler.py +321 -0
  58. oagi-0.7.0/tests/test_screenshot_maker.py +175 -0
  59. oagi-0.7.0/tests/test_short_task.py +150 -0
  60. oagi-0.7.0/tests/test_single_step.py +216 -0
  61. oagi-0.7.0/tests/test_sync_client.py +573 -0
  62. oagi-0.7.0/tests/test_task.py +423 -0
  63. oagi-0.7.0/uv.lock +666 -0
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ branches: ["main"]
7
+
8
+ jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v3
16
+
17
+ - name: Install dependencies
18
+ run: make install
19
+
20
+ - name: Run lint
21
+ run: make lint
22
+
23
+ build:
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ - uses: astral-sh/setup-uv@v3
28
+ - run: make install
29
+ - run: make build
30
+
31
+ test:
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+ - uses: astral-sh/setup-uv@v3
36
+
37
+ - name: Install system dependencies
38
+ run: |
39
+ sudo apt-get update
40
+ sudo apt-get install -y xvfb
41
+
42
+ - run: make install
43
+
44
+ - name: Run tests with virtual display
45
+ run: xvfb-run -a make test-verbose
@@ -0,0 +1,48 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write # For trusted publishing
13
+ contents: write # For GitHub release
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Install uv
19
+ uses: astral-sh/setup-uv@v3
20
+ with:
21
+ enable-cache: true
22
+
23
+ - name: Set up Python
24
+ run: uv python install 3.12
25
+
26
+ - name: Build package
27
+ run: uv build
28
+
29
+ - name: Publish to PyPI
30
+ uses: pypa/gh-action-pypi-publish@release/v1
31
+ with:
32
+ password: ${{ secrets.PYPI_API_TOKEN }}
33
+ # Another option: Use Trusted Publishing (recommended, no token needed)
34
+ # Configure at: https://pypi.org/manage/project/oagi/settings/publishing/
35
+
36
+ - name: Get commit message
37
+ id: commit_message
38
+ run: |
39
+ # Get the commit message for the tagged commit
40
+ echo "message<<EOF" >> $GITHUB_OUTPUT
41
+ git log -1 --pretty=%B >> $GITHUB_OUTPUT
42
+ echo "EOF" >> $GITHUB_OUTPUT
43
+
44
+ - name: Create GitHub Release
45
+ uses: softprops/action-gh-release@v1
46
+ with:
47
+ body: ${{ steps.commit_message.outputs.message }}
48
+ files: dist/*
oagi-0.7.0/.gitignore ADDED
@@ -0,0 +1,208 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+ .DS_Store
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py.cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # UV
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ #uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ #poetry.lock
110
+ #poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ #pdm.lock
117
+ #pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ #pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi
127
+
128
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
129
+ __pypackages__/
130
+
131
+ # Celery stuff
132
+ celerybeat-schedule
133
+ celerybeat.pid
134
+
135
+ # SageMath parsed files
136
+ *.sage.py
137
+
138
+ # Environments
139
+ .env
140
+ .envrc
141
+ .venv
142
+ env/
143
+ venv/
144
+ ENV/
145
+ env.bak/
146
+ venv.bak/
147
+
148
+ # Spyder project settings
149
+ .spyderproject
150
+ .spyproject
151
+
152
+ # Rope project settings
153
+ .ropeproject
154
+
155
+ # mkdocs documentation
156
+ /site
157
+
158
+ # mypy
159
+ .mypy_cache/
160
+ .dmypy.json
161
+ dmypy.json
162
+
163
+ # Pyre type checker
164
+ .pyre/
165
+
166
+ # pytype static type analyzer
167
+ .pytype/
168
+
169
+ # Cython debug symbols
170
+ cython_debug/
171
+
172
+ # PyCharm
173
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
174
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
175
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
176
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
177
+ .idea/
178
+
179
+ # Abstra
180
+ # Abstra is an AI-powered process automation framework.
181
+ # Ignore directories containing user credentials, local state, and settings.
182
+ # Learn more at https://abstra.io/docs
183
+ .abstra/
184
+
185
+ # Visual Studio Code
186
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
187
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
188
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
189
+ # you could uncomment the following to ignore the entire vscode folder
190
+ # .vscode/
191
+
192
+ # Ruff stuff:
193
+ .ruff_cache/
194
+
195
+ # PyPI configuration file
196
+ .pypirc
197
+
198
+ # Cursor
199
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
200
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
201
+ # refer to https://docs.cursor.com/context/ignore-files
202
+ .cursorignore
203
+ .cursorindexingignore
204
+
205
+ # Marimo
206
+ marimo/_static/
207
+ marimo/_lsp/
208
+ __marimo__/
@@ -0,0 +1 @@
1
+ 3.10.18
@@ -0,0 +1 @@
1
+ ## Development
oagi-0.7.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 OpenAGI Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
oagi-0.7.0/Makefile ADDED
@@ -0,0 +1,31 @@
1
+ .PHONY: .uv
2
+ .uv:
3
+ @uv -V || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
4
+
5
+ .PHONY: install-dev
6
+ install-dev: .uv
7
+ uv sync --frozen --all-groups --all-extras
8
+
9
+ .PHONY: install
10
+ install: install-dev
11
+
12
+ .PHONY: format
13
+ format: .uv
14
+ uv run ruff check --fix
15
+ uv run ruff format
16
+
17
+ .PHONY: lint
18
+ lint: .uv
19
+ uv run ruff check
20
+ uv run ruff format --check
21
+
22
+ build: .uv
23
+ uv build
24
+
25
+ .PHONY: test
26
+ test: .uv
27
+ uv run pytest
28
+
29
+ .PHONY: test-verbose
30
+ test-verbose: .uv
31
+ uv run pytest -v
oagi-0.7.0/PKG-INFO ADDED
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.3
2
+ Name: oagi
3
+ Version: 0.7.0
4
+ Summary: Official API of OpenAGI Foundation
5
+ Project-URL: Homepage, https://github.com/agiopen-org/oagi
6
+ Author-email: OpenAGI Foundation <contact@agiopen.org>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2025 OpenAGI Foundation
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ Requires-Python: >=3.10
29
+ Requires-Dist: httpx>=0.28.0
30
+ Requires-Dist: pillow>=11.3.0
31
+ Requires-Dist: pyautogui>=0.9.54
32
+ Requires-Dist: pydantic>=2.0.0
33
+ Description-Content-Type: text/markdown
34
+
35
+ # OAGI Python SDK
36
+
37
+ Python SDK for the OAGI API - vision-based task automation.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install oagi # requires Python >= 3.10
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ Set your API credentials:
48
+ ```bash
49
+ export OAGI_API_KEY="your-api-key"
50
+ export OAGI_BASE_URL="https://api.oagi.com" # or your server URL
51
+ ```
52
+
53
+ ### Single-Step Analysis
54
+
55
+ Analyze a screenshot and get recommended actions:
56
+
57
+ ```python
58
+ from oagi import single_step
59
+
60
+ step = single_step(
61
+ task_description="Click the submit button",
62
+ screenshot="screenshot.png" # or bytes, or Image object
63
+ )
64
+
65
+ print(f"Actions: {step.actions}")
66
+ print(f"Complete: {step.is_complete}")
67
+ ```
68
+
69
+ ### Automated Task Execution
70
+
71
+ Run tasks automatically with screenshot capture and action execution:
72
+
73
+ ```python
74
+ from oagi import ShortTask, ScreenshotMaker, PyautoguiActionHandler
75
+
76
+ task = ShortTask()
77
+ completed = task.auto_mode(
78
+ "Search weather on Google",
79
+ max_steps=10,
80
+ executor=PyautoguiActionHandler(), # Executes mouse/keyboard actions
81
+ image_provider=ScreenshotMaker(), # Captures screenshots
82
+ )
83
+ ```
84
+
85
+ Configure PyAutoGUI behavior with custom settings:
86
+
87
+ ```python
88
+ from oagi import PyautoguiActionHandler, PyautoguiConfig
89
+
90
+ # Customize action behavior
91
+ config = PyautoguiConfig(
92
+ drag_duration=1.0, # Slower drags for precision (default: 0.5)
93
+ scroll_amount=50, # Larger scroll steps (default: 30)
94
+ wait_duration=2.0, # Longer waits (default: 1.0)
95
+ action_pause=0.2, # More pause between actions (default: 0.1)
96
+ hotkey_interval=0.1, # Interval between keys in hotkey combinations (default: 0.1)
97
+ capslock_mode="session" # Caps lock mode: 'session' or 'system' (default: 'session')
98
+ )
99
+
100
+ executor = PyautoguiActionHandler(config=config)
101
+ task.auto_mode("Complete form", executor=executor, image_provider=ScreenshotMaker())
102
+ ```
103
+
104
+ ### Image Processing
105
+
106
+ Process and optimize images before sending to API:
107
+
108
+ ```python
109
+ from oagi import PILImage, ImageConfig
110
+
111
+ # Load and compress an image
112
+ image = PILImage.from_file("large_screenshot.png")
113
+ config = ImageConfig(
114
+ format="JPEG",
115
+ quality=85,
116
+ width=1260,
117
+ height=700
118
+ )
119
+ compressed = image.transform(config)
120
+
121
+ # Use with single_step
122
+ step = single_step("Click button", screenshot=compressed)
123
+ ```
124
+
125
+ ### Async Support
126
+
127
+ Use async client for non-blocking operations and better concurrency:
128
+
129
+ ```python
130
+ import asyncio
131
+ from oagi import async_single_step, AsyncShortTask
132
+
133
+ async def main():
134
+ # Single-step async analysis
135
+ step = await async_single_step(
136
+ "Find the search bar",
137
+ screenshot="screenshot.png"
138
+ )
139
+ print(f"Found {len(step.actions)} actions")
140
+
141
+ # Async task automation
142
+ task = AsyncShortTask()
143
+ async with task:
144
+ await task.init_task("Complete the form")
145
+ # ... continue with async operations
146
+
147
+ asyncio.run(main())
148
+ ```
149
+
150
+ ## Examples
151
+
152
+ See the [`examples/`](examples/) directory for more usage patterns:
153
+ - `google_weather.py` - Basic task execution with `ShortTask`
154
+ - `single_step.py` - Basic single-step inference
155
+ - `screenshot_with_config.py` - Image compression and optimization
156
+ - `execute_task_auto.py` - Automated task execution
157
+
158
+ ## Documentation
159
+
160
+
161
+ ## License
162
+
163
+ MIT
oagi-0.7.0/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # OAGI Python SDK
2
+
3
+ Python SDK for the OAGI API - vision-based task automation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install oagi # requires Python >= 3.10
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ Set your API credentials:
14
+ ```bash
15
+ export OAGI_API_KEY="your-api-key"
16
+ export OAGI_BASE_URL="https://api.oagi.com" # or your server URL
17
+ ```
18
+
19
+ ### Single-Step Analysis
20
+
21
+ Analyze a screenshot and get recommended actions:
22
+
23
+ ```python
24
+ from oagi import single_step
25
+
26
+ step = single_step(
27
+ task_description="Click the submit button",
28
+ screenshot="screenshot.png" # or bytes, or Image object
29
+ )
30
+
31
+ print(f"Actions: {step.actions}")
32
+ print(f"Complete: {step.is_complete}")
33
+ ```
34
+
35
+ ### Automated Task Execution
36
+
37
+ Run tasks automatically with screenshot capture and action execution:
38
+
39
+ ```python
40
+ from oagi import ShortTask, ScreenshotMaker, PyautoguiActionHandler
41
+
42
+ task = ShortTask()
43
+ completed = task.auto_mode(
44
+ "Search weather on Google",
45
+ max_steps=10,
46
+ executor=PyautoguiActionHandler(), # Executes mouse/keyboard actions
47
+ image_provider=ScreenshotMaker(), # Captures screenshots
48
+ )
49
+ ```
50
+
51
+ Configure PyAutoGUI behavior with custom settings:
52
+
53
+ ```python
54
+ from oagi import PyautoguiActionHandler, PyautoguiConfig
55
+
56
+ # Customize action behavior
57
+ config = PyautoguiConfig(
58
+ drag_duration=1.0, # Slower drags for precision (default: 0.5)
59
+ scroll_amount=50, # Larger scroll steps (default: 30)
60
+ wait_duration=2.0, # Longer waits (default: 1.0)
61
+ action_pause=0.2, # More pause between actions (default: 0.1)
62
+ hotkey_interval=0.1, # Interval between keys in hotkey combinations (default: 0.1)
63
+ capslock_mode="session" # Caps lock mode: 'session' or 'system' (default: 'session')
64
+ )
65
+
66
+ executor = PyautoguiActionHandler(config=config)
67
+ task.auto_mode("Complete form", executor=executor, image_provider=ScreenshotMaker())
68
+ ```
69
+
70
+ ### Image Processing
71
+
72
+ Process and optimize images before sending to API:
73
+
74
+ ```python
75
+ from oagi import PILImage, ImageConfig
76
+
77
+ # Load and compress an image
78
+ image = PILImage.from_file("large_screenshot.png")
79
+ config = ImageConfig(
80
+ format="JPEG",
81
+ quality=85,
82
+ width=1260,
83
+ height=700
84
+ )
85
+ compressed = image.transform(config)
86
+
87
+ # Use with single_step
88
+ step = single_step("Click button", screenshot=compressed)
89
+ ```
90
+
91
+ ### Async Support
92
+
93
+ Use async client for non-blocking operations and better concurrency:
94
+
95
+ ```python
96
+ import asyncio
97
+ from oagi import async_single_step, AsyncShortTask
98
+
99
+ async def main():
100
+ # Single-step async analysis
101
+ step = await async_single_step(
102
+ "Find the search bar",
103
+ screenshot="screenshot.png"
104
+ )
105
+ print(f"Found {len(step.actions)} actions")
106
+
107
+ # Async task automation
108
+ task = AsyncShortTask()
109
+ async with task:
110
+ await task.init_task("Complete the form")
111
+ # ... continue with async operations
112
+
113
+ asyncio.run(main())
114
+ ```
115
+
116
+ ## Examples
117
+
118
+ See the [`examples/`](examples/) directory for more usage patterns:
119
+ - `google_weather.py` - Basic task execution with `ShortTask`
120
+ - `single_step.py` - Basic single-step inference
121
+ - `screenshot_with_config.py` - Image compression and optimization
122
+ - `execute_task_auto.py` - Automated task execution
123
+
124
+ ## Documentation
125
+
126
+
127
+ ## License
128
+
129
+ MIT
@@ -0,0 +1,23 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Copyright (c) OpenAGI Foundation
3
+ # All rights reserved.
4
+ #
5
+ # This file is part of the official API project.
6
+ # Licensed under the MIT License.
7
+ # -----------------------------------------------------------------------------
8
+
9
+ import asyncio
10
+
11
+ from examples.execute_task_manual import async_execute_task_manual
12
+
13
+
14
+ async def main():
15
+ is_completed, screenshot = await async_execute_task_manual(
16
+ desc := "Search weather with Google", max_steps=5
17
+ )
18
+
19
+ print(f"is_completed: {is_completed}, desc: {desc}")
20
+
21
+
22
+ if __name__ == "__main__":
23
+ asyncio.run(main())