toblab commited on
Commit
8688eba
1 Parent(s): 3325b24

Upload folder using huggingface_hub

Browse files
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ FROM python:3.9
3
+
4
+ WORKDIR /code
5
+
6
+ COPY --link --chown=1000 . .
7
+
8
+ RUN mkdir -p /tmp/cache/
9
+ RUN chmod a+rwx -R /tmp/cache/
10
+ ENV TRANSFORMERS_CACHE=/tmp/cache/
11
+
12
+ RUN pip install --no-cache-dir -r requirements.txt
13
+
14
+ ENV PYTHONUNBUFFERED=1 GRADIO_ALLOW_FLAGGING=never GRADIO_NUM_PORTS=1 GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 SYSTEM=spaces
15
+
16
+ CMD ["python", "space.py"]
README.md CHANGED
@@ -1,10 +1,17 @@
 
1
  ---
2
- title: Gradio Highlightedtextlabeldefault
3
- emoji: 🔥
4
- colorFrom: yellow
5
- colorTo: blue
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
1
+
2
  ---
3
+ tags: [gradio-custom-component,gradio-template-HighlightedText]
4
+ title: gradio_highlightedtextlabeldefault V0.0.1
5
+ colorFrom: gray
6
+ colorTo: red
7
  sdk: docker
8
  pinned: false
9
+ license: apache-2.0
10
  ---
11
 
12
+
13
+ # Name: gradio_highlightedtextlabeldefault
14
+
15
+ Description: Modify the default label when selecting a word in the interactive HighlightedText component.
16
+
17
+ Install with: pip install gradio_highlightedtextlabeldefault
__init__.py ADDED
File without changes
__pycache__/__init__.cpython-311.pyc ADDED
Binary file (185 Bytes). View file
 
__pycache__/app.cpython-311.pyc ADDED
Binary file (1.31 kB). View file
 
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from gradio_highlightedtextlabeldefault import HighlightedTextLabelDefault
4
+
5
+
6
+ example = HighlightedTextLabelDefault().example_value()
7
+
8
+ with gr.Blocks() as demo:
9
+ with gr.Row():
10
+ test_1 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]),
11
+ label="Double click word to see standard default label", interactive=True) # default label
12
+ test_2 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]), label="Double click word to see modified default label",
13
+ interactive=True, default_label="x", color_map={"x": "green"}) # blank component
14
+
15
+
16
+ if __name__ == "__main__":
17
+ demo.launch()
css.css ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html {
2
+ font-family: Inter;
3
+ font-size: 16px;
4
+ font-weight: 400;
5
+ line-height: 1.5;
6
+ -webkit-text-size-adjust: 100%;
7
+ background: #fff;
8
+ color: #323232;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ text-rendering: optimizeLegibility;
12
+ }
13
+
14
+ :root {
15
+ --space: 1;
16
+ --vspace: calc(var(--space) * 1rem);
17
+ --vspace-0: calc(3 * var(--space) * 1rem);
18
+ --vspace-1: calc(2 * var(--space) * 1rem);
19
+ --vspace-2: calc(1.5 * var(--space) * 1rem);
20
+ --vspace-3: calc(0.5 * var(--space) * 1rem);
21
+ }
22
+
23
+ .app {
24
+ max-width: 748px !important;
25
+ }
26
+
27
+ .prose p {
28
+ margin: var(--vspace) 0;
29
+ line-height: var(--vspace * 2);
30
+ font-size: 1rem;
31
+ }
32
+
33
+ code {
34
+ font-family: "Inconsolata", sans-serif;
35
+ font-size: 16px;
36
+ }
37
+
38
+ h1,
39
+ h1 code {
40
+ font-weight: 400;
41
+ line-height: calc(2.5 / var(--space) * var(--vspace));
42
+ }
43
+
44
+ h1 code {
45
+ background: none;
46
+ border: none;
47
+ letter-spacing: 0.05em;
48
+ padding-bottom: 5px;
49
+ position: relative;
50
+ padding: 0;
51
+ }
52
+
53
+ h2 {
54
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
55
+ line-height: 1em;
56
+ }
57
+
58
+ h3,
59
+ h3 code {
60
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
61
+ line-height: 1em;
62
+ }
63
+
64
+ h4,
65
+ h5,
66
+ h6 {
67
+ margin: var(--vspace-3) 0 var(--vspace-3) 0;
68
+ line-height: var(--vspace);
69
+ }
70
+
71
+ .bigtitle,
72
+ h1,
73
+ h1 code {
74
+ font-size: calc(8px * 4.5);
75
+ word-break: break-word;
76
+ }
77
+
78
+ .title,
79
+ h2,
80
+ h2 code {
81
+ font-size: calc(8px * 3.375);
82
+ font-weight: lighter;
83
+ word-break: break-word;
84
+ border: none;
85
+ background: none;
86
+ }
87
+
88
+ .subheading1,
89
+ h3,
90
+ h3 code {
91
+ font-size: calc(8px * 1.8);
92
+ font-weight: 600;
93
+ border: none;
94
+ background: none;
95
+ letter-spacing: 0.1em;
96
+ text-transform: uppercase;
97
+ }
98
+
99
+ h2 code {
100
+ padding: 0;
101
+ position: relative;
102
+ letter-spacing: 0.05em;
103
+ }
104
+
105
+ blockquote {
106
+ font-size: calc(8px * 1.1667);
107
+ font-style: italic;
108
+ line-height: calc(1.1667 * var(--vspace));
109
+ margin: var(--vspace-2) var(--vspace-2);
110
+ }
111
+
112
+ .subheading2,
113
+ h4 {
114
+ font-size: calc(8px * 1.4292);
115
+ text-transform: uppercase;
116
+ font-weight: 600;
117
+ }
118
+
119
+ .subheading3,
120
+ h5 {
121
+ font-size: calc(8px * 1.2917);
122
+ line-height: calc(1.2917 * var(--vspace));
123
+
124
+ font-weight: lighter;
125
+ text-transform: uppercase;
126
+ letter-spacing: 0.15em;
127
+ }
128
+
129
+ h6 {
130
+ font-size: calc(8px * 1.1667);
131
+ font-size: 1.1667em;
132
+ font-weight: normal;
133
+ font-style: italic;
134
+ font-family: "le-monde-livre-classic-byol", serif !important;
135
+ letter-spacing: 0px !important;
136
+ }
137
+
138
+ #start .md > *:first-child {
139
+ margin-top: 0;
140
+ }
141
+
142
+ h2 + h3 {
143
+ margin-top: 0;
144
+ }
145
+
146
+ .md hr {
147
+ border: none;
148
+ border-top: 1px solid var(--block-border-color);
149
+ margin: var(--vspace-2) 0 var(--vspace-2) 0;
150
+ }
151
+ .prose ul {
152
+ margin: var(--vspace-2) 0 var(--vspace-1) 0;
153
+ }
154
+
155
+ .gap {
156
+ gap: 0;
157
+ }
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio_highlightedtextlabeldefault==0.0.1
space.py ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from app import demo as app
4
+ import os
5
+
6
+ _docs = {'HighlightedTextLabelDefault': {'description': 'Displays text that contains spans that are highlighted by category or numerical value.\n', 'members': {'__init__': {'value': {'type': 'list[tuple[str, str | float | None]]\n | dict\n | Callable\n | None', 'default': 'None', 'description': 'Default value to show. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'color_map': {'type': 'dict[str, str] | None', 'default': 'None', 'description': 'A dictionary mapping labels to colors. The colors may be specified as hex codes or by their names. For example: {"person": "red", "location": "#FFEE22"}'}, 'show_legend': {'type': 'bool', 'default': 'False', 'description': 'whether to show span categories in a separate legend or inline.'}, 'combine_adjacent': {'type': 'bool', 'default': 'False', 'description': 'If True, will merge the labels of adjacent tokens belonging to the same category.'}, 'adjacent_separator': {'type': 'str', 'default': '""', 'description': 'Specifies the separator to be used between tokens if combine_adjacent is True.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'If True, the component will be editable, and allow user to select spans of text and label them.'}, 'default_label': {'type': 'str | None', 'default': 'None', 'description': None}}, 'postprocess': {'value': {'type': 'list[tuple[str, str | float | None]] | dict | None', 'description': 'Expects a list of (word, category) tuples, or a dictionary of two keys: "text", and "entities", which itself is a list of dictionaries, each of which have the keys: "entity" (or "entity_group"), "start", and "end"'}}, 'preprocess': {'return': {'type': 'list[tuple[str, str | float | None]] | None', 'description': 'Passes the value as a list of tuples as a `list[tuple]` into the function. Each `tuple` consists of a `str` substring of the text (so the entire text is included) and `str | float | None` label, which is the category or confidence of that substring.'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the HighlightedTextLabelDefault changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'select': {'type': None, 'default': None, 'description': 'Event listener for when the user selects or deselects the HighlightedTextLabelDefault. Uses event data gradio.SelectData to carry `value` referring to the label of the HighlightedTextLabelDefault, and `selected` to refer to state of the HighlightedTextLabelDefault. See EventData documentation on how to use this event data'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'HighlightedTextLabelDefault': []}}}
7
+
8
+ abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
+
10
+ with gr.Blocks(
11
+ css=abs_path,
12
+ theme=gr.themes.Default(
13
+ font_mono=[
14
+ gr.themes.GoogleFont("Inconsolata"),
15
+ "monospace",
16
+ ],
17
+ ),
18
+ ) as demo:
19
+ gr.Markdown(
20
+ """
21
+ # `gradio_highlightedtextlabeldefault`
22
+
23
+ <div style="display: flex; gap: 7px;">
24
+ <img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
25
+ </div>
26
+
27
+ Modify the default label when selecting a word in the interactive HighlightedText component.
28
+ """, elem_classes=["md-custom"], header_links=True)
29
+ app.render()
30
+ gr.Markdown(
31
+ """
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install gradio_highlightedtextlabeldefault
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+
42
+ import gradio as gr
43
+ from gradio_highlightedtextlabeldefault import HighlightedTextLabelDefault
44
+
45
+
46
+ example = HighlightedTextLabelDefault().example_value()
47
+
48
+ with gr.Blocks() as demo:
49
+ with gr.Row():
50
+ test_1 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]),
51
+ label="Double click word to see standard default label", interactive=True) # default label
52
+ test_2 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]), label="Double click word to see modified default label",
53
+ interactive=True, default_label="x", color_map={"x": "green"}) # blank component
54
+
55
+
56
+ if __name__ == "__main__":
57
+ demo.launch()
58
+
59
+ ```
60
+ """, elem_classes=["md-custom"], header_links=True)
61
+
62
+
63
+ gr.Markdown("""
64
+ ## `HighlightedTextLabelDefault`
65
+
66
+ ### Initialization
67
+ """, elem_classes=["md-custom"], header_links=True)
68
+
69
+ gr.ParamViewer(value=_docs["HighlightedTextLabelDefault"]["members"]["__init__"], linkify=[])
70
+
71
+
72
+ gr.Markdown("### Events")
73
+ gr.ParamViewer(value=_docs["HighlightedTextLabelDefault"]["events"], linkify=['Event'])
74
+
75
+
76
+
77
+
78
+ gr.Markdown("""
79
+
80
+ ### User function
81
+
82
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
83
+
84
+ - When used as an Input, the component only impacts the input signature of the user function.
85
+ - When used as an output, the component only impacts the return signature of the user function.
86
+
87
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
88
+
89
+ - **As input:** Is passed, passes the value as a list of tuples as a `list[tuple]` into the function. Each `tuple` consists of a `str` substring of the text (so the entire text is included) and `str | float | None` label, which is the category or confidence of that substring.
90
+ - **As output:** Should return, expects a list of (word, category) tuples, or a dictionary of two keys: "text", and "entities", which itself is a list of dictionaries, each of which have the keys: "entity" (or "entity_group"), "start", and "end".
91
+
92
+ ```python
93
+ def predict(
94
+ value: list[tuple[str, str | float | None]] | None
95
+ ) -> list[tuple[str, str | float | None]] | dict | None:
96
+ return value
97
+ ```
98
+ """, elem_classes=["md-custom", "HighlightedTextLabelDefault-user-fn"], header_links=True)
99
+
100
+
101
+
102
+
103
+ demo.load(None, js=r"""function() {
104
+ const refs = {};
105
+ const user_fn_refs = {
106
+ HighlightedTextLabelDefault: [], };
107
+ requestAnimationFrame(() => {
108
+
109
+ Object.entries(user_fn_refs).forEach(([key, refs]) => {
110
+ if (refs.length > 0) {
111
+ const el = document.querySelector(`.${key}-user-fn`);
112
+ if (!el) return;
113
+ refs.forEach(ref => {
114
+ el.innerHTML = el.innerHTML.replace(
115
+ new RegExp("\\b"+ref+"\\b", "g"),
116
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
117
+ );
118
+ })
119
+ }
120
+ })
121
+
122
+ Object.entries(refs).forEach(([key, refs]) => {
123
+ if (refs.length > 0) {
124
+ const el = document.querySelector(`.${key}`);
125
+ if (!el) return;
126
+ refs.forEach(ref => {
127
+ el.innerHTML = el.innerHTML.replace(
128
+ new RegExp("\\b"+ref+"\\b", "g"),
129
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
130
+ );
131
+ })
132
+ }
133
+ })
134
+ })
135
+ }
136
+
137
+ """)
138
+
139
+ demo.launch()
src/.gitignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ .eggs/
2
+ dist/
3
+ *.pyc
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+ __tmp/*
8
+ *.pyi
9
+ node_modules
src/README.md ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # `gradio_highlightedtextlabeldefault`
3
+ <img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
4
+
5
+ Modify the default label when selecting a word in the interactive HighlightedText component.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install gradio_highlightedtextlabeldefault
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```python
16
+
17
+ import gradio as gr
18
+ from gradio_highlightedtextlabeldefault import HighlightedTextLabelDefault
19
+
20
+
21
+ example = HighlightedTextLabelDefault().example_value()
22
+
23
+ with gr.Blocks() as demo:
24
+ with gr.Row():
25
+ test_1 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]),
26
+ label="Double click word to see standard default label", interactive=True) # default label
27
+ test_2 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]), label="Double click word to see modified default label",
28
+ interactive=True, default_label="x", color_map={"x": "green"}) # blank component
29
+
30
+
31
+ if __name__ == "__main__":
32
+ demo.launch()
33
+
34
+ ```
35
+
36
+ ## `HighlightedTextLabelDefault`
37
+
38
+ ### Initialization
39
+
40
+ <table>
41
+ <thead>
42
+ <tr>
43
+ <th align="left">name</th>
44
+ <th align="left" style="width: 25%;">type</th>
45
+ <th align="left">default</th>
46
+ <th align="left">description</th>
47
+ </tr>
48
+ </thead>
49
+ <tbody>
50
+ <tr>
51
+ <td align="left"><code>value</code></td>
52
+ <td align="left" style="width: 25%;">
53
+
54
+ ```python
55
+ list[tuple[str, str | float | None]]
56
+ | dict
57
+ | Callable
58
+ | None
59
+ ```
60
+
61
+ </td>
62
+ <td align="left"><code>None</code></td>
63
+ <td align="left">Default value to show. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>
64
+ </tr>
65
+
66
+ <tr>
67
+ <td align="left"><code>color_map</code></td>
68
+ <td align="left" style="width: 25%;">
69
+
70
+ ```python
71
+ dict[str, str] | None
72
+ ```
73
+
74
+ </td>
75
+ <td align="left"><code>None</code></td>
76
+ <td align="left">A dictionary mapping labels to colors. The colors may be specified as hex codes or by their names. For example: {"person": "red", "location": "#FFEE22"}</td>
77
+ </tr>
78
+
79
+ <tr>
80
+ <td align="left"><code>show_legend</code></td>
81
+ <td align="left" style="width: 25%;">
82
+
83
+ ```python
84
+ bool
85
+ ```
86
+
87
+ </td>
88
+ <td align="left"><code>False</code></td>
89
+ <td align="left">whether to show span categories in a separate legend or inline.</td>
90
+ </tr>
91
+
92
+ <tr>
93
+ <td align="left"><code>combine_adjacent</code></td>
94
+ <td align="left" style="width: 25%;">
95
+
96
+ ```python
97
+ bool
98
+ ```
99
+
100
+ </td>
101
+ <td align="left"><code>False</code></td>
102
+ <td align="left">If True, will merge the labels of adjacent tokens belonging to the same category.</td>
103
+ </tr>
104
+
105
+ <tr>
106
+ <td align="left"><code>adjacent_separator</code></td>
107
+ <td align="left" style="width: 25%;">
108
+
109
+ ```python
110
+ str
111
+ ```
112
+
113
+ </td>
114
+ <td align="left"><code>""</code></td>
115
+ <td align="left">Specifies the separator to be used between tokens if combine_adjacent is True.</td>
116
+ </tr>
117
+
118
+ <tr>
119
+ <td align="left"><code>label</code></td>
120
+ <td align="left" style="width: 25%;">
121
+
122
+ ```python
123
+ str | None
124
+ ```
125
+
126
+ </td>
127
+ <td align="left"><code>None</code></td>
128
+ <td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
129
+ </tr>
130
+
131
+ <tr>
132
+ <td align="left"><code>every</code></td>
133
+ <td align="left" style="width: 25%;">
134
+
135
+ ```python
136
+ float | None
137
+ ```
138
+
139
+ </td>
140
+ <td align="left"><code>None</code></td>
141
+ <td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
142
+ </tr>
143
+
144
+ <tr>
145
+ <td align="left"><code>show_label</code></td>
146
+ <td align="left" style="width: 25%;">
147
+
148
+ ```python
149
+ bool | None
150
+ ```
151
+
152
+ </td>
153
+ <td align="left"><code>None</code></td>
154
+ <td align="left">if True, will display label.</td>
155
+ </tr>
156
+
157
+ <tr>
158
+ <td align="left"><code>container</code></td>
159
+ <td align="left" style="width: 25%;">
160
+
161
+ ```python
162
+ bool
163
+ ```
164
+
165
+ </td>
166
+ <td align="left"><code>True</code></td>
167
+ <td align="left">If True, will place the component in a container - providing some extra padding around the border.</td>
168
+ </tr>
169
+
170
+ <tr>
171
+ <td align="left"><code>scale</code></td>
172
+ <td align="left" style="width: 25%;">
173
+
174
+ ```python
175
+ int | None
176
+ ```
177
+
178
+ </td>
179
+ <td align="left"><code>None</code></td>
180
+ <td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
181
+ </tr>
182
+
183
+ <tr>
184
+ <td align="left"><code>min_width</code></td>
185
+ <td align="left" style="width: 25%;">
186
+
187
+ ```python
188
+ int
189
+ ```
190
+
191
+ </td>
192
+ <td align="left"><code>160</code></td>
193
+ <td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
194
+ </tr>
195
+
196
+ <tr>
197
+ <td align="left"><code>visible</code></td>
198
+ <td align="left" style="width: 25%;">
199
+
200
+ ```python
201
+ bool
202
+ ```
203
+
204
+ </td>
205
+ <td align="left"><code>True</code></td>
206
+ <td align="left">If False, component will be hidden.</td>
207
+ </tr>
208
+
209
+ <tr>
210
+ <td align="left"><code>elem_id</code></td>
211
+ <td align="left" style="width: 25%;">
212
+
213
+ ```python
214
+ str | None
215
+ ```
216
+
217
+ </td>
218
+ <td align="left"><code>None</code></td>
219
+ <td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
220
+ </tr>
221
+
222
+ <tr>
223
+ <td align="left"><code>elem_classes</code></td>
224
+ <td align="left" style="width: 25%;">
225
+
226
+ ```python
227
+ list[str] | str | None
228
+ ```
229
+
230
+ </td>
231
+ <td align="left"><code>None</code></td>
232
+ <td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
233
+ </tr>
234
+
235
+ <tr>
236
+ <td align="left"><code>render</code></td>
237
+ <td align="left" style="width: 25%;">
238
+
239
+ ```python
240
+ bool
241
+ ```
242
+
243
+ </td>
244
+ <td align="left"><code>True</code></td>
245
+ <td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
246
+ </tr>
247
+
248
+ <tr>
249
+ <td align="left"><code>interactive</code></td>
250
+ <td align="left" style="width: 25%;">
251
+
252
+ ```python
253
+ bool | None
254
+ ```
255
+
256
+ </td>
257
+ <td align="left"><code>None</code></td>
258
+ <td align="left">If True, the component will be editable, and allow user to select spans of text and label them.</td>
259
+ </tr>
260
+
261
+ <tr>
262
+ <td align="left"><code>default_label</code></td>
263
+ <td align="left" style="width: 25%;">
264
+
265
+ ```python
266
+ str | None
267
+ ```
268
+
269
+ </td>
270
+ <td align="left"><code>None</code></td>
271
+ <td align="left">None</td>
272
+ </tr>
273
+ </tbody></table>
274
+
275
+
276
+ ### Events
277
+
278
+ | name | description |
279
+ |:-----|:------------|
280
+ | `change` | Triggered when the value of the HighlightedTextLabelDefault changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
281
+ | `select` | Event listener for when the user selects or deselects the HighlightedTextLabelDefault. Uses event data gradio.SelectData to carry `value` referring to the label of the HighlightedTextLabelDefault, and `selected` to refer to state of the HighlightedTextLabelDefault. See EventData documentation on how to use this event data |
282
+
283
+
284
+
285
+ ### User function
286
+
287
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
288
+
289
+ - When used as an Input, the component only impacts the input signature of the user function.
290
+ - When used as an output, the component only impacts the return signature of the user function.
291
+
292
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
293
+
294
+ - **As output:** Is passed, passes the value as a list of tuples as a `list[tuple]` into the function. Each `tuple` consists of a `str` substring of the text (so the entire text is included) and `str | float | None` label, which is the category or confidence of that substring.
295
+ - **As input:** Should return, expects a list of (word, category) tuples, or a dictionary of two keys: "text", and "entities", which itself is a list of dictionaries, each of which have the keys: "entity" (or "entity_group"), "start", and "end".
296
+
297
+ ```python
298
+ def predict(
299
+ value: list[tuple[str, str | float | None]] | None
300
+ ) -> list[tuple[str, str | float | None]] | dict | None:
301
+ return value
302
+ ```
303
+
src/backend/gradio_highlightedtextlabeldefault/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ from .highlightedtextlabeldefault import HighlightedTextLabelDefault
3
+
4
+ __all__ = ['HighlightedTextLabelDefault']
src/backend/gradio_highlightedtextlabeldefault/highlightedtextlabeldefault.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """gr.HighlightedText() component."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Callable, List, Union
6
+
7
+ from gradio_client.documentation import document
8
+
9
+ from gradio.components.base import Component
10
+ from gradio.data_classes import GradioModel, GradioRootModel
11
+ from gradio.events import Events
12
+
13
+
14
+ class HighlightedToken(GradioModel):
15
+ token: str
16
+ class_or_confidence: Union[str, float, None] = None
17
+
18
+
19
+ class HighlightedTextData(GradioRootModel):
20
+ root: List[HighlightedToken]
21
+
22
+
23
+ class HighlightedTextLabelDefault(Component):
24
+ """
25
+ Displays text that contains spans that are highlighted by category or numerical value.
26
+
27
+ Demos: diff_texts
28
+ Guides: named-entity-recognition
29
+ """
30
+
31
+ data_model = HighlightedTextData
32
+ EVENTS = [Events.change, Events.select]
33
+
34
+ def __init__(
35
+ self,
36
+ value: list[tuple[str, str | float | None]] | dict | Callable | None = None,
37
+ *,
38
+ color_map: dict[str, str]
39
+ | None = None, # Parameter moved to HighlightedTextLabelDefault.style()
40
+ show_legend: bool = False,
41
+ combine_adjacent: bool = False,
42
+ adjacent_separator: str = "",
43
+ label: str | None = None,
44
+ every: float | None = None,
45
+ show_label: bool | None = None,
46
+ container: bool = True,
47
+ scale: int | None = None,
48
+ min_width: int = 160,
49
+ visible: bool = True,
50
+ elem_id: str | None = None,
51
+ elem_classes: list[str] | str | None = None,
52
+ render: bool = True,
53
+ interactive: bool | None = None,
54
+ default_label: str | None = None
55
+
56
+ ):
57
+ """
58
+ Parameters:
59
+ value: Default value to show. If callable, the function will be called whenever the app loads to set the initial value of the component.
60
+ color_map: A dictionary mapping labels to colors. The colors may be specified as hex codes or by their names. For example: {"person": "red", "location": "#FFEE22"}
61
+ show_legend: whether to show span categories in a separate legend or inline.
62
+ combine_adjacent: If True, will merge the labels of adjacent tokens belonging to the same category.
63
+ adjacent_separator: Specifies the separator to be used between tokens if combine_adjacent is True.
64
+ label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
65
+ every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
66
+ show_label: if True, will display label.
67
+ container: If True, will place the component in a container - providing some extra padding around the border.
68
+ scale: relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.
69
+ min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
70
+ visible: If False, component will be hidden.
71
+ elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
72
+ elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
73
+ render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
74
+ interactive: If True, the component will be editable, and allow user to select spans of text and label them.
75
+ """
76
+ self.color_map = color_map
77
+ self.show_legend = show_legend
78
+ self.combine_adjacent = combine_adjacent
79
+ self.adjacent_separator = adjacent_separator
80
+ self.default_label = default_label
81
+ super().__init__(
82
+ label=label,
83
+ every=every,
84
+ show_label=show_label,
85
+ container=container,
86
+ scale=scale,
87
+ min_width=min_width,
88
+ visible=visible,
89
+ elem_id=elem_id,
90
+ elem_classes=elem_classes,
91
+ render=render,
92
+ value=value,
93
+ interactive=interactive,
94
+ )
95
+
96
+ def example_payload(self) -> Any:
97
+ return [
98
+ {"token": "The", "class_or_confidence": None},
99
+ {"token": "quick", "class_or_confidence": "adj"},
100
+ ]
101
+
102
+ def example_value(self) -> Any:
103
+ return [("The", None), ("quick", "adj"), ("brown", "adj"), ("fox", "noun")]
104
+
105
+ def preprocess(
106
+ self, payload: HighlightedTextData | None
107
+ ) -> list[tuple[str, str | float | None]] | None:
108
+ """
109
+ Parameters:
110
+ payload: An instance of HighlightedTextData
111
+ Returns:
112
+ Passes the value as a list of tuples as a `list[tuple]` into the function. Each `tuple` consists of a `str` substring of the text (so the entire text is included) and `str | float | None` label, which is the category or confidence of that substring.
113
+ """
114
+ if payload is None:
115
+ return None
116
+ return payload.model_dump() # type: ignore
117
+
118
+ def postprocess(
119
+ self, value: list[tuple[str, str | float | None]] | dict | None
120
+ ) -> HighlightedTextData | None:
121
+ """
122
+ Parameters:
123
+ value: Expects a list of (word, category) tuples, or a dictionary of two keys: "text", and "entities", which itself is a list of dictionaries, each of which have the keys: "entity" (or "entity_group"), "start", and "end"
124
+ Returns:
125
+ An instance of HighlightedTextData
126
+ """
127
+ if value is None:
128
+ return None
129
+ if isinstance(value, dict):
130
+ try:
131
+ text = value["text"]
132
+ entities = value["entities"]
133
+ except KeyError as ke:
134
+ raise ValueError(
135
+ "Expected a dictionary with keys 'text' and 'entities' "
136
+ "for the value of the HighlightedTextLabelDefault component."
137
+ ) from ke
138
+ if len(entities) == 0:
139
+ value = [(text, None)]
140
+ else:
141
+ list_format = []
142
+ index = 0
143
+ entities = sorted(entities, key=lambda x: x["start"])
144
+ for entity in entities:
145
+ list_format.append((text[index : entity["start"]], None))
146
+ entity_category = entity.get("entity") or entity.get("entity_group")
147
+ list_format.append(
148
+ (text[entity["start"] : entity["end"]], entity_category)
149
+ )
150
+ index = entity["end"]
151
+ list_format.append((text[index:], None))
152
+ value = list_format
153
+ if self.combine_adjacent:
154
+ output = []
155
+ running_text, running_category = None, None
156
+ for text, category in value:
157
+ if running_text is None:
158
+ running_text = text
159
+ running_category = category
160
+ elif category == running_category:
161
+ running_text += self.adjacent_separator + text
162
+ elif not text:
163
+ # Skip fully empty item, these get added in processing
164
+ # of dictionaries.
165
+ pass
166
+ else:
167
+ output.append((running_text, running_category))
168
+ running_text = text
169
+ running_category = category
170
+ if running_text is not None:
171
+ output.append((running_text, running_category))
172
+ return HighlightedTextData(
173
+ root=[
174
+ HighlightedToken(token=o[0], class_or_confidence=o[1])
175
+ for o in output
176
+ ]
177
+ )
178
+ else:
179
+ return HighlightedTextData(
180
+ root=[
181
+ HighlightedToken(token=o[0], class_or_confidence=o[1])
182
+ for o in value
183
+ ]
184
+ )
src/backend/gradio_highlightedtextlabeldefault/highlightedtextlabeldefault.pyi ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """gr.HighlightedText() component."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Callable, List, Union
6
+
7
+ from gradio_client.documentation import document
8
+
9
+ from gradio.components.base import Component
10
+ from gradio.data_classes import GradioModel, GradioRootModel
11
+ from gradio.events import Events
12
+
13
+
14
+ class HighlightedToken(GradioModel):
15
+ token: str
16
+ class_or_confidence: Union[str, float, None] = None
17
+
18
+
19
+ class HighlightedTextData(GradioRootModel):
20
+ root: List[HighlightedToken]
21
+
22
+
23
+ class HighlightedTextLabelDefault(Component):
24
+ """
25
+ Displays text that contains spans that are highlighted by category or numerical value.
26
+
27
+ Demos: diff_texts
28
+ Guides: named-entity-recognition
29
+ """
30
+
31
+ data_model = HighlightedTextData
32
+ EVENTS = [Events.change, Events.select]
33
+
34
+ def __init__(
35
+ self,
36
+ value: list[tuple[str, str | float | None]] | dict | Callable | None = None,
37
+ *,
38
+ color_map: dict[str, str]
39
+ | None = None, # Parameter moved to HighlightedTextLabelDefault.style()
40
+ show_legend: bool = False,
41
+ combine_adjacent: bool = False,
42
+ adjacent_separator: str = "",
43
+ label: str | None = None,
44
+ every: float | None = None,
45
+ show_label: bool | None = None,
46
+ container: bool = True,
47
+ scale: int | None = None,
48
+ min_width: int = 160,
49
+ visible: bool = True,
50
+ elem_id: str | None = None,
51
+ elem_classes: list[str] | str | None = None,
52
+ render: bool = True,
53
+ interactive: bool | None = None,
54
+ default_label: str | None = None
55
+
56
+ ):
57
+ """
58
+ Parameters:
59
+ value: Default value to show. If callable, the function will be called whenever the app loads to set the initial value of the component.
60
+ color_map: A dictionary mapping labels to colors. The colors may be specified as hex codes or by their names. For example: {"person": "red", "location": "#FFEE22"}
61
+ show_legend: whether to show span categories in a separate legend or inline.
62
+ combine_adjacent: If True, will merge the labels of adjacent tokens belonging to the same category.
63
+ adjacent_separator: Specifies the separator to be used between tokens if combine_adjacent is True.
64
+ label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
65
+ every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
66
+ show_label: if True, will display label.
67
+ container: If True, will place the component in a container - providing some extra padding around the border.
68
+ scale: relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.
69
+ min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
70
+ visible: If False, component will be hidden.
71
+ elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
72
+ elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
73
+ render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
74
+ interactive: If True, the component will be editable, and allow user to select spans of text and label them.
75
+ """
76
+ self.color_map = color_map
77
+ self.show_legend = show_legend
78
+ self.combine_adjacent = combine_adjacent
79
+ self.adjacent_separator = adjacent_separator
80
+ self.default_label = default_label
81
+ super().__init__(
82
+ label=label,
83
+ every=every,
84
+ show_label=show_label,
85
+ container=container,
86
+ scale=scale,
87
+ min_width=min_width,
88
+ visible=visible,
89
+ elem_id=elem_id,
90
+ elem_classes=elem_classes,
91
+ render=render,
92
+ value=value,
93
+ interactive=interactive,
94
+ )
95
+
96
+ def example_payload(self) -> Any:
97
+ return [
98
+ {"token": "The", "class_or_confidence": None},
99
+ {"token": "quick", "class_or_confidence": "adj"},
100
+ ]
101
+
102
+ def example_value(self) -> Any:
103
+ return [("The", None), ("quick", "adj"), ("brown", "adj"), ("fox", "noun")]
104
+
105
+ def preprocess(
106
+ self, payload: HighlightedTextData | None
107
+ ) -> list[tuple[str, str | float | None]] | None:
108
+ """
109
+ Parameters:
110
+ payload: An instance of HighlightedTextData
111
+ Returns:
112
+ Passes the value as a list of tuples as a `list[tuple]` into the function. Each `tuple` consists of a `str` substring of the text (so the entire text is included) and `str | float | None` label, which is the category or confidence of that substring.
113
+ """
114
+ if payload is None:
115
+ return None
116
+ return payload.model_dump() # type: ignore
117
+
118
+ def postprocess(
119
+ self, value: list[tuple[str, str | float | None]] | dict | None
120
+ ) -> HighlightedTextData | None:
121
+ """
122
+ Parameters:
123
+ value: Expects a list of (word, category) tuples, or a dictionary of two keys: "text", and "entities", which itself is a list of dictionaries, each of which have the keys: "entity" (or "entity_group"), "start", and "end"
124
+ Returns:
125
+ An instance of HighlightedTextData
126
+ """
127
+ if value is None:
128
+ return None
129
+ if isinstance(value, dict):
130
+ try:
131
+ text = value["text"]
132
+ entities = value["entities"]
133
+ except KeyError as ke:
134
+ raise ValueError(
135
+ "Expected a dictionary with keys 'text' and 'entities' "
136
+ "for the value of the HighlightedTextLabelDefault component."
137
+ ) from ke
138
+ if len(entities) == 0:
139
+ value = [(text, None)]
140
+ else:
141
+ list_format = []
142
+ index = 0
143
+ entities = sorted(entities, key=lambda x: x["start"])
144
+ for entity in entities:
145
+ list_format.append((text[index : entity["start"]], None))
146
+ entity_category = entity.get("entity") or entity.get("entity_group")
147
+ list_format.append(
148
+ (text[entity["start"] : entity["end"]], entity_category)
149
+ )
150
+ index = entity["end"]
151
+ list_format.append((text[index:], None))
152
+ value = list_format
153
+ if self.combine_adjacent:
154
+ output = []
155
+ running_text, running_category = None, None
156
+ for text, category in value:
157
+ if running_text is None:
158
+ running_text = text
159
+ running_category = category
160
+ elif category == running_category:
161
+ running_text += self.adjacent_separator + text
162
+ elif not text:
163
+ # Skip fully empty item, these get added in processing
164
+ # of dictionaries.
165
+ pass
166
+ else:
167
+ output.append((running_text, running_category))
168
+ running_text = text
169
+ running_category = category
170
+ if running_text is not None:
171
+ output.append((running_text, running_category))
172
+ return HighlightedTextData(
173
+ root=[
174
+ HighlightedToken(token=o[0], class_or_confidence=o[1])
175
+ for o in output
176
+ ]
177
+ )
178
+ else:
179
+ return HighlightedTextData(
180
+ root=[
181
+ HighlightedToken(token=o[0], class_or_confidence=o[1])
182
+ for o in value
183
+ ]
184
+ )
185
+
186
+
187
+ def change(self,
188
+ fn: Callable | None,
189
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
190
+ outputs: Component | Sequence[Component] | None = None,
191
+ api_name: str | None | Literal[False] = None,
192
+ scroll_to_output: bool = False,
193
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
194
+ queue: bool | None = None,
195
+ batch: bool = False,
196
+ max_batch_size: int = 4,
197
+ preprocess: bool = True,
198
+ postprocess: bool = True,
199
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
200
+ every: float | None = None,
201
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
202
+ js: str | None = None,
203
+ concurrency_limit: int | None | Literal["default"] = "default",
204
+ concurrency_id: str | None = None,
205
+ show_api: bool = True) -> Dependency:
206
+ """
207
+ Parameters:
208
+ fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
209
+ inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
210
+ outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
211
+ api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
212
+ scroll_to_output: If True, will scroll to output component on completion
213
+ show_progress: If True, will show progress animation while pending
214
+ queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
215
+ batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
216
+ max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
217
+ preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
218
+ postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
219
+ cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
220
+ every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds.
221
+ trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` and `.key_up()` events) would allow a second submission after the pending event is complete.
222
+ js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
223
+ concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
224
+ concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
225
+ show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
226
+ """
227
+ ...
228
+
229
+ def select(self,
230
+ fn: Callable | None,
231
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
232
+ outputs: Component | Sequence[Component] | None = None,
233
+ api_name: str | None | Literal[False] = None,
234
+ scroll_to_output: bool = False,
235
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
236
+ queue: bool | None = None,
237
+ batch: bool = False,
238
+ max_batch_size: int = 4,
239
+ preprocess: bool = True,
240
+ postprocess: bool = True,
241
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
242
+ every: float | None = None,
243
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
244
+ js: str | None = None,
245
+ concurrency_limit: int | None | Literal["default"] = "default",
246
+ concurrency_id: str | None = None,
247
+ show_api: bool = True) -> Dependency:
248
+ """
249
+ Parameters:
250
+ fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
251
+ inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
252
+ outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
253
+ api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
254
+ scroll_to_output: If True, will scroll to output component on completion
255
+ show_progress: If True, will show progress animation while pending
256
+ queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
257
+ batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
258
+ max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
259
+ preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
260
+ postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
261
+ cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
262
+ every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds.
263
+ trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` and `.key_up()` events) would allow a second submission after the pending event is complete.
264
+ js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
265
+ concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
266
+ concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
267
+ show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
268
+ """
269
+ ...
src/backend/gradio_highlightedtextlabeldefault/templates/component/index.js ADDED
The diff for this file is too large to render. See raw diff
 
src/backend/gradio_highlightedtextlabeldefault/templates/component/style.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .container.svelte-1woixh4.svelte-1woixh4{display:flex;flex-direction:column;gap:var(--spacing-sm);padding:var(--block-padding)}.hl.svelte-1woixh4+.hl.svelte-1woixh4{margin-left:var(--size-1)}.textspan.svelte-1woixh4:last-child>.label.svelte-1woixh4{margin-right:0}.category-legend.svelte-1woixh4.svelte-1woixh4{display:flex;flex-wrap:wrap;gap:var(--spacing-sm);color:#000}.category-label.svelte-1woixh4.svelte-1woixh4{cursor:pointer;border-radius:var(--radius-xs);padding-right:var(--size-2);padding-left:var(--size-2);font-weight:var(--weight-semibold)}.color-legend.svelte-1woixh4.svelte-1woixh4{display:flex;justify-content:space-between;border-radius:var(--radius-xs);background:linear-gradient(to right,var(--color-purple),rgba(255,255,255,0),var(--color-red));padding:var(--size-1) var(--size-2);font-weight:var(--weight-semibold)}.textfield.svelte-1woixh4.svelte-1woixh4{box-sizing:border-box;border-radius:var(--radius-xs);background:var(--background-fill-primary);background-color:transparent;max-width:var(--size-full);line-height:var(--scale-4);word-break:break-all}.textspan.svelte-1woixh4.svelte-1woixh4{transition:.15s;border-radius:var(--radius-xs);padding-top:2.5px;padding-right:var(--size-1);padding-bottom:3.5px;padding-left:var(--size-1);color:#000}.label.svelte-1woixh4.svelte-1woixh4{transition:.15s;margin-top:1px;border-radius:var(--radius-xs);padding:1px 5px;color:var(--body-text-color);color:#fff;font-weight:var(--weight-bold);font-size:var(--text-sm);text-transform:uppercase}.text.svelte-1woixh4.svelte-1woixh4{color:#000;white-space:pre-wrap}.score-text.svelte-1woixh4 .text.svelte-1woixh4{color:var(--body-text-color)}.score-text.svelte-1woixh4.svelte-1woixh4{margin-right:var(--size-1);padding:var(--size-1)}.no-cat.svelte-1woixh4.svelte-1woixh4,.no-label.svelte-1woixh4.svelte-1woixh4{color:var(--body-text-color)}.selectable.svelte-1woixh4.svelte-1woixh4{cursor:pointer}.label-input.svelte-df6jzs{transition:.15s;margin-top:1px;margin-right:calc(var(--size-1));border-radius:var(--radius-xs);padding:1px 5px;color:#000;font-weight:var(--weight-bold);font-size:var(--text-sm);text-transform:uppercase;line-height:1;color:#fff}.label-input.svelte-df6jzs::placeholder{color:#01010180}.label-clear-button.svelte-u7mykt.svelte-u7mykt{display:none;border-radius:var(--radius-xs);padding-top:2.5px;padding-right:var(--size-1);padding-bottom:3.5px;padding-left:var(--size-1);color:#000;background-color:var(--background-fill-secondary);-webkit-user-select:none;user-select:none;position:relative;left:-3px;border-radius:0 var(--radius-xs) var(--radius-xs) 0;color:var(--block-label-text-color)}.text-class_or_confidence-container.svelte-u7mykt:hover .label-clear-button.svelte-u7mykt,.text-class_or_confidence-container.svelte-u7mykt:focus-within .label-clear-button.svelte-u7mykt,.score-text-container.svelte-u7mykt:hover .label-clear-button.svelte-u7mykt,.score-text-container.svelte-u7mykt:focus-within .label-clear-button.svelte-u7mykt{display:inline}.text-class_or_confidence-container.svelte-u7mykt:hover .textspan.hl.svelte-u7mykt,.text-class_or_confidence-container.svelte-u7mykt:focus-within .textspan.hl.svelte-u7mykt,.score-text.svelte-u7mykt.svelte-u7mykt:hover{border-radius:var(--radius-xs) 0 0 var(--radius-xs)}.container.svelte-u7mykt.svelte-u7mykt{display:flex;flex-direction:column;gap:var(--spacing-sm);padding:var(--block-padding)}.hl.svelte-u7mykt.svelte-u7mykt{margin-left:var(--size-1);transition:background-color .3s;-webkit-user-select:none;user-select:none}.textspan.svelte-u7mykt:last-child>.label.svelte-u7mykt{margin-right:0}.class_or_confidence-legend.svelte-u7mykt.svelte-u7mykt{display:flex;flex-wrap:wrap;gap:var(--spacing-sm);color:#000}.class_or_confidence-label.svelte-u7mykt.svelte-u7mykt{cursor:pointer;border-radius:var(--radius-xs);padding-right:var(--size-2);padding-left:var(--size-2);font-weight:var(--weight-semibold)}.color-legend.svelte-u7mykt.svelte-u7mykt{display:flex;justify-content:space-between;border-radius:var(--radius-xs);background:linear-gradient(to right,var(--color-purple),rgba(255,255,255,0),var(--color-red));padding:var(--size-1) var(--size-2);font-weight:var(--weight-semibold)}.textfield.svelte-u7mykt.svelte-u7mykt{box-sizing:border-box;border-radius:var(--radius-xs);background:var(--background-fill-primary);background-color:transparent;max-width:var(--size-full);line-height:var(--scale-4);word-break:break-all}.textspan.svelte-u7mykt.svelte-u7mykt{transition:.15s;border-radius:var(--radius-xs);padding-top:2.5px;padding-right:var(--size-1);padding-bottom:3.5px;padding-left:var(--size-1);color:#000;cursor:text}.label.svelte-u7mykt.svelte-u7mykt{transition:.15s;margin-top:1px;border-radius:var(--radius-xs);padding:1px 5px;color:var(--body-text-color);color:#fff;font-weight:var(--weight-bold);font-size:var(--text-sm);text-transform:uppercase;-webkit-user-select:none;user-select:none}.text.svelte-u7mykt.svelte-u7mykt{color:#000;white-space:pre-wrap}.textspan.hl.svelte-u7mykt.svelte-u7mykt{-webkit-user-select:none;user-select:none}.score-text-container.svelte-u7mykt.svelte-u7mykt{margin-right:var(--size-1)}.score-text.svelte-u7mykt .text.svelte-u7mykt,.no-cat.svelte-u7mykt.svelte-u7mykt{color:var(--body-text-color)}.no-label.svelte-u7mykt.svelte-u7mykt{color:var(--body-text-color);-webkit-user-select:text;user-select:text}.selectable.svelte-u7mykt.svelte-u7mykt{cursor:text;-webkit-user-select:text;user-select:text}.block.svelte-nl1om8{position:relative;margin:0;box-shadow:var(--block-shadow);border-width:var(--block-border-width);border-color:var(--block-border-color);border-radius:var(--block-radius);background:var(--block-background-fill);width:100%;line-height:var(--line-sm)}.block.border_focus.svelte-nl1om8{border-color:var(--color-accent)}.block.border_contrast.svelte-nl1om8{border-color:var(--body-text-color)}.padded.svelte-nl1om8{padding:var(--block-padding)}.hidden.svelte-nl1om8{display:none}.hide-container.svelte-nl1om8{margin:0;box-shadow:none;--block-border-width:0;background:transparent;padding:0;overflow:visible}div.svelte-1hnfib2{margin-bottom:var(--spacing-lg);color:var(--block-info-text-color);font-weight:var(--block-info-text-weight);font-size:var(--block-info-text-size);line-height:var(--line-sm)}span.has-info.svelte-22c38v{margin-bottom:var(--spacing-xs)}span.svelte-22c38v:not(.has-info){margin-bottom:var(--spacing-lg)}span.svelte-22c38v{display:inline-block;position:relative;z-index:var(--layer-4);border:solid var(--block-title-border-width) var(--block-title-border-color);border-radius:var(--block-title-radius);background:var(--block-title-background-fill);padding:var(--block-title-padding);color:var(--block-title-text-color);font-weight:var(--block-title-text-weight);font-size:var(--block-title-text-size);line-height:var(--line-sm)}.hide.svelte-22c38v{margin:0;height:0}label.svelte-9gxdi0{display:inline-flex;align-items:center;z-index:var(--layer-2);box-shadow:var(--block-label-shadow);border:var(--block-label-border-width) solid var(--border-color-primary);border-top:none;border-left:none;border-radius:var(--block-label-radius);background:var(--block-label-background-fill);padding:var(--block-label-padding);pointer-events:none;color:var(--block-label-text-color);font-weight:var(--block-label-text-weight);font-size:var(--block-label-text-size);line-height:var(--line-sm)}.gr-group label.svelte-9gxdi0{border-top-left-radius:0}label.float.svelte-9gxdi0{position:absolute;top:var(--block-label-margin);left:var(--block-label-margin)}label.svelte-9gxdi0:not(.float){position:static;margin-top:var(--block-label-margin);margin-left:var(--block-label-margin)}.hide.svelte-9gxdi0{height:0}span.svelte-9gxdi0{opacity:.8;margin-right:var(--size-2);width:calc(var(--block-label-text-size) - 1px);height:calc(var(--block-label-text-size) - 1px)}.hide-label.svelte-9gxdi0{box-shadow:none;border-width:0;background:transparent;overflow:visible}button.svelte-lpi64a{display:flex;justify-content:center;align-items:center;gap:1px;z-index:var(--layer-2);border-radius:var(--radius-sm);color:var(--block-label-text-color);border:1px solid transparent}button[disabled].svelte-lpi64a{opacity:.5;box-shadow:none}button[disabled].svelte-lpi64a:hover{cursor:not-allowed}.padded.svelte-lpi64a{padding:2px;background:var(--bg-color);box-shadow:var(--shadow-drop);border:1px solid var(--button-secondary-border-color)}button.svelte-lpi64a:hover,button.highlight.svelte-lpi64a{cursor:pointer;color:var(--color-accent)}.padded.svelte-lpi64a:hover{border:2px solid var(--button-secondary-border-color-hover);padding:1px;color:var(--block-label-text-color)}span.svelte-lpi64a{padding:0 1px;font-size:10px}div.svelte-lpi64a{padding:2px;display:flex;align-items:flex-end}.small.svelte-lpi64a{width:14px;height:14px}.large.svelte-lpi64a{width:22px;height:22px}.pending.svelte-lpi64a{animation:svelte-lpi64a-flash .5s infinite}@keyframes svelte-lpi64a-flash{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.transparent.svelte-lpi64a{background:transparent;border:none;box-shadow:none}.empty.svelte-3w3rth{display:flex;justify-content:center;align-items:center;margin-top:calc(0px - var(--size-6));height:var(--size-full)}.icon.svelte-3w3rth{opacity:.5;height:var(--size-5);color:var(--body-text-color)}.small.svelte-3w3rth{min-height:calc(var(--size-32) - 20px)}.large.svelte-3w3rth{min-height:calc(var(--size-64) - 20px)}.unpadded_box.svelte-3w3rth{margin-top:0}.small_parent.svelte-3w3rth{min-height:100%!important}.dropdown-arrow.svelte-145leq6{fill:currentColor}.wrap.svelte-kzcjhc{display:flex;flex-direction:column;justify-content:center;align-items:center;min-height:var(--size-60);color:var(--block-label-text-color);line-height:var(--line-md);height:100%;padding-top:var(--size-3)}.or.svelte-kzcjhc{color:var(--body-text-color-subdued);display:flex}.icon-wrap.svelte-kzcjhc{width:30px;margin-bottom:var(--spacing-lg)}@media (--screen-md){.wrap.svelte-kzcjhc{font-size:var(--text-lg)}}.hovered.svelte-kzcjhc{color:var(--color-accent)}div.svelte-ipfyu7{border-top:1px solid transparent;display:flex;max-height:100%;justify-content:center;gap:var(--spacing-sm);height:auto;align-items:flex-end;padding-bottom:var(--spacing-xl);color:var(--block-label-text-color);flex-shrink:0;width:95%}.show_border.svelte-ipfyu7{border-top:1px solid var(--block-border-color);margin-top:var(--spacing-xxl);box-shadow:var(--shadow-drop)}.source-selection.svelte-1jp3vgd{display:flex;align-items:center;justify-content:center;border-top:1px solid var(--border-color-primary);width:95%;bottom:0;left:0;right:0;margin-left:auto;margin-right:auto}.icon.svelte-1jp3vgd{width:22px;height:22px;margin:var(--spacing-lg) var(--spacing-xs);padding:var(--spacing-xs);color:var(--neutral-400);border-radius:var(--radius-md)}.selected.svelte-1jp3vgd{color:var(--color-accent)}.icon.svelte-1jp3vgd:hover,.icon.svelte-1jp3vgd:focus{color:var(--color-accent)}svg.svelte-43sxxs.svelte-43sxxs{width:var(--size-20);height:var(--size-20)}svg.svelte-43sxxs path.svelte-43sxxs{fill:var(--loader-color)}div.svelte-43sxxs.svelte-43sxxs{z-index:var(--layer-2)}.margin.svelte-43sxxs.svelte-43sxxs{margin:var(--size-4)}.wrap.svelte-1yserjw.svelte-1yserjw{display:flex;flex-direction:column;justify-content:center;align-items:center;z-index:var(--layer-top);transition:opacity .1s ease-in-out;border-radius:var(--block-radius);background:var(--block-background-fill);padding:0 var(--size-6);max-height:var(--size-screen-h);overflow:hidden;pointer-events:none}.wrap.center.svelte-1yserjw.svelte-1yserjw{top:0;right:0;left:0}.wrap.default.svelte-1yserjw.svelte-1yserjw{top:0;right:0;bottom:0;left:0}.hide.svelte-1yserjw.svelte-1yserjw{opacity:0;pointer-events:none}.generating.svelte-1yserjw.svelte-1yserjw{animation:svelte-1yserjw-pulse 2s cubic-bezier(.4,0,.6,1) infinite;border:2px solid var(--color-accent);background:transparent;z-index:var(--layer-1)}.translucent.svelte-1yserjw.svelte-1yserjw{background:none}@keyframes svelte-1yserjw-pulse{0%,to{opacity:1}50%{opacity:.5}}.loading.svelte-1yserjw.svelte-1yserjw{z-index:var(--layer-2);color:var(--body-text-color)}.eta-bar.svelte-1yserjw.svelte-1yserjw{position:absolute;top:0;right:0;bottom:0;left:0;transform-origin:left;opacity:.8;z-index:var(--layer-1);transition:10ms;background:var(--background-fill-secondary)}.progress-bar-wrap.svelte-1yserjw.svelte-1yserjw{border:1px solid var(--border-color-primary);background:var(--background-fill-primary);width:55.5%;height:var(--size-4)}.progress-bar.svelte-1yserjw.svelte-1yserjw{transform-origin:left;background-color:var(--loader-color);width:var(--size-full);height:var(--size-full)}.progress-level.svelte-1yserjw.svelte-1yserjw{display:flex;flex-direction:column;align-items:center;gap:1;z-index:var(--layer-2);width:var(--size-full)}.progress-level-inner.svelte-1yserjw.svelte-1yserjw{margin:var(--size-2) auto;color:var(--body-text-color);font-size:var(--text-sm);font-family:var(--font-mono)}.meta-text.svelte-1yserjw.svelte-1yserjw{position:absolute;top:0;right:0;z-index:var(--layer-2);padding:var(--size-1) var(--size-2);font-size:var(--text-sm);font-family:var(--font-mono)}.meta-text-center.svelte-1yserjw.svelte-1yserjw{display:flex;position:absolute;top:0;right:0;justify-content:center;align-items:center;transform:translateY(var(--size-6));z-index:var(--layer-2);padding:var(--size-1) var(--size-2);font-size:var(--text-sm);font-family:var(--font-mono);text-align:center}.error.svelte-1yserjw.svelte-1yserjw{box-shadow:var(--shadow-drop);border:solid 1px var(--error-border-color);border-radius:var(--radius-full);background:var(--error-background-fill);padding-right:var(--size-4);padding-left:var(--size-4);color:var(--error-text-color);font-weight:var(--weight-semibold);font-size:var(--text-lg);line-height:var(--line-lg);font-family:var(--font)}.minimal.svelte-1yserjw .progress-text.svelte-1yserjw{background:var(--block-background-fill)}.border.svelte-1yserjw.svelte-1yserjw{border:1px solid var(--border-color-primary)}.toast-body.svelte-solcu7{display:flex;position:relative;right:0;left:0;align-items:center;margin:var(--size-6) var(--size-4);margin:auto;border-radius:var(--container-radius);overflow:hidden;pointer-events:auto}.toast-body.error.svelte-solcu7{border:1px solid var(--color-red-700);background:var(--color-red-50)}.dark .toast-body.error.svelte-solcu7{border:1px solid var(--color-red-500);background-color:var(--color-grey-950)}.toast-body.warning.svelte-solcu7{border:1px solid var(--color-yellow-700);background:var(--color-yellow-50)}.dark .toast-body.warning.svelte-solcu7{border:1px solid var(--color-yellow-500);background-color:var(--color-grey-950)}.toast-body.info.svelte-solcu7{border:1px solid var(--color-grey-700);background:var(--color-grey-50)}.dark .toast-body.info.svelte-solcu7{border:1px solid var(--color-grey-500);background-color:var(--color-grey-950)}.toast-title.svelte-solcu7{display:flex;align-items:center;font-weight:var(--weight-bold);font-size:var(--text-lg);line-height:var(--line-sm);text-transform:capitalize}.toast-title.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-title.error.svelte-solcu7{color:var(--color-red-50)}.toast-title.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-title.warning.svelte-solcu7{color:var(--color-yellow-50)}.toast-title.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-title.info.svelte-solcu7{color:var(--color-grey-50)}.toast-close.svelte-solcu7{margin:0 var(--size-3);border-radius:var(--size-3);padding:0px var(--size-1-5);font-size:var(--size-5);line-height:var(--size-5)}.toast-close.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-close.error.svelte-solcu7{color:var(--color-red-500)}.toast-close.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-close.warning.svelte-solcu7{color:var(--color-yellow-500)}.toast-close.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-close.info.svelte-solcu7{color:var(--color-grey-500)}.toast-text.svelte-solcu7{font-size:var(--text-lg)}.toast-text.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-text.error.svelte-solcu7{color:var(--color-red-50)}.toast-text.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-text.warning.svelte-solcu7{color:var(--color-yellow-50)}.toast-text.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-text.info.svelte-solcu7{color:var(--color-grey-50)}.toast-details.svelte-solcu7{margin:var(--size-3) var(--size-3) var(--size-3) 0;width:100%}.toast-icon.svelte-solcu7{display:flex;position:absolute;position:relative;flex-shrink:0;justify-content:center;align-items:center;margin:var(--size-2);border-radius:var(--radius-full);padding:var(--size-1);padding-left:calc(var(--size-1) - 1px);width:35px;height:35px}.toast-icon.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-icon.error.svelte-solcu7{color:var(--color-red-500)}.toast-icon.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-icon.warning.svelte-solcu7{color:var(--color-yellow-500)}.toast-icon.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-icon.info.svelte-solcu7{color:var(--color-grey-500)}@keyframes svelte-solcu7-countdown{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.timer.svelte-solcu7{position:absolute;bottom:0;left:0;transform-origin:0 0;animation:svelte-solcu7-countdown 10s linear forwards;width:100%;height:var(--size-1)}.timer.error.svelte-solcu7{background:var(--color-red-700)}.dark .timer.error.svelte-solcu7{background:var(--color-red-500)}.timer.warning.svelte-solcu7{background:var(--color-yellow-700)}.dark .timer.warning.svelte-solcu7{background:var(--color-yellow-500)}.timer.info.svelte-solcu7{background:var(--color-grey-700)}.dark .timer.info.svelte-solcu7{background:var(--color-grey-500)}.toast-wrap.svelte-gatr8h{display:flex;position:fixed;top:var(--size-4);right:var(--size-4);flex-direction:column;align-items:end;gap:var(--size-2);z-index:var(--layer-top);width:calc(100% - var(--size-8))}@media (--screen-sm){.toast-wrap.svelte-gatr8h{width:calc(var(--size-96) + var(--size-10))}}
src/demo/__init__.py ADDED
File without changes
src/demo/app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from gradio_highlightedtextlabeldefault import HighlightedTextLabelDefault
4
+
5
+
6
+ example = HighlightedTextLabelDefault().example_value()
7
+
8
+ with gr.Blocks() as demo:
9
+ with gr.Row():
10
+ test_1 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]),
11
+ label="Double click word to see standard default label", interactive=True) # default label
12
+ test_2 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]), label="Double click word to see modified default label",
13
+ interactive=True, default_label="x", color_map={"x": "green"}) # blank component
14
+
15
+
16
+ if __name__ == "__main__":
17
+ demo.launch()
src/demo/css.css ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html {
2
+ font-family: Inter;
3
+ font-size: 16px;
4
+ font-weight: 400;
5
+ line-height: 1.5;
6
+ -webkit-text-size-adjust: 100%;
7
+ background: #fff;
8
+ color: #323232;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ text-rendering: optimizeLegibility;
12
+ }
13
+
14
+ :root {
15
+ --space: 1;
16
+ --vspace: calc(var(--space) * 1rem);
17
+ --vspace-0: calc(3 * var(--space) * 1rem);
18
+ --vspace-1: calc(2 * var(--space) * 1rem);
19
+ --vspace-2: calc(1.5 * var(--space) * 1rem);
20
+ --vspace-3: calc(0.5 * var(--space) * 1rem);
21
+ }
22
+
23
+ .app {
24
+ max-width: 748px !important;
25
+ }
26
+
27
+ .prose p {
28
+ margin: var(--vspace) 0;
29
+ line-height: var(--vspace * 2);
30
+ font-size: 1rem;
31
+ }
32
+
33
+ code {
34
+ font-family: "Inconsolata", sans-serif;
35
+ font-size: 16px;
36
+ }
37
+
38
+ h1,
39
+ h1 code {
40
+ font-weight: 400;
41
+ line-height: calc(2.5 / var(--space) * var(--vspace));
42
+ }
43
+
44
+ h1 code {
45
+ background: none;
46
+ border: none;
47
+ letter-spacing: 0.05em;
48
+ padding-bottom: 5px;
49
+ position: relative;
50
+ padding: 0;
51
+ }
52
+
53
+ h2 {
54
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
55
+ line-height: 1em;
56
+ }
57
+
58
+ h3,
59
+ h3 code {
60
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
61
+ line-height: 1em;
62
+ }
63
+
64
+ h4,
65
+ h5,
66
+ h6 {
67
+ margin: var(--vspace-3) 0 var(--vspace-3) 0;
68
+ line-height: var(--vspace);
69
+ }
70
+
71
+ .bigtitle,
72
+ h1,
73
+ h1 code {
74
+ font-size: calc(8px * 4.5);
75
+ word-break: break-word;
76
+ }
77
+
78
+ .title,
79
+ h2,
80
+ h2 code {
81
+ font-size: calc(8px * 3.375);
82
+ font-weight: lighter;
83
+ word-break: break-word;
84
+ border: none;
85
+ background: none;
86
+ }
87
+
88
+ .subheading1,
89
+ h3,
90
+ h3 code {
91
+ font-size: calc(8px * 1.8);
92
+ font-weight: 600;
93
+ border: none;
94
+ background: none;
95
+ letter-spacing: 0.1em;
96
+ text-transform: uppercase;
97
+ }
98
+
99
+ h2 code {
100
+ padding: 0;
101
+ position: relative;
102
+ letter-spacing: 0.05em;
103
+ }
104
+
105
+ blockquote {
106
+ font-size: calc(8px * 1.1667);
107
+ font-style: italic;
108
+ line-height: calc(1.1667 * var(--vspace));
109
+ margin: var(--vspace-2) var(--vspace-2);
110
+ }
111
+
112
+ .subheading2,
113
+ h4 {
114
+ font-size: calc(8px * 1.4292);
115
+ text-transform: uppercase;
116
+ font-weight: 600;
117
+ }
118
+
119
+ .subheading3,
120
+ h5 {
121
+ font-size: calc(8px * 1.2917);
122
+ line-height: calc(1.2917 * var(--vspace));
123
+
124
+ font-weight: lighter;
125
+ text-transform: uppercase;
126
+ letter-spacing: 0.15em;
127
+ }
128
+
129
+ h6 {
130
+ font-size: calc(8px * 1.1667);
131
+ font-size: 1.1667em;
132
+ font-weight: normal;
133
+ font-style: italic;
134
+ font-family: "le-monde-livre-classic-byol", serif !important;
135
+ letter-spacing: 0px !important;
136
+ }
137
+
138
+ #start .md > *:first-child {
139
+ margin-top: 0;
140
+ }
141
+
142
+ h2 + h3 {
143
+ margin-top: 0;
144
+ }
145
+
146
+ .md hr {
147
+ border: none;
148
+ border-top: 1px solid var(--block-border-color);
149
+ margin: var(--vspace-2) 0 var(--vspace-2) 0;
150
+ }
151
+ .prose ul {
152
+ margin: var(--vspace-2) 0 var(--vspace-1) 0;
153
+ }
154
+
155
+ .gap {
156
+ gap: 0;
157
+ }
src/demo/space.py ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from app import demo as app
4
+ import os
5
+
6
+ _docs = {'HighlightedTextLabelDefault': {'description': 'Displays text that contains spans that are highlighted by category or numerical value.\n', 'members': {'__init__': {'value': {'type': 'list[tuple[str, str | float | None]]\n | dict\n | Callable\n | None', 'default': 'None', 'description': 'Default value to show. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'color_map': {'type': 'dict[str, str] | None', 'default': 'None', 'description': 'A dictionary mapping labels to colors. The colors may be specified as hex codes or by their names. For example: {"person": "red", "location": "#FFEE22"}'}, 'show_legend': {'type': 'bool', 'default': 'False', 'description': 'whether to show span categories in a separate legend or inline.'}, 'combine_adjacent': {'type': 'bool', 'default': 'False', 'description': 'If True, will merge the labels of adjacent tokens belonging to the same category.'}, 'adjacent_separator': {'type': 'str', 'default': '""', 'description': 'Specifies the separator to be used between tokens if combine_adjacent is True.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'If True, the component will be editable, and allow user to select spans of text and label them.'}, 'default_label': {'type': 'str | None', 'default': 'None', 'description': None}}, 'postprocess': {'value': {'type': 'list[tuple[str, str | float | None]] | dict | None', 'description': 'Expects a list of (word, category) tuples, or a dictionary of two keys: "text", and "entities", which itself is a list of dictionaries, each of which have the keys: "entity" (or "entity_group"), "start", and "end"'}}, 'preprocess': {'return': {'type': 'list[tuple[str, str | float | None]] | None', 'description': 'Passes the value as a list of tuples as a `list[tuple]` into the function. Each `tuple` consists of a `str` substring of the text (so the entire text is included) and `str | float | None` label, which is the category or confidence of that substring.'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the HighlightedTextLabelDefault changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'select': {'type': None, 'default': None, 'description': 'Event listener for when the user selects or deselects the HighlightedTextLabelDefault. Uses event data gradio.SelectData to carry `value` referring to the label of the HighlightedTextLabelDefault, and `selected` to refer to state of the HighlightedTextLabelDefault. See EventData documentation on how to use this event data'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'HighlightedTextLabelDefault': []}}}
7
+
8
+ abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
+
10
+ with gr.Blocks(
11
+ css=abs_path,
12
+ theme=gr.themes.Default(
13
+ font_mono=[
14
+ gr.themes.GoogleFont("Inconsolata"),
15
+ "monospace",
16
+ ],
17
+ ),
18
+ ) as demo:
19
+ gr.Markdown(
20
+ """
21
+ # `gradio_highlightedtextlabeldefault`
22
+
23
+ <div style="display: flex; gap: 7px;">
24
+ <img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
25
+ </div>
26
+
27
+ Modify the default label when selecting a word in the interactive HighlightedText component.
28
+ """, elem_classes=["md-custom"], header_links=True)
29
+ app.render()
30
+ gr.Markdown(
31
+ """
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install gradio_highlightedtextlabeldefault
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+
42
+ import gradio as gr
43
+ from gradio_highlightedtextlabeldefault import HighlightedTextLabelDefault
44
+
45
+
46
+ example = HighlightedTextLabelDefault().example_value()
47
+
48
+ with gr.Blocks() as demo:
49
+ with gr.Row():
50
+ test_1 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]),
51
+ label="Double click word to see standard default label", interactive=True) # default label
52
+ test_2 = HighlightedTextLabelDefault(value=([("Hello, my name is Slim Shady.", None)]), label="Double click word to see modified default label",
53
+ interactive=True, default_label="x", color_map={"x": "green"}) # blank component
54
+
55
+
56
+ if __name__ == "__main__":
57
+ demo.launch()
58
+
59
+ ```
60
+ """, elem_classes=["md-custom"], header_links=True)
61
+
62
+
63
+ gr.Markdown("""
64
+ ## `HighlightedTextLabelDefault`
65
+
66
+ ### Initialization
67
+ """, elem_classes=["md-custom"], header_links=True)
68
+
69
+ gr.ParamViewer(value=_docs["HighlightedTextLabelDefault"]["members"]["__init__"], linkify=[])
70
+
71
+
72
+ gr.Markdown("### Events")
73
+ gr.ParamViewer(value=_docs["HighlightedTextLabelDefault"]["events"], linkify=['Event'])
74
+
75
+
76
+
77
+
78
+ gr.Markdown("""
79
+
80
+ ### User function
81
+
82
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
83
+
84
+ - When used as an Input, the component only impacts the input signature of the user function.
85
+ - When used as an output, the component only impacts the return signature of the user function.
86
+
87
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
88
+
89
+ - **As input:** Is passed, passes the value as a list of tuples as a `list[tuple]` into the function. Each `tuple` consists of a `str` substring of the text (so the entire text is included) and `str | float | None` label, which is the category or confidence of that substring.
90
+ - **As output:** Should return, expects a list of (word, category) tuples, or a dictionary of two keys: "text", and "entities", which itself is a list of dictionaries, each of which have the keys: "entity" (or "entity_group"), "start", and "end".
91
+
92
+ ```python
93
+ def predict(
94
+ value: list[tuple[str, str | float | None]] | None
95
+ ) -> list[tuple[str, str | float | None]] | dict | None:
96
+ return value
97
+ ```
98
+ """, elem_classes=["md-custom", "HighlightedTextLabelDefault-user-fn"], header_links=True)
99
+
100
+
101
+
102
+
103
+ demo.load(None, js=r"""function() {
104
+ const refs = {};
105
+ const user_fn_refs = {
106
+ HighlightedTextLabelDefault: [], };
107
+ requestAnimationFrame(() => {
108
+
109
+ Object.entries(user_fn_refs).forEach(([key, refs]) => {
110
+ if (refs.length > 0) {
111
+ const el = document.querySelector(`.${key}-user-fn`);
112
+ if (!el) return;
113
+ refs.forEach(ref => {
114
+ el.innerHTML = el.innerHTML.replace(
115
+ new RegExp("\\b"+ref+"\\b", "g"),
116
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
117
+ );
118
+ })
119
+ }
120
+ })
121
+
122
+ Object.entries(refs).forEach(([key, refs]) => {
123
+ if (refs.length > 0) {
124
+ const el = document.querySelector(`.${key}`);
125
+ if (!el) return;
126
+ refs.forEach(ref => {
127
+ el.innerHTML = el.innerHTML.replace(
128
+ new RegExp("\\b"+ref+"\\b", "g"),
129
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
130
+ );
131
+ })
132
+ }
133
+ })
134
+ })
135
+ }
136
+
137
+ """)
138
+
139
+ demo.launch()
src/frontend/Index.svelte ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script context="module" lang="ts">
2
+ export { default as BaseStaticHighlightedText } from "./shared/StaticHighlightedtext.svelte";
3
+ export { default as BaseInteractiveHighlightedText } from "./shared/InteractiveHighlightedtext.svelte";
4
+ </script>
5
+
6
+ <script lang="ts">
7
+ import type { Gradio, SelectData, I18nFormatter } from "@gradio/utils";
8
+ import StaticHighlightedText from "./shared/StaticHighlightedtext.svelte";
9
+ import InteractiveHighlightedText from "./shared/InteractiveHighlightedtext.svelte";
10
+ import { Block, BlockLabel, Empty } from "@gradio/atoms";
11
+ import { TextHighlight } from "@gradio/icons";
12
+ import { StatusTracker } from "@gradio/statustracker";
13
+ import type { LoadingStatus } from "@gradio/statustracker";
14
+ import { merge_elements } from "./shared/utils";
15
+
16
+ export let gradio: Gradio<{
17
+ select: SelectData;
18
+ change: never;
19
+ }>;
20
+ export let elem_id = "";
21
+ export let elem_classes: string[] = [];
22
+ export let visible = true;
23
+ export let value: {
24
+ token: string;
25
+ class_or_confidence: string | number | null;
26
+ }[];
27
+ let old_value: typeof value;
28
+ export let show_legend: boolean;
29
+ export let color_map: Record<string, string> = {};
30
+ export let label = gradio.i18n("highlighted_text.highlighted_text");
31
+ export let container = true;
32
+ export let scale: number | null = null;
33
+ export let min_width: number | undefined = undefined;
34
+ export let _selectable = false;
35
+ export let combine_adjacent = false;
36
+ export let interactive: boolean;
37
+ export let default_label: str | None = "label";
38
+
39
+
40
+ $: if (!color_map && Object.keys(color_map).length) {
41
+ color_map = color_map;
42
+ }
43
+
44
+ export let loading_status: LoadingStatus;
45
+
46
+ $: {
47
+ if (value !== old_value) {
48
+ old_value = value;
49
+ gradio.dispatch("change");
50
+ }
51
+ }
52
+
53
+ $: if (value && combine_adjacent) {
54
+ value = merge_elements(value, "equal");
55
+ }
56
+ </script>
57
+
58
+ {#if !interactive}
59
+ <Block
60
+ variant={"solid"}
61
+ test_id="highlighted-text"
62
+ {visible}
63
+ {elem_id}
64
+ {elem_classes}
65
+ padding={false}
66
+ {container}
67
+ {scale}
68
+ {min_width}
69
+ >
70
+ <StatusTracker
71
+ autoscroll={gradio.autoscroll}
72
+ i18n={gradio.i18n}
73
+ {...loading_status}
74
+ />
75
+ {#if label}
76
+ <BlockLabel
77
+ Icon={TextHighlight}
78
+ {label}
79
+ float={false}
80
+ disable={container === false}
81
+ />
82
+ {/if}
83
+
84
+ {#if value}
85
+ <StaticHighlightedText
86
+ on:select={({ detail }) => gradio.dispatch("select", detail)}
87
+ selectable={_selectable}
88
+ {value}
89
+ {show_legend}
90
+ {color_map}
91
+ />
92
+ {:else}
93
+ <Empty>
94
+ <TextHighlight />
95
+ </Empty>
96
+ {/if}
97
+ </Block>
98
+ {:else}
99
+ <Block
100
+ variant={interactive ? "dashed" : "solid"}
101
+ test_id="highlighted-text"
102
+ {visible}
103
+ {elem_id}
104
+ {elem_classes}
105
+ padding={false}
106
+ {container}
107
+ {scale}
108
+ {min_width}
109
+ >
110
+ <StatusTracker
111
+ autoscroll={gradio.autoscroll}
112
+ {...loading_status}
113
+ i18n={gradio.i18n}
114
+ />
115
+ {#if label}
116
+ <BlockLabel
117
+ Icon={TextHighlight}
118
+ {label}
119
+ float={false}
120
+ disable={container === false}
121
+ />
122
+ {/if}
123
+
124
+ {#if value}
125
+ <InteractiveHighlightedText
126
+ bind:value
127
+ on:change={() => gradio.dispatch("change")}
128
+ selectable={_selectable}
129
+ {show_legend}
130
+ {color_map}
131
+ {default_label}
132
+ />
133
+ {:else}
134
+ <Empty>
135
+ <TextHighlight />
136
+ </Empty>
137
+ {/if}
138
+ </Block>
139
+ {/if}
src/frontend/package-lock.json ADDED
@@ -0,0 +1,952 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gradio_highlightedtextlabeldefault",
3
+ "version": "0.4.14",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "gradio_highlightedtextlabeldefault",
9
+ "version": "0.4.14",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "@gradio/atoms": "0.6.2",
13
+ "@gradio/icons": "0.3.4",
14
+ "@gradio/statustracker": "0.4.11",
15
+ "@gradio/theme": "0.2.1",
16
+ "@gradio/utils": "0.3.1"
17
+ }
18
+ },
19
+ "node_modules/@ampproject/remapping": {
20
+ "version": "2.3.0",
21
+ "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
22
+ "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==",
23
+ "peer": true,
24
+ "dependencies": {
25
+ "@jridgewell/gen-mapping": "^0.3.5",
26
+ "@jridgewell/trace-mapping": "^0.3.24"
27
+ },
28
+ "engines": {
29
+ "node": ">=6.0.0"
30
+ }
31
+ },
32
+ "node_modules/@esbuild/aix-ppc64": {
33
+ "version": "0.19.12",
34
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz",
35
+ "integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==",
36
+ "cpu": [
37
+ "ppc64"
38
+ ],
39
+ "optional": true,
40
+ "os": [
41
+ "aix"
42
+ ],
43
+ "engines": {
44
+ "node": ">=12"
45
+ }
46
+ },
47
+ "node_modules/@esbuild/android-arm": {
48
+ "version": "0.19.12",
49
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.12.tgz",
50
+ "integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==",
51
+ "cpu": [
52
+ "arm"
53
+ ],
54
+ "optional": true,
55
+ "os": [
56
+ "android"
57
+ ],
58
+ "engines": {
59
+ "node": ">=12"
60
+ }
61
+ },
62
+ "node_modules/@esbuild/android-arm64": {
63
+ "version": "0.19.12",
64
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz",
65
+ "integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==",
66
+ "cpu": [
67
+ "arm64"
68
+ ],
69
+ "optional": true,
70
+ "os": [
71
+ "android"
72
+ ],
73
+ "engines": {
74
+ "node": ">=12"
75
+ }
76
+ },
77
+ "node_modules/@esbuild/android-x64": {
78
+ "version": "0.19.12",
79
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.12.tgz",
80
+ "integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==",
81
+ "cpu": [
82
+ "x64"
83
+ ],
84
+ "optional": true,
85
+ "os": [
86
+ "android"
87
+ ],
88
+ "engines": {
89
+ "node": ">=12"
90
+ }
91
+ },
92
+ "node_modules/@esbuild/darwin-arm64": {
93
+ "version": "0.19.12",
94
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz",
95
+ "integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==",
96
+ "cpu": [
97
+ "arm64"
98
+ ],
99
+ "optional": true,
100
+ "os": [
101
+ "darwin"
102
+ ],
103
+ "engines": {
104
+ "node": ">=12"
105
+ }
106
+ },
107
+ "node_modules/@esbuild/darwin-x64": {
108
+ "version": "0.19.12",
109
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz",
110
+ "integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==",
111
+ "cpu": [
112
+ "x64"
113
+ ],
114
+ "optional": true,
115
+ "os": [
116
+ "darwin"
117
+ ],
118
+ "engines": {
119
+ "node": ">=12"
120
+ }
121
+ },
122
+ "node_modules/@esbuild/freebsd-arm64": {
123
+ "version": "0.19.12",
124
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz",
125
+ "integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==",
126
+ "cpu": [
127
+ "arm64"
128
+ ],
129
+ "optional": true,
130
+ "os": [
131
+ "freebsd"
132
+ ],
133
+ "engines": {
134
+ "node": ">=12"
135
+ }
136
+ },
137
+ "node_modules/@esbuild/freebsd-x64": {
138
+ "version": "0.19.12",
139
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz",
140
+ "integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==",
141
+ "cpu": [
142
+ "x64"
143
+ ],
144
+ "optional": true,
145
+ "os": [
146
+ "freebsd"
147
+ ],
148
+ "engines": {
149
+ "node": ">=12"
150
+ }
151
+ },
152
+ "node_modules/@esbuild/linux-arm": {
153
+ "version": "0.19.12",
154
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz",
155
+ "integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==",
156
+ "cpu": [
157
+ "arm"
158
+ ],
159
+ "optional": true,
160
+ "os": [
161
+ "linux"
162
+ ],
163
+ "engines": {
164
+ "node": ">=12"
165
+ }
166
+ },
167
+ "node_modules/@esbuild/linux-arm64": {
168
+ "version": "0.19.12",
169
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz",
170
+ "integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==",
171
+ "cpu": [
172
+ "arm64"
173
+ ],
174
+ "optional": true,
175
+ "os": [
176
+ "linux"
177
+ ],
178
+ "engines": {
179
+ "node": ">=12"
180
+ }
181
+ },
182
+ "node_modules/@esbuild/linux-ia32": {
183
+ "version": "0.19.12",
184
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz",
185
+ "integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==",
186
+ "cpu": [
187
+ "ia32"
188
+ ],
189
+ "optional": true,
190
+ "os": [
191
+ "linux"
192
+ ],
193
+ "engines": {
194
+ "node": ">=12"
195
+ }
196
+ },
197
+ "node_modules/@esbuild/linux-loong64": {
198
+ "version": "0.19.12",
199
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz",
200
+ "integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==",
201
+ "cpu": [
202
+ "loong64"
203
+ ],
204
+ "optional": true,
205
+ "os": [
206
+ "linux"
207
+ ],
208
+ "engines": {
209
+ "node": ">=12"
210
+ }
211
+ },
212
+ "node_modules/@esbuild/linux-mips64el": {
213
+ "version": "0.19.12",
214
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz",
215
+ "integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==",
216
+ "cpu": [
217
+ "mips64el"
218
+ ],
219
+ "optional": true,
220
+ "os": [
221
+ "linux"
222
+ ],
223
+ "engines": {
224
+ "node": ">=12"
225
+ }
226
+ },
227
+ "node_modules/@esbuild/linux-ppc64": {
228
+ "version": "0.19.12",
229
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz",
230
+ "integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==",
231
+ "cpu": [
232
+ "ppc64"
233
+ ],
234
+ "optional": true,
235
+ "os": [
236
+ "linux"
237
+ ],
238
+ "engines": {
239
+ "node": ">=12"
240
+ }
241
+ },
242
+ "node_modules/@esbuild/linux-riscv64": {
243
+ "version": "0.19.12",
244
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz",
245
+ "integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==",
246
+ "cpu": [
247
+ "riscv64"
248
+ ],
249
+ "optional": true,
250
+ "os": [
251
+ "linux"
252
+ ],
253
+ "engines": {
254
+ "node": ">=12"
255
+ }
256
+ },
257
+ "node_modules/@esbuild/linux-s390x": {
258
+ "version": "0.19.12",
259
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz",
260
+ "integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==",
261
+ "cpu": [
262
+ "s390x"
263
+ ],
264
+ "optional": true,
265
+ "os": [
266
+ "linux"
267
+ ],
268
+ "engines": {
269
+ "node": ">=12"
270
+ }
271
+ },
272
+ "node_modules/@esbuild/linux-x64": {
273
+ "version": "0.19.12",
274
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz",
275
+ "integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==",
276
+ "cpu": [
277
+ "x64"
278
+ ],
279
+ "optional": true,
280
+ "os": [
281
+ "linux"
282
+ ],
283
+ "engines": {
284
+ "node": ">=12"
285
+ }
286
+ },
287
+ "node_modules/@esbuild/netbsd-x64": {
288
+ "version": "0.19.12",
289
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz",
290
+ "integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==",
291
+ "cpu": [
292
+ "x64"
293
+ ],
294
+ "optional": true,
295
+ "os": [
296
+ "netbsd"
297
+ ],
298
+ "engines": {
299
+ "node": ">=12"
300
+ }
301
+ },
302
+ "node_modules/@esbuild/openbsd-x64": {
303
+ "version": "0.19.12",
304
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz",
305
+ "integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==",
306
+ "cpu": [
307
+ "x64"
308
+ ],
309
+ "optional": true,
310
+ "os": [
311
+ "openbsd"
312
+ ],
313
+ "engines": {
314
+ "node": ">=12"
315
+ }
316
+ },
317
+ "node_modules/@esbuild/sunos-x64": {
318
+ "version": "0.19.12",
319
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz",
320
+ "integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==",
321
+ "cpu": [
322
+ "x64"
323
+ ],
324
+ "optional": true,
325
+ "os": [
326
+ "sunos"
327
+ ],
328
+ "engines": {
329
+ "node": ">=12"
330
+ }
331
+ },
332
+ "node_modules/@esbuild/win32-arm64": {
333
+ "version": "0.19.12",
334
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz",
335
+ "integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==",
336
+ "cpu": [
337
+ "arm64"
338
+ ],
339
+ "optional": true,
340
+ "os": [
341
+ "win32"
342
+ ],
343
+ "engines": {
344
+ "node": ">=12"
345
+ }
346
+ },
347
+ "node_modules/@esbuild/win32-ia32": {
348
+ "version": "0.19.12",
349
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz",
350
+ "integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==",
351
+ "cpu": [
352
+ "ia32"
353
+ ],
354
+ "optional": true,
355
+ "os": [
356
+ "win32"
357
+ ],
358
+ "engines": {
359
+ "node": ">=12"
360
+ }
361
+ },
362
+ "node_modules/@esbuild/win32-x64": {
363
+ "version": "0.19.12",
364
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz",
365
+ "integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==",
366
+ "cpu": [
367
+ "x64"
368
+ ],
369
+ "optional": true,
370
+ "os": [
371
+ "win32"
372
+ ],
373
+ "engines": {
374
+ "node": ">=12"
375
+ }
376
+ },
377
+ "node_modules/@formatjs/ecma402-abstract": {
378
+ "version": "1.11.4",
379
+ "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.4.tgz",
380
+ "integrity": "sha512-EBikYFp2JCdIfGEb5G9dyCkTGDmC57KSHhRQOC3aYxoPWVZvfWCDjZwkGYHN7Lis/fmuWl906bnNTJifDQ3sXw==",
381
+ "dependencies": {
382
+ "@formatjs/intl-localematcher": "0.2.25",
383
+ "tslib": "^2.1.0"
384
+ }
385
+ },
386
+ "node_modules/@formatjs/fast-memoize": {
387
+ "version": "1.2.1",
388
+ "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-1.2.1.tgz",
389
+ "integrity": "sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg==",
390
+ "dependencies": {
391
+ "tslib": "^2.1.0"
392
+ }
393
+ },
394
+ "node_modules/@formatjs/icu-messageformat-parser": {
395
+ "version": "2.1.0",
396
+ "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.1.0.tgz",
397
+ "integrity": "sha512-Qxv/lmCN6hKpBSss2uQ8IROVnta2r9jd3ymUEIjm2UyIkUCHVcbUVRGL/KS/wv7876edvsPe+hjHVJ4z8YuVaw==",
398
+ "dependencies": {
399
+ "@formatjs/ecma402-abstract": "1.11.4",
400
+ "@formatjs/icu-skeleton-parser": "1.3.6",
401
+ "tslib": "^2.1.0"
402
+ }
403
+ },
404
+ "node_modules/@formatjs/icu-skeleton-parser": {
405
+ "version": "1.3.6",
406
+ "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.6.tgz",
407
+ "integrity": "sha512-I96mOxvml/YLrwU2Txnd4klA7V8fRhb6JG/4hm3VMNmeJo1F03IpV2L3wWt7EweqNLES59SZ4d6hVOPCSf80Bg==",
408
+ "dependencies": {
409
+ "@formatjs/ecma402-abstract": "1.11.4",
410
+ "tslib": "^2.1.0"
411
+ }
412
+ },
413
+ "node_modules/@formatjs/intl-localematcher": {
414
+ "version": "0.2.25",
415
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.2.25.tgz",
416
+ "integrity": "sha512-YmLcX70BxoSopLFdLr1Ds99NdlTI2oWoLbaUW2M406lxOIPzE1KQhRz2fPUkq34xVZQaihCoU29h0KK7An3bhA==",
417
+ "dependencies": {
418
+ "tslib": "^2.1.0"
419
+ }
420
+ },
421
+ "node_modules/@gradio/atoms": {
422
+ "version": "0.6.2",
423
+ "resolved": "https://registry.npmjs.org/@gradio/atoms/-/atoms-0.6.2.tgz",
424
+ "integrity": "sha512-1HlNIX3XzPJEakv9RB5Cn7l/GH618qDtfb30YR7CBw8lljXvn/i1nBCG+DO1mdoNfRA3x/pc3vM7X3G6cuh4PQ==",
425
+ "dependencies": {
426
+ "@gradio/icons": "^0.3.4",
427
+ "@gradio/utils": "^0.3.1"
428
+ }
429
+ },
430
+ "node_modules/@gradio/column": {
431
+ "version": "0.1.0",
432
+ "resolved": "https://registry.npmjs.org/@gradio/column/-/column-0.1.0.tgz",
433
+ "integrity": "sha512-P24nqqVnMXBaDA1f/zSN5HZRho4PxP8Dq+7VltPHlmxIEiZYik2AJ4J0LeuIha34FDO0guu/16evdrpvGIUAfw=="
434
+ },
435
+ "node_modules/@gradio/icons": {
436
+ "version": "0.3.4",
437
+ "resolved": "https://registry.npmjs.org/@gradio/icons/-/icons-0.3.4.tgz",
438
+ "integrity": "sha512-rtH7u3OiYy9UuO1bnebXkTXgc+D62H6BILrMtM4EfsKGgQQICD0n7NPvbPtS0zpi/fz0ppCdlfFIKKIOeVaeFg=="
439
+ },
440
+ "node_modules/@gradio/statustracker": {
441
+ "version": "0.4.11",
442
+ "resolved": "https://registry.npmjs.org/@gradio/statustracker/-/statustracker-0.4.11.tgz",
443
+ "integrity": "sha512-8SiS5kC0092e1J06j55D8xAYqsA6wvmFeosnGd557OTigOpVPKuqsa1ekTHxAPgE/RbGEzYQ851UsMT6Oh5fWg==",
444
+ "dependencies": {
445
+ "@gradio/atoms": "^0.6.2",
446
+ "@gradio/column": "^0.1.0",
447
+ "@gradio/icons": "^0.3.4",
448
+ "@gradio/utils": "^0.3.1"
449
+ }
450
+ },
451
+ "node_modules/@gradio/theme": {
452
+ "version": "0.2.1",
453
+ "resolved": "https://registry.npmjs.org/@gradio/theme/-/theme-0.2.1.tgz",
454
+ "integrity": "sha512-ua1fWiXRDl/Yrn2JS/bda2oI5UYJs0PjkIgOgJy6TQKt8rRspb+3sp33em9t8CJjxtavR/efwWOFfBJaIzEMig=="
455
+ },
456
+ "node_modules/@gradio/utils": {
457
+ "version": "0.3.1",
458
+ "resolved": "https://registry.npmjs.org/@gradio/utils/-/utils-0.3.1.tgz",
459
+ "integrity": "sha512-LlDr/QlX8eZNzqfgtx4M3lFP0qSybbecDXwnKe7jgkL01qollJpSsOvZ5t1wxmas1qbINws6kT821XUxEjmutQ==",
460
+ "dependencies": {
461
+ "@gradio/theme": "^0.2.1",
462
+ "svelte-i18n": "^3.6.0"
463
+ }
464
+ },
465
+ "node_modules/@jridgewell/gen-mapping": {
466
+ "version": "0.3.5",
467
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz",
468
+ "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==",
469
+ "peer": true,
470
+ "dependencies": {
471
+ "@jridgewell/set-array": "^1.2.1",
472
+ "@jridgewell/sourcemap-codec": "^1.4.10",
473
+ "@jridgewell/trace-mapping": "^0.3.24"
474
+ },
475
+ "engines": {
476
+ "node": ">=6.0.0"
477
+ }
478
+ },
479
+ "node_modules/@jridgewell/resolve-uri": {
480
+ "version": "3.1.2",
481
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
482
+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
483
+ "peer": true,
484
+ "engines": {
485
+ "node": ">=6.0.0"
486
+ }
487
+ },
488
+ "node_modules/@jridgewell/set-array": {
489
+ "version": "1.2.1",
490
+ "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz",
491
+ "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==",
492
+ "peer": true,
493
+ "engines": {
494
+ "node": ">=6.0.0"
495
+ }
496
+ },
497
+ "node_modules/@jridgewell/sourcemap-codec": {
498
+ "version": "1.4.15",
499
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
500
+ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
501
+ "peer": true
502
+ },
503
+ "node_modules/@jridgewell/trace-mapping": {
504
+ "version": "0.3.25",
505
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz",
506
+ "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==",
507
+ "peer": true,
508
+ "dependencies": {
509
+ "@jridgewell/resolve-uri": "^3.1.0",
510
+ "@jridgewell/sourcemap-codec": "^1.4.14"
511
+ }
512
+ },
513
+ "node_modules/@types/estree": {
514
+ "version": "1.0.5",
515
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
516
+ "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
517
+ "peer": true
518
+ },
519
+ "node_modules/acorn": {
520
+ "version": "8.11.3",
521
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
522
+ "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
523
+ "peer": true,
524
+ "bin": {
525
+ "acorn": "bin/acorn"
526
+ },
527
+ "engines": {
528
+ "node": ">=0.4.0"
529
+ }
530
+ },
531
+ "node_modules/aria-query": {
532
+ "version": "5.3.0",
533
+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
534
+ "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
535
+ "peer": true,
536
+ "dependencies": {
537
+ "dequal": "^2.0.3"
538
+ }
539
+ },
540
+ "node_modules/axobject-query": {
541
+ "version": "4.0.0",
542
+ "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.0.0.tgz",
543
+ "integrity": "sha512-+60uv1hiVFhHZeO+Lz0RYzsVHy5Wr1ayX0mwda9KPDVLNJgZ1T9Ny7VmFbLDzxsH0D87I86vgj3gFrjTJUYznw==",
544
+ "peer": true,
545
+ "dependencies": {
546
+ "dequal": "^2.0.3"
547
+ }
548
+ },
549
+ "node_modules/cli-color": {
550
+ "version": "2.0.4",
551
+ "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.4.tgz",
552
+ "integrity": "sha512-zlnpg0jNcibNrO7GG9IeHH7maWFeCz+Ja1wx/7tZNU5ASSSSZ+/qZciM0/LHCYxSdqv5h2sdbQ/PXYdOuetXvA==",
553
+ "dependencies": {
554
+ "d": "^1.0.1",
555
+ "es5-ext": "^0.10.64",
556
+ "es6-iterator": "^2.0.3",
557
+ "memoizee": "^0.4.15",
558
+ "timers-ext": "^0.1.7"
559
+ },
560
+ "engines": {
561
+ "node": ">=0.10"
562
+ }
563
+ },
564
+ "node_modules/code-red": {
565
+ "version": "1.0.4",
566
+ "resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz",
567
+ "integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==",
568
+ "peer": true,
569
+ "dependencies": {
570
+ "@jridgewell/sourcemap-codec": "^1.4.15",
571
+ "@types/estree": "^1.0.1",
572
+ "acorn": "^8.10.0",
573
+ "estree-walker": "^3.0.3",
574
+ "periscopic": "^3.1.0"
575
+ }
576
+ },
577
+ "node_modules/css-tree": {
578
+ "version": "2.3.1",
579
+ "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz",
580
+ "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==",
581
+ "peer": true,
582
+ "dependencies": {
583
+ "mdn-data": "2.0.30",
584
+ "source-map-js": "^1.0.1"
585
+ },
586
+ "engines": {
587
+ "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"
588
+ }
589
+ },
590
+ "node_modules/d": {
591
+ "version": "1.0.2",
592
+ "resolved": "https://registry.npmjs.org/d/-/d-1.0.2.tgz",
593
+ "integrity": "sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==",
594
+ "dependencies": {
595
+ "es5-ext": "^0.10.64",
596
+ "type": "^2.7.2"
597
+ },
598
+ "engines": {
599
+ "node": ">=0.12"
600
+ }
601
+ },
602
+ "node_modules/deepmerge": {
603
+ "version": "4.3.1",
604
+ "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
605
+ "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
606
+ "engines": {
607
+ "node": ">=0.10.0"
608
+ }
609
+ },
610
+ "node_modules/dequal": {
611
+ "version": "2.0.3",
612
+ "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
613
+ "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
614
+ "peer": true,
615
+ "engines": {
616
+ "node": ">=6"
617
+ }
618
+ },
619
+ "node_modules/es5-ext": {
620
+ "version": "0.10.64",
621
+ "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz",
622
+ "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==",
623
+ "hasInstallScript": true,
624
+ "dependencies": {
625
+ "es6-iterator": "^2.0.3",
626
+ "es6-symbol": "^3.1.3",
627
+ "esniff": "^2.0.1",
628
+ "next-tick": "^1.1.0"
629
+ },
630
+ "engines": {
631
+ "node": ">=0.10"
632
+ }
633
+ },
634
+ "node_modules/es6-iterator": {
635
+ "version": "2.0.3",
636
+ "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
637
+ "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
638
+ "dependencies": {
639
+ "d": "1",
640
+ "es5-ext": "^0.10.35",
641
+ "es6-symbol": "^3.1.1"
642
+ }
643
+ },
644
+ "node_modules/es6-symbol": {
645
+ "version": "3.1.4",
646
+ "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.4.tgz",
647
+ "integrity": "sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==",
648
+ "dependencies": {
649
+ "d": "^1.0.2",
650
+ "ext": "^1.7.0"
651
+ },
652
+ "engines": {
653
+ "node": ">=0.12"
654
+ }
655
+ },
656
+ "node_modules/es6-weak-map": {
657
+ "version": "2.0.3",
658
+ "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz",
659
+ "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==",
660
+ "dependencies": {
661
+ "d": "1",
662
+ "es5-ext": "^0.10.46",
663
+ "es6-iterator": "^2.0.3",
664
+ "es6-symbol": "^3.1.1"
665
+ }
666
+ },
667
+ "node_modules/esbuild": {
668
+ "version": "0.19.12",
669
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz",
670
+ "integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==",
671
+ "hasInstallScript": true,
672
+ "bin": {
673
+ "esbuild": "bin/esbuild"
674
+ },
675
+ "engines": {
676
+ "node": ">=12"
677
+ },
678
+ "optionalDependencies": {
679
+ "@esbuild/aix-ppc64": "0.19.12",
680
+ "@esbuild/android-arm": "0.19.12",
681
+ "@esbuild/android-arm64": "0.19.12",
682
+ "@esbuild/android-x64": "0.19.12",
683
+ "@esbuild/darwin-arm64": "0.19.12",
684
+ "@esbuild/darwin-x64": "0.19.12",
685
+ "@esbuild/freebsd-arm64": "0.19.12",
686
+ "@esbuild/freebsd-x64": "0.19.12",
687
+ "@esbuild/linux-arm": "0.19.12",
688
+ "@esbuild/linux-arm64": "0.19.12",
689
+ "@esbuild/linux-ia32": "0.19.12",
690
+ "@esbuild/linux-loong64": "0.19.12",
691
+ "@esbuild/linux-mips64el": "0.19.12",
692
+ "@esbuild/linux-ppc64": "0.19.12",
693
+ "@esbuild/linux-riscv64": "0.19.12",
694
+ "@esbuild/linux-s390x": "0.19.12",
695
+ "@esbuild/linux-x64": "0.19.12",
696
+ "@esbuild/netbsd-x64": "0.19.12",
697
+ "@esbuild/openbsd-x64": "0.19.12",
698
+ "@esbuild/sunos-x64": "0.19.12",
699
+ "@esbuild/win32-arm64": "0.19.12",
700
+ "@esbuild/win32-ia32": "0.19.12",
701
+ "@esbuild/win32-x64": "0.19.12"
702
+ }
703
+ },
704
+ "node_modules/esniff": {
705
+ "version": "2.0.1",
706
+ "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz",
707
+ "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==",
708
+ "dependencies": {
709
+ "d": "^1.0.1",
710
+ "es5-ext": "^0.10.62",
711
+ "event-emitter": "^0.3.5",
712
+ "type": "^2.7.2"
713
+ },
714
+ "engines": {
715
+ "node": ">=0.10"
716
+ }
717
+ },
718
+ "node_modules/estree-walker": {
719
+ "version": "3.0.3",
720
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
721
+ "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
722
+ "peer": true,
723
+ "dependencies": {
724
+ "@types/estree": "^1.0.0"
725
+ }
726
+ },
727
+ "node_modules/event-emitter": {
728
+ "version": "0.3.5",
729
+ "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
730
+ "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==",
731
+ "dependencies": {
732
+ "d": "1",
733
+ "es5-ext": "~0.10.14"
734
+ }
735
+ },
736
+ "node_modules/ext": {
737
+ "version": "1.7.0",
738
+ "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz",
739
+ "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==",
740
+ "dependencies": {
741
+ "type": "^2.7.2"
742
+ }
743
+ },
744
+ "node_modules/globalyzer": {
745
+ "version": "0.1.0",
746
+ "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
747
+ "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q=="
748
+ },
749
+ "node_modules/globrex": {
750
+ "version": "0.1.2",
751
+ "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
752
+ "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
753
+ },
754
+ "node_modules/intl-messageformat": {
755
+ "version": "9.13.0",
756
+ "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-9.13.0.tgz",
757
+ "integrity": "sha512-7sGC7QnSQGa5LZP7bXLDhVDtQOeKGeBFGHF2Y8LVBwYZoQZCgWeKoPGTa5GMG8g/TzDgeXuYJQis7Ggiw2xTOw==",
758
+ "dependencies": {
759
+ "@formatjs/ecma402-abstract": "1.11.4",
760
+ "@formatjs/fast-memoize": "1.2.1",
761
+ "@formatjs/icu-messageformat-parser": "2.1.0",
762
+ "tslib": "^2.1.0"
763
+ }
764
+ },
765
+ "node_modules/is-promise": {
766
+ "version": "2.2.2",
767
+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
768
+ "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ=="
769
+ },
770
+ "node_modules/is-reference": {
771
+ "version": "3.0.2",
772
+ "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz",
773
+ "integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==",
774
+ "peer": true,
775
+ "dependencies": {
776
+ "@types/estree": "*"
777
+ }
778
+ },
779
+ "node_modules/locate-character": {
780
+ "version": "3.0.0",
781
+ "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",
782
+ "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
783
+ "peer": true
784
+ },
785
+ "node_modules/lru-queue": {
786
+ "version": "0.1.0",
787
+ "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
788
+ "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==",
789
+ "dependencies": {
790
+ "es5-ext": "~0.10.2"
791
+ }
792
+ },
793
+ "node_modules/magic-string": {
794
+ "version": "0.30.9",
795
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.9.tgz",
796
+ "integrity": "sha512-S1+hd+dIrC8EZqKyT9DstTH/0Z+f76kmmvZnkfQVmOpDEF9iVgdYif3Q/pIWHmCoo59bQVGW0kVL3e2nl+9+Sw==",
797
+ "peer": true,
798
+ "dependencies": {
799
+ "@jridgewell/sourcemap-codec": "^1.4.15"
800
+ },
801
+ "engines": {
802
+ "node": ">=12"
803
+ }
804
+ },
805
+ "node_modules/mdn-data": {
806
+ "version": "2.0.30",
807
+ "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz",
808
+ "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==",
809
+ "peer": true
810
+ },
811
+ "node_modules/memoizee": {
812
+ "version": "0.4.15",
813
+ "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz",
814
+ "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==",
815
+ "dependencies": {
816
+ "d": "^1.0.1",
817
+ "es5-ext": "^0.10.53",
818
+ "es6-weak-map": "^2.0.3",
819
+ "event-emitter": "^0.3.5",
820
+ "is-promise": "^2.2.2",
821
+ "lru-queue": "^0.1.0",
822
+ "next-tick": "^1.1.0",
823
+ "timers-ext": "^0.1.7"
824
+ }
825
+ },
826
+ "node_modules/mri": {
827
+ "version": "1.2.0",
828
+ "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
829
+ "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
830
+ "engines": {
831
+ "node": ">=4"
832
+ }
833
+ },
834
+ "node_modules/next-tick": {
835
+ "version": "1.1.0",
836
+ "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
837
+ "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
838
+ },
839
+ "node_modules/periscopic": {
840
+ "version": "3.1.0",
841
+ "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz",
842
+ "integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==",
843
+ "peer": true,
844
+ "dependencies": {
845
+ "@types/estree": "^1.0.0",
846
+ "estree-walker": "^3.0.0",
847
+ "is-reference": "^3.0.0"
848
+ }
849
+ },
850
+ "node_modules/sade": {
851
+ "version": "1.8.1",
852
+ "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
853
+ "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
854
+ "dependencies": {
855
+ "mri": "^1.1.0"
856
+ },
857
+ "engines": {
858
+ "node": ">=6"
859
+ }
860
+ },
861
+ "node_modules/source-map-js": {
862
+ "version": "1.2.0",
863
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
864
+ "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
865
+ "peer": true,
866
+ "engines": {
867
+ "node": ">=0.10.0"
868
+ }
869
+ },
870
+ "node_modules/svelte": {
871
+ "version": "4.2.13",
872
+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.13.tgz",
873
+ "integrity": "sha512-jtVt2KXLbQnsWN93Zd7EVboNh8Tqexes4rZfXNP7nYRjd9+JjubTD8BXloUmU1OUYpc6pdd1aKBhCV+b2ZKoMg==",
874
+ "peer": true,
875
+ "dependencies": {
876
+ "@ampproject/remapping": "^2.2.1",
877
+ "@jridgewell/sourcemap-codec": "^1.4.15",
878
+ "@jridgewell/trace-mapping": "^0.3.18",
879
+ "@types/estree": "^1.0.1",
880
+ "acorn": "^8.9.0",
881
+ "aria-query": "^5.3.0",
882
+ "axobject-query": "^4.0.0",
883
+ "code-red": "^1.0.3",
884
+ "css-tree": "^2.3.1",
885
+ "estree-walker": "^3.0.3",
886
+ "is-reference": "^3.0.1",
887
+ "locate-character": "^3.0.0",
888
+ "magic-string": "^0.30.4",
889
+ "periscopic": "^3.1.0"
890
+ },
891
+ "engines": {
892
+ "node": ">=16"
893
+ }
894
+ },
895
+ "node_modules/svelte-i18n": {
896
+ "version": "3.7.4",
897
+ "resolved": "https://registry.npmjs.org/svelte-i18n/-/svelte-i18n-3.7.4.tgz",
898
+ "integrity": "sha512-yGRCNo+eBT4cPuU7IVsYTYjxB7I2V8qgUZPlHnNctJj5IgbJgV78flsRzpjZ/8iUYZrS49oCt7uxlU3AZv/N5Q==",
899
+ "dependencies": {
900
+ "cli-color": "^2.0.3",
901
+ "deepmerge": "^4.2.2",
902
+ "esbuild": "^0.19.2",
903
+ "estree-walker": "^2",
904
+ "intl-messageformat": "^9.13.0",
905
+ "sade": "^1.8.1",
906
+ "tiny-glob": "^0.2.9"
907
+ },
908
+ "bin": {
909
+ "svelte-i18n": "dist/cli.js"
910
+ },
911
+ "engines": {
912
+ "node": ">= 16"
913
+ },
914
+ "peerDependencies": {
915
+ "svelte": "^3 || ^4"
916
+ }
917
+ },
918
+ "node_modules/svelte-i18n/node_modules/estree-walker": {
919
+ "version": "2.0.2",
920
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
921
+ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
922
+ },
923
+ "node_modules/timers-ext": {
924
+ "version": "0.1.7",
925
+ "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
926
+ "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
927
+ "dependencies": {
928
+ "es5-ext": "~0.10.46",
929
+ "next-tick": "1"
930
+ }
931
+ },
932
+ "node_modules/tiny-glob": {
933
+ "version": "0.2.9",
934
+ "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
935
+ "integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
936
+ "dependencies": {
937
+ "globalyzer": "0.1.0",
938
+ "globrex": "^0.1.2"
939
+ }
940
+ },
941
+ "node_modules/tslib": {
942
+ "version": "2.6.2",
943
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
944
+ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
945
+ },
946
+ "node_modules/type": {
947
+ "version": "2.7.2",
948
+ "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
949
+ "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
950
+ }
951
+ }
952
+ }
src/frontend/package.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gradio_highlightedtextlabeldefault",
3
+ "version": "0.4.14",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": false,
9
+ "main_changeset": true,
10
+ "dependencies": {
11
+ "@gradio/atoms": "0.6.2",
12
+ "@gradio/icons": "0.3.4",
13
+ "@gradio/statustracker": "0.4.11",
14
+ "@gradio/theme": "0.2.1",
15
+ "@gradio/utils": "0.3.1"
16
+ },
17
+ "main": "./Index.svelte",
18
+ "exports": {
19
+ ".": "./Index.svelte",
20
+ "./package.json": "./package.json"
21
+ }
22
+ }
src/frontend/shared/InteractiveHighlightedtext.svelte ADDED
@@ -0,0 +1,512 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ const browser = typeof document !== "undefined";
3
+ import { get_next_color } from "@gradio/utils";
4
+ import type { SelectData } from "@gradio/utils";
5
+ import { createEventDispatcher, onMount } from "svelte";
6
+ import { correct_color_map, merge_elements } from "./utils";
7
+ import LabelInput from "./LabelInput.svelte";
8
+
9
+ export let value: {
10
+ token: string;
11
+ class_or_confidence: string | number | null;
12
+ }[] = [];
13
+ export let show_legend = false;
14
+ export let color_map: Record<string, string> = {};
15
+ export let selectable = false;
16
+ export let default_label: str;
17
+
18
+
19
+ let activeElementIndex = -1;
20
+ let ctx: CanvasRenderingContext2D;
21
+ let _color_map: Record<string, { primary: string; secondary: string }> = {};
22
+ let active = "";
23
+ let selection: Selection | null;
24
+ let labelToEdit = -1;
25
+
26
+ onMount(() => {
27
+ const mouseUpHandler = (): void => {
28
+ selection = window.getSelection();
29
+ handleSelectionComplete();
30
+ window.removeEventListener("mouseup", mouseUpHandler);
31
+ };
32
+
33
+ window.addEventListener("mousedown", () => {
34
+ window.addEventListener("mouseup", mouseUpHandler);
35
+ });
36
+ });
37
+
38
+ async function handleTextSelected(
39
+ startIndex: number,
40
+ endIndex: number
41
+ ): Promise<void> {
42
+ if (
43
+ selection?.toString() &&
44
+ activeElementIndex !== -1 &&
45
+ value[activeElementIndex].token.toString().includes(selection.toString())
46
+ ) {
47
+ const tempFlag = Symbol();
48
+
49
+ const str = value[activeElementIndex].token;
50
+ const [before, selected, after] = [
51
+ str.substring(0, startIndex),
52
+ str.substring(startIndex, endIndex),
53
+ str.substring(endIndex)
54
+ ];
55
+
56
+ let tempValue: {
57
+ token: string;
58
+ class_or_confidence: string | number | null;
59
+ flag?: symbol;
60
+ }[] = [
61
+ ...value.slice(0, activeElementIndex),
62
+ { token: before, class_or_confidence: null },
63
+ {
64
+ token: selected,
65
+ class_or_confidence: mode === "scores" ? 1 : default_label,
66
+ flag: tempFlag
67
+ }, // add a temp flag to the new highlighted text element
68
+ { token: after, class_or_confidence: null },
69
+ ...value.slice(activeElementIndex + 1)
70
+ ];
71
+
72
+ // store the index of the new highlighted text element and remove the flag
73
+ labelToEdit = tempValue.findIndex(({ flag }) => flag === tempFlag);
74
+ // tempValue[labelToEdit].pop();
75
+
76
+ // remove elements with empty labels
77
+ tempValue = tempValue.filter((item) => item.token.trim() !== "");
78
+ value = tempValue.map(({ flag, ...rest }) => rest);
79
+
80
+ handleValueChange();
81
+ document.getElementById(`label-input-${labelToEdit}`)?.focus();
82
+ }
83
+ }
84
+
85
+ const dispatch = createEventDispatcher<{
86
+ select: SelectData;
87
+ change: typeof value;
88
+ input: never;
89
+ }>();
90
+
91
+ function splitTextByNewline(text: string): string[] {
92
+ return text.split("\n");
93
+ }
94
+
95
+ function removeHighlightedText(index: number): void {
96
+ if (!value || index < 0 || index >= value.length) return;
97
+ value[index].class_or_confidence = null;
98
+ value = merge_elements(value, "equal");
99
+ handleValueChange();
100
+ window.getSelection()?.empty();
101
+ }
102
+
103
+ function handleValueChange(): void {
104
+ dispatch("change", value);
105
+ labelToEdit = -1;
106
+
107
+ // reset legend color maps
108
+ if (show_legend) {
109
+ color_map = {};
110
+ _color_map = {};
111
+ }
112
+ }
113
+
114
+ let mode: "categories" | "scores";
115
+
116
+ $: {
117
+ if (!color_map) {
118
+ color_map = {};
119
+ }
120
+ if (value.length > 0) {
121
+ for (let entry of value) {
122
+ if (entry.class_or_confidence !== null) {
123
+ if (typeof entry.class_or_confidence === "string") {
124
+ mode = "categories";
125
+ if (!(entry.class_or_confidence in color_map)) {
126
+ let color = get_next_color(Object.keys(color_map).length);
127
+ color_map[entry.class_or_confidence] = color;
128
+ }
129
+ } else {
130
+ mode = "scores";
131
+ }
132
+ }
133
+ }
134
+ }
135
+
136
+ correct_color_map(color_map, _color_map, browser, ctx);
137
+ }
138
+
139
+ function handle_mouseover(label: string): void {
140
+ active = label;
141
+ }
142
+ function handle_mouseout(): void {
143
+ active = "";
144
+ }
145
+
146
+ async function handleKeydownSelection(event: KeyboardEvent): Promise<void> {
147
+ selection = window.getSelection();
148
+
149
+ if (event.key === "Enter") {
150
+ handleSelectionComplete();
151
+ }
152
+ }
153
+
154
+ function handleSelectionComplete(): void {
155
+ if (selection && selection?.toString().trim() !== "") {
156
+ const textBeginningIndex = selection.getRangeAt(0).startOffset;
157
+ const textEndIndex = selection.getRangeAt(0).endOffset;
158
+ handleTextSelected(textBeginningIndex, textEndIndex);
159
+ }
160
+ }
161
+
162
+ function handleSelect(
163
+ i: number,
164
+ text: string,
165
+ class_or_confidence: string | number | null
166
+ ): void {
167
+ dispatch("select", {
168
+ index: i,
169
+ value: [text, class_or_confidence]
170
+ });
171
+ }
172
+ </script>
173
+
174
+ <div class="container">
175
+ {#if mode === "categories"}
176
+ {#if show_legend}
177
+ <div
178
+ class="class_or_confidence-legend"
179
+ data-testid="highlighted-text:class_or_confidence-legend"
180
+ >
181
+ {#if _color_map}
182
+ {#each Object.entries(_color_map) as [class_or_confidence, color], i}
183
+ <div
184
+ role="button"
185
+ aria-roledescription="Categories of highlighted text. Hover to see text with this class_or_confidence highlighted."
186
+ tabindex="0"
187
+ on:mouseover={() => handle_mouseover(class_or_confidence)}
188
+ on:focus={() => handle_mouseover(class_or_confidence)}
189
+ on:mouseout={() => handle_mouseout()}
190
+ on:blur={() => handle_mouseout()}
191
+ class="class_or_confidence-label"
192
+ style={"background-color:" + color.secondary}
193
+ >
194
+ {class_or_confidence}
195
+ </div>
196
+ {/each}
197
+ {/if}
198
+ </div>
199
+ {/if}
200
+
201
+ <div class="textfield">
202
+ {#each value as { token, class_or_confidence }, i}
203
+ {#each splitTextByNewline(token) as line, j}
204
+ {#if line.trim() !== ""}
205
+ <span class="text-class_or_confidence-container">
206
+ <span
207
+ role="button"
208
+ tabindex="0"
209
+ class="textspan"
210
+ style:background-color={class_or_confidence === null ||
211
+ (active && active !== class_or_confidence)
212
+ ? ""
213
+ : class_or_confidence && _color_map[class_or_confidence]
214
+ ? _color_map[class_or_confidence].secondary
215
+ : ""}
216
+ class:no-cat={class_or_confidence === null ||
217
+ (active && active !== class_or_confidence)}
218
+ class:hl={class_or_confidence !== null}
219
+ class:selectable
220
+ on:click={() => {
221
+ if (class_or_confidence !== null) {
222
+ handleSelect(i, token, class_or_confidence);
223
+ }
224
+ }}
225
+ on:keydown={(e) => {
226
+ if (class_or_confidence !== null) {
227
+ labelToEdit = i;
228
+ handleSelect(i, token, class_or_confidence);
229
+ } else {
230
+ handleKeydownSelection(e);
231
+ }
232
+ }}
233
+ on:focus={() => (activeElementIndex = i)}
234
+ on:mouseover={() => (activeElementIndex = i)}
235
+ >
236
+ <span
237
+ class:no-label={class_or_confidence === null}
238
+ class="text"
239
+ role="button"
240
+ on:keydown={(e) => handleKeydownSelection(e)}
241
+ on:focus={() => (activeElementIndex = i)}
242
+ on:mouseover={() => (activeElementIndex = i)}
243
+ on:click={() => (labelToEdit = i)}
244
+ tabindex="0">{line}</span
245
+ >
246
+ {#if !show_legend && class_or_confidence !== null && labelToEdit !== i}
247
+ <span
248
+ id={`label-tag-${i}`}
249
+ class="label"
250
+ role="button"
251
+ tabindex="0"
252
+ style:background-color={class_or_confidence === null ||
253
+ (active && active !== class_or_confidence)
254
+ ? ""
255
+ : _color_map[class_or_confidence].primary}
256
+ on:click={() => (labelToEdit = i)}
257
+ on:keydown={() => (labelToEdit = i)}
258
+ >
259
+ {class_or_confidence}
260
+ </span>
261
+ {/if}
262
+ {#if labelToEdit === i && class_or_confidence !== null}
263
+ &nbsp;
264
+ <LabelInput
265
+ bind:value
266
+ {labelToEdit}
267
+ category={class_or_confidence}
268
+ {active}
269
+ {_color_map}
270
+ indexOfLabel={i}
271
+ text={token}
272
+ {handleValueChange}
273
+ />
274
+ {/if}
275
+ </span>
276
+ {#if class_or_confidence !== null}
277
+ <span
278
+ class="label-clear-button"
279
+ role="button"
280
+ aria-roledescription="Remove label from text"
281
+ tabindex="0"
282
+ on:click={() => removeHighlightedText(i)}
283
+ on:keydown={(event) => {
284
+ if (event.key === "Enter") {
285
+ removeHighlightedText(i);
286
+ }
287
+ }}
288
+
289
+ </span>
290
+ {/if}
291
+ </span>
292
+ {/if}
293
+ {#if j < splitTextByNewline(token).length - 1}
294
+ <br />
295
+ {/if}
296
+ {/each}
297
+ {/each}
298
+ </div>
299
+ {:else}
300
+ {#if show_legend}
301
+ <div class="color-legend" data-testid="highlighted-text:color-legend">
302
+ <span>-1</span>
303
+ <span>0</span>
304
+ <span>+1</span>
305
+ </div>
306
+ {/if}
307
+
308
+ <div class="textfield" data-testid="highlighted-text:textfield">
309
+ {#each value as { token, class_or_confidence }, i}
310
+ {@const score =
311
+ typeof class_or_confidence === "string"
312
+ ? parseInt(class_or_confidence)
313
+ : class_or_confidence}
314
+ <span class="score-text-container">
315
+ <span
316
+ class="textspan score-text"
317
+ role="button"
318
+ tabindex="0"
319
+ class:no-cat={class_or_confidence === null ||
320
+ (active && active !== class_or_confidence)}
321
+ class:hl={class_or_confidence !== null}
322
+ on:mouseover={() => (activeElementIndex = i)}
323
+ on:focus={() => (activeElementIndex = i)}
324
+ on:click={() => (labelToEdit = i)}
325
+ on:keydown={(e) => {
326
+ if (e.key === "Enter") {
327
+ labelToEdit = i;
328
+ }
329
+ }}
330
+ style={"background-color: rgba(" +
331
+ (score && score < 0
332
+ ? "128, 90, 213," + -score
333
+ : "239, 68, 60," + score) +
334
+ ")"}
335
+ >
336
+ <span class="text">{token}</span>
337
+ {#if class_or_confidence && labelToEdit === i}
338
+ <LabelInput
339
+ bind:value
340
+ {labelToEdit}
341
+ {_color_map}
342
+ category={class_or_confidence}
343
+ {active}
344
+ indexOfLabel={i}
345
+ text={token}
346
+ {handleValueChange}
347
+ isScoresMode
348
+ />
349
+ {/if}
350
+ </span>
351
+ {#if class_or_confidence && activeElementIndex === i}
352
+ <span
353
+ class="label-clear-button"
354
+ role="button"
355
+ aria-roledescription="Remove label from text"
356
+ tabindex="0"
357
+ on:click={() => removeHighlightedText(i)}
358
+ on:keydown={(event) => {
359
+ if (event.key === "Enter") {
360
+ removeHighlightedText(i);
361
+ }
362
+ }}
363
+
364
+ </span>
365
+ {/if}
366
+ </span>
367
+ {/each}
368
+ </div>
369
+ {/if}
370
+ </div>
371
+
372
+ <style>
373
+ .label-clear-button {
374
+ display: none;
375
+ border-radius: var(--radius-xs);
376
+ padding-top: 2.5px;
377
+ padding-right: var(--size-1);
378
+ padding-bottom: 3.5px;
379
+ padding-left: var(--size-1);
380
+ color: black;
381
+ background-color: var(--background-fill-secondary);
382
+ user-select: none;
383
+ position: relative;
384
+ left: -3px;
385
+ border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
386
+ color: var(--block-label-text-color);
387
+ }
388
+
389
+ .text-class_or_confidence-container:hover .label-clear-button,
390
+ .text-class_or_confidence-container:focus-within .label-clear-button,
391
+ .score-text-container:hover .label-clear-button,
392
+ .score-text-container:focus-within .label-clear-button {
393
+ display: inline;
394
+ }
395
+
396
+ .text-class_or_confidence-container:hover .textspan.hl,
397
+ .text-class_or_confidence-container:focus-within .textspan.hl,
398
+ .score-text:hover {
399
+ border-radius: var(--radius-xs) 0 0 var(--radius-xs);
400
+ }
401
+
402
+ .container {
403
+ display: flex;
404
+ flex-direction: column;
405
+ gap: var(--spacing-sm);
406
+ padding: var(--block-padding);
407
+ }
408
+
409
+ .hl {
410
+ margin-left: var(--size-1);
411
+ transition: background-color 0.3s;
412
+ user-select: none;
413
+ }
414
+
415
+ .textspan:last-child > .label {
416
+ margin-right: 0;
417
+ }
418
+
419
+ .class_or_confidence-legend {
420
+ display: flex;
421
+ flex-wrap: wrap;
422
+ gap: var(--spacing-sm);
423
+ color: black;
424
+ }
425
+
426
+ .class_or_confidence-label {
427
+ cursor: pointer;
428
+ border-radius: var(--radius-xs);
429
+ padding-right: var(--size-2);
430
+ padding-left: var(--size-2);
431
+ font-weight: var(--weight-semibold);
432
+ }
433
+
434
+ .color-legend {
435
+ display: flex;
436
+ justify-content: space-between;
437
+ border-radius: var(--radius-xs);
438
+ background: linear-gradient(
439
+ to right,
440
+ var(--color-purple),
441
+ rgba(255, 255, 255, 0),
442
+ var(--color-red)
443
+ );
444
+ padding: var(--size-1) var(--size-2);
445
+ font-weight: var(--weight-semibold);
446
+ }
447
+
448
+ .textfield {
449
+ box-sizing: border-box;
450
+ border-radius: var(--radius-xs);
451
+ background: var(--background-fill-primary);
452
+ background-color: transparent;
453
+ max-width: var(--size-full);
454
+ line-height: var(--scale-4);
455
+ word-break: break-all;
456
+ }
457
+
458
+ .textspan {
459
+ transition: 150ms;
460
+ border-radius: var(--radius-xs);
461
+ padding-top: 2.5px;
462
+ padding-right: var(--size-1);
463
+ padding-bottom: 3.5px;
464
+ padding-left: var(--size-1);
465
+ color: black;
466
+ cursor: text;
467
+ }
468
+
469
+ .label {
470
+ transition: 150ms;
471
+ margin-top: 1px;
472
+ border-radius: var(--radius-xs);
473
+ padding: 1px 5px;
474
+ color: var(--body-text-color);
475
+ color: white;
476
+ font-weight: var(--weight-bold);
477
+ font-size: var(--text-sm);
478
+ text-transform: uppercase;
479
+ user-select: none;
480
+ }
481
+
482
+ .text {
483
+ color: black;
484
+ white-space: pre-wrap;
485
+ }
486
+
487
+ .textspan.hl {
488
+ user-select: none;
489
+ }
490
+
491
+ .score-text-container {
492
+ margin-right: var(--size-1);
493
+ }
494
+
495
+ .score-text .text {
496
+ color: var(--body-text-color);
497
+ }
498
+
499
+ .no-cat {
500
+ color: var(--body-text-color);
501
+ }
502
+
503
+ .no-label {
504
+ color: var(--body-text-color);
505
+ user-select: text;
506
+ }
507
+
508
+ .selectable {
509
+ cursor: text;
510
+ user-select: text;
511
+ }
512
+ </style>
src/frontend/shared/LabelInput.svelte ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ type HighlightedTextType = {
3
+ token: string;
4
+ class_or_confidence: string | number | null;
5
+ };
6
+
7
+ export let value: HighlightedTextType[];
8
+ export let category: string | number | null;
9
+ export let active: string;
10
+ export let labelToEdit: number;
11
+ export let indexOfLabel: number;
12
+ export let text: string;
13
+ export let handleValueChange: () => void;
14
+ export let isScoresMode = false;
15
+ export let _color_map: Record<string, { primary: string; secondary: string }>;
16
+
17
+ let _input_value = category;
18
+
19
+ function handleInput(e: Event): void {
20
+ let target = e.target as HTMLInputElement;
21
+ if (target) {
22
+ _input_value = target.value;
23
+ }
24
+ }
25
+
26
+ function updateLabelValue(
27
+ e: Event,
28
+ elementIndex: number,
29
+ text: string
30
+ ): void {
31
+ let target = e.target as HTMLInputElement;
32
+ value = [
33
+ ...value.slice(0, elementIndex),
34
+ {
35
+ token: text,
36
+ class_or_confidence:
37
+ target.value === ""
38
+ ? null
39
+ : isScoresMode
40
+ ? Number(target.value)
41
+ : target.value
42
+ },
43
+ ...value.slice(elementIndex + 1)
44
+ ];
45
+
46
+ handleValueChange();
47
+ }
48
+
49
+ function clearPlaceHolderOnFocus(e: FocusEvent): void {
50
+ let target = e.target as HTMLInputElement;
51
+ if (target && target.placeholder) target.placeholder = "";
52
+ }
53
+ </script>
54
+
55
+ <!-- svelte-ignore a11y-autofocus -->
56
+ <!-- autofocus should not be disorienting for a screen reader users
57
+ as input is only rendered once a new label is created -->
58
+ {#if !isScoresMode}
59
+ <input
60
+ class="label-input"
61
+ autofocus
62
+ id={`label-input-${indexOfLabel}`}
63
+ type="text"
64
+ placeholder="label"
65
+ value={category}
66
+ style:background-color={category === null || (active && active !== category)
67
+ ? ""
68
+ : _color_map[category].primary}
69
+ style:width={_input_value
70
+ ? _input_value.toString()?.length + 4 + "ch"
71
+ : "8ch"}
72
+ on:input={handleInput}
73
+ on:blur={(e) => updateLabelValue(e, indexOfLabel, text)}
74
+ on:keydown={(e) => {
75
+ if (e.key === "Enter") {
76
+ updateLabelValue(e, indexOfLabel, text);
77
+ labelToEdit = -1;
78
+ }
79
+ }}
80
+ on:focus={clearPlaceHolderOnFocus}
81
+ />
82
+ {:else}
83
+ <input
84
+ class="label-input"
85
+ autofocus
86
+ type="number"
87
+ step="0.1"
88
+ style={"background-color: rgba(" +
89
+ (typeof category === "number" && category < 0
90
+ ? "128, 90, 213," + -category
91
+ : "239, 68, 60," + category) +
92
+ ")"}
93
+ value={category}
94
+ style:width="7ch"
95
+ on:input={handleInput}
96
+ on:blur={(e) => updateLabelValue(e, indexOfLabel, text)}
97
+ on:keydown={(e) => {
98
+ if (e.key === "Enter") {
99
+ updateLabelValue(e, indexOfLabel, text);
100
+ labelToEdit = -1;
101
+ }
102
+ }}
103
+ />
104
+ {/if}
105
+
106
+ <style>
107
+ .label-input {
108
+ transition: 150ms;
109
+ margin-top: 1px;
110
+ margin-right: calc(var(--size-1));
111
+ border-radius: var(--radius-xs);
112
+ padding: 1px 5px;
113
+ color: black;
114
+ font-weight: var(--weight-bold);
115
+ font-size: var(--text-sm);
116
+ text-transform: uppercase;
117
+ line-height: 1;
118
+ color: white;
119
+ }
120
+
121
+ .label-input::placeholder {
122
+ color: rgba(1, 1, 1, 0.5);
123
+ }
124
+ </style>
src/frontend/shared/StaticHighlightedtext.svelte ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ const browser = typeof document !== "undefined";
3
+ import { get_next_color } from "@gradio/utils";
4
+ import type { SelectData } from "@gradio/utils";
5
+ import { createEventDispatcher } from "svelte";
6
+ import { correct_color_map } from "./utils";
7
+
8
+ export let value: {
9
+ token: string;
10
+ class_or_confidence: string | number | null;
11
+ }[] = [];
12
+ export let show_legend = false;
13
+ export let color_map: Record<string, string> = {};
14
+ export let selectable = false;
15
+
16
+ let ctx: CanvasRenderingContext2D;
17
+ let _color_map: Record<string, { primary: string; secondary: string }> = {};
18
+ let active = "";
19
+
20
+ function splitTextByNewline(text: string): string[] {
21
+ return text.split("\n");
22
+ }
23
+
24
+ const dispatch = createEventDispatcher<{
25
+ select: SelectData;
26
+ }>();
27
+
28
+ let mode: "categories" | "scores";
29
+
30
+ $: {
31
+ if (!color_map) {
32
+ color_map = {};
33
+ }
34
+ if (value.length > 0) {
35
+ for (let entry of value) {
36
+ if (entry.class_or_confidence !== null) {
37
+ if (typeof entry.class_or_confidence === "string") {
38
+ mode = "categories";
39
+ if (!(entry.class_or_confidence in color_map)) {
40
+ let color = get_next_color(Object.keys(color_map).length);
41
+ color_map[entry.class_or_confidence] = color;
42
+ }
43
+ } else {
44
+ mode = "scores";
45
+ }
46
+ }
47
+ }
48
+ }
49
+
50
+ correct_color_map(color_map, _color_map, browser, ctx);
51
+ }
52
+
53
+ function handle_mouseover(label: string): void {
54
+ active = label;
55
+ }
56
+ function handle_mouseout(): void {
57
+ active = "";
58
+ }
59
+ </script>
60
+
61
+ <!--
62
+ @todo victor: try reimplementing without flex (negative margins on container to avoid left margin on linebreak).
63
+ If not possible hijack the copy execution like this:
64
+
65
+ <svelte:window
66
+ on:copy|preventDefault={() => {
67
+ const selection =.getSelection()?.toString();
68
+ console.log(selection?.replaceAll("\n", " "));
69
+ }}
70
+ />
71
+ -->
72
+
73
+ <div class="container">
74
+ {#if mode === "categories"}
75
+ {#if show_legend}
76
+ <div
77
+ class="category-legend"
78
+ data-testid="highlighted-text:category-legend"
79
+ >
80
+ {#each Object.entries(_color_map) as [category, color], i}
81
+ <!-- TODO: fix -->
82
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
83
+ <div
84
+ on:mouseover={() => handle_mouseover(category)}
85
+ on:focus={() => handle_mouseover(category)}
86
+ on:mouseout={() => handle_mouseout()}
87
+ on:blur={() => handle_mouseout()}
88
+ class="category-label"
89
+ style={"background-color:" + color.secondary}
90
+ >
91
+ {category}
92
+ </div>
93
+ {/each}
94
+ </div>
95
+ {/if}
96
+ <div class="textfield">
97
+ {#each value as v, i}
98
+ {#each splitTextByNewline(v.token) as line, j}
99
+ {#if line.trim() !== ""}
100
+ <!-- TODO: fix -->
101
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
102
+ <!-- svelte-ignore a11y-click-events-have-key-events-->
103
+ <span
104
+ class="textspan"
105
+ style:background-color={v.class_or_confidence === null ||
106
+ (active && active !== v.class_or_confidence)
107
+ ? ""
108
+ : _color_map[v.class_or_confidence].secondary}
109
+ class:no-cat={v.class_or_confidence === null ||
110
+ (active && active !== v.class_or_confidence)}
111
+ class:hl={v.class_or_confidence !== null}
112
+ class:selectable
113
+ on:click={() => {
114
+ dispatch("select", {
115
+ index: i,
116
+ value: [v.token, v.class_or_confidence]
117
+ });
118
+ }}
119
+ >
120
+ <span
121
+ class:no-label={v.class_or_confidence === null ||
122
+ !_color_map[v.class_or_confidence]}
123
+ class="text">{line}</span
124
+ >
125
+ {#if !show_legend && v.class_or_confidence !== null}
126
+ &nbsp;
127
+ <span
128
+ class="label"
129
+ style:background-color={v.class_or_confidence === null ||
130
+ (active && active !== v.class_or_confidence)
131
+ ? ""
132
+ : _color_map[v.class_or_confidence].primary}
133
+ >
134
+ {v.class_or_confidence}
135
+ </span>
136
+ {/if}
137
+ </span>
138
+ {/if}
139
+ {#if j < splitTextByNewline(v.token).length - 1}
140
+ <br />
141
+ {/if}
142
+ {/each}
143
+ {/each}
144
+ </div>
145
+ {:else}
146
+ {#if show_legend}
147
+ <div class="color-legend" data-testid="highlighted-text:color-legend">
148
+ <span>-1</span>
149
+ <span>0</span>
150
+ <span>+1</span>
151
+ </div>
152
+ {/if}
153
+ <div class="textfield" data-testid="highlighted-text:textfield">
154
+ {#each value as v}
155
+ {@const score =
156
+ typeof v.class_or_confidence === "string"
157
+ ? parseInt(v.class_or_confidence)
158
+ : v.class_or_confidence}
159
+ <span
160
+ class="textspan score-text"
161
+ style={"background-color: rgba(" +
162
+ (score && score < 0
163
+ ? "128, 90, 213," + -score
164
+ : "239, 68, 60," + score) +
165
+ ")"}
166
+ >
167
+ <span class="text">{v.token}</span>
168
+ </span>
169
+ {/each}
170
+ </div>
171
+ {/if}
172
+ </div>
173
+
174
+ <style>
175
+ .container {
176
+ display: flex;
177
+ flex-direction: column;
178
+ gap: var(--spacing-sm);
179
+ padding: var(--block-padding);
180
+ }
181
+ .hl + .hl {
182
+ margin-left: var(--size-1);
183
+ }
184
+
185
+ .textspan:last-child > .label {
186
+ margin-right: 0;
187
+ }
188
+
189
+ .category-legend {
190
+ display: flex;
191
+ flex-wrap: wrap;
192
+ gap: var(--spacing-sm);
193
+ color: black;
194
+ }
195
+
196
+ .category-label {
197
+ cursor: pointer;
198
+ border-radius: var(--radius-xs);
199
+ padding-right: var(--size-2);
200
+ padding-left: var(--size-2);
201
+ font-weight: var(--weight-semibold);
202
+ }
203
+
204
+ .color-legend {
205
+ display: flex;
206
+ justify-content: space-between;
207
+ border-radius: var(--radius-xs);
208
+ background: linear-gradient(
209
+ to right,
210
+ var(--color-purple),
211
+ rgba(255, 255, 255, 0),
212
+ var(--color-red)
213
+ );
214
+ padding: var(--size-1) var(--size-2);
215
+ font-weight: var(--weight-semibold);
216
+ }
217
+
218
+ .textfield {
219
+ box-sizing: border-box;
220
+ border-radius: var(--radius-xs);
221
+ background: var(--background-fill-primary);
222
+ background-color: transparent;
223
+ max-width: var(--size-full);
224
+ line-height: var(--scale-4);
225
+ word-break: break-all;
226
+ }
227
+
228
+ .textspan {
229
+ transition: 150ms;
230
+ border-radius: var(--radius-xs);
231
+ padding-top: 2.5px;
232
+ padding-right: var(--size-1);
233
+ padding-bottom: 3.5px;
234
+ padding-left: var(--size-1);
235
+ color: black;
236
+ }
237
+
238
+ .label {
239
+ transition: 150ms;
240
+ margin-top: 1px;
241
+ border-radius: var(--radius-xs);
242
+ padding: 1px 5px;
243
+ color: var(--body-text-color);
244
+ color: white;
245
+ font-weight: var(--weight-bold);
246
+ font-size: var(--text-sm);
247
+ text-transform: uppercase;
248
+ }
249
+
250
+ .text {
251
+ color: black;
252
+ white-space: pre-wrap;
253
+ }
254
+
255
+ .score-text .text {
256
+ color: var(--body-text-color);
257
+ }
258
+
259
+ .score-text {
260
+ margin-right: var(--size-1);
261
+ padding: var(--size-1);
262
+ }
263
+
264
+ .no-cat {
265
+ color: var(--body-text-color);
266
+ }
267
+
268
+ .no-label {
269
+ color: var(--body-text-color);
270
+ }
271
+
272
+ .selectable {
273
+ cursor: pointer;
274
+ }
275
+ </style>
src/frontend/shared/utils.ts ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { colors } from "@gradio/theme";
2
+
3
+ export function name_to_rgba(
4
+ name: string,
5
+ a: number,
6
+ ctx: CanvasRenderingContext2D | null
7
+ ): string {
8
+ if (!ctx) {
9
+ var canvas = document.createElement("canvas");
10
+ ctx = canvas.getContext("2d")!;
11
+ }
12
+ ctx.fillStyle = name;
13
+ ctx.fillRect(0, 0, 1, 1);
14
+ const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
15
+ ctx.clearRect(0, 0, 1, 1);
16
+ return `rgba(${r}, ${g}, ${b}, ${255 / a})`;
17
+ }
18
+
19
+ export function correct_color_map(
20
+ color_map: Record<string, string>,
21
+ _color_map: Record<string, { primary: string; secondary: string }>,
22
+ browser: any,
23
+ ctx: CanvasRenderingContext2D | null
24
+ ): void {
25
+ for (const col in color_map) {
26
+ const _c = color_map[col].trim();
27
+
28
+ if (_c in colors) {
29
+ _color_map[col] = colors[_c as keyof typeof colors];
30
+ } else {
31
+ _color_map[col] = {
32
+ primary: browser
33
+ ? name_to_rgba(color_map[col], 1, ctx)
34
+ : color_map[col],
35
+ secondary: browser
36
+ ? name_to_rgba(color_map[col], 0.5, ctx)
37
+ : color_map[col]
38
+ };
39
+ }
40
+ }
41
+ }
42
+
43
+ export function merge_elements(
44
+ value: { token: string; class_or_confidence: string | number | null }[],
45
+ mergeMode: "empty" | "equal"
46
+ ): { token: string; class_or_confidence: string | number | null }[] {
47
+ let result: typeof value = [];
48
+ let tempStr: string | null = null;
49
+ let tempVal: string | number | null = null;
50
+
51
+ for (const val of value) {
52
+ if (
53
+ (mergeMode === "empty" && val.class_or_confidence === null) ||
54
+ (mergeMode === "equal" && tempVal === val.class_or_confidence)
55
+ ) {
56
+ tempStr = tempStr ? tempStr + val.token : val.token;
57
+ } else {
58
+ if (tempStr !== null) {
59
+ result.push({
60
+ token: tempStr,
61
+ class_or_confidence: tempVal
62
+ });
63
+ }
64
+ tempStr = val.token;
65
+ tempVal = val.class_or_confidence;
66
+ }
67
+ }
68
+
69
+ if (tempStr !== null) {
70
+ result.push({
71
+ token: tempStr,
72
+ class_or_confidence: tempVal
73
+ });
74
+ }
75
+
76
+ return result;
77
+ }
src/pyproject.toml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = [
3
+ "hatchling",
4
+ "hatch-requirements-txt",
5
+ "hatch-fancy-pypi-readme>=22.5.0",
6
+ ]
7
+ build-backend = "hatchling.build"
8
+
9
+ [project]
10
+ name = "gradio_highlightedtextlabeldefault"
11
+ version = "0.0.1"
12
+ description = "Modify the default label when selecting a word in the interactive HighlightedText component."
13
+ readme = "README.md"
14
+ license = "MIT"
15
+ requires-python = ">=3.8"
16
+ authors = [{ name = "YOUR NAME", email = "YOUREMAIL@domain.com" }]
17
+ keywords = ["gradio-custom-component", "gradio-template-HighlightedText"]
18
+ # Add dependencies here
19
+ dependencies = ["gradio>=4.0,<5.0"]
20
+ classifiers = [
21
+ 'Development Status :: 3 - Alpha',
22
+ 'License :: OSI Approved :: Apache Software License',
23
+ 'Operating System :: OS Independent',
24
+ 'Programming Language :: Python :: 3',
25
+ 'Programming Language :: Python :: 3 :: Only',
26
+ 'Programming Language :: Python :: 3.8',
27
+ 'Programming Language :: Python :: 3.9',
28
+ 'Programming Language :: Python :: 3.10',
29
+ 'Programming Language :: Python :: 3.11',
30
+ 'Topic :: Scientific/Engineering',
31
+ 'Topic :: Scientific/Engineering :: Artificial Intelligence',
32
+ 'Topic :: Scientific/Engineering :: Visualization',
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ dev = ["build", "twine"]
37
+
38
+ [tool.hatch.build]
39
+ artifacts = ["/backend/gradio_highlightedtextlabeldefault/templates", "*.pyi", "backend/gradio_highlightedtextlabeldefault/templates"]
40
+
41
+ [tool.hatch.build.targets.wheel]
42
+ packages = ["/backend/gradio_highlightedtextlabeldefault"]