pythonhere 0.3.0__tar.gz → 0.4.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.
- {pythonhere-0.3.0/pythonhere.egg-info → pythonhere-0.4.0}/PKG-INFO +5 -2
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pyproject.toml +8 -1
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/SKILL.md +18 -5
- pythonhere-0.4.0/pythonhere/.agents/skills/pythonhere/references/litert.md +121 -0
- pythonhere-0.4.0/pythonhere/ml_here/__init__.py +17 -0
- pythonhere-0.4.0/pythonhere/ml_here/huggingface.py +998 -0
- pythonhere-0.4.0/pythonhere/ml_here/storage.py +145 -0
- pythonhere-0.4.0/pythonhere/version_here.py +1 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0/pythonhere.egg-info}/PKG-INFO +5 -2
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere.egg-info/SOURCES.txt +5 -0
- pythonhere-0.4.0/pythonhere.egg-info/requires.txt +8 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_main.py +3 -13
- pythonhere-0.4.0/tests/test_ml_here.py +416 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_pythonhere_skill.py +3 -1
- pythonhere-0.3.0/pythonhere/version_here.py +0 -1
- pythonhere-0.3.0/pythonhere.egg-info/requires.txt +0 -4
- {pythonhere-0.3.0 → pythonhere-0.4.0}/LICENSE +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/README.rst +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/agents/openai.yaml +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/able.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/android-media.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/android-packages.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/android-permissions.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/android-runtime.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/jnius.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/kivy-kv.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/kivy-runtime.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/midi.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/.agents/skills/pythonhere/references/plyer.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/__init__.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/android_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/data/logo/logo-128.png +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/data/logo/logo-32.png +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/data/logo/logo-splash.png +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/enum_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/exception_manager_here.kv +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/exception_manager_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/launcher_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/__init__.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/README.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/able.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/android-media.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/android-packages.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/android-permissions.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/android-runtime.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/jnius.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/kivy-kv.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/kivy-runtime.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/midi.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts/plyer.md +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/prompts.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/magic_here/shortcuts.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/main.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/network_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/patches_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/pythonhere.kv +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/server_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/tools_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/__init__.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/actionbar_here.kv +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/common_here.kv +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/connection_address_here.kv +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/connection_address_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/layout_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/server_screen_here.kv +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/server_screen_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/settings_here.kv +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/ui_here/settings_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere/window_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere.egg-info/dependency_links.txt +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/pythonhere.egg-info/top_level.txt +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/setup.cfg +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/setup.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_ai_prompts.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_android_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_exception_manager_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_launcher_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_magic.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_network.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_patches.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_server_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_settings.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_tools_here.py +0 -0
- {pythonhere-0.3.0 → pythonhere-0.4.0}/tests/test_window_here.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pythonhere
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Here is the Kivy based app to run code from the Jupyter magic %there
|
|
5
5
|
Author-email: b3b <ash.b3b@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -16,10 +16,13 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
16
16
|
Requires-Python: >=3.10
|
|
17
17
|
Description-Content-Type: text/x-rst
|
|
18
18
|
License-File: LICENSE
|
|
19
|
-
Requires-Dist: herethere[magic]>=0.3.
|
|
19
|
+
Requires-Dist: herethere[magic]>=0.3.2
|
|
20
20
|
Requires-Dist: ipython
|
|
21
21
|
Requires-Dist: ipywidgets
|
|
22
22
|
Requires-Dist: Pillow
|
|
23
|
+
Provides-Extra: litert
|
|
24
|
+
Requires-Dist: litert-lm-api==0.16.0; extra == "litert"
|
|
25
|
+
Requires-Dist: requests; extra == "litert"
|
|
23
26
|
Dynamic: license-file
|
|
24
27
|
|
|
25
28
|
PythonHere
|
|
@@ -22,12 +22,18 @@ classifiers = [
|
|
|
22
22
|
"Programming Language :: Python :: 3.14",
|
|
23
23
|
]
|
|
24
24
|
dependencies = [
|
|
25
|
-
"herethere[magic]>=0.3.
|
|
25
|
+
"herethere[magic]>=0.3.2",
|
|
26
26
|
"ipython",
|
|
27
27
|
"ipywidgets",
|
|
28
28
|
"Pillow",
|
|
29
29
|
]
|
|
30
30
|
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
litert = [
|
|
33
|
+
"litert-lm-api==0.16.0",
|
|
34
|
+
"requests",
|
|
35
|
+
]
|
|
36
|
+
|
|
31
37
|
[dependency-groups]
|
|
32
38
|
dev = [
|
|
33
39
|
{ include-group = "docker" },
|
|
@@ -66,6 +72,7 @@ pythonpath = ["pythonhere"]
|
|
|
66
72
|
[tool.setuptools]
|
|
67
73
|
packages = [
|
|
68
74
|
"pythonhere",
|
|
75
|
+
"pythonhere.ml_here",
|
|
69
76
|
"pythonhere.magic_here",
|
|
70
77
|
"pythonhere.ui_here",
|
|
71
78
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pythonhere
|
|
3
|
-
description: "Build, inspect, and debug PythonHere applications by executing Python through the `there` CLI in an already-running Kivy/Python-for-Android process. Use when a task targets a PythonHere device or `there.env` connection and involves live Kivy UI, KV language, Android APIs, Pyjnius, permissions, installed Android packages, media/files, Plyer device features, BLE with able, or
|
|
3
|
+
description: "Build, inspect, and debug PythonHere applications by executing Python through the `there` CLI in an already-running Kivy/Python-for-Android process. Use when a task targets a PythonHere device or `there.env` connection and involves live Kivy UI, KV language, Android APIs, Pyjnius, permissions, installed Android packages, media/files, Plyer device features, BLE with able, MIDI with midistream, or on-device AI with LiteRT-LM and `.litertlm` models."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Operate PythonHere with `there`
|
|
@@ -40,6 +40,8 @@ when the task depends on it broadly or requires its exact current contents.
|
|
|
40
40
|
recording, camera, file selection, GPS, battery, or sensors.
|
|
41
41
|
- Consult [able.md](references/able.md) for Bluetooth Low Energy work.
|
|
42
42
|
- Consult [midi.md](references/midi.md) for MIDI or synthesizer work.
|
|
43
|
+
- Consult [litert.md](references/litert.md) for PythonHere's ML model helpers
|
|
44
|
+
and LiteRT-LM usage.
|
|
43
45
|
|
|
44
46
|
Combine references when a feature genuinely needs details from several
|
|
45
47
|
concerns; for example, an Android gallery may need permission, MediaStore, and
|
|
@@ -66,9 +68,11 @@ They complement rather than restrict normal Python:
|
|
|
66
68
|
These helpers may be called on Kivy's main thread or from a worker. Worker calls
|
|
67
69
|
are transparently marshaled to Kivy's thread and block that worker until Kivy
|
|
68
70
|
finishes the operation, normally on its next frame. Continue to prefer normal
|
|
69
|
-
foreground `there get` and `there run` for quick UI operations.
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
foreground `there get` and `there run` for quick UI operations. Add `--worker`
|
|
72
|
+
to `get` or `run` when surrounding slow or blocking work would otherwise block
|
|
73
|
+
the UI. The CLI remains attached, waits for completion, and then returns the
|
|
74
|
+
value or captured output. Worker execution does not make other Kivy access
|
|
75
|
+
thread-safe.
|
|
72
76
|
|
|
73
77
|
Do not call a worker-marshaled helper while Kivy's main thread is synchronously
|
|
74
78
|
waiting for that same worker. Neither side can progress in that cross-thread
|
|
@@ -179,7 +183,9 @@ there --json run --code "from tools_here import pin_shortcut; pin_shortcut('demo
|
|
|
179
183
|
- Keep callbacks non-blocking and marshal UI changes to the Kivy thread.
|
|
180
184
|
4. For more than a short expression, create a local UTF-8 Python file and run it
|
|
181
185
|
with `there --json run FILE`. Prefer a file over fragile shell quoting or a
|
|
182
|
-
long `--code` value. Keep within the installed CLI's input limit.
|
|
186
|
+
long `--code` value. Keep within the installed CLI's input limit. Add
|
|
187
|
+
`--worker` for slow or blocking code that should not occupy Kivy's main
|
|
188
|
+
thread.
|
|
183
189
|
5. Make only the requested live-app mutation. Reuse existing state when
|
|
184
190
|
practical and provide cleanup helpers for scheduled events, sensors,
|
|
185
191
|
Bluetooth, MIDI, files, or other held resources.
|
|
@@ -223,6 +229,13 @@ Run a prepared UI change:
|
|
|
223
229
|
there --json run /tmp/pythonhere-ui.py
|
|
224
230
|
```
|
|
225
231
|
|
|
232
|
+
Run slow or blocking non-UI work without freezing Kivy, while waiting for its
|
|
233
|
+
buffered output:
|
|
234
|
+
|
|
235
|
+
```console
|
|
236
|
+
there --json run --worker /tmp/pythonhere-long-task.py
|
|
237
|
+
```
|
|
238
|
+
|
|
226
239
|
Verify a named status left by that code:
|
|
227
240
|
|
|
228
241
|
```console
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# ML model helpers for LiteRT
|
|
2
|
+
|
|
3
|
+
PythonHere provides `ml_here` for acquiring and locating ML model files. It
|
|
4
|
+
does not wrap LiteRT-LM inference.
|
|
5
|
+
|
|
6
|
+
All public model helpers return paths as strings (a list of strings for
|
|
7
|
+
`discover_models()`), ready to pass to `litert_lm.Engine()`.
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from ml_here import (
|
|
11
|
+
discover_models,
|
|
12
|
+
download_hf_model,
|
|
13
|
+
model_path,
|
|
14
|
+
models_directory,
|
|
15
|
+
require_model,
|
|
16
|
+
)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- `models_directory(create=False)` returns PythonHere's model directory. On
|
|
20
|
+
Android this is the app-specific external files directory under `models`; on
|
|
21
|
+
Linux it is `~/.local/share/pythonhere/models`.
|
|
22
|
+
- `model_path(repo_id, filename)` returns the namespaced path for a model. It
|
|
23
|
+
does not create directories and rejects unsafe path components.
|
|
24
|
+
- `require_model(repo_id, filename)` returns that path when the model is
|
|
25
|
+
installed and raises `FileNotFoundError` otherwise.
|
|
26
|
+
- `discover_models(extra_directories=(), extensions=".litertlm")` recursively
|
|
27
|
+
returns sorted, unique LiteRT-LM model paths from managed storage and any
|
|
28
|
+
additional directories. Pass another extension or iterable to select other
|
|
29
|
+
formats, or `extensions=None` to include every completed stored artifact.
|
|
30
|
+
- `download_hf_model(repo_id, filename, *, revision="main", token=None,
|
|
31
|
+
destination=None, progress=None, cancelled=None, overwrite=False,
|
|
32
|
+
expected_sha256=None)` downloads a Hugging Face model file of any format. By
|
|
33
|
+
default, it stores the file at `model_path(repo_id, filename)`.
|
|
34
|
+
|
|
35
|
+
Choose by intent: use `require_model()` to load a known installed model, the
|
|
36
|
+
path returned by `download_hf_model()` after a download, and
|
|
37
|
+
`discover_models()` only to inventory models whose identities are not already
|
|
38
|
+
known. Use `model_path()` when only the expected location is needed.
|
|
39
|
+
|
|
40
|
+
Downloads are resumable across restarts and make the final file visible only
|
|
41
|
+
after the download completes. Cancellation preserves the partial download for
|
|
42
|
+
resuming. Pass a token for private or gated models. The `progress` callback
|
|
43
|
+
receives the following interface; use it directly rather than redefining it:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
class DownloadProgress:
|
|
47
|
+
repo_id: str
|
|
48
|
+
filename: str
|
|
49
|
+
destination: str
|
|
50
|
+
downloaded: int
|
|
51
|
+
total: int | None
|
|
52
|
+
elapsed: float
|
|
53
|
+
speed_bps: float
|
|
54
|
+
fraction: float | None
|
|
55
|
+
percent: float | None
|
|
56
|
+
speed_mbps: float
|
|
57
|
+
remaining: int | None
|
|
58
|
+
eta: float | None
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Use `litert_lm` directly to load and run the returned model path.
|
|
62
|
+
|
|
63
|
+
## Run an installed model
|
|
64
|
+
|
|
65
|
+
Run model loading and inference on a worker (`--worker`) to keep Kivy
|
|
66
|
+
responsive. In the app runtime, import model helpers from `ml_here`.
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import litert_lm
|
|
70
|
+
from ml_here import require_model
|
|
71
|
+
|
|
72
|
+
model_file = require_model(
|
|
73
|
+
"litert-community/SmolLM2-135M-Instruct",
|
|
74
|
+
"SmolLM2_135M_Instruct.litertlm",
|
|
75
|
+
)
|
|
76
|
+
engine = litert_lm.Engine(model_file)
|
|
77
|
+
try:
|
|
78
|
+
with engine.create_conversation(max_output_tokens=128) as conversation:
|
|
79
|
+
response = conversation.send_message(
|
|
80
|
+
"What is the Kivy framework? Answer in one short paragraph."
|
|
81
|
+
)
|
|
82
|
+
text = "".join(
|
|
83
|
+
part["text"]
|
|
84
|
+
for part in response["content"]
|
|
85
|
+
if part.get("type") == "text"
|
|
86
|
+
)
|
|
87
|
+
print(text)
|
|
88
|
+
finally:
|
|
89
|
+
engine.close()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The conversation closes before the engine, including when inference raises.
|
|
93
|
+
For an interactive chat, keep the engine loaded and reuse the conversation
|
|
94
|
+
for follow-up messages; close both when the chat is finished.
|
|
95
|
+
|
|
96
|
+
`litert_lm.Engine(model_file)` uses CPU by default. For a model and device
|
|
97
|
+
that support GPU inference, replace the engine construction above with:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
engine = litert_lm.Engine(model_file, backend=litert_lm.Backend.GPU())
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Download first when needed
|
|
104
|
+
|
|
105
|
+
If the model is not installed, download it on a worker before inference:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from ml_here import download_hf_model
|
|
109
|
+
|
|
110
|
+
model_file = download_hf_model(
|
|
111
|
+
"litert-community/SmolLM2-135M-Instruct",
|
|
112
|
+
"SmolLM2_135M_Instruct.litertlm",
|
|
113
|
+
)
|
|
114
|
+
print(model_file)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
When downloading and loading in the same script, pass the returned
|
|
118
|
+
`model_file` directly to `litert_lm.Engine()`.
|
|
119
|
+
|
|
120
|
+
See the [upstream Python API](https://github.com/google-ai-edge/LiteRT-LM/tree/main/python)
|
|
121
|
+
for streaming, sampling, and multimodal inference.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Acquire, store, index, and discover ML model files for PythonHere."""
|
|
2
|
+
|
|
3
|
+
from .huggingface import download_hf_model
|
|
4
|
+
from .storage import (
|
|
5
|
+
discover_models,
|
|
6
|
+
model_path,
|
|
7
|
+
models_directory,
|
|
8
|
+
require_model,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = (
|
|
12
|
+
"discover_models",
|
|
13
|
+
"download_hf_model",
|
|
14
|
+
"model_path",
|
|
15
|
+
"models_directory",
|
|
16
|
+
"require_model",
|
|
17
|
+
)
|