llms-py 3.0.0b1__py3-none-any.whl → 3.0.0b2__py3-none-any.whl
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.
- llms/__pycache__/__init__.cpython-312.pyc +0 -0
- llms/__pycache__/__init__.cpython-313.pyc +0 -0
- llms/__pycache__/__init__.cpython-314.pyc +0 -0
- llms/__pycache__/__main__.cpython-312.pyc +0 -0
- llms/__pycache__/__main__.cpython-314.pyc +0 -0
- llms/__pycache__/llms.cpython-312.pyc +0 -0
- llms/__pycache__/main.cpython-312.pyc +0 -0
- llms/__pycache__/main.cpython-313.pyc +0 -0
- llms/__pycache__/main.cpython-314.pyc +0 -0
- llms/__pycache__/plugins.cpython-314.pyc +0 -0
- llms/index.html +25 -56
- llms/llms.json +2 -2
- llms/main.py +452 -93
- llms/providers.json +1 -1
- llms/ui/App.mjs +25 -4
- llms/ui/Avatar.mjs +3 -2
- llms/ui/ChatPrompt.mjs +43 -52
- llms/ui/Main.mjs +87 -98
- llms/ui/OAuthSignIn.mjs +2 -33
- llms/ui/ProviderStatus.mjs +7 -8
- llms/ui/Recents.mjs +10 -9
- llms/ui/Sidebar.mjs +2 -1
- llms/ui/SignIn.mjs +7 -6
- llms/ui/ai.mjs +9 -41
- llms/ui/app.css +137 -138
- llms/ui/index.mjs +213 -0
- llms/ui/{ModelSelector.mjs → model-selector.mjs} +193 -200
- llms/ui/tailwind.input.css +441 -79
- llms/ui/threadStore.mjs +17 -6
- llms/ui/utils.mjs +1 -0
- {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/METADATA +1 -1
- llms_py-3.0.0b2.dist-info/RECORD +58 -0
- llms/ui/SystemPromptEditor.mjs +0 -31
- llms/ui/SystemPromptSelector.mjs +0 -56
- llms_py-3.0.0b1.dist-info/RECORD +0 -49
- {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/WHEEL +0 -0
- {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/entry_points.txt +0 -0
- {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/licenses/LICENSE +0 -0
- {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/top_level.txt +0 -0
llms/ui/index.mjs
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
|
|
2
|
+
import { createApp, reactive, defineAsyncComponent } from 'vue'
|
|
3
|
+
import { createWebHistory, createRouter } from "vue-router"
|
|
4
|
+
import { EventBus, humanize } from "@servicestack/client"
|
|
5
|
+
import ServiceStackVue from "@servicestack/vue"
|
|
6
|
+
import App from '/ui/App.mjs'
|
|
7
|
+
import ai from '/ui/ai.mjs'
|
|
8
|
+
import threadStore, { useThreadStore } from './threadStore.mjs'
|
|
9
|
+
import SettingsDialog from '/ui/SettingsDialog.mjs'
|
|
10
|
+
import ModelSelectorInstaller from '/ui/model-selector.mjs'
|
|
11
|
+
import { storageObject } from './utils.mjs'
|
|
12
|
+
|
|
13
|
+
const { config, models } = await ai.init()
|
|
14
|
+
const MainComponent = defineAsyncComponent(() => import(ai.base + '/ui/Main.mjs'))
|
|
15
|
+
const RecentsComponent = defineAsyncComponent(() => import(ai.base + '/ui/Recents.mjs'))
|
|
16
|
+
const AnalyticsComponent = defineAsyncComponent(() => import(ai.base + '/ui/Analytics.mjs'))
|
|
17
|
+
|
|
18
|
+
const Components = {
|
|
19
|
+
SettingsDialog,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const BuiltInModules = [
|
|
23
|
+
ModelSelectorInstaller,
|
|
24
|
+
threadStore,
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
const routes = [
|
|
28
|
+
{ path: '/', component: MainComponent },
|
|
29
|
+
{ path: '/c/:id', component: MainComponent },
|
|
30
|
+
{ path: '/recents', component: RecentsComponent },
|
|
31
|
+
{ path: '/analytics', component: AnalyticsComponent },
|
|
32
|
+
{ path: '/:fallback(.*)*', component: MainComponent }
|
|
33
|
+
]
|
|
34
|
+
routes.forEach(r => r.path = ai.base + r.path)
|
|
35
|
+
const router = createRouter({
|
|
36
|
+
history: createWebHistory(),
|
|
37
|
+
routes,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class AppExtension {
|
|
42
|
+
constructor(ctx, ext) {
|
|
43
|
+
this.ctx = ctx
|
|
44
|
+
Object.assign(this, ext)
|
|
45
|
+
this.baseUrl = `${ctx.ai.base}/ext/${this.id}`
|
|
46
|
+
this.storageKey = `llms.${this.id}`
|
|
47
|
+
if (!this.name) {
|
|
48
|
+
this.name = humanize(this.id)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
storageObject(o) {
|
|
52
|
+
return storageObject(this.storageKey, o)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class AppContext {
|
|
57
|
+
constructor({ app, config, models, extensions, routes, ai, router, threadStore, modules }) {
|
|
58
|
+
this.app = app
|
|
59
|
+
this.state = reactive({
|
|
60
|
+
config,
|
|
61
|
+
models,
|
|
62
|
+
extensions,
|
|
63
|
+
})
|
|
64
|
+
this.routes = routes
|
|
65
|
+
this.ai = ai
|
|
66
|
+
this.router = router
|
|
67
|
+
this.threadStore = threadStore
|
|
68
|
+
this.modules = modules
|
|
69
|
+
this.events = new EventBus()
|
|
70
|
+
this.modalComponents = {}
|
|
71
|
+
this.extensions = []
|
|
72
|
+
this.layout = reactive(storageObject(`llms.layout`))
|
|
73
|
+
this.chatRequestFilters = []
|
|
74
|
+
this.chatResponseFilters = []
|
|
75
|
+
this.chatErrorFilters = []
|
|
76
|
+
this.createThreadFilters = []
|
|
77
|
+
this.updateThreadFilters = []
|
|
78
|
+
|
|
79
|
+
app.config.globalProperties.$ctx = this
|
|
80
|
+
app.config.globalProperties.$state = this.state
|
|
81
|
+
app.config.globalProperties.$layout = this.layout
|
|
82
|
+
document.addEventListener('keydown', (e) => this.handleKeydown(e))
|
|
83
|
+
}
|
|
84
|
+
component(name, component) {
|
|
85
|
+
if (!name) return name
|
|
86
|
+
if (component) {
|
|
87
|
+
this.app.component(name, component)
|
|
88
|
+
}
|
|
89
|
+
return component || this.app.component(name)
|
|
90
|
+
}
|
|
91
|
+
components(components) {
|
|
92
|
+
Object.keys(components).forEach(name => {
|
|
93
|
+
this.app.component(name, components[name])
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
extension(extension) {
|
|
97
|
+
const ext = new AppExtension(this, extension)
|
|
98
|
+
this.extensions.push(ext)
|
|
99
|
+
return ext
|
|
100
|
+
}
|
|
101
|
+
modals(modals) {
|
|
102
|
+
Object.keys(modals).forEach(name => {
|
|
103
|
+
this.modalComponents[name] = modals[name]
|
|
104
|
+
this.component(name, modals[name])
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
openModal(name) {
|
|
108
|
+
const component = this.modalComponents[name]
|
|
109
|
+
if (!component) {
|
|
110
|
+
console.error(`Modal ${name} not found`)
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
console.debug('openModal', name)
|
|
114
|
+
this.router.push({ query: { open: name } })
|
|
115
|
+
this.events.publish('modal:open', name)
|
|
116
|
+
return component
|
|
117
|
+
}
|
|
118
|
+
closeModal(name) {
|
|
119
|
+
console.debug('closeModal', name)
|
|
120
|
+
this.router.push({ query: { open: undefined } })
|
|
121
|
+
this.events.publish('modal:close', name)
|
|
122
|
+
}
|
|
123
|
+
handleKeydown(e) {
|
|
124
|
+
if (e.key === 'Escape') {
|
|
125
|
+
const modal = this.router.currentRoute.value?.query?.open
|
|
126
|
+
if (modal) {
|
|
127
|
+
this.closeModal(modal)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
setState(o) {
|
|
132
|
+
Object.assign(this.state, o)
|
|
133
|
+
//this.events.publish('update:state', this.state)
|
|
134
|
+
}
|
|
135
|
+
setLayout(o) {
|
|
136
|
+
Object.assign(this.layout, o)
|
|
137
|
+
storageObject(`llms.layout`, this.layout)
|
|
138
|
+
}
|
|
139
|
+
getPrefs() {
|
|
140
|
+
return storageObject(this.ai.prefsKey)
|
|
141
|
+
}
|
|
142
|
+
setPrefs(o) {
|
|
143
|
+
storageObject(this.ai.prefsKey, o)
|
|
144
|
+
}
|
|
145
|
+
toggleLayout(o) {
|
|
146
|
+
Object.keys(o).forEach(key => {
|
|
147
|
+
this.layout[key] = this.layout[key] == o[key] ? undefined : o[key]
|
|
148
|
+
})
|
|
149
|
+
storageObject(`llms.layout`, this.layout)
|
|
150
|
+
}
|
|
151
|
+
getCurrentThread() {
|
|
152
|
+
return this.threadStore.currentThread.value
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export async function createContext() {
|
|
157
|
+
const app = createApp(App, { config, models })
|
|
158
|
+
|
|
159
|
+
app.use(router)
|
|
160
|
+
app.use(ServiceStackVue)
|
|
161
|
+
Object.keys(Components).forEach(name => {
|
|
162
|
+
app.component(name, Components[name])
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
window.ai = app.config.globalProperties.$ai = ai
|
|
167
|
+
|
|
168
|
+
// Load Extensions
|
|
169
|
+
const exts = await (await fetch("/ext")).json()
|
|
170
|
+
|
|
171
|
+
// Load modules in parallel
|
|
172
|
+
const validExtensions = exts.filter(x => x.path);
|
|
173
|
+
const modules = await Promise.all(validExtensions.map(async extension => {
|
|
174
|
+
try {
|
|
175
|
+
const module = await import(extension.path)
|
|
176
|
+
return { extension, module }
|
|
177
|
+
} catch (e) {
|
|
178
|
+
console.error(`Failed to load extension module ${extension.name}:`, e)
|
|
179
|
+
return null
|
|
180
|
+
}
|
|
181
|
+
}))
|
|
182
|
+
|
|
183
|
+
const threadStore = useThreadStore()
|
|
184
|
+
|
|
185
|
+
const ctx = new AppContext({
|
|
186
|
+
app,
|
|
187
|
+
config,
|
|
188
|
+
models,
|
|
189
|
+
routes,
|
|
190
|
+
ai,
|
|
191
|
+
router,
|
|
192
|
+
threadStore,
|
|
193
|
+
exts,
|
|
194
|
+
modules,
|
|
195
|
+
})
|
|
196
|
+
app.provide('ctx', ctx)
|
|
197
|
+
|
|
198
|
+
BuiltInModules.forEach(ext => ext.install(ctx))
|
|
199
|
+
|
|
200
|
+
// Install sequentially
|
|
201
|
+
for (const result of modules) {
|
|
202
|
+
if (result && result.module.default && result.module.default.install) {
|
|
203
|
+
try {
|
|
204
|
+
result.module.default.install(ctx)
|
|
205
|
+
console.log(`Installed extension: ${result.extension.id}`)
|
|
206
|
+
} catch (e) {
|
|
207
|
+
console.error(`Failed to install extension ${result.extension.id}:`, e)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return ctx
|
|
213
|
+
}
|