@axium/ai 0.1.2 → 0.1.3

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.
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import { text } from '@axium/client';
3
+ import { Icon } from '@axium/client/components';
4
+ </script>
5
+
6
+ <a href="/ai" class="back" title={text('ai.back')} aria-label={text('ai.back')}>
7
+ <Icon i="chevron-left" />
8
+ </a>
9
+
10
+ <style>
11
+ .back {
12
+ display: none;
13
+ }
14
+
15
+ @media (width < 700px) {
16
+ .back {
17
+ display: inline-flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ flex-shrink: 0;
21
+ padding: 0.5em;
22
+ margin: -0.5em 0 -0.5em -0.5em;
23
+ }
24
+ }
25
+ </style>
@@ -101,7 +101,9 @@
101
101
  void send();
102
102
  }}></textarea>
103
103
  <div class="controls">
104
- <ModelOptions {models} bind:model bind:reasoning onchange={onoptions} />
104
+ <div class="options">
105
+ <ModelOptions {models} bind:model bind:reasoning onchange={onoptions} />
106
+ </div>
105
107
  {#if recording}
106
108
  <button
107
109
  type="button"
@@ -168,6 +170,7 @@
168
170
  max-width: 50em;
169
171
  width: 100%;
170
172
  view-transition-name: ai-composer;
173
+ container: ai-composer / inline-size;
171
174
  }
172
175
 
173
176
  textarea {
@@ -182,10 +185,23 @@
182
185
 
183
186
  .controls {
184
187
  display: flex;
185
- flex-wrap: wrap;
188
+ align-items: center;
189
+ gap: 0.75em;
190
+ }
191
+
192
+ .options {
193
+ display: flex;
194
+ flex: 1 1 auto;
186
195
  align-items: center;
187
196
  justify-content: flex-end;
188
197
  gap: 0.75em;
198
+ min-width: 0;
199
+ }
200
+
201
+ .dictate,
202
+ .cancel,
203
+ .send {
204
+ flex-shrink: 0;
189
205
  }
190
206
 
191
207
  .dictate {
@@ -8,6 +8,7 @@
8
8
  import { toast } from '@axium/client/toast';
9
9
  import { tick, type Snippet } from 'svelte';
10
10
  import { renameConversation } from './actions.js';
11
+ import BackLink from './BackLink.svelte';
11
12
  import ChatMessage from './ChatMessage.svelte';
12
13
  import Composer from './Composer.svelte';
13
14
  import ConversationMenu from './ConversationMenu.svelte';
@@ -292,6 +293,7 @@
292
293
 
293
294
  <div class={['conversation', temporary && !messages.length && 'empty']}>
294
295
  <div class="header">
296
+ <BackLink />
295
297
  {#if temporary}
296
298
  <div class="title icon-text">
297
299
  {#if messages.length}
@@ -71,12 +71,15 @@
71
71
  {/each}
72
72
  </select>
73
73
  {:else}
74
- <span class="reasoning toggle subtle">
74
+ <span class="reasoning toggle subtle" title={text('ai.reasoning')}>
75
75
  <input id="{id}:reasoning" type="checkbox" checked={enabled} onchange={e => setEnabled(e.currentTarget.checked)} />
76
76
  <label for="{id}:reasoning" class="checkbox">
77
77
  {#if enabled}<Icon i="check" --size="1.3em" />{/if}
78
78
  </label>
79
- <label for="{id}:reasoning">{text('ai.reasoning')}</label>
79
+ <label for="{id}:reasoning" class="name">
80
+ <Icon i="lightbulb" class="compact" />
81
+ <span>{text('ai.reasoning')}</span>
82
+ </label>
80
83
  </span>
81
84
  {/if}
82
85
 
@@ -87,15 +90,38 @@
87
90
  color: inherit;
88
91
  cursor: pointer;
89
92
  min-width: 0;
93
+ text-overflow: ellipsis;
90
94
  }
91
95
 
92
96
  .toggle {
93
97
  display: inline-flex;
94
98
  align-items: center;
95
99
  gap: 0.5em;
100
+ flex-shrink: 0;
96
101
 
97
102
  label {
98
103
  cursor: pointer;
99
104
  }
105
+
106
+ .name :global(.compact) {
107
+ display: none;
108
+ }
109
+ }
110
+
111
+ @container ai-composer (width < 28em) {
112
+ .toggle .name {
113
+ :global(.compact) {
114
+ display: inline-block;
115
+ }
116
+
117
+ span {
118
+ position: absolute;
119
+ width: 1px;
120
+ height: 1px;
121
+ overflow: hidden;
122
+ clip-path: inset(50%);
123
+ white-space: nowrap;
124
+ }
125
+ }
100
126
  }
101
127
  </style>
package/lib/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as BackLink } from './BackLink.svelte';
1
2
  export { default as ChatMessage } from './ChatMessage.svelte';
2
3
  export { default as Composer } from './Composer.svelte';
3
4
  export { default as Conversation } from './Conversation.svelte';
package/locales/en.json CHANGED
@@ -22,6 +22,7 @@
22
22
  "started": "Downloading {name}",
23
23
  "title": "Add model"
24
24
  },
25
+ "back": "Back to chats",
25
26
  "conversation_missing": "That conversation doesn't exist. It may have been deleted.",
26
27
  "conversation_title": "AI — {title}",
27
28
  "delete_body": "The model's files are deleted. Conversations using it switch to the default chat model.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/ai",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "Local-first AI assistant for Axium",
6
6
  "funding": {
@@ -42,7 +42,7 @@
42
42
 
43
43
  <TopBarContent name={text('app_name.ai')} icon="sparkles" href="/ai" />
44
44
 
45
- <div id="ai-app" class={[(page.params.id || page.url.pathname != '/ai') && 'in-page']}>
45
+ <div id="ai-app" class={[(page.params.id || page.url.pathname != '/ai' || page.url.searchParams.has('temporary')) && 'in-page']}>
46
46
  <nav id="ai-sidebar">
47
47
  <a href="/ai" class="new icon-text">
48
48
  <Icon i="plus" />
@@ -65,6 +65,10 @@
65
65
  {/each}
66
66
  <div class="footer">
67
67
  <Timers />
68
+ <a href="/ai?temporary" class="icon-text mobile-only" title={text('ai.temporary.description')}>
69
+ <Icon i="ghost" />
70
+ <span>{text('ai.temporary.toggle')}</span>
71
+ </a>
68
72
  <a href="/ai/memory" class={['icon-text', page.url.pathname == '/ai/memory' && 'active']}>
69
73
  <Icon i="brain" />
70
74
  <span>{text('ai.memory.title')}</span>
@@ -159,9 +163,18 @@
159
163
  overflow: hidden;
160
164
  }
161
165
 
166
+ .mobile-only {
167
+ display: none;
168
+ }
169
+
162
170
  @media (width < 700px) {
163
171
  #ai-app {
164
172
  grid-template-columns: 1fr;
173
+ grid-template-rows: minmax(0, 1fr) auto;
174
+ }
175
+
176
+ #ai-app.in-page {
177
+ grid-template-rows: 1fr;
165
178
  }
166
179
 
167
180
  #ai-main {
@@ -169,9 +182,62 @@
169
182
  border-radius: 0;
170
183
  }
171
184
 
172
- #ai-app.in-page #ai-sidebar,
173
- #ai-app:not(.in-page) #ai-main {
185
+ #ai-app.in-page #ai-sidebar {
174
186
  display: none;
175
187
  }
188
+
189
+ #ai-app:not(.in-page) #ai-main {
190
+ background: none;
191
+ }
192
+
193
+ #ai-sidebar {
194
+ gap: 0;
195
+ padding-bottom: 0;
196
+
197
+ .new {
198
+ display: none;
199
+ }
200
+
201
+ .item {
202
+ padding: 0.75em 1em;
203
+ }
204
+
205
+ .footer {
206
+ order: -1;
207
+ flex-direction: row;
208
+ flex-wrap: wrap;
209
+ gap: 0.5em;
210
+ margin: 0 0 0.75em;
211
+ padding: 0;
212
+
213
+ > :global(a),
214
+ > :global(button.icon-text) {
215
+ flex: 1;
216
+ justify-content: center;
217
+ background-color: var(--bg-alt);
218
+ }
219
+
220
+ > :global(a.active) {
221
+ background-color: var(--bg-accent);
222
+ }
223
+
224
+ > :global(:is(a, button.icon-text) span) {
225
+ position: absolute;
226
+ width: 1px;
227
+ height: 1px;
228
+ overflow: hidden;
229
+ clip-path: inset(50%);
230
+ white-space: nowrap;
231
+ }
232
+
233
+ > :global(.timer) {
234
+ flex-basis: 100%;
235
+ }
236
+ }
237
+
238
+ .mobile-only {
239
+ display: inline-flex;
240
+ }
241
+ }
176
242
  }
177
243
  </style>
@@ -95,6 +95,18 @@
95
95
  right: 1em;
96
96
  }
97
97
 
98
+ @media (width < 700px) {
99
+ .start {
100
+ height: auto;
101
+ padding: 0.5em 1em 1em;
102
+
103
+ h2,
104
+ .corner {
105
+ display: none;
106
+ }
107
+ }
108
+ }
109
+
98
110
  .toggle {
99
111
  padding: 0.4em 0.9em;
100
112
  border-radius: 1.5em;
@@ -2,6 +2,7 @@
2
2
  import type { Node as Memory, Update as MemoryUpdate } from '@axium/ai/memory';
3
3
  import { markdown } from '@axium/ai/markdown';
4
4
  import { fetchAPI, text } from '@axium/client';
5
+ import { BackLink } from '@axium/ai/components';
5
6
  import { Icon } from '@axium/client/components';
6
7
  import { confirm } from '@axium/client/dialogs';
7
8
  import { toast } from '@axium/client/toast';
@@ -92,6 +93,7 @@
92
93
 
93
94
  <div class="memory-page">
94
95
  <div class="header">
96
+ <BackLink />
95
97
  <h2>{text('ai.memory.title')}</h2>
96
98
  {#if !adding}
97
99
  <button class="icon-text" onclick={() => (adding = true)} disabled={memories.length >= limit}>
@@ -217,7 +219,7 @@
217
219
 
218
220
  .header {
219
221
  display: flex;
220
- align-items: baseline;
222
+ align-items: center;
221
223
  gap: 1em;
222
224
 
223
225
  h2 {
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { ModelActions, ModelStatus } from '@axium/ai/components';
2
+ import { BackLink, ModelActions, ModelStatus } from '@axium/ai/components';
3
3
  import { withUpdates } from '@axium/ai/live';
4
4
  import { fetchAPI, text } from '@axium/client';
5
5
  import { Icon } from '@axium/client/components';
@@ -34,6 +34,7 @@
34
34
 
35
35
  <div class="models-page">
36
36
  <div class="header">
37
+ <BackLink />
37
38
  <h2>{text('ai.models')}</h2>
38
39
  {#if isAdmin}
39
40
  <button class="icon-text" onclick={() => addDialog?.showModal()}>
@@ -55,23 +56,28 @@
55
56
  <section class="list">
56
57
  {#each models as model (model.id)}
57
58
  <div class="model">
59
+ {const assigned = $derived(ai.roles.filter(role => ai.resolveRole(models, current.roles, role)?.id == model.id))}
58
60
  <div class="info">
59
- <div class="title">
60
- <a href="/ai/models/{model.id}" class="name">{model.name}</a>
61
- {#each ai.roles.filter(role => ai.resolveRole(models, current.roles, role)?.id == model.id) as role (role)}
62
- <span class="badge">{text(`ai.role.name.${role}`)}</span>
63
- {/each}
64
- </div>
61
+ <a href="/ai/models/{model.id}" class="name">{model.name}</a>
65
62
  <span class="subtle">{model.id}</span>
63
+ {#if assigned.length}
64
+ <div class="roles">
65
+ {#each assigned as role (role)}
66
+ <span class="badge">{text(`ai.role.name.${role}`)}</span>
67
+ {/each}
68
+ </div>
69
+ {/if}
70
+ </div>
71
+ <div class="meta">
72
+ <div class="status"><ModelStatus {model} /></div>
73
+ <span class="subtle size">{bytes(model.size)}</span>
66
74
  </div>
67
- <ModelStatus {model} />
68
- <span class="subtle size">{bytes(model.size)}</span>
69
75
  <div class="actions">
70
76
  {#if isAdmin}
71
77
  <ModelActions {model} onremove={refresh} />
72
78
  {/if}
73
79
  </div>
74
- <Icon i="chevron-right" />
80
+ <span class="chevron"><Icon i="chevron-right" /></span>
75
81
  </div>
76
82
  {:else}
77
83
  <p class="subtle">{text(isAdmin ? 'ai.no_models_admin' : 'ai.no_models')}</p>
@@ -105,12 +111,15 @@
105
111
  display: flex;
106
112
  flex-wrap: wrap;
107
113
  align-items: center;
108
- justify-content: space-between;
109
114
  gap: 1em;
110
115
 
111
116
  h2 {
112
117
  margin: 0;
113
118
  }
119
+
120
+ button {
121
+ margin-left: auto;
122
+ }
114
123
  }
115
124
 
116
125
  h3 {
@@ -149,11 +158,11 @@
149
158
  gap: 0.25em;
150
159
  min-width: 0;
151
160
 
152
- .title {
161
+ .roles {
153
162
  display: flex;
154
163
  flex-wrap: wrap;
155
- align-items: center;
156
- gap: 0.25em 0.75em;
164
+ gap: 0.25em 0.5em;
165
+ margin-top: 0.25em;
157
166
  }
158
167
 
159
168
  .name {
@@ -179,6 +188,14 @@
179
188
  font-size: 0.8em;
180
189
  }
181
190
 
191
+ .meta {
192
+ display: contents;
193
+ }
194
+
195
+ .status {
196
+ min-width: 0;
197
+ }
198
+
182
199
  .size {
183
200
  text-align: end;
184
201
  }
@@ -189,11 +206,42 @@
189
206
 
190
207
  @media (width < 800px) {
191
208
  .list {
192
- grid-template-columns: minmax(0, 1fr) max-content max-content;
209
+ display: flex;
210
+ flex-direction: column;
211
+ }
212
+
213
+ .model {
214
+ grid-template-columns: minmax(0, 1fr) max-content;
215
+ grid-template-areas:
216
+ 'info chevron'
217
+ 'meta meta'
218
+ 'actions actions';
219
+ gap: 0.75em 1em;
220
+ }
221
+
222
+ .info {
223
+ grid-area: info;
224
+ }
225
+
226
+ .meta {
227
+ grid-area: meta;
228
+ display: flex;
229
+ align-items: first baseline;
230
+ gap: 1em;
231
+ }
232
+
233
+ .size {
234
+ text-align: start;
193
235
  }
194
236
 
195
237
  .actions {
196
- grid-column: 1 / 3;
238
+ grid-area: actions;
239
+ }
240
+
241
+ .chevron {
242
+ grid-area: chevron;
243
+ align-self: start;
244
+ justify-self: end;
197
245
  }
198
246
  }
199
247
  </style>