llm_meta_widget 0.7.4 → 0.7.5
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 +65 -16
- 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: 8d2cc5c7bfb6fa54893df26cef21788e90384052cda6a60acc05aca7fdc90f61
|
|
4
|
+
data.tar.gz: 43aa3c8567f74595ff9b66e6fcbf2e71291da2c3699c4ac84c1b3b07b6c2a6b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43d04fc32c9e167cb7958f80ef2f5d8632621703542f7679e444c1f55b12cf68276945b4adb45a17e6e699a4ec9ee3c9ac017b646e8069ecf1688abd7e5376ef
|
|
7
|
+
data.tar.gz: b2b04bf2577dfc7ee3de38581734b4385354c81146b9523d2d33d78d6aa126ff0dfadc42018889f2f4fcd2ab859f7148bf5e0694f096377060497b28a91a9dd6
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Embeddable browser chat widget for the [llm_meta](https://github.com/pubannotati
|
|
|
4
4
|
|
|
5
5
|
Client-orchestrated: the widget fetches host-side action schemas + host-published `.well-known/mcp.json` manifests at boot, dispatches tool_calls locally (page-embedded actions) or directly to MCP endpoints (host-wide well-known), and consumes the meta-server's SSE `single_llm_calls` API. Ships as a custom element in one self-contained ES module — on npm for any host, and in a Rails gem whose helper serves the identical file.
|
|
6
6
|
|
|
7
|
-
**No** Devise, DB migrations, ChatManager, or PromptNavigator.
|
|
7
|
+
**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 are not Rails at all skip the gem entirely.
|
|
8
8
|
|
|
9
9
|
## What you need first
|
|
10
10
|
|
|
@@ -22,13 +22,26 @@ answers the chat, or use no hub at all. Page actions and your own
|
|
|
22
22
|
Nothing else is required: no database, no migrations, no JavaScript build
|
|
23
23
|
step, no Node at runtime.
|
|
24
24
|
|
|
25
|
-
| Requirement | Version |
|
|
26
|
-
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
25
|
+
| Requirement | Version | Needed when |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| A browser with custom elements + ES modules | any current | always |
|
|
28
|
+
| An llm_meta_server **or** an Ollama | any | always — something has to answer the chat |
|
|
29
|
+
| Ruby | >= 3.2 | only if you install the gem |
|
|
30
|
+
| Rails | >= 8.0 (8.1 not required) | only if you install the gem |
|
|
31
|
+
|
|
32
|
+
## Two ways to add the widget — choose one
|
|
33
|
+
|
|
34
|
+
You do **not** need both. Pick the row that matches your app, then read only
|
|
35
|
+
that section.
|
|
36
|
+
|
|
37
|
+
| Your app | What you add | What you write |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| **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 |
|
|
41
|
+
|
|
42
|
+
Both ways load the same file and run the same widget.
|
|
30
43
|
|
|
31
|
-
##
|
|
44
|
+
## Rails apps: install the gem
|
|
32
45
|
|
|
33
46
|
```ruby
|
|
34
47
|
# Gemfile
|
|
@@ -44,7 +57,27 @@ deliberately skips `isolate_namespace`, so the helper is included into
|
|
|
44
57
|
ActionView and the asset routes appear at the host's top level on their own.
|
|
45
58
|
There are no migrations and no generators to run.
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
**Why install the gem?** The gem gives you the same widget as the CDN — the
|
|
61
|
+
same file, byte for byte. It does not add features. What it gives you is a
|
|
62
|
+
simpler way to deliver and configure the widget:
|
|
63
|
+
|
|
64
|
+
- **Your own server sends the file**, at
|
|
65
|
+
`/llm_meta_widget_assets/llm-meta-widget.js`. The page makes no request to
|
|
66
|
+
any other site. If the CDN is down, your page still works, and the widget
|
|
67
|
+
also works behind a firewall or on a network with no internet access.
|
|
68
|
+
- **Bundler manages the version**, like every other gem. You update it with
|
|
69
|
+
`bundle update`. With the CDN, the version is part of a URL that someone
|
|
70
|
+
has to remember to change.
|
|
71
|
+
- **You write Ruby, not HTML attributes.** The helper takes normal Ruby
|
|
72
|
+
values and converts them for you. That matters most where the attributes
|
|
73
|
+
are easy to get wrong: `nil` and `[]` mean different things for
|
|
74
|
+
`well_known_urls:`, the allowlists take arrays, and the pickers take real
|
|
75
|
+
`true`/`false`. Written by hand, all three must be encoded correctly as
|
|
76
|
+
text.
|
|
77
|
+
- **The defaults are set for you**, so your view names only the options you
|
|
78
|
+
want to change.
|
|
79
|
+
|
|
80
|
+
## Rails apps: a minimal working example
|
|
48
81
|
|
|
49
82
|
Put this on any view — a fresh `pages/demo.html.erb` is fine:
|
|
50
83
|
|
|
@@ -79,7 +112,12 @@ Once that works, the widget can converse but cannot *do* anything. To let the
|
|
|
79
112
|
LLM act on your page or call your own services, declare tools using any of the
|
|
80
113
|
**three tool classes** below.
|
|
81
114
|
|
|
82
|
-
##
|
|
115
|
+
## Non-Rails hosts: write the element yourself
|
|
116
|
+
|
|
117
|
+
**If your app is Rails, you can skip this section.** The gem already does
|
|
118
|
+
everything described here: its helper writes this tag for you and its engine
|
|
119
|
+
sends this file. Read on if your app is not Rails — or if you use Rails but
|
|
120
|
+
prefer the CDN to the gem, which the `element_path:` option allows.
|
|
83
121
|
|
|
84
122
|
The widget is a custom element in a single self-contained ES module, so a host
|
|
85
123
|
that is not Rails needs no gem, no template engine and no asset pipeline — two
|
|
@@ -87,11 +125,16 @@ lines of HTML:
|
|
|
87
125
|
|
|
88
126
|
```html
|
|
89
127
|
<script type="module" src="https://cdn.jsdelivr.net/npm/@aibranch/llm-meta-widget@0.7"></script>
|
|
90
|
-
<llm-meta-widget llm-url="https://your-
|
|
91
|
-
model="qwen3-
|
|
128
|
+
<llm-meta-widget llm-url="https://your-meta-server.example"
|
|
129
|
+
model="qwen3-6-35b-fast"
|
|
92
130
|
greeting="Hi — ask me anything about this page."></llm-meta-widget>
|
|
93
131
|
```
|
|
94
132
|
|
|
133
|
+
This is the same configuration as the Rails example above, written in HTML
|
|
134
|
+
instead of ERB. Both produce the same widget, so the advice in that section
|
|
135
|
+
— CORS, a reachable `llm_url`, the hub's name for the model — applies here
|
|
136
|
+
too.
|
|
137
|
+
|
|
95
138
|
Nothing else is needed: the stylesheets and the markdown renderer are bundled
|
|
96
139
|
in, and the element injects its own styles. The host serves no CSS and no JS.
|
|
97
140
|
|
|
@@ -105,10 +148,11 @@ Three ways to get that one file, in descending order of convenience:
|
|
|
105
148
|
- **self-hosted** — copy it out of the package or the gem and serve it as a
|
|
106
149
|
static asset, if you would rather not depend on a CDN.
|
|
107
150
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
are declared exactly as they are under Rails (see the three
|
|
151
|
+
Going without the gem removes the Rails pieces — the helper and the partial.
|
|
152
|
+
It does not remove your page's own contract, because those parts belong to the
|
|
153
|
+
page rather than to Rails: the `#ai-actions` JSON block, `window.aiState` and
|
|
154
|
+
`window.aiActions` are declared exactly as they are under Rails (see the three
|
|
155
|
+
tool classes below).
|
|
112
156
|
|
|
113
157
|
**Attributes** map one-to-one onto the helper's keyword options. Three are not
|
|
114
158
|
obvious and are the ones that bite:
|
|
@@ -248,7 +292,7 @@ By default the widget renders two pickers below the input textarea:
|
|
|
248
292
|
- **Model dropdown** — populated from the hub's `GET /api/llms` (anon path returns Ollama-only, since the widget's LLM calls use `api_key_uuid: "ollama-local"`).
|
|
249
293
|
- **Tool picker** — populated from the hub's `GET /api/mcp_servers` (anon path returns `public_to_anonymous: true` servers). Two-level UX: server bulk-toggle + individual tool checkboxes on expand.
|
|
250
294
|
|
|
251
|
-
Both pickers require **CORS
|
|
295
|
+
Both pickers require **CORS**, the same way the chat itself does: the hub must list your page's origin in its `CORS_ORIGINS` environment variable for the `/api/*` resource. Without that the fetches are blocked silently and both pickers simply stay empty.
|
|
252
296
|
|
|
253
297
|
To adjust picker behavior at the helper call site:
|
|
254
298
|
|
|
@@ -274,6 +318,11 @@ To lock the widget to the fixed `model:` prop and disable Class-1 tools entirely
|
|
|
274
318
|
|
|
275
319
|
## All helper options
|
|
276
320
|
|
|
321
|
+
These are the gem helper's keyword options. If you write the element by hand,
|
|
322
|
+
each one has an attribute of the same name in kebab-case — `llm_url:` becomes
|
|
323
|
+
`llm-url`, and so on. The attribute table above lists the few that do not
|
|
324
|
+
translate directly.
|
|
325
|
+
|
|
277
326
|
| Option | Default | Purpose |
|
|
278
327
|
|---|---|---|
|
|
279
328
|
| `llm_url:` | required | Who answers the chat — an llm_meta_server, or an Ollama |
|