opik-genui 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opik_genui-2.3.0/.gitignore +5 -0
- opik_genui-2.3.0/LICENSE +203 -0
- opik_genui-2.3.0/PKG-INFO +62 -0
- opik_genui-2.3.0/README.md +40 -0
- opik_genui-2.3.0/hatch_build.py +35 -0
- opik_genui-2.3.0/package.json +90 -0
- opik_genui-2.3.0/pyproject.toml +49 -0
- opik_genui-2.3.0/src/opik_genui/__init__.py +40 -0
- opik_genui-2.3.0/src/opik_genui/data/engine.json +195 -0
- opik_genui-2.3.0/src/opik_genui/data/prompt-widget.txt +52 -0
- opik_genui-2.3.0/src/opik_genui/py.typed +0 -0
opik_genui-2.3.0/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Copyright (c) Comet ML, Inc
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
|
179
|
+
|
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
181
|
+
|
|
182
|
+
To apply the Apache License to your work, attach the following
|
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
184
|
+
replaced with your own identifying information. (Don't include
|
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
186
|
+
comment syntax for the file format. We also recommend that a
|
|
187
|
+
file or class name and description of purpose be included on the
|
|
188
|
+
same "printed page" as the copyright notice for easier
|
|
189
|
+
identification within third-party archives.
|
|
190
|
+
|
|
191
|
+
Copyright 2024 Comet ML, Inc
|
|
192
|
+
|
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
you may not use this file except in compliance with the License.
|
|
195
|
+
You may obtain a copy of the License at
|
|
196
|
+
|
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
|
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
|
+
See the License for the specific language governing permissions and
|
|
203
|
+
limitations under the License.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: opik-genui
|
|
3
|
+
Version: 2.3.0
|
|
4
|
+
Summary: Opik generative UI authoring guidance and HTML contract version for Python authors
|
|
5
|
+
Project-URL: Homepage, https://github.com/comet-ml/opik/tree/main/sdks/genui
|
|
6
|
+
Project-URL: Source, https://github.com/comet-ml/opik
|
|
7
|
+
Project-URL: Issues, https://github.com/comet-ml/opik/issues
|
|
8
|
+
Author-email: "Comet ML Inc." <support@comet.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: comet,generative-ui,mcp-apps,opik
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# opik-genui
|
|
24
|
+
|
|
25
|
+
Authoring data for [Opik](https://github.com/comet-ml/opik) views. A view is HTML, CSS and script written by a model and rendered in a sandboxed iframe by the `opik-genui` npm package. This package gives a Python author the prompt to write a view and the constants to check it against.
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
pip install opik-genui
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
It has no dependencies. The version of this package is the Opik release it shipped with, and it always matches the npm package of the same version.
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import opik_genui
|
|
37
|
+
|
|
38
|
+
system_prompt = opik_genui.prompt("widget")
|
|
39
|
+
|
|
40
|
+
view = {
|
|
41
|
+
"type": "html",
|
|
42
|
+
"engine_version": opik_genui.ENGINE_VERSION,
|
|
43
|
+
"html": html,
|
|
44
|
+
"inputs": {"rows": {"kind": "query", "query_id": query_id}},
|
|
45
|
+
"libraries": ["vega"],
|
|
46
|
+
}
|
|
47
|
+
assert len(html) <= opik_genui.MAX_HTML_LENGTH
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
| Name | What it is |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `prompt(area)` | The authoring prompt for an area. |
|
|
53
|
+
| `AREAS` | The places a view can be shown. |
|
|
54
|
+
| `LIBRARIES` | The libraries a view may declare. |
|
|
55
|
+
| `ENGINE_VERSION` | The HTML contract version a view written with this prompt targets. |
|
|
56
|
+
| `MAX_HTML_LENGTH` | The size cap the Opik backend enforces on save. |
|
|
57
|
+
| `TOKENS` | The `--ov-` token values for light and dark. |
|
|
58
|
+
| `__version__` | The package version. |
|
|
59
|
+
|
|
60
|
+
## Licence
|
|
61
|
+
|
|
62
|
+
Apache-2.0.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# opik-genui
|
|
2
|
+
|
|
3
|
+
Authoring data for [Opik](https://github.com/comet-ml/opik) views. A view is HTML, CSS and script written by a model and rendered in a sandboxed iframe by the `opik-genui` npm package. This package gives a Python author the prompt to write a view and the constants to check it against.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
pip install opik-genui
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
It has no dependencies. The version of this package is the Opik release it shipped with, and it always matches the npm package of the same version.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import opik_genui
|
|
15
|
+
|
|
16
|
+
system_prompt = opik_genui.prompt("widget")
|
|
17
|
+
|
|
18
|
+
view = {
|
|
19
|
+
"type": "html",
|
|
20
|
+
"engine_version": opik_genui.ENGINE_VERSION,
|
|
21
|
+
"html": html,
|
|
22
|
+
"inputs": {"rows": {"kind": "query", "query_id": query_id}},
|
|
23
|
+
"libraries": ["vega"],
|
|
24
|
+
}
|
|
25
|
+
assert len(html) <= opik_genui.MAX_HTML_LENGTH
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
| Name | What it is |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `prompt(area)` | The authoring prompt for an area. |
|
|
31
|
+
| `AREAS` | The places a view can be shown. |
|
|
32
|
+
| `LIBRARIES` | The libraries a view may declare. |
|
|
33
|
+
| `ENGINE_VERSION` | The HTML contract version a view written with this prompt targets. |
|
|
34
|
+
| `MAX_HTML_LENGTH` | The size cap the Opik backend enforces on save. |
|
|
35
|
+
| `TOKENS` | The `--ov-` token values for light and dark. |
|
|
36
|
+
| `__version__` | The package version. |
|
|
37
|
+
|
|
38
|
+
## Licence
|
|
39
|
+
|
|
40
|
+
Apache-2.0.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from hatchling.metadata.plugin.interface import MetadataHookInterface
|
|
5
|
+
|
|
6
|
+
HERE = Path(__file__).parent
|
|
7
|
+
PACKAGE_JSON = (HERE / "package.json", HERE.parent / "js" / "package.json")
|
|
8
|
+
DATA = HERE / "src" / "opik_genui" / "data"
|
|
9
|
+
ENGINE_DATA = DATA / "engine.json"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class PackageVersionHook(MetadataHookInterface):
|
|
13
|
+
def update(self, metadata: dict) -> None:
|
|
14
|
+
source = next((path for path in PACKAGE_JSON if path.is_file()), None)
|
|
15
|
+
if source is None:
|
|
16
|
+
raise RuntimeError(
|
|
17
|
+
f"{PACKAGE_JSON[1]} is missing; build the wheel from sdks/genui/python"
|
|
18
|
+
)
|
|
19
|
+
missing = [] if ENGINE_DATA.is_file() else [ENGINE_DATA]
|
|
20
|
+
if not missing:
|
|
21
|
+
areas = json.loads(ENGINE_DATA.read_text())["areas"]
|
|
22
|
+
prompts = (DATA / f"prompt-{area}.txt" for area in areas)
|
|
23
|
+
missing = [path for path in prompts if not path.is_file()]
|
|
24
|
+
if missing:
|
|
25
|
+
raise RuntimeError(
|
|
26
|
+
f"{', '.join(map(str, missing))} missing; run npm run build in sdks/genui first"
|
|
27
|
+
)
|
|
28
|
+
version = json.loads(source.read_text())["version"]
|
|
29
|
+
built = json.loads(ENGINE_DATA.read_text()).get("version")
|
|
30
|
+
if built != version:
|
|
31
|
+
raise RuntimeError(
|
|
32
|
+
f"{ENGINE_DATA} was built for version {built}, not {version}; "
|
|
33
|
+
"run npm run build in sdks/genui again"
|
|
34
|
+
)
|
|
35
|
+
metadata["version"] = version
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opik-genui",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "Opik generative UI engine: the sandboxed iframe host and HTML contract for model-written views",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/comet-ml/opik.git",
|
|
8
|
+
"directory": "sdks/genui/js"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/comet-ml/opik/tree/main/sdks/genui",
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "Comet",
|
|
13
|
+
"email": "support@comet.com",
|
|
14
|
+
"url": "https://github.com/comet-ml"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/comet-ml/opik/issues",
|
|
18
|
+
"email": "support@comet.com"
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"keywords": [
|
|
22
|
+
"opik",
|
|
23
|
+
"comet",
|
|
24
|
+
"generative-ui",
|
|
25
|
+
"mcp-apps",
|
|
26
|
+
"iframe",
|
|
27
|
+
"sandbox"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"sideEffects": [
|
|
31
|
+
"*.css"
|
|
32
|
+
],
|
|
33
|
+
"exports": {
|
|
34
|
+
"./package.json": "./package.json",
|
|
35
|
+
"./ViewHost": {
|
|
36
|
+
"types": "./dist/types/ViewHost.d.ts",
|
|
37
|
+
"default": "./dist/ViewHost.js"
|
|
38
|
+
},
|
|
39
|
+
"./HtmlFrame": {
|
|
40
|
+
"types": "./dist/types/HtmlFrame.d.ts",
|
|
41
|
+
"default": "./dist/HtmlFrame.js"
|
|
42
|
+
},
|
|
43
|
+
"./contract": {
|
|
44
|
+
"types": "./dist/types/contract.d.ts",
|
|
45
|
+
"default": "./dist/contract.js"
|
|
46
|
+
},
|
|
47
|
+
"./tokens": {
|
|
48
|
+
"types": "./dist/types/tokens.d.ts",
|
|
49
|
+
"default": "./dist/tokens.js"
|
|
50
|
+
},
|
|
51
|
+
"./view": {
|
|
52
|
+
"types": "./dist/types/view.d.ts",
|
|
53
|
+
"default": "./dist/view.js"
|
|
54
|
+
},
|
|
55
|
+
"./libraries/vega.js": "./dist/libraries/vega.js",
|
|
56
|
+
"./styles.css": "./dist/styles.css",
|
|
57
|
+
"./libraries/vega.licenses.txt": "./dist/libraries/vega.licenses.txt"
|
|
58
|
+
},
|
|
59
|
+
"files": [
|
|
60
|
+
"dist"
|
|
61
|
+
],
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsup && tsc -p tsconfig.build.json && cp src/styles.css dist/styles.css && npm run licenses && npm run emit",
|
|
67
|
+
"emit": "tsx scripts/emit.ts",
|
|
68
|
+
"licenses": "tsx scripts/licenses.ts",
|
|
69
|
+
"smoke": "tsx scripts/smoke.ts",
|
|
70
|
+
"typecheck": "tsc --noEmit"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"react": "^19.0.0",
|
|
74
|
+
"react-dom": "^19.0.0"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@modelcontextprotocol/ext-apps": "2.1.0",
|
|
78
|
+
"@types/node": "^26.6.5",
|
|
79
|
+
"@types/react": "^19.3.0",
|
|
80
|
+
"react": "^19.3.1",
|
|
81
|
+
"react-dom": "^19.3.1",
|
|
82
|
+
"tsup": "9.0.0",
|
|
83
|
+
"tsx": "^4.19.0",
|
|
84
|
+
"typescript": "^7.0.2",
|
|
85
|
+
"vega": "^6.4.0",
|
|
86
|
+
"vega-embed": "^7.3.0",
|
|
87
|
+
"vega-interpreter": "^2.3.2",
|
|
88
|
+
"vega-lite": "^6.5.0"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "opik-genui"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Opik generative UI authoring guidance and HTML contract version for Python authors"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Comet ML Inc.", email = "support@comet.com" }]
|
|
14
|
+
keywords = ["opik", "comet", "generative-ui", "mcp-apps"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Typing :: Typed",
|
|
24
|
+
]
|
|
25
|
+
dependencies = []
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/comet-ml/opik/tree/main/sdks/genui"
|
|
29
|
+
Source = "https://github.com/comet-ml/opik"
|
|
30
|
+
Issues = "https://github.com/comet-ml/opik/issues"
|
|
31
|
+
|
|
32
|
+
[dependency-groups]
|
|
33
|
+
dev = ["pytest>=8"]
|
|
34
|
+
|
|
35
|
+
[tool.hatch.metadata.hooks.custom]
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.sdist]
|
|
38
|
+
include = ["src/opik_genui", "hatch_build.py", "README.md", "LICENSE"]
|
|
39
|
+
artifacts = ["src/opik_genui/data/*"]
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.sdist.force-include]
|
|
42
|
+
"../js/package.json" = "package.json"
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.wheel]
|
|
45
|
+
packages = ["src/opik_genui"]
|
|
46
|
+
artifacts = ["src/opik_genui/data/*"]
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from functools import cache
|
|
3
|
+
from importlib.resources import files
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
_DATA = files("opik_genui") / "data"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _read_text(name: str) -> str:
|
|
10
|
+
return (_DATA / name).read_text(encoding="utf-8")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@cache
|
|
14
|
+
def _engine() -> dict[str, Any]:
|
|
15
|
+
return json.loads(_read_text("engine.json"))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__version__: str = _engine()["version"]
|
|
19
|
+
ENGINE_VERSION: int = _engine()["engine_version"]
|
|
20
|
+
AREAS: tuple[str, ...] = tuple(_engine()["areas"])
|
|
21
|
+
LIBRARIES: tuple[str, ...] = tuple(_engine()["libraries"])
|
|
22
|
+
MAX_HTML_LENGTH: int = _engine()["max_html_length"]
|
|
23
|
+
TOKENS: dict[str, dict[str, str]] = _engine()["tokens"]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def prompt(area: str) -> str:
|
|
27
|
+
if area not in AREAS:
|
|
28
|
+
raise ValueError(f'unknown area "{area}"; expected one of {", ".join(AREAS)}')
|
|
29
|
+
return _read_text(f"prompt-{area}.txt").removesuffix("\n")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
__all__ = [
|
|
33
|
+
"AREAS",
|
|
34
|
+
"ENGINE_VERSION",
|
|
35
|
+
"LIBRARIES",
|
|
36
|
+
"MAX_HTML_LENGTH",
|
|
37
|
+
"TOKENS",
|
|
38
|
+
"__version__",
|
|
39
|
+
"prompt",
|
|
40
|
+
]
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.3.0",
|
|
3
|
+
"engine_version": 1,
|
|
4
|
+
"areas": [
|
|
5
|
+
"widget"
|
|
6
|
+
],
|
|
7
|
+
"libraries": [
|
|
8
|
+
"vega"
|
|
9
|
+
],
|
|
10
|
+
"max_html_length": 1000000,
|
|
11
|
+
"tokens": {
|
|
12
|
+
"light": {
|
|
13
|
+
"--ov-background-primary": "#ffffff",
|
|
14
|
+
"--ov-background-primary-hover": "#fafafa",
|
|
15
|
+
"--ov-background-secondary": "#f4f4f5",
|
|
16
|
+
"--ov-background-secondary-hover": "#e4e4e7",
|
|
17
|
+
"--ov-background-subtle": "#fafafa",
|
|
18
|
+
"--ov-text-primary": "#27272a",
|
|
19
|
+
"--ov-text-secondary": "#71717a",
|
|
20
|
+
"--ov-text-placeholder": "#71717a",
|
|
21
|
+
"--ov-text-disabled": "#a1a1aa",
|
|
22
|
+
"--ov-text-brand": "#5155f5",
|
|
23
|
+
"--ov-text-on-action": "#f4f4f5",
|
|
24
|
+
"--ov-icon-primary": "#27272a",
|
|
25
|
+
"--ov-icon-secondary": "#71717a",
|
|
26
|
+
"--ov-icon-brand": "#5155f5",
|
|
27
|
+
"--ov-icon-on-action": "#f4f4f5",
|
|
28
|
+
"--ov-icon-on-color": "#27272a",
|
|
29
|
+
"--ov-border-default": "#efeff1",
|
|
30
|
+
"--ov-border-strong": "#71717a",
|
|
31
|
+
"--ov-border-focus": "#5155f5",
|
|
32
|
+
"--ov-action-primary": "#5155f5",
|
|
33
|
+
"--ov-action-primary-hover": "#3f43e0",
|
|
34
|
+
"--ov-accent-lime-tile": "#bbf451",
|
|
35
|
+
"--ov-accent-lime-mark": "#9ae600",
|
|
36
|
+
"--ov-accent-yellow-tile": "#ffdf20",
|
|
37
|
+
"--ov-accent-yellow-mark": "#fdc700",
|
|
38
|
+
"--ov-accent-teal-tile": "#46ecd5",
|
|
39
|
+
"--ov-accent-teal-mark": "#00d5be",
|
|
40
|
+
"--ov-accent-cyan-tile": "#53eafd",
|
|
41
|
+
"--ov-accent-cyan-mark": "#00d3f2",
|
|
42
|
+
"--ov-accent-violet-tile": "#c4b4ff",
|
|
43
|
+
"--ov-accent-violet-mark": "#a684ff",
|
|
44
|
+
"--ov-accent-fuchsia-tile": "#f4a8ff",
|
|
45
|
+
"--ov-accent-fuchsia-mark": "#ed6aff",
|
|
46
|
+
"--ov-accent-pink-tile": "#ff90cd",
|
|
47
|
+
"--ov-accent-pink-mark": "#fb64b6",
|
|
48
|
+
"--ov-chart-series-1": "#a684ff",
|
|
49
|
+
"--ov-chart-series-2": "#00d3f2",
|
|
50
|
+
"--ov-chart-series-3": "#ed6aff",
|
|
51
|
+
"--ov-chart-series-4": "#9ae600",
|
|
52
|
+
"--ov-chart-series-5": "#fdc700",
|
|
53
|
+
"--ov-chart-series-6": "#00d5be",
|
|
54
|
+
"--ov-chart-series-7": "#fb64b6",
|
|
55
|
+
"--ov-chart-error": "#fd4c50",
|
|
56
|
+
"--ov-chart-success": "#05df72",
|
|
57
|
+
"--ov-chart-warning": "#ffab14",
|
|
58
|
+
"--ov-chart-grid": "#efeff1",
|
|
59
|
+
"--ov-status-error-default": "#fb2c36",
|
|
60
|
+
"--ov-status-error-text": "#dc2626",
|
|
61
|
+
"--ov-status-error-tile": "#ff6467",
|
|
62
|
+
"--ov-status-error-mark": "#fd4c50",
|
|
63
|
+
"--ov-status-success-default": "#00c950",
|
|
64
|
+
"--ov-status-success-text": "#11834b",
|
|
65
|
+
"--ov-status-success-tile": "#4df89a",
|
|
66
|
+
"--ov-status-success-mark": "#05df72",
|
|
67
|
+
"--ov-status-warning-default": "#fe9a00",
|
|
68
|
+
"--ov-status-warning-text": "#bb4d00",
|
|
69
|
+
"--ov-status-warning-tile": "#ffbb29",
|
|
70
|
+
"--ov-status-warning-mark": "#ffab14",
|
|
71
|
+
"--ov-font-sans": "Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
|
|
72
|
+
"--ov-font-mono": "\"Ubuntu Mono\", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace",
|
|
73
|
+
"--ov-type-heading-1": "600 20px/28px var(--ov-font-sans)",
|
|
74
|
+
"--ov-type-heading-2": "600 16px/24px var(--ov-font-sans)",
|
|
75
|
+
"--ov-type-heading-3": "600 14px/20px var(--ov-font-sans)",
|
|
76
|
+
"--ov-type-body-medium": "400 14px/20px var(--ov-font-sans)",
|
|
77
|
+
"--ov-type-body-medium-strong": "500 14px/20px var(--ov-font-sans)",
|
|
78
|
+
"--ov-type-body-small": "400 12px/16px var(--ov-font-sans)",
|
|
79
|
+
"--ov-type-body-small-strong": "500 12px/16px var(--ov-font-sans)",
|
|
80
|
+
"--ov-type-caption": "400 11px/14px var(--ov-font-sans)",
|
|
81
|
+
"--ov-type-overline": "500 10px/16px var(--ov-font-sans)",
|
|
82
|
+
"--ov-type-mono-medium": "400 14px/20px var(--ov-font-mono)",
|
|
83
|
+
"--ov-type-mono-medium-strong": "500 14px/20px var(--ov-font-mono)",
|
|
84
|
+
"--ov-type-mono-small": "400 12px/16px var(--ov-font-mono)",
|
|
85
|
+
"--ov-type-mono-small-strong": "500 12px/16px var(--ov-font-mono)",
|
|
86
|
+
"--ov-type-mono-caption": "400 11px/14px var(--ov-font-mono)",
|
|
87
|
+
"--ov-type-mono-caption-strong": "500 11px/14px var(--ov-font-mono)",
|
|
88
|
+
"--ov-spacing-2": "2px",
|
|
89
|
+
"--ov-spacing-4": "4px",
|
|
90
|
+
"--ov-spacing-6": "6px",
|
|
91
|
+
"--ov-spacing-8": "8px",
|
|
92
|
+
"--ov-spacing-12": "12px",
|
|
93
|
+
"--ov-spacing-16": "16px",
|
|
94
|
+
"--ov-spacing-24": "24px",
|
|
95
|
+
"--ov-spacing-32": "32px",
|
|
96
|
+
"--ov-radius-2": "2px",
|
|
97
|
+
"--ov-radius-4": "4px",
|
|
98
|
+
"--ov-radius-8": "8px",
|
|
99
|
+
"--ov-radius-full": "9999px",
|
|
100
|
+
"--ov-opacity-inactive": "0.8",
|
|
101
|
+
"--ov-opacity-disabled": "0.6"
|
|
102
|
+
},
|
|
103
|
+
"dark": {
|
|
104
|
+
"--ov-background-primary": "#09090b",
|
|
105
|
+
"--ov-background-primary-hover": "#18181b",
|
|
106
|
+
"--ov-background-secondary": "#27272a",
|
|
107
|
+
"--ov-background-secondary-hover": "#3f3f46",
|
|
108
|
+
"--ov-background-subtle": "#18181b",
|
|
109
|
+
"--ov-text-primary": "#f4f4f5",
|
|
110
|
+
"--ov-text-secondary": "#a1a1aa",
|
|
111
|
+
"--ov-text-placeholder": "#a1a1aa",
|
|
112
|
+
"--ov-text-disabled": "#52525b",
|
|
113
|
+
"--ov-text-brand": "#6487fc",
|
|
114
|
+
"--ov-text-on-action": "#f4f4f5",
|
|
115
|
+
"--ov-icon-primary": "#e4e4e7",
|
|
116
|
+
"--ov-icon-secondary": "#a1a1aa",
|
|
117
|
+
"--ov-icon-brand": "#6487fc",
|
|
118
|
+
"--ov-icon-on-action": "#f4f4f5",
|
|
119
|
+
"--ov-icon-on-color": "#27272a",
|
|
120
|
+
"--ov-border-default": "#27272a",
|
|
121
|
+
"--ov-border-strong": "#71717a",
|
|
122
|
+
"--ov-border-focus": "#6487fc",
|
|
123
|
+
"--ov-action-primary": "#5155f5",
|
|
124
|
+
"--ov-action-primary-hover": "#6487fc",
|
|
125
|
+
"--ov-accent-lime-tile": "#9ae600",
|
|
126
|
+
"--ov-accent-lime-mark": "#bbf451",
|
|
127
|
+
"--ov-accent-yellow-tile": "#fdc700",
|
|
128
|
+
"--ov-accent-yellow-mark": "#ffdf20",
|
|
129
|
+
"--ov-accent-teal-tile": "#00d5be",
|
|
130
|
+
"--ov-accent-teal-mark": "#46ecd5",
|
|
131
|
+
"--ov-accent-cyan-tile": "#00d3f2",
|
|
132
|
+
"--ov-accent-cyan-mark": "#53eafd",
|
|
133
|
+
"--ov-accent-violet-tile": "#a684ff",
|
|
134
|
+
"--ov-accent-violet-mark": "#c4b4ff",
|
|
135
|
+
"--ov-accent-fuchsia-tile": "#ed6aff",
|
|
136
|
+
"--ov-accent-fuchsia-mark": "#f4a8ff",
|
|
137
|
+
"--ov-accent-pink-tile": "#fb64b6",
|
|
138
|
+
"--ov-accent-pink-mark": "#ff90cd",
|
|
139
|
+
"--ov-chart-series-1": "#a684ff",
|
|
140
|
+
"--ov-chart-series-2": "#00d3f2",
|
|
141
|
+
"--ov-chart-series-3": "#ed6aff",
|
|
142
|
+
"--ov-chart-series-4": "#9ae600",
|
|
143
|
+
"--ov-chart-series-5": "#fdc700",
|
|
144
|
+
"--ov-chart-series-6": "#00d5be",
|
|
145
|
+
"--ov-chart-series-7": "#fb64b6",
|
|
146
|
+
"--ov-chart-error": "#fd4c50",
|
|
147
|
+
"--ov-chart-success": "#05df72",
|
|
148
|
+
"--ov-chart-warning": "#ffab14",
|
|
149
|
+
"--ov-chart-grid": "#27272a",
|
|
150
|
+
"--ov-status-error-default": "#fb2c36",
|
|
151
|
+
"--ov-status-error-text": "#fd4c50",
|
|
152
|
+
"--ov-status-error-tile": "#fd4c50",
|
|
153
|
+
"--ov-status-error-mark": "#ff6467",
|
|
154
|
+
"--ov-status-success-default": "#00c950",
|
|
155
|
+
"--ov-status-success-text": "#05df72",
|
|
156
|
+
"--ov-status-success-tile": "#05df72",
|
|
157
|
+
"--ov-status-success-mark": "#4df89a",
|
|
158
|
+
"--ov-status-warning-default": "#fe9a00",
|
|
159
|
+
"--ov-status-warning-text": "#ffab14",
|
|
160
|
+
"--ov-status-warning-tile": "#ffab14",
|
|
161
|
+
"--ov-status-warning-mark": "#ffbb29",
|
|
162
|
+
"--ov-font-sans": "Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
|
|
163
|
+
"--ov-font-mono": "\"Ubuntu Mono\", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace",
|
|
164
|
+
"--ov-type-heading-1": "600 20px/28px var(--ov-font-sans)",
|
|
165
|
+
"--ov-type-heading-2": "600 16px/24px var(--ov-font-sans)",
|
|
166
|
+
"--ov-type-heading-3": "600 14px/20px var(--ov-font-sans)",
|
|
167
|
+
"--ov-type-body-medium": "400 14px/20px var(--ov-font-sans)",
|
|
168
|
+
"--ov-type-body-medium-strong": "500 14px/20px var(--ov-font-sans)",
|
|
169
|
+
"--ov-type-body-small": "400 12px/16px var(--ov-font-sans)",
|
|
170
|
+
"--ov-type-body-small-strong": "500 12px/16px var(--ov-font-sans)",
|
|
171
|
+
"--ov-type-caption": "400 11px/14px var(--ov-font-sans)",
|
|
172
|
+
"--ov-type-overline": "500 10px/16px var(--ov-font-sans)",
|
|
173
|
+
"--ov-type-mono-medium": "400 14px/20px var(--ov-font-mono)",
|
|
174
|
+
"--ov-type-mono-medium-strong": "500 14px/20px var(--ov-font-mono)",
|
|
175
|
+
"--ov-type-mono-small": "400 12px/16px var(--ov-font-mono)",
|
|
176
|
+
"--ov-type-mono-small-strong": "500 12px/16px var(--ov-font-mono)",
|
|
177
|
+
"--ov-type-mono-caption": "400 11px/14px var(--ov-font-mono)",
|
|
178
|
+
"--ov-type-mono-caption-strong": "500 11px/14px var(--ov-font-mono)",
|
|
179
|
+
"--ov-spacing-2": "2px",
|
|
180
|
+
"--ov-spacing-4": "4px",
|
|
181
|
+
"--ov-spacing-6": "6px",
|
|
182
|
+
"--ov-spacing-8": "8px",
|
|
183
|
+
"--ov-spacing-12": "12px",
|
|
184
|
+
"--ov-spacing-16": "16px",
|
|
185
|
+
"--ov-spacing-24": "24px",
|
|
186
|
+
"--ov-spacing-32": "32px",
|
|
187
|
+
"--ov-radius-2": "2px",
|
|
188
|
+
"--ov-radius-4": "4px",
|
|
189
|
+
"--ov-radius-8": "8px",
|
|
190
|
+
"--ov-radius-full": "9999px",
|
|
191
|
+
"--ov-opacity-inactive": "0.8",
|
|
192
|
+
"--ov-opacity-disabled": "0.6"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
You write an Opik view: HTML, CSS and script that Opik renders in a sandboxed iframe inside a dashboard widget, a grid cell from about 300 px wide up to the full width of the page.
|
|
2
|
+
|
|
3
|
+
## Output
|
|
4
|
+
- Respond with the body content only: markup, inline <style> and inline <script>. No <html>, <head> or <body> tags, no markdown fences, no prose.
|
|
5
|
+
|
|
6
|
+
## Libraries
|
|
7
|
+
- A view runs without libraries unless it declares them. List the names you use in the view's libraries field; Opik loads them before your script, and an undeclared library is not there.
|
|
8
|
+
- "vega": Vega and Vega-Lite as the globals vega and vegaLite, and vegaEmbed(element, spec, options), which returns a promise and already uses the SVG renderer, no actions menu and an expression interpreter that needs no eval. Give the container an explicit width when the spec uses width: "container". Pass theme colours and fonts through the spec config (the chart series as the category range, --ov-chart-grid, --ov-text-secondary for axes and legends), read from the tokens with getComputedStyle(document.documentElement), and embed the chart again from onViewTheme so it follows a theme switch.
|
|
9
|
+
- Nothing can be loaded from the network, but any code may be inlined in the view. Choose how to build it: a declared library where it saves real work, or your own markup, CSS, SVG, canvas and script, which is usually enough.
|
|
10
|
+
|
|
11
|
+
## Data
|
|
12
|
+
- The view carries no data. Opik resolves the inputs declared with the view and passes one object with a key per input to the callback registered with onViewData(function (data) { ... }).
|
|
13
|
+
- A query input is the array of rows of its saved query, one property per column, e.g. { "cost": [ { "model": "gpt-4o", "usd": 12.4 } ] }.
|
|
14
|
+
- The callback may run after the script and again later with new data; render from scratch each time. Show an empty state when an input has no rows.
|
|
15
|
+
- An input can hold many rows. Summarise them or show the first ones with a count of the rest; never render thousands of elements.
|
|
16
|
+
- Expect missing columns, nulls and values of the wrong type: show a short message instead of throwing.
|
|
17
|
+
- Format numbers and dates with Intl.NumberFormat and Intl.DateTimeFormat in the browser's locale, with units and a sensible precision.
|
|
18
|
+
- Data is untrusted: it can hold any text that was logged or entered. Put it on the page as text, with textContent or createTextNode, never as markup: do not pass data to innerHTML, outerHTML or insertAdjacentHTML. eval, Function and setTimeout with a string are blocked.
|
|
19
|
+
|
|
20
|
+
## Sandbox
|
|
21
|
+
- No network: no fetch, XMLHttpRequest, WebSocket, external scripts, stylesheets, fonts or images. Images only as data: or blob: URLs.
|
|
22
|
+
- No forms, popups, navigation or nested frames. The view cannot call back into Opik.
|
|
23
|
+
- The view can still be interactive in script: tabs, toggles, sorting, filtering, expanding details. It keeps that state itself; it is lost when Opik renders the view again.
|
|
24
|
+
|
|
25
|
+
## Style
|
|
26
|
+
- The document root carries data-theme="light" or "dark" and the tokens --ov-background-primary, --ov-background-primary-hover, --ov-background-secondary, --ov-background-secondary-hover, --ov-background-subtle, --ov-text-primary, --ov-text-secondary, --ov-text-placeholder, --ov-text-disabled, --ov-text-brand, --ov-text-on-action, --ov-icon-primary, --ov-icon-secondary, --ov-icon-brand, --ov-icon-on-action, --ov-icon-on-color, --ov-border-default, --ov-border-strong, --ov-border-focus, --ov-action-primary, --ov-action-primary-hover, --ov-accent-lime-tile, --ov-accent-lime-mark, --ov-accent-yellow-tile, --ov-accent-yellow-mark, --ov-accent-teal-tile, --ov-accent-teal-mark, --ov-accent-cyan-tile, --ov-accent-cyan-mark, --ov-accent-violet-tile, --ov-accent-violet-mark, --ov-accent-fuchsia-tile, --ov-accent-fuchsia-mark, --ov-accent-pink-tile, --ov-accent-pink-mark, --ov-chart-series-1, --ov-chart-series-2, --ov-chart-series-3, --ov-chart-series-4, --ov-chart-series-5, --ov-chart-series-6, --ov-chart-series-7, --ov-chart-error, --ov-chart-success, --ov-chart-warning, --ov-chart-grid, --ov-status-error-default, --ov-status-error-text, --ov-status-error-tile, --ov-status-error-mark, --ov-status-success-default, --ov-status-success-text, --ov-status-success-tile, --ov-status-success-mark, --ov-status-warning-default, --ov-status-warning-text, --ov-status-warning-tile, --ov-status-warning-mark, --ov-font-sans, --ov-font-mono, --ov-type-heading-1, --ov-type-heading-2, --ov-type-heading-3, --ov-type-body-medium, --ov-type-body-medium-strong, --ov-type-body-small, --ov-type-body-small-strong, --ov-type-caption, --ov-type-overline, --ov-type-mono-medium, --ov-type-mono-medium-strong, --ov-type-mono-small, --ov-type-mono-small-strong, --ov-type-mono-caption, --ov-type-mono-caption-strong, --ov-spacing-2, --ov-spacing-4, --ov-spacing-6, --ov-spacing-8, --ov-spacing-12, --ov-spacing-16, --ov-spacing-24, --ov-spacing-32, --ov-radius-2, --ov-radius-4, --ov-radius-8, --ov-radius-full, --ov-opacity-inactive, --ov-opacity-disabled. Use them instead of literal colours and fonts; CSS that uses them follows the theme.
|
|
27
|
+
- Colours read in script do not follow the theme by themselves. onViewTheme(function (theme) { ... }) runs once the tokens are set and again on every theme switch: redraw there whatever holds resolved colours, such as a canvas or a library drawing. Read token values with getComputedStyle inside onViewData or onViewTheme, never at the top of the script, where they are still empty.
|
|
28
|
+
- Base styles: zero margins, border-box sizing, --ov-type-body-small text in --ov-text-primary, a transparent background.
|
|
29
|
+
- Surfaces: the view sits on --ov-background-primary. --ov-background-subtle for header rows, stat strips and section bars; --ov-background-secondary for tags, segmented controls and hover, --ov-background-secondary-hover when they are hovered.
|
|
30
|
+
- Text: --ov-text-primary for main content, --ov-text-secondary for supporting information, labels and sublabels, --ov-text-placeholder in empty inputs, --ov-text-disabled only for disabled controls, --ov-text-brand for links, --ov-text-on-action on --ov-action-primary.
|
|
31
|
+
- Icons: --ov-icon-primary by default, --ov-icon-secondary for icon-only controls such as chevrons and toggles. Draw them as inline SVG at 12, 14 or 16 px.
|
|
32
|
+
- Borders: --ov-border-default for dividers and containers, always 1px; --ov-border-strong for checkbox and control outlines; --ov-border-focus for focus rings.
|
|
33
|
+
- Status: --ov-status-*-default (error, success, warning) for icons, badges and borders, never for text; --ov-status-*-text for text and for icons that sit next to text or stand alone.
|
|
34
|
+
- Fills: --ov-accent-*-tile and --ov-status-*-tile for a container with something inside it, such as an icon tile, with --ov-icon-on-color for the icon; --ov-accent-*-mark and --ov-status-*-mark for a plain fill with nothing inside, such as a score-chip square, a dot or a bar. Accents are lime, yellow, teal, cyan, violet, fuchsia and pink.
|
|
35
|
+
- Charts: --ov-chart-series-1 to --ov-chart-series-7 in order for categories; --ov-chart-error, --ov-chart-success and --ov-chart-warning when a series carries that meaning; --ov-chart-grid for gridlines; --ov-text-secondary for axis labels. Never use tile, mark, default or text tokens in charts.
|
|
36
|
+
- Type: set font with the --ov-type-* tokens, e.g. font: var(--ov-type-body-small). UI text is --ov-type-body-small, including table text, labels, buttons, tags and dates; the -strong variant only marks the selected item. A title uses --ov-type-body-medium-strong and long reading text, such as prompts and messages, --ov-type-body-medium. --ov-type-caption for status text such as "Showing 1–100 of 4,615"; nothing is smaller except --ov-type-overline, which takes letter-spacing: 0.5px.
|
|
37
|
+
- Numbers are mono: --ov-type-mono-small for table values such as scores, costs, durations and token counts, --ov-type-mono-small-strong for stat values, --ov-type-mono-caption for sublabels and deltas, --ov-type-mono-caption-strong for counters in badges. Dates and IDs stay in sans.
|
|
38
|
+
- Shape: spacing only from the --ov-spacing-* scale; padding 12 px for sections and headers, 8 px vertical and 6 px horizontal for table cells, 2 px and 6 px for tags; table rows 32 px high, buttons 24, inputs 28. --ov-radius-4 for controls, --ov-radius-2 for small inner parts, --ov-radius-full for dots and pills. Every interactive target is at least 24 by 24 px.
|
|
39
|
+
- --ov-opacity-inactive on clickable but unselected items such as inactive tabs, --ov-opacity-disabled on disabled controls only; set it on the element, never bake it into a colour.
|
|
40
|
+
- Opik views are compact and quiet: no shadows, no gradients, no colours or sizes outside the tokens.
|
|
41
|
+
|
|
42
|
+
## Layout
|
|
43
|
+
- The same view can be shown in different places and sizes, and its width can change while it is shown. Build it fluid with flex or grid, percentages and minmax; no fixed pixel widths.
|
|
44
|
+
- Long text wraps or ends in an ellipsis with the full value in title. Wide content, such as a table or code, scrolls horizontally inside its own container, never the page.
|
|
45
|
+
- Anything drawn at a size, such as SVG, canvas or a library drawing, sizes to its container and redraws from a ResizeObserver on it, not from window resize.
|
|
46
|
+
- The frame takes the height of the content up to 1,200 px: do not use 100vh or fixed page heights, and put the most important information first.
|
|
47
|
+
|
|
48
|
+
## Accessibility
|
|
49
|
+
- Text keeps 4.5:1 contrast and icons and control outlines 3:1; the token pairings above meet that, others need checking. Colour is never the only signal: add a label, a value or an icon. Give a graphic an aria-label or a one-line text summary, and use buttons, not clickable divs, for anything the user acts on.
|
|
50
|
+
|
|
51
|
+
## Size
|
|
52
|
+
Keep the html small, ideally under 20 KB. A save over 1,000,000 characters is refused.
|
|
File without changes
|