polanyi 0.3.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.
- polanyi-0.3.0/.gitignore +17 -0
- polanyi-0.3.0/LICENSE +190 -0
- polanyi-0.3.0/PKG-INFO +212 -0
- polanyi-0.3.0/README.md +174 -0
- polanyi-0.3.0/pyproject.toml +75 -0
- polanyi-0.3.0/schemas/browser_use_recsys_event.schema.json +61 -0
- polanyi-0.3.0/src/polanyi/__init__.py +23 -0
- polanyi-0.3.0/src/polanyi/browser/__init__.py +209 -0
- polanyi-0.3.0/src/polanyi/cli.py +284 -0
- polanyi-0.3.0/src/polanyi/client.py +331 -0
- polanyi-0.3.0/src/polanyi/config.py +78 -0
- polanyi-0.3.0/src/polanyi/diagnose.py +145 -0
- polanyi-0.3.0/src/polanyi/events/__init__.py +92 -0
- polanyi-0.3.0/src/polanyi/events/mapper.py +121 -0
- polanyi-0.3.0/src/polanyi/export/__init__.py +28 -0
- polanyi-0.3.0/src/polanyi/personas/__init__.py +274 -0
- polanyi-0.3.0/src/polanyi/planner.py +877 -0
- polanyi-0.3.0/src/polanyi/remote.py +237 -0
- polanyi-0.3.0/src/polanyi/schema/__init__.py +148 -0
- polanyi-0.3.0/src/polanyi/server/__init__.py +5 -0
- polanyi-0.3.0/src/polanyi/server/app.py +267 -0
- polanyi-0.3.0/src/polanyi/site.py +99 -0
polanyi-0.3.0/.gitignore
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.env
|
|
2
|
+
.venv/
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
.mypy_cache/
|
|
7
|
+
.ruff_cache/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
.DS_Store
|
|
11
|
+
|
|
12
|
+
# ignore raw dump, keep sample dataset outputs
|
|
13
|
+
output/browser_use_raw.json
|
|
14
|
+
!output/.gitkeep
|
|
15
|
+
!output/persona.json
|
|
16
|
+
!output/recsys_events.jsonl
|
|
17
|
+
!output/recsys_events.parquet
|
polanyi-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Polanyi Labs
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
polanyi-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: polanyi
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Synthetic shoppers hard-pinned to any website that emit recommendation-system event data.
|
|
5
|
+
Project-URL: Homepage, https://github.com/tmoula/polanyi_agent_harness
|
|
6
|
+
Project-URL: Repository, https://github.com/tmoula/polanyi_agent_harness
|
|
7
|
+
Project-URL: Issues, https://github.com/tmoula/polanyi_agent_harness/issues
|
|
8
|
+
Author: Polanyi Labs
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: browser-agents,personas,recommendation-systems,recsys,synthetic-data
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: browser-use-sdk>=3.11.0
|
|
23
|
+
Requires-Dist: datasets>=3.0.0
|
|
24
|
+
Requires-Dist: httpx>=0.27.0
|
|
25
|
+
Requires-Dist: pandas>=2.2.0
|
|
26
|
+
Requires-Dist: pyarrow>=17.0.0
|
|
27
|
+
Requires-Dist: pydantic>=2.7.0
|
|
28
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: fastapi>=0.115.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: httpx>=0.27.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: uvicorn[standard]>=0.30.0; extra == 'dev'
|
|
34
|
+
Provides-Extra: server
|
|
35
|
+
Requires-Dist: fastapi>=0.115.0; extra == 'server'
|
|
36
|
+
Requires-Dist: uvicorn[standard]>=0.30.0; extra == 'server'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# Polanyi
|
|
40
|
+
|
|
41
|
+
**Synthetic shoppers hard-pinned to any website → recommendation-system event logs.**
|
|
42
|
+
|
|
43
|
+
Point Polanyi at a URL. It runs a diverse set of Nemotron personas as on-site shoppers (search, compare, select, stop before PII/payment) and emits privacy-safe `recsys_events` for offline experiments.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install polanyi
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
From source:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cd polanyi_agent_harness
|
|
55
|
+
python -m venv .venv
|
|
56
|
+
source .venv/bin/activate
|
|
57
|
+
pip install -e ".[dev]"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Colab / product path (`POLANYI_API_KEY`)
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import os
|
|
64
|
+
os.environ["POLANYI_API_KEY"] = "pk_live_..." # from Polanyi
|
|
65
|
+
|
|
66
|
+
from polanyi import Client
|
|
67
|
+
|
|
68
|
+
client = Client() # talks to https://api.polanyi.ai
|
|
69
|
+
result = client.simulate(site="https://www.nike.com", n=5, concurrency=5)
|
|
70
|
+
print(result.summary())
|
|
71
|
+
result.to_jsonl("nike_events.jsonl")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
While the hosted API is warming up, point the SDK at your own server:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
os.environ["POLANYI_API_KEY"] = "pk_live_dev"
|
|
78
|
+
os.environ["POLANYI_API_BASE_URL"] = "http://127.0.0.1:8080"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Local / power-user path (`BROWSER_USE_API_KEY`)
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
cp .env.example .env
|
|
85
|
+
# BROWSER_USE_API_KEY=bu_...
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from polanyi import Client
|
|
90
|
+
|
|
91
|
+
client = Client() # uses Browser Use Cloud directly
|
|
92
|
+
result = client.simulate(
|
|
93
|
+
site="https://www.expedia.com",
|
|
94
|
+
n=10,
|
|
95
|
+
concurrency=5,
|
|
96
|
+
output_dir="runs/expedia",
|
|
97
|
+
)
|
|
98
|
+
print(result.summary())
|
|
99
|
+
result.to_jsonl("runs/expedia/merged.jsonl")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Agents are **hard-pinned**: they start on your site and must not leave that domain. External “Book with…” handoffs stop with `checkout_boundary_stop` (first-party-shaped data).
|
|
103
|
+
|
|
104
|
+
## Host your own Polanyi API
|
|
105
|
+
|
|
106
|
+
The server wraps Browser Use behind `POLANYI_API_KEY` auth so end users never see `bu_…` keys.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pip install "polanyi[server]"
|
|
110
|
+
|
|
111
|
+
# mint a customer key
|
|
112
|
+
polanyi-serve --generate-key
|
|
113
|
+
# → pk_live_...
|
|
114
|
+
|
|
115
|
+
export POLANYI_API_KEYS=pk_live_...
|
|
116
|
+
export BROWSER_USE_API_KEY=bu_... # stays on the server only
|
|
117
|
+
polanyi-serve --host 0.0.0.0 --port 8080
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Docker:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
docker build -t polanyi-api .
|
|
124
|
+
docker run --rm -p 8080:8080 \
|
|
125
|
+
-e POLANYI_API_KEYS=pk_live_... \
|
|
126
|
+
-e BROWSER_USE_API_KEY=bu_... \
|
|
127
|
+
polanyi-api
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
API surface:
|
|
131
|
+
|
|
132
|
+
| Method | Path | Purpose |
|
|
133
|
+
|--------|------|---------|
|
|
134
|
+
| `GET` | `/health` | Liveness |
|
|
135
|
+
| `POST` | `/v1/simulations` | Start a job (Bearer `pk_…`) |
|
|
136
|
+
| `GET` | `/v1/simulations/{id}` | Poll status + events |
|
|
137
|
+
|
|
138
|
+
## CLI
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Any site, N diverse personas
|
|
142
|
+
polanyi-sim --site https://www.nike.com --batch 5 --concurrency 5 \
|
|
143
|
+
--output-dir output/nike_run
|
|
144
|
+
|
|
145
|
+
# Optional journey brief
|
|
146
|
+
polanyi-sim --site expedia.com --batch 10 --concurrency 10 \
|
|
147
|
+
--prompt "Browse hotels and flights; pick what fits your budget." \
|
|
148
|
+
--output-dir output/expedia_run
|
|
149
|
+
|
|
150
|
+
# Dry-run (personas only, no Browser Use)
|
|
151
|
+
polanyi-sim --site example.com --batch 3 --dry-run-persona --output-dir output/dry
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Legacy (no `--site`) still works but is **not** hard-pinned.
|
|
155
|
+
|
|
156
|
+
## Outputs
|
|
157
|
+
|
|
158
|
+
Each session directory contains:
|
|
159
|
+
|
|
160
|
+
| File | Purpose |
|
|
161
|
+
|------|---------|
|
|
162
|
+
| `persona.json` | Synthetic identity |
|
|
163
|
+
| `browser_use_raw.json` | Raw Browser Use run |
|
|
164
|
+
| `recsys_events.jsonl` / `.parquet` | Ordered recsys events |
|
|
165
|
+
| `simulate_meta.json` | Site + run config (SDK / `--site` runs) |
|
|
166
|
+
| `simulate_plan.json` | Inferred vertical + per-persona journey goals |
|
|
167
|
+
|
|
168
|
+
## How journeys are planned
|
|
169
|
+
|
|
170
|
+
Live runs (`Client.simulate` / `polanyi-sim --site` without `--dry-run-persona`):
|
|
171
|
+
|
|
172
|
+
1. **LLM diagnosis** — a Browser Use agent opens the real site and returns an accurate JSON profile (`site_name`, `vertical`, `description`, `journey_templates`)
|
|
173
|
+
2. Saved to `simulate_diagnosis.json`
|
|
174
|
+
3. Each persona gets a different template from that diagnosis, personalized with their location/budget
|
|
175
|
+
|
|
176
|
+
Dry-runs skip the LLM and fall back to URL heuristics only.
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from polanyi import diagnose_site, plan_journeys
|
|
180
|
+
from polanyi.personas import load_personas
|
|
181
|
+
|
|
182
|
+
diagnosis = diagnose_site("https://www.ticketnetwork.com")
|
|
183
|
+
print(diagnosis.site_name, diagnosis.vertical)
|
|
184
|
+
print(diagnosis.description)
|
|
185
|
+
plan = plan_journeys("https://www.ticketnetwork.com", load_personas(count=3), diagnosis=diagnosis)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Safety
|
|
189
|
+
|
|
190
|
+
- Synthetic actor IDs only (`syn_nmusa_*`)
|
|
191
|
+
- `training_use=offline_sandbox_only`
|
|
192
|
+
- Hard stop before identity / payment
|
|
193
|
+
- Hard site pin (first-party shaped)
|
|
194
|
+
|
|
195
|
+
## Publish to PyPI
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
pip install build twine
|
|
199
|
+
python -m build
|
|
200
|
+
twine upload dist/*
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The `polanyi` name is available on PyPI as of packaging time.
|
|
204
|
+
|
|
205
|
+
## Roadmap
|
|
206
|
+
|
|
207
|
+
1. ~~Schema, personas, Cloud runner, batch concurrency~~
|
|
208
|
+
2. ~~Python SDK `Client.simulate(site=…)` + hard pin~~
|
|
209
|
+
3. ~~LLM site diagnosis → diverse per-persona journeys~~
|
|
210
|
+
4. ~~`POLANYI_API_KEY` + self-hostable API wrapping Browser Use~~
|
|
211
|
+
5. Parse quality gates + JSON repair for agent output
|
|
212
|
+
6. Hosted `api.polanyi.ai` + public PyPI release
|
polanyi-0.3.0/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Polanyi
|
|
2
|
+
|
|
3
|
+
**Synthetic shoppers hard-pinned to any website → recommendation-system event logs.**
|
|
4
|
+
|
|
5
|
+
Point Polanyi at a URL. It runs a diverse set of Nemotron personas as on-site shoppers (search, compare, select, stop before PII/payment) and emits privacy-safe `recsys_events` for offline experiments.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install polanyi
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
From source:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd polanyi_agent_harness
|
|
17
|
+
python -m venv .venv
|
|
18
|
+
source .venv/bin/activate
|
|
19
|
+
pip install -e ".[dev]"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Colab / product path (`POLANYI_API_KEY`)
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import os
|
|
26
|
+
os.environ["POLANYI_API_KEY"] = "pk_live_..." # from Polanyi
|
|
27
|
+
|
|
28
|
+
from polanyi import Client
|
|
29
|
+
|
|
30
|
+
client = Client() # talks to https://api.polanyi.ai
|
|
31
|
+
result = client.simulate(site="https://www.nike.com", n=5, concurrency=5)
|
|
32
|
+
print(result.summary())
|
|
33
|
+
result.to_jsonl("nike_events.jsonl")
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
While the hosted API is warming up, point the SDK at your own server:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
os.environ["POLANYI_API_KEY"] = "pk_live_dev"
|
|
40
|
+
os.environ["POLANYI_API_BASE_URL"] = "http://127.0.0.1:8080"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Local / power-user path (`BROWSER_USE_API_KEY`)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cp .env.example .env
|
|
47
|
+
# BROWSER_USE_API_KEY=bu_...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from polanyi import Client
|
|
52
|
+
|
|
53
|
+
client = Client() # uses Browser Use Cloud directly
|
|
54
|
+
result = client.simulate(
|
|
55
|
+
site="https://www.expedia.com",
|
|
56
|
+
n=10,
|
|
57
|
+
concurrency=5,
|
|
58
|
+
output_dir="runs/expedia",
|
|
59
|
+
)
|
|
60
|
+
print(result.summary())
|
|
61
|
+
result.to_jsonl("runs/expedia/merged.jsonl")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Agents are **hard-pinned**: they start on your site and must not leave that domain. External “Book with…” handoffs stop with `checkout_boundary_stop` (first-party-shaped data).
|
|
65
|
+
|
|
66
|
+
## Host your own Polanyi API
|
|
67
|
+
|
|
68
|
+
The server wraps Browser Use behind `POLANYI_API_KEY` auth so end users never see `bu_…` keys.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install "polanyi[server]"
|
|
72
|
+
|
|
73
|
+
# mint a customer key
|
|
74
|
+
polanyi-serve --generate-key
|
|
75
|
+
# → pk_live_...
|
|
76
|
+
|
|
77
|
+
export POLANYI_API_KEYS=pk_live_...
|
|
78
|
+
export BROWSER_USE_API_KEY=bu_... # stays on the server only
|
|
79
|
+
polanyi-serve --host 0.0.0.0 --port 8080
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Docker:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
docker build -t polanyi-api .
|
|
86
|
+
docker run --rm -p 8080:8080 \
|
|
87
|
+
-e POLANYI_API_KEYS=pk_live_... \
|
|
88
|
+
-e BROWSER_USE_API_KEY=bu_... \
|
|
89
|
+
polanyi-api
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
API surface:
|
|
93
|
+
|
|
94
|
+
| Method | Path | Purpose |
|
|
95
|
+
|--------|------|---------|
|
|
96
|
+
| `GET` | `/health` | Liveness |
|
|
97
|
+
| `POST` | `/v1/simulations` | Start a job (Bearer `pk_…`) |
|
|
98
|
+
| `GET` | `/v1/simulations/{id}` | Poll status + events |
|
|
99
|
+
|
|
100
|
+
## CLI
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Any site, N diverse personas
|
|
104
|
+
polanyi-sim --site https://www.nike.com --batch 5 --concurrency 5 \
|
|
105
|
+
--output-dir output/nike_run
|
|
106
|
+
|
|
107
|
+
# Optional journey brief
|
|
108
|
+
polanyi-sim --site expedia.com --batch 10 --concurrency 10 \
|
|
109
|
+
--prompt "Browse hotels and flights; pick what fits your budget." \
|
|
110
|
+
--output-dir output/expedia_run
|
|
111
|
+
|
|
112
|
+
# Dry-run (personas only, no Browser Use)
|
|
113
|
+
polanyi-sim --site example.com --batch 3 --dry-run-persona --output-dir output/dry
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Legacy (no `--site`) still works but is **not** hard-pinned.
|
|
117
|
+
|
|
118
|
+
## Outputs
|
|
119
|
+
|
|
120
|
+
Each session directory contains:
|
|
121
|
+
|
|
122
|
+
| File | Purpose |
|
|
123
|
+
|------|---------|
|
|
124
|
+
| `persona.json` | Synthetic identity |
|
|
125
|
+
| `browser_use_raw.json` | Raw Browser Use run |
|
|
126
|
+
| `recsys_events.jsonl` / `.parquet` | Ordered recsys events |
|
|
127
|
+
| `simulate_meta.json` | Site + run config (SDK / `--site` runs) |
|
|
128
|
+
| `simulate_plan.json` | Inferred vertical + per-persona journey goals |
|
|
129
|
+
|
|
130
|
+
## How journeys are planned
|
|
131
|
+
|
|
132
|
+
Live runs (`Client.simulate` / `polanyi-sim --site` without `--dry-run-persona`):
|
|
133
|
+
|
|
134
|
+
1. **LLM diagnosis** — a Browser Use agent opens the real site and returns an accurate JSON profile (`site_name`, `vertical`, `description`, `journey_templates`)
|
|
135
|
+
2. Saved to `simulate_diagnosis.json`
|
|
136
|
+
3. Each persona gets a different template from that diagnosis, personalized with their location/budget
|
|
137
|
+
|
|
138
|
+
Dry-runs skip the LLM and fall back to URL heuristics only.
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from polanyi import diagnose_site, plan_journeys
|
|
142
|
+
from polanyi.personas import load_personas
|
|
143
|
+
|
|
144
|
+
diagnosis = diagnose_site("https://www.ticketnetwork.com")
|
|
145
|
+
print(diagnosis.site_name, diagnosis.vertical)
|
|
146
|
+
print(diagnosis.description)
|
|
147
|
+
plan = plan_journeys("https://www.ticketnetwork.com", load_personas(count=3), diagnosis=diagnosis)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Safety
|
|
151
|
+
|
|
152
|
+
- Synthetic actor IDs only (`syn_nmusa_*`)
|
|
153
|
+
- `training_use=offline_sandbox_only`
|
|
154
|
+
- Hard stop before identity / payment
|
|
155
|
+
- Hard site pin (first-party shaped)
|
|
156
|
+
|
|
157
|
+
## Publish to PyPI
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pip install build twine
|
|
161
|
+
python -m build
|
|
162
|
+
twine upload dist/*
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The `polanyi` name is available on PyPI as of packaging time.
|
|
166
|
+
|
|
167
|
+
## Roadmap
|
|
168
|
+
|
|
169
|
+
1. ~~Schema, personas, Cloud runner, batch concurrency~~
|
|
170
|
+
2. ~~Python SDK `Client.simulate(site=…)` + hard pin~~
|
|
171
|
+
3. ~~LLM site diagnosis → diverse per-persona journeys~~
|
|
172
|
+
4. ~~`POLANYI_API_KEY` + self-hostable API wrapping Browser Use~~
|
|
173
|
+
5. Parse quality gates + JSON repair for agent output
|
|
174
|
+
6. Hosted `api.polanyi.ai` + public PyPI release
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "polanyi"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
description = "Synthetic shoppers hard-pinned to any website that emit recommendation-system event data."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Polanyi Labs" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"synthetic-data",
|
|
17
|
+
"recsys",
|
|
18
|
+
"browser-agents",
|
|
19
|
+
"personas",
|
|
20
|
+
"recommendation-systems",
|
|
21
|
+
]
|
|
22
|
+
classifiers = [
|
|
23
|
+
"Development Status :: 3 - Alpha",
|
|
24
|
+
"Intended Audience :: Developers",
|
|
25
|
+
"Intended Audience :: Science/Research",
|
|
26
|
+
"License :: OSI Approved :: Apache Software License",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.11",
|
|
29
|
+
"Programming Language :: Python :: 3.12",
|
|
30
|
+
"Programming Language :: Python :: 3.13",
|
|
31
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
32
|
+
]
|
|
33
|
+
dependencies = [
|
|
34
|
+
"browser-use-sdk>=3.11.0",
|
|
35
|
+
"datasets>=3.0.0",
|
|
36
|
+
"httpx>=0.27.0",
|
|
37
|
+
"pandas>=2.2.0",
|
|
38
|
+
"pyarrow>=17.0.0",
|
|
39
|
+
"pydantic>=2.7.0",
|
|
40
|
+
"python-dotenv>=1.0.0",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
server = [
|
|
45
|
+
"fastapi>=0.115.0",
|
|
46
|
+
"uvicorn[standard]>=0.30.0",
|
|
47
|
+
]
|
|
48
|
+
dev = [
|
|
49
|
+
"pytest>=8.0.0",
|
|
50
|
+
"fastapi>=0.115.0",
|
|
51
|
+
"uvicorn[standard]>=0.30.0",
|
|
52
|
+
"httpx>=0.27.0",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[project.urls]
|
|
56
|
+
Homepage = "https://github.com/tmoula/polanyi_agent_harness"
|
|
57
|
+
Repository = "https://github.com/tmoula/polanyi_agent_harness"
|
|
58
|
+
Issues = "https://github.com/tmoula/polanyi_agent_harness/issues"
|
|
59
|
+
|
|
60
|
+
[project.scripts]
|
|
61
|
+
polanyi-sim = "polanyi.cli:main"
|
|
62
|
+
polanyi-serve = "polanyi.server.app:main"
|
|
63
|
+
|
|
64
|
+
[tool.hatch.build.targets.wheel]
|
|
65
|
+
packages = ["src/polanyi"]
|
|
66
|
+
|
|
67
|
+
[tool.hatch.build.targets.wheel.sources]
|
|
68
|
+
"src/polanyi" = "polanyi"
|
|
69
|
+
|
|
70
|
+
[tool.hatch.build.targets.sdist]
|
|
71
|
+
include = ["src/polanyi", "schemas", "README.md", "LICENSE"]
|
|
72
|
+
|
|
73
|
+
[tool.pytest.ini_options]
|
|
74
|
+
testpaths = ["tests"]
|
|
75
|
+
pythonpath = ["src"]
|