Skip to content

Commit 3788eb5

Browse files
committed
Add license
1 parent b8a91dd commit 3788eb5

4 files changed

Lines changed: 95 additions & 15 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Thassilo M. Schiepanski
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.

README.md

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,77 @@
1-
# D2Snap
1+
<h1 align="center">D2Snap</h1>
22

33
![Example of downsampling on an image (top) and a DOM (bottom) instance](./.github/downsampling.png)
44

5-
**D2Snap** is a first-of-its-kind DOM downsampling algorithm, designed for use with LLM-based web agents.
5+
**D2Snap** is a first-of-its-kind DOM downsampling algorithm, designed for use with LLM-based web agents.
66

7-
### Setup
7+
##
8+
9+
### Integrate
10+
11+
``` ts
12+
D2Snap.d2Snap(
13+
dom: DOM,
14+
k: number, l: number, m: number,
15+
options?: Options
16+
): Promise<string>
17+
18+
D2Snap.d2Snap(
19+
dom: DOM,
20+
maxTokens: number = 4096,
21+
maxIterations: number = 5,
22+
options?: Options
23+
): Promise<string>
24+
```
25+
26+
``` ts
27+
type DOM = Document | Element | string;
28+
type Options = {
29+
assignUniqueIDs?: boolean; // false
30+
debug?: boolean; // true
31+
};
32+
```
33+
34+
#### Browser
35+
36+
``` html
37+
<script src="https://cdn.jsdelivr.net/gh/surfly/D2Snap@main/dist/D2Snap.browser.js"></script>
38+
```
39+
40+
#### Module
841

942
``` console
10-
npm install
43+
npm install surfly/D2Snap
1144
```
1245

13-
> Provide LLM API provider key(s) to .env (compare [example](./.env.example)).
46+
``` js
47+
import { d2Snap, adaptiveD2Snap } from "@surfly/d2snap";
48+
```
49+
50+
##
1451

15-
##
52+
### Experiment
1653

17-
### Build
54+
#### Setup
55+
56+
``` console
57+
npm install
58+
```
59+
60+
#### Build
1861

1962
``` console
2063
npm run build
2164
```
2265

23-
### Test
66+
#### Test
2467

2568
``` console
2669
npm run test
2770
```
2871

29-
### Evaluate
72+
#### Evaluate
73+
74+
> Provide LLM API provider key(s) to .env (compare [example](./.env.example)).
3075
3176
``` console
3277
npm run eval:<snapshot>
@@ -38,8 +83,20 @@ npm run eval:<snapshot>
3883
npm run eval:D2Snap -- --verbose --split 10,20 --provider openai --model gpt-4o
3984
```
4085

41-
### Re-create Snapshots
86+
#### Re-create Snapshots
4287

4388
``` console
4489
npm run snapshots:create
45-
```
90+
```
91+
92+
##
93+
94+
<p align="center">
95+
<strong>Beyond Pixels: Exploring DOM Downsampling for LLM-Based Web Agents</strong>
96+
<br>
97+
<sub><a href="https://github.com/t-ski" target="_blank">Thassilo M. Schiepanski</a></sub>
98+
&hairsp;
99+
<sub><a href="https://nl.linkedin.com/in/nicholasp" target="_blank">Nicholas Piël</a></sub>
100+
<br>
101+
<sub>Surfly BV</sub>
102+
</p>

inject/_inject.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ document
1010
console.log(document.body.innerHTML);
1111

1212
presentSnapshot(
13-
await D2Snap.d2Snap(2, 5, 0.375, {
13+
await D2Snap.d2Snap(0.7, 0.7, 0.7, {
1414
debug: true
1515
}),
16-
{ k: 2, l: 5, m: 0.375 }
16+
{ k: 0.7, l: 0.7, m: 0.7 }
1717
);
1818
presentSnapshot(
19-
await D2Snap.d2Snap(4, 2, 0.6, {
19+
await D2Snap.d2Snap(0.2, 0.4, 0.6, {
2020
debug: true
2121
}),
22-
{ k: 4, l: 2, m: 0.6 }
22+
{ k: 0.2, l: 0.4, m: 0.6 }
2323
);
2424
presentSnapshot(
2525
await D2Snap.adaptiveD2Snap(undefined, undefined, {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"private": true,
3+
"name": "@surfly/d2snap",
4+
"version": "1.0.0",
35
"author": "Thassilo M. Schiepanski",
46
"type": "module",
57
"scripts": {

0 commit comments

Comments
 (0)