llm_meta_widget 0.8.1 → 0.8.2
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.
- checksums.yaml +4 -4
- data/README.md +67 -25
- data/lib/llm_meta_widget/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f19be36c0ac6c12b514836a44a383e8d417c59cddd97f771947044f6d027091f
|
|
4
|
+
data.tar.gz: 33ebfee68850e7396faff9739d306273e281950f11ae2eeb4fba88d4a6924386
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e320dce7bc260d9ef3f646328536d01c2eeec6ae40b4ca20c3aaac390ace093507f04f4e0f060e1db3497a94e81bc899936663f09c79c1c85e5abbc62d663b77
|
|
7
|
+
data.tar.gz: 73b783e9b2a436f2fe44d1fc447276d9e243cf3e7387f884684823412a54d9dbfe3f14c37f9e2a7078c67234c6561380f9c76089526240dc8e1997da9cb6df53
|
data/README.md
CHANGED
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Embeddable browser chat widget for the [llm_meta](https://github.com/pubannotation) ecosystem.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The browser does the orchestrating. At boot the widget reads the tools your page
|
|
6
|
+
declares and any `.well-known/mcp.json` your host publishes. When the model calls
|
|
7
|
+
a tool, the widget runs it: in the page itself, or against an MCP endpoint
|
|
8
|
+
directly. Only the chat goes through the meta-server, over SSE.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
It ships as a custom element in one self-contained ES module. The same file is on
|
|
11
|
+
npm for any host, and in a Rails gem whose helper serves it for you.
|
|
12
|
+
|
|
13
|
+
**No** Devise, DB migrations, ChatManager, or PromptNavigator. The gem adds only `rails >= 8.0` as a runtime dep — so hosts that haven't bumped to 8.1 can adopt it without a Rails upgrade — and hosts that do not use Rails do not need the gem.
|
|
8
14
|
|
|
9
15
|
## What you need first
|
|
10
16
|
|
|
@@ -37,7 +43,7 @@ that section.
|
|
|
37
43
|
| Your app | What you add | What you write |
|
|
38
44
|
|---|---|---|
|
|
39
45
|
| **Rails** | the gem, one line in your `Gemfile` | one helper call in a view. The helper writes the `<llm-meta-widget>` tag for you, so you never write that tag yourself |
|
|
40
|
-
| **Anything else** — Python, Go, PHP, plain HTML… | one `<script>` tag from the CDN | the `<llm-meta-widget>` tag yourself |
|
|
46
|
+
| **Anything else** — Python, Go, PHP, plain HTML… | one `<script>` tag from the CDN, or an npm dependency you bundle | the `<llm-meta-widget>` tag yourself |
|
|
41
47
|
|
|
42
48
|
Both ways load the same file and run the same widget.
|
|
43
49
|
|
|
@@ -108,7 +114,7 @@ Two more things worth knowing before you go further:
|
|
|
108
114
|
- The model name is the hub's name for it (`GET /api/llms` lists them), not
|
|
109
115
|
the provider's.
|
|
110
116
|
|
|
111
|
-
Once that works, the widget can
|
|
117
|
+
Once that works, the widget can talk, but it cannot *do* anything yet. To let the
|
|
112
118
|
LLM act on your page or call your own services, declare tools using any of the
|
|
113
119
|
**three tool classes** below.
|
|
114
120
|
|
|
@@ -135,37 +141,73 @@ instead of ERB. Both produce the same widget, so the advice in that section
|
|
|
135
141
|
— CORS, a reachable `llm_url`, the hub's name for the model — applies here
|
|
136
142
|
too.
|
|
137
143
|
|
|
138
|
-
**`@0.8` is a range, and it stops at 0.8.x on purpose.** You
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
**`@0.8` is a version range, and it stops at 0.8.x on purpose.** You receive bug
|
|
145
|
+
fixes without editing your page, and a release that breaks your page cannot
|
|
146
|
+
arrive on its own.
|
|
147
|
+
|
|
148
|
+
Moving to 0.9 is therefore a change you make yourself. Read
|
|
149
|
+
[CHANGELOG.md](CHANGELOG.md) before you do, because this is where what your page
|
|
150
|
+
must provide can change. For example, 0.8.0 changed the shape of
|
|
151
|
+
`window.aiState`. A page that used the new shape while still loading `@0.7`
|
|
152
|
+
would have shown an error string in place of every value, with no other warning.
|
|
153
|
+
|
|
154
|
+
A Rails app is protected from that mismatch, because the `Gemfile` will not
|
|
155
|
+
resolve a widget version the page cannot use. A page that loads the widget from
|
|
156
|
+
the CDN has no such check, so the version you write in that URL is the only
|
|
157
|
+
protection you have.
|
|
147
158
|
|
|
148
159
|
Nothing else is needed: the stylesheets and the markdown renderer are bundled
|
|
149
160
|
in, and the element injects its own styles. The host serves no CSS and no JS.
|
|
150
161
|
|
|
151
|
-
|
|
162
|
+
### If you have a JS build pipeline, install it instead
|
|
163
|
+
|
|
164
|
+
Vite, webpack, esbuild, Next.js, SvelteKit, Astro — if your app already builds
|
|
165
|
+
JavaScript, take the widget as a dependency rather than a script tag:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npm install @aibranch/llm-meta-widget
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
// Once, at your app's entry point. Importing the package is all you need: it
|
|
173
|
+
// defines the custom element. There is no function to call and nothing to name.
|
|
174
|
+
import "@aibranch/llm-meta-widget";
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Then write the `<llm-meta-widget>` tag exactly as above — same attributes, same
|
|
178
|
+
behaviour.
|
|
179
|
+
|
|
180
|
+
**Why do this, when the script tag is only one line?** Because your build then
|
|
181
|
+
checks the version for you. The version is pinned in your lockfile and installed by `npm ci`
|
|
182
|
+
with integrity checking, so you know which widget your page runs and your
|
|
183
|
+
colleague's build runs the same one. On the CDN path the version lives in a URL
|
|
184
|
+
that nothing checks. That matters most at a breaking release: 0.8.0 changed the
|
|
185
|
+
shape of `window.aiState`, and a lockfile makes the upgrade a deliberate, visible
|
|
186
|
+
step instead of a URL someone edits.
|
|
187
|
+
|
|
188
|
+
The only cost is that this path needs a build pipeline. The CDN path needs none,
|
|
189
|
+
which is why it is listed first.
|
|
190
|
+
|
|
191
|
+
Four ways to get that one file, in descending order of convenience:
|
|
152
192
|
|
|
153
193
|
- **the CDN**, as above — `@aibranch/llm-meta-widget` on npm, no path needed
|
|
154
194
|
because the package's `main` is the bundle;
|
|
195
|
+
- **npm install plus your own bundler**, as above — the same package, resolved
|
|
196
|
+
through `exports` and pinned by your lockfile;
|
|
155
197
|
- **the gem**, which serves the identical file at
|
|
156
198
|
`/llm_meta_widget_assets/llm-meta-widget.js` for Rails hosts, and is what the
|
|
157
199
|
`llm_meta_widget` helper points at;
|
|
158
200
|
- **self-hosted** — copy it out of the package or the gem and serve it as a
|
|
159
201
|
static asset, if you would rather not depend on a CDN.
|
|
160
202
|
|
|
161
|
-
Going without the gem removes the Rails
|
|
162
|
-
|
|
163
|
-
page
|
|
164
|
-
`window.aiActions`
|
|
165
|
-
|
|
203
|
+
Going without the gem removes the Rails parts: the helper and the partial. It
|
|
204
|
+
does not change what your page itself must provide, because those parts belong to
|
|
205
|
+
the page, not to Rails. You declare the `#ai-actions` JSON block, `window.aiState`
|
|
206
|
+
and `window.aiActions` exactly as a Rails page does — see the three tool classes
|
|
207
|
+
below.
|
|
166
208
|
|
|
167
|
-
**Attributes**
|
|
168
|
-
|
|
209
|
+
**Attributes** match the helper's keyword options one to one. Three of them are
|
|
210
|
+
easy to get wrong:
|
|
169
211
|
|
|
170
212
|
| attribute | notes |
|
|
171
213
|
|---|---|
|
|
@@ -176,11 +218,11 @@ obvious and are the ones that bite:
|
|
|
176
218
|
| `actions-schema-id`, `state-global`, `actions-global`, `remote-tools-schema-id` | as the helper options |
|
|
177
219
|
| `models`, `hub-tools` | comma-separated. Omitted **or empty** means no allowlist — an allowlist permitting nothing is never what anyone meant |
|
|
178
220
|
| `enable-model-picker`, `enable-tool-picker` | **value attributes, not boolean attributes.** They default to true, so presence cannot mean true. Disable with `enable-tool-picker="false"`; any other value is true |
|
|
179
|
-
| `well-known-urls` | **
|
|
221
|
+
| `well-known-urls` | **Three different states**, because an attribute cannot tell "not set" from "set to empty": omitted = auto-discover same-origin `/.well-known/mcp.json`; `""` = discovery off; `"a,b"` = fetch those |
|
|
180
222
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
console.
|
|
223
|
+
The last one fails quietly. If you expect discovery to be off but leave the
|
|
224
|
+
attribute out, the widget fetches your own origin instead. Nothing appears to
|
|
225
|
+
happen, except a 404 in the browser console.
|
|
184
226
|
|
|
185
227
|
One widget per page. The panel uses fixed element ids, so a second
|
|
186
228
|
`<llm-meta-widget>` is ignored with a console warning rather than fighting the
|