programasweights 0.2.2.dev1__py3-none-any.whl → 0.2.4__py3-none-any.whl
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.
- programasweights/__init__.py +2 -1
- programasweights/client.py +17 -4
- programasweights/runtime_llamacpp.py +12 -12
- {programasweights-0.2.2.dev1.dist-info → programasweights-0.2.4.dist-info}/METADATA +5 -1
- {programasweights-0.2.2.dev1.dist-info → programasweights-0.2.4.dist-info}/RECORD +8 -8
- {programasweights-0.2.2.dev1.dist-info → programasweights-0.2.4.dist-info}/WHEEL +0 -0
- {programasweights-0.2.2.dev1.dist-info → programasweights-0.2.4.dist-info}/entry_points.txt +0 -0
- {programasweights-0.2.2.dev1.dist-info → programasweights-0.2.4.dist-info}/licenses/LICENSE +0 -0
programasweights/__init__.py
CHANGED
|
@@ -21,8 +21,9 @@ API reference:
|
|
|
21
21
|
paw.api_url Server URL (default: https://programasweights.com)
|
|
22
22
|
paw.api_key API key (set via login() or PAW_API_KEY env var)
|
|
23
23
|
"""
|
|
24
|
+
from __future__ import annotations
|
|
24
25
|
|
|
25
|
-
__version__ = "0.2.
|
|
26
|
+
__version__ = "0.2.4"
|
|
26
27
|
|
|
27
28
|
from .config import get_api_url, get_api_key, set_api_key
|
|
28
29
|
|
programasweights/client.py
CHANGED
|
@@ -108,25 +108,38 @@ class PAWClient:
|
|
|
108
108
|
"""Download a .paw bundle to the local cache.
|
|
109
109
|
|
|
110
110
|
Returns the path to the extracted program directory.
|
|
111
|
-
|
|
111
|
+
Handles 202 Accepted (assets still generating) and 302 redirects (HF CDN).
|
|
112
112
|
"""
|
|
113
113
|
program_dir = config.get_programs_dir() / program_id
|
|
114
114
|
if (program_dir / "prompt_template.txt").exists():
|
|
115
115
|
return program_dir
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
max_wait = 30
|
|
118
|
+
elapsed = 0
|
|
119
|
+
resp = None
|
|
120
|
+
while elapsed < max_wait:
|
|
119
121
|
resp = httpx.get(
|
|
120
122
|
f"{self._api_url}/api/v1/programs/{program_id}/download",
|
|
121
123
|
headers=self._headers(),
|
|
122
124
|
timeout=60.0,
|
|
123
125
|
follow_redirects=True,
|
|
124
126
|
)
|
|
125
|
-
if resp.status_code ==
|
|
127
|
+
if resp.status_code == 202:
|
|
128
|
+
retry_after = int(resp.headers.get("Retry-After", "3"))
|
|
129
|
+
time.sleep(retry_after)
|
|
130
|
+
elapsed += retry_after
|
|
131
|
+
continue
|
|
132
|
+
if resp.status_code == 404 and elapsed < max_wait - 3:
|
|
126
133
|
time.sleep(3)
|
|
134
|
+
elapsed += 3
|
|
127
135
|
continue
|
|
128
136
|
resp.raise_for_status()
|
|
129
137
|
break
|
|
138
|
+
else:
|
|
139
|
+
raise RuntimeError(
|
|
140
|
+
f"Program {program_id} assets not ready after {max_wait}s. "
|
|
141
|
+
"The program may still be generating. Try again shortly."
|
|
142
|
+
)
|
|
130
143
|
|
|
131
144
|
program_dir.mkdir(parents=True, exist_ok=True)
|
|
132
145
|
paw_path = program_dir / f"{program_id}.paw"
|
|
@@ -67,24 +67,24 @@ class PawFunction:
|
|
|
67
67
|
n_gpu_layers=n_gpu_layers,
|
|
68
68
|
verbose=verbose,
|
|
69
69
|
)
|
|
70
|
+
|
|
71
|
+
adapter_path = program_dir / "adapter.gguf"
|
|
72
|
+
if adapter_path.exists():
|
|
73
|
+
self._adapter = llama_cpp.llama_adapter_lora_init(
|
|
74
|
+
self._llm.model, str(adapter_path).encode("utf-8"),
|
|
75
|
+
)
|
|
76
|
+
if self._adapter:
|
|
77
|
+
llama_cpp.llama_set_adapter_lora(self._llm.ctx, self._adapter, 1.0)
|
|
78
|
+
else:
|
|
79
|
+
raise RuntimeError(f"Failed to load LoRA adapter: {adapter_path}")
|
|
80
|
+
else:
|
|
81
|
+
self._adapter = None
|
|
70
82
|
finally:
|
|
71
83
|
if not verbose:
|
|
72
84
|
_os.dup2(_old_stderr, _stderr_fd)
|
|
73
85
|
_os.close(_devnull)
|
|
74
86
|
_os.close(_old_stderr)
|
|
75
87
|
|
|
76
|
-
adapter_path = program_dir / "adapter.gguf"
|
|
77
|
-
if adapter_path.exists():
|
|
78
|
-
self._adapter = llama_cpp.llama_adapter_lora_init(
|
|
79
|
-
self._llm.model, str(adapter_path).encode("utf-8"),
|
|
80
|
-
)
|
|
81
|
-
if self._adapter:
|
|
82
|
-
llama_cpp.llama_set_adapter_lora(self._llm.ctx, self._adapter, 1.0)
|
|
83
|
-
else:
|
|
84
|
-
raise RuntimeError(f"Failed to load LoRA adapter: {adapter_path}")
|
|
85
|
-
else:
|
|
86
|
-
self._adapter = None
|
|
87
|
-
|
|
88
88
|
placeholder = "{INPUT_PLACEHOLDER}"
|
|
89
89
|
self._use_special = interpreter not in ("gpt2",)
|
|
90
90
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: programasweights
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Compile natural language specifications into neural programs that run locally via llama.cpp.
|
|
5
5
|
Project-URL: Homepage, https://programasweights.com
|
|
6
6
|
Project-URL: Repository, https://github.com/programasweights/programasweights-python
|
|
@@ -58,6 +58,10 @@ program = paw.compile(
|
|
|
58
58
|
)
|
|
59
59
|
fn = paw.function(program.slug) # or paw.function(program.id)
|
|
60
60
|
fn("{name: 'Alice',}") # '{"name": "Alice"}'
|
|
61
|
+
|
|
62
|
+
# Or compile and load in one step
|
|
63
|
+
fn = paw.compile_and_load("Classify sentiment as positive or negative")
|
|
64
|
+
fn("I love this!") # "positive"
|
|
61
65
|
```
|
|
62
66
|
|
|
63
67
|
## Two Compilers
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
programasweights/__init__.py,sha256=
|
|
1
|
+
programasweights/__init__.py,sha256=PJKL0I4KZPFhMfhUbPmgXOZhMV9dfuKgsGrV6UfTVBE,7882
|
|
2
2
|
programasweights/artifacts.py,sha256=bSRZgYadAYyuH9aIW6P3VocExfGDGAHeDuj8vod5-Bo,1968
|
|
3
3
|
programasweights/cache.py,sha256=7L4D5juQLtARVT4aEqzy9N2Lz6xUv9uk7LBZMuJJFrY,3866
|
|
4
4
|
programasweights/cli.py,sha256=X0M3OddGvsBJXjcaKw0qebaU9koe8r30BHgj9Wbf5WM,6840
|
|
5
|
-
programasweights/client.py,sha256=
|
|
5
|
+
programasweights/client.py,sha256=RlMDMueDtMnZ-OkIe_Zqt_ayTyFDmr7X67dlzG_I5rU,5638
|
|
6
6
|
programasweights/config.py,sha256=zQFnVNfYR4bFx2DsZheMnPy2yd9T4-fe0u2sG1GluE8,1553
|
|
7
7
|
programasweights/convert_peft_to_paw.py,sha256=yvavaAzLUqc-lFHEC_9AOhsuI-fCobu6k-GDMVQdOHk,6521
|
|
8
8
|
programasweights/paw_format.py,sha256=wRXolwtnPgKoopiJC8-yMVZZtiwB-PoAqaWpDFKMoj8,10679
|
|
9
|
-
programasweights/runtime_llamacpp.py,sha256=
|
|
9
|
+
programasweights/runtime_llamacpp.py,sha256=zZ5KFZiH_PBjEXX8aJXl4moDQ9uzikKvajdjCvXZg7M,6973
|
|
10
10
|
programasweights/compiler/__init__.py,sha256=_q0L02k6Cl9zyvxKQlMuW2o6w7cX6OZ_bZ9wHuZqs18,9508
|
|
11
11
|
programasweights/compiler/dummy.py,sha256=PcLwijRNM4q2E9PNUcfCPf_y08QjsteVENR0TVsOIfY,1011
|
|
12
12
|
programasweights/runtime/__init__.py,sha256=S4jp7-eWAcMa0X417U7P6HkTL1j3v8ffQA-nneh9wY0,549
|
|
13
13
|
programasweights/runtime/interpreter.py,sha256=brYCtatSsu23lq87cuki4MViqZX6U32LBw7Z3USbQmA,19632
|
|
14
14
|
programasweights/runtime/interpreter_onnx.py,sha256=kzYKmwg_h0tVhoQlixJGKoHPVhcCK22AcHG59oeYX2Q,21559
|
|
15
|
-
programasweights-0.2.
|
|
16
|
-
programasweights-0.2.
|
|
17
|
-
programasweights-0.2.
|
|
18
|
-
programasweights-0.2.
|
|
19
|
-
programasweights-0.2.
|
|
15
|
+
programasweights-0.2.4.dist-info/METADATA,sha256=AoTSUtBPVXNEyLjMYIoz4pz2AQDVwgpQoyLGZLjIGtY,5913
|
|
16
|
+
programasweights-0.2.4.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
17
|
+
programasweights-0.2.4.dist-info/entry_points.txt,sha256=l4ZnfCPU0oMzhGB9T2Fv9AnDbSCMM70KUUJVtSvMJBc,50
|
|
18
|
+
programasweights-0.2.4.dist-info/licenses/LICENSE,sha256=6GRcDlVhbPMVgkKqBt0cgwyvtvFxpdp4s2vcYKST4r0,1073
|
|
19
|
+
programasweights-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|