webmarker-js 0.2.0 → 0.3.0
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.
- package/README.md +16 -16
- package/dist/index.d.ts +2 -2
- package/package.json +2 -2
- package/src/index.ts +2 -2
package/README.md
CHANGED
@@ -11,7 +11,7 @@ Mark web pages for use with vision-language models.
|
|
11
11
|
|
12
12
|
## Overview
|
13
13
|
|
14
|
-
**WebMarker** adds visual markings with labels to elements on a web page. This can be used for [Set-of-Mark
|
14
|
+
**WebMarker** adds visual markings with labels to elements on a web page. This can be used for [Set-of-Mark](https://github.com/microsoft/SoM) prompting, which improves visual grounding abilities of vision-language models such as GPT-4o, Claude 3.5, and Google Gemini 1.5.
|
15
15
|
|
16
16
|

|
17
17
|
|
@@ -89,6 +89,13 @@ A custom CSS selector to specify which elements to mark.
|
|
89
89
|
- Type: `string`
|
90
90
|
- Default: `"button, input, a, select, textarea"`
|
91
91
|
|
92
|
+
### getLabel
|
93
|
+
|
94
|
+
Provide a function for generating labels. By default, labels are generated as integers starting from 0.
|
95
|
+
|
96
|
+
- Type: `(element: Element, index: number) => string`
|
97
|
+
- Default: `(_, index) => index.toString()`
|
98
|
+
|
92
99
|
### markAttribute
|
93
100
|
|
94
101
|
A custom attribute to add to the marked elements. This attribute contains the label of the mark.
|
@@ -96,13 +103,6 @@ A custom attribute to add to the marked elements. This attribute contains the la
|
|
96
103
|
- Type: `string`
|
97
104
|
- Default: `"data-mark-label"`
|
98
105
|
|
99
|
-
### markStyle
|
100
|
-
|
101
|
-
A CSS style to apply to the label element. You can also specify a function that returns a CSS style object.
|
102
|
-
|
103
|
-
- Type: `Readonly<Partial<CSSStyleDeclaration>> or (element: Element) => Readonly<Partial<CSSStyleDeclaration>>`
|
104
|
-
- Default: `{backgroundColor: "red", color: "white", padding: "2px 4px", fontSize: "12px", fontWeight: "bold"}`
|
105
|
-
|
106
106
|
### markPlacement
|
107
107
|
|
108
108
|
The placement of the mark relative to the element.
|
@@ -110,11 +110,18 @@ The placement of the mark relative to the element.
|
|
110
110
|
- Type: `'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end'`
|
111
111
|
- Default: `'top-start'`
|
112
112
|
|
113
|
+
### markStyle
|
114
|
+
|
115
|
+
A CSS style to apply to the label element. You can also specify a function that returns a CSS style object.
|
116
|
+
|
117
|
+
- Type: `Partial<CSSStyleDeclaration> | (element: Element) => Partial<CSSStyleDeclaration>`
|
118
|
+
- Default: `{backgroundColor: "red", color: "white", padding: "2px 4px", fontSize: "12px", fontWeight: "bold"}`
|
119
|
+
|
113
120
|
### boundingBoxStyle
|
114
121
|
|
115
122
|
A CSS style to apply to the bounding box element. You can also specify a function that returns a CSS style object. Bounding boxes are only shown if showBoundingBoxes is true.
|
116
123
|
|
117
|
-
- Type: `
|
124
|
+
- Type: `Partial<CSSStyleDeclaration> | (element: Element) => Partial<CSSStyleDeclaration>`
|
118
125
|
- Default: `{outline: "2px dashed red", backgroundColor: "transparent"}`
|
119
126
|
|
120
127
|
### showBoundingBoxes
|
@@ -124,13 +131,6 @@ Whether or not to show bounding boxes around the elements.
|
|
124
131
|
- Type: `boolean`
|
125
132
|
- Default: `true`
|
126
133
|
|
127
|
-
### getLabel
|
128
|
-
|
129
|
-
Provide a function for generating labels. By default, labels are generated as integers starting from 0.
|
130
|
-
|
131
|
-
- Type: `(element: Element, index: number) => string`
|
132
|
-
- Default: `(_, index) => index.toString()`
|
133
|
-
|
134
134
|
### containerElement
|
135
135
|
|
136
136
|
Provide a container element to query the elements to be marked. By default, the container element is document.body.
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
type Placement = "top" | "top-start" | "top-end" | "right" | "right-start" | "right-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end";
|
2
|
-
type StyleFunction = (element: Element) => CSSStyleDeclaration
|
3
|
-
type StyleObject =
|
2
|
+
type StyleFunction = (element: Element) => Partial<CSSStyleDeclaration>;
|
3
|
+
type StyleObject = Partial<CSSStyleDeclaration>;
|
4
4
|
interface MarkOptions {
|
5
5
|
/**
|
6
6
|
* A CSS selector to query the elements to be marked.
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "webmarker-js",
|
3
|
-
"version": "0.
|
4
|
-
"description": "A library for marking web pages for Set-of-Mark
|
3
|
+
"version": "0.3.0",
|
4
|
+
"description": "A library for marking web pages for Set-of-Mark prompting with vision-language models.",
|
5
5
|
"source": "src/index.ts",
|
6
6
|
"main": "dist/main.js",
|
7
7
|
"module": "dist/module.js",
|
package/src/index.ts
CHANGED
@@ -14,8 +14,8 @@ type Placement =
|
|
14
14
|
| "left-start"
|
15
15
|
| "left-end";
|
16
16
|
|
17
|
-
type StyleFunction = (element: Element) => CSSStyleDeclaration
|
18
|
-
type StyleObject =
|
17
|
+
type StyleFunction = (element: Element) => Partial<CSSStyleDeclaration>;
|
18
|
+
type StyleObject = Partial<CSSStyleDeclaration>;
|
19
19
|
|
20
20
|
interface MarkOptions {
|
21
21
|
/**
|