You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/extensions/ui.mdx
+38-34Lines changed: 38 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,23 @@
1
1
---
2
2
title: UI Extensions API
3
-
description: This guide provides a walkthrough of the LLM UI Extensions API (`ctx.mjs`), using the `xmas` extension as a practical example. The Extensions API allows you to customize the UI, add new pages, modify the layout, and intercept chat functionality.
3
+
description: This guide provides a walkthrough of the LLM UI Extensions API which allows you to customize the UI, add new pages, modify the layout, and intercept chat functionality.
4
4
---
5
5
6
+
We'll use the [xmas extension](https://github.com/llmspy/xmas/blob/main/ui/index.mjs) as a practical example to explore the capabilities
7
+
in the App Extensions API which starts from [ctx.mjs](https://github.com/ServiceStack/llms/blob/main/llms/ui/ctx.mjs).
6
8
7
9
## Extension Entry Point
8
10
9
11
Every UI extension must export an object with an `install(ctx)` method. `ctx` is the `AppContext` instance which provides access to the core UI functionality.
10
12
11
13
```js
14
+
let ext
15
+
12
16
exportdefault {
13
17
install(ctx) {
18
+
// Manage state, stored prefs and API Integrations scoped to this ExtensionScope
19
+
ext =ctx.scope('xmas')
20
+
14
21
// Registration logic goes here
15
22
},
16
23
asyncload(ctx) {
@@ -25,10 +32,9 @@ export default {
25
32
You can register custom Vue components to be used throughout the application or to replace existing ones. This is done using `ctx.components()`.
26
33
27
34
### Replacing Core Components
28
-
Overrides default components like `Brand`, `Welcome`, or`HomeTools` by registering components with the same name.
35
+
Overrides default `Brand`, `Welcome`, and`HomeTools` components by registering components with the same name.
29
36
30
37
```js
31
-
// Replace Brand component with a custom Christmas theme
text:`Write a short, feel-good Christmas story set on a quiet winter evening. Focus on simple kindness, cozy details, and gentle magic—twinkling lights, warm drinks, falling snow, and a small act of generosity that brings people together. Keep the tone hopeful and comforting, with a soft, joyful ending that leaves the reader smiling.`,
272
+
text:`Write a short, feel-good Christmas story set on a quiet winter evening...`,
248
273
systemPrompt: santaSystemPrompt,
249
274
})
250
275
@@ -261,24 +286,3 @@ onMounted(async () => {
261
286
}
262
287
})
263
288
```
264
-
265
-
## Full Example Component: Top Panel
266
-
267
-
This is how you define a complex UI component like a Top Panel. It's just a standard Vue 3 component.
0 commit comments