@mieweb/ui 0.10.0-dev.21 → 0.10.0-dev.22
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.
|
@@ -198,3 +198,80 @@ abstraction solely to make it contributable.
|
|
|
198
198
|
Follow the repository's permissions and approval requirements for commits,
|
|
199
199
|
pushes, and PR creation. Do not treat these instructions as authorization to
|
|
200
200
|
publish changes.
|
|
201
|
+
|
|
202
|
+
## Rule 16: Embedding the Ozwell assistant that acts on the page
|
|
203
|
+
|
|
204
|
+
Two different things share the "Ozwell" name — pick deliberately:
|
|
205
|
+
|
|
206
|
+
- **`OzwellChat` / `AIChat` (this library)** — the *chat UI shell*. You own the
|
|
207
|
+
transport and render messages you already have. Use it when the assistant is
|
|
208
|
+
part of your own product and you wire the answers yourself (see the
|
|
209
|
+
[Chat family](https://ui.mieweb.org/?path=/docs/modules-chat-overview--docs)
|
|
210
|
+
and the [Ozwell backend guide](https://github.com/mieweb/ui/blob/main/src/components/AI/OZWELL-BACKEND.md)).
|
|
211
|
+
- **The embedded Ozwell assistant (`@ozwell/react`, from ozwellai-api)** — a
|
|
212
|
+
drop-in, page-aware assistant that can **read and act on your page** through
|
|
213
|
+
tool calls. Use this when the user says things like "add Ozwell" or "let
|
|
214
|
+
Ozwell click / read / fill something on the page."
|
|
215
|
+
|
|
216
|
+
To add the page-aware assistant to a `@mieweb/ui` app:
|
|
217
|
+
|
|
218
|
+
- Install `@ozwell/react` alongside `@mieweb/ui`.
|
|
219
|
+
- Render `OzwellChat` from `@ozwell/react` and declare one tool in `tools` for
|
|
220
|
+
each page action the user wants Ozwell to perform (click, read, fill, …).
|
|
221
|
+
- Authenticate with a **site-approved agent key** (`agnt_key-…`) via
|
|
222
|
+
`VITE_OZWELL_AGENT_KEY`. Vite inlines every `VITE_*` value into the browser
|
|
223
|
+
bundle — this is **not** secret storage, so never expose a parent (`ozw_…`),
|
|
224
|
+
admin, or model-provider key this way; use a server-side integration when a
|
|
225
|
+
credential must stay private.
|
|
226
|
+
- Handle each call in `onToolCall(name, args, respond)`: perform the DOM action
|
|
227
|
+
and **always** `respond(...)`. Return `isError: true` for an unknown tool name
|
|
228
|
+
or a missing target, so the assistant never claims an action that did not happen.
|
|
229
|
+
- Follow the canonical guide — a full **Vite + MIE UI "Click Hello World"**
|
|
230
|
+
example — at <https://mieweb.github.io/ozwellai-api/frontend/react/>.
|
|
231
|
+
|
|
232
|
+
Example — let Ozwell fill a field on the page (adapt the tool to your app's own actions):
|
|
233
|
+
|
|
234
|
+
```tsx
|
|
235
|
+
import { useState } from 'react';
|
|
236
|
+
import { Input } from '@mieweb/ui';
|
|
237
|
+
import { OzwellChat, type OzwellTool } from '@ozwell/react';
|
|
238
|
+
|
|
239
|
+
const tools: OzwellTool[] = [{
|
|
240
|
+
type: 'function',
|
|
241
|
+
function: {
|
|
242
|
+
name: 'set_note',
|
|
243
|
+
description: 'Write text into the Note field when the user asks.',
|
|
244
|
+
parameters: {
|
|
245
|
+
type: 'object',
|
|
246
|
+
properties: { text: { type: 'string', description: 'Text to put in the Note field' } },
|
|
247
|
+
required: ['text'],
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
}];
|
|
251
|
+
|
|
252
|
+
export default function App() {
|
|
253
|
+
const [note, setNote] = useState('');
|
|
254
|
+
return (
|
|
255
|
+
<>
|
|
256
|
+
<Input label="Note" value={note} onChange={(e) => setNote(e.target.value)} />
|
|
257
|
+
<output aria-live="polite">Note: {note}</output>
|
|
258
|
+
<OzwellChat
|
|
259
|
+
apiKey={import.meta.env.VITE_OZWELL_AGENT_KEY}
|
|
260
|
+
tools={tools}
|
|
261
|
+
onToolCall={(name, args, respond) => {
|
|
262
|
+
if (name !== 'set_note' || typeof args.text !== 'string') {
|
|
263
|
+
respond({ isError: true, content: [{ type: 'text', text: 'Tool unavailable' }] });
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
setNote(args.text);
|
|
267
|
+
respond({ content: [{ type: 'text', text: `Note set to "${args.text}"` }] });
|
|
268
|
+
}}
|
|
269
|
+
/>
|
|
270
|
+
</>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Privacy: conversation content stays between the user and Ozwell and is never
|
|
276
|
+
relayed to the host page. The host receives only the tool calls it declares,
|
|
277
|
+
lifecycle/error events, and any data the user explicitly shares (opt-in).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mieweb/ui",
|
|
3
|
-
"version": "0.10.0-dev.
|
|
3
|
+
"version": "0.10.0-dev.22",
|
|
4
4
|
"description": "A themeable, accessible React component library built with Tailwind CSS",
|
|
5
5
|
"author": "Medical Informatics Engineering, Inc.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|