llms-py 2.0.20__py3-none-any.whl → 3.0.18__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/__init__.py +3 -1
- llms/db.py +359 -0
- llms/{ui/Analytics.mjs → extensions/analytics/ui/index.mjs} +254 -327
- llms/extensions/app/README.md +20 -0
- llms/extensions/app/__init__.py +588 -0
- llms/extensions/app/db.py +540 -0
- llms/{ui → extensions/app/ui}/Recents.mjs +99 -73
- llms/{ui/Sidebar.mjs → extensions/app/ui/index.mjs} +139 -68
- llms/extensions/app/ui/threadStore.mjs +440 -0
- llms/extensions/computer/README.md +96 -0
- llms/extensions/computer/__init__.py +59 -0
- llms/extensions/computer/base.py +80 -0
- llms/extensions/computer/bash.py +185 -0
- llms/extensions/computer/computer.py +523 -0
- llms/extensions/computer/edit.py +299 -0
- llms/extensions/computer/filesystem.py +542 -0
- llms/extensions/computer/platform.py +461 -0
- llms/extensions/computer/run.py +37 -0
- llms/extensions/core_tools/CALCULATOR.md +32 -0
- llms/extensions/core_tools/__init__.py +599 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/closebrackets.js +201 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/closetag.js +185 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/continuelist.js +101 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/matchbrackets.js +160 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/matchtags.js +66 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/trailingspace.js +27 -0
- llms/extensions/core_tools/ui/codemirror/addon/selection/active-line.js +72 -0
- llms/extensions/core_tools/ui/codemirror/addon/selection/mark-selection.js +119 -0
- llms/extensions/core_tools/ui/codemirror/addon/selection/selection-pointer.js +98 -0
- llms/extensions/core_tools/ui/codemirror/codemirror.css +344 -0
- llms/extensions/core_tools/ui/codemirror/codemirror.js +9884 -0
- llms/extensions/core_tools/ui/codemirror/doc/docs.css +225 -0
- llms/extensions/core_tools/ui/codemirror/doc/source_sans.woff +0 -0
- llms/extensions/core_tools/ui/codemirror/mode/clike/clike.js +942 -0
- llms/extensions/core_tools/ui/codemirror/mode/javascript/index.html +118 -0
- llms/extensions/core_tools/ui/codemirror/mode/javascript/javascript.js +962 -0
- llms/extensions/core_tools/ui/codemirror/mode/javascript/typescript.html +62 -0
- llms/extensions/core_tools/ui/codemirror/mode/python/python.js +402 -0
- llms/extensions/core_tools/ui/codemirror/theme/dracula.css +40 -0
- llms/extensions/core_tools/ui/codemirror/theme/mocha.css +135 -0
- llms/extensions/core_tools/ui/index.mjs +650 -0
- llms/extensions/gallery/README.md +61 -0
- llms/extensions/gallery/__init__.py +63 -0
- llms/extensions/gallery/db.py +243 -0
- llms/extensions/gallery/ui/index.mjs +482 -0
- llms/extensions/katex/README.md +39 -0
- llms/extensions/katex/__init__.py +6 -0
- llms/extensions/katex/ui/README.md +125 -0
- llms/extensions/katex/ui/contrib/auto-render.js +338 -0
- llms/extensions/katex/ui/contrib/auto-render.min.js +1 -0
- llms/extensions/katex/ui/contrib/auto-render.mjs +244 -0
- llms/extensions/katex/ui/contrib/copy-tex.js +127 -0
- llms/extensions/katex/ui/contrib/copy-tex.min.js +1 -0
- llms/extensions/katex/ui/contrib/copy-tex.mjs +105 -0
- llms/extensions/katex/ui/contrib/mathtex-script-type.js +109 -0
- llms/extensions/katex/ui/contrib/mathtex-script-type.min.js +1 -0
- llms/extensions/katex/ui/contrib/mathtex-script-type.mjs +24 -0
- llms/extensions/katex/ui/contrib/mhchem.js +3213 -0
- llms/extensions/katex/ui/contrib/mhchem.min.js +1 -0
- llms/extensions/katex/ui/contrib/mhchem.mjs +3109 -0
- llms/extensions/katex/ui/contrib/render-a11y-string.js +887 -0
- llms/extensions/katex/ui/contrib/render-a11y-string.min.js +1 -0
- llms/extensions/katex/ui/contrib/render-a11y-string.mjs +800 -0
- llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- llms/extensions/katex/ui/index.mjs +92 -0
- llms/extensions/katex/ui/katex-swap.css +1230 -0
- llms/extensions/katex/ui/katex-swap.min.css +1 -0
- llms/extensions/katex/ui/katex.css +1230 -0
- llms/extensions/katex/ui/katex.js +19080 -0
- llms/extensions/katex/ui/katex.min.css +1 -0
- llms/extensions/katex/ui/katex.min.js +1 -0
- llms/extensions/katex/ui/katex.min.mjs +1 -0
- llms/extensions/katex/ui/katex.mjs +18547 -0
- llms/extensions/providers/__init__.py +22 -0
- llms/extensions/providers/anthropic.py +260 -0
- llms/extensions/providers/cerebras.py +36 -0
- llms/extensions/providers/chutes.py +153 -0
- llms/extensions/providers/google.py +559 -0
- llms/extensions/providers/nvidia.py +103 -0
- llms/extensions/providers/openai.py +154 -0
- llms/extensions/providers/openrouter.py +74 -0
- llms/extensions/providers/zai.py +182 -0
- llms/extensions/skills/LICENSE +202 -0
- llms/extensions/skills/__init__.py +130 -0
- llms/extensions/skills/errors.py +25 -0
- llms/extensions/skills/models.py +39 -0
- llms/extensions/skills/parser.py +178 -0
- llms/extensions/skills/ui/index.mjs +376 -0
- llms/extensions/skills/ui/skills/create-plan/SKILL.md +74 -0
- llms/extensions/skills/validator.py +177 -0
- llms/extensions/system_prompts/README.md +22 -0
- llms/extensions/system_prompts/__init__.py +45 -0
- llms/extensions/system_prompts/ui/index.mjs +276 -0
- llms/extensions/system_prompts/ui/prompts.json +1067 -0
- llms/extensions/tools/__init__.py +67 -0
- llms/extensions/tools/ui/index.mjs +837 -0
- llms/index.html +36 -62
- llms/llms.json +180 -879
- llms/main.py +4009 -912
- llms/providers-extra.json +394 -0
- llms/providers.json +1 -0
- llms/ui/App.mjs +176 -8
- llms/ui/ai.mjs +156 -20
- llms/ui/app.css +3768 -321
- llms/ui/ctx.mjs +459 -0
- llms/ui/index.mjs +131 -0
- llms/ui/lib/chart.js +14 -0
- llms/ui/lib/charts.mjs +16 -0
- llms/ui/lib/color.js +14 -0
- llms/ui/lib/highlight.min.mjs +1243 -0
- llms/ui/lib/idb.min.mjs +8 -0
- llms/ui/lib/marked.min.mjs +8 -0
- llms/ui/lib/servicestack-client.mjs +1 -0
- llms/ui/lib/servicestack-vue.mjs +37 -0
- llms/ui/lib/vue-router.min.mjs +6 -0
- llms/ui/lib/vue.min.mjs +13 -0
- llms/ui/lib/vue.mjs +18530 -0
- llms/ui/markdown.mjs +25 -14
- llms/ui/modules/chat/ChatBody.mjs +1156 -0
- llms/ui/{SettingsDialog.mjs → modules/chat/SettingsDialog.mjs} +74 -74
- llms/ui/modules/chat/index.mjs +995 -0
- llms/ui/modules/icons.mjs +46 -0
- llms/ui/modules/layout.mjs +271 -0
- llms/ui/modules/model-selector.mjs +811 -0
- llms/ui/tailwind.input.css +560 -78
- llms/ui/typography.css +54 -36
- llms/ui/utils.mjs +221 -92
- llms_py-3.0.18.dist-info/METADATA +49 -0
- llms_py-3.0.18.dist-info/RECORD +194 -0
- {llms_py-2.0.20.dist-info → llms_py-3.0.18.dist-info}/WHEEL +1 -1
- {llms_py-2.0.20.dist-info → llms_py-3.0.18.dist-info}/licenses/LICENSE +1 -2
- llms/ui/Avatar.mjs +0 -28
- llms/ui/Brand.mjs +0 -34
- llms/ui/ChatPrompt.mjs +0 -443
- llms/ui/Main.mjs +0 -740
- llms/ui/ModelSelector.mjs +0 -60
- llms/ui/ProviderIcon.mjs +0 -29
- llms/ui/ProviderStatus.mjs +0 -105
- llms/ui/SignIn.mjs +0 -64
- llms/ui/SystemPromptEditor.mjs +0 -31
- llms/ui/SystemPromptSelector.mjs +0 -36
- llms/ui/Welcome.mjs +0 -8
- llms/ui/threadStore.mjs +0 -524
- llms/ui.json +0 -1069
- llms_py-2.0.20.dist-info/METADATA +0 -931
- llms_py-2.0.20.dist-info/RECORD +0 -36
- {llms_py-2.0.20.dist-info → llms_py-3.0.18.dist-info}/entry_points.txt +0 -0
- {llms_py-2.0.20.dist-info → llms_py-3.0.18.dist-info}/top_level.txt +0 -0
llms/ui/App.mjs
CHANGED
|
@@ -1,20 +1,188 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ref, computed, watch, inject, onMounted, onUnmounted } from "vue"
|
|
2
|
+
import { useRouter, useRoute } from "vue-router"
|
|
3
|
+
import { AppContext } from "./ctx.mjs"
|
|
4
|
+
|
|
5
|
+
// Vertical Sidebar Icons
|
|
6
|
+
const LeftBar = {
|
|
7
|
+
template: `
|
|
8
|
+
<div class="select-none flex flex-col space-y-2 pt-2.5 px-1">
|
|
9
|
+
<div v-for="(icon, id) in $ctx.left" :key="id" class="relative flex items-center justify-center">
|
|
10
|
+
<component :is="icon.component"
|
|
11
|
+
class="size-7 p-1 cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 rounded block"
|
|
12
|
+
:class="{ 'bg-gray-200 dark:bg-gray-700' : icon.isActive({ ...$layout }) }"
|
|
13
|
+
@mouseenter="tooltip = icon.id"
|
|
14
|
+
@mouseleave="tooltip = ''"
|
|
15
|
+
/>
|
|
16
|
+
<div v-if="tooltip === icon.id && !icon.isActive({ ...$layout })"
|
|
17
|
+
class="absolute left-full top-1/2 -translate-y-1/2 ml-2 px-2 py-1 text-xs text-white bg-gray-900 dark:bg-gray-800 rounded shadow-md z-50 whitespace-nowrap pointer-events-none" style="z-index: 60">
|
|
18
|
+
{{icon.title ?? icon.name}}
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
`,
|
|
23
|
+
setup() {
|
|
24
|
+
const tooltip = ref('')
|
|
25
|
+
return {
|
|
26
|
+
tooltip,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const LeftPanel = {
|
|
32
|
+
template: `
|
|
33
|
+
<div v-if="component" class="flex flex-col h-full border-r border-gray-200 dark:border-gray-700">
|
|
34
|
+
<button type="button" @click="$ctx.toggleLayout('left',false)" class="absolute top-2 right-2 p-1 rounded-md text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700 lg:hidden z-20">
|
|
35
|
+
<svg class="size-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
|
|
36
|
+
</button>
|
|
37
|
+
<component :is="component" />
|
|
38
|
+
</div>
|
|
39
|
+
`,
|
|
40
|
+
setup() {
|
|
41
|
+
/**@type {AppContext} */
|
|
42
|
+
const ctx = inject('ctx')
|
|
43
|
+
const component = computed(() => ctx.component(ctx.layout.left))
|
|
44
|
+
return {
|
|
45
|
+
component,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const TopBar = {
|
|
51
|
+
template: `
|
|
52
|
+
<div class="select-none flex space-x-1">
|
|
53
|
+
<div v-for="(icon, id) in $ctx.top" :key="id" class="relative flex items-center justify-center">
|
|
54
|
+
<component :is="icon.component"
|
|
55
|
+
class="size-7 p-1 cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 block border border-transparent"
|
|
56
|
+
:class="{ 'bg-gray-100 dark:bg-gray-800 border-gray-300 dark:border-gray-600 rounded' : icon.isActive({ ...$layout }) }"
|
|
57
|
+
@mouseenter="tooltip = icon.id"
|
|
58
|
+
@mouseleave="tooltip = ''"
|
|
59
|
+
/>
|
|
60
|
+
<div v-if="tooltip === icon.id && !icon.isActive({ ...$layout })"
|
|
61
|
+
class="absolute top-full mt-2 px-2 py-1 text-xs text-white bg-gray-900 dark:bg-gray-800 rounded shadow-md z-50 whitespace-nowrap pointer-events-none"
|
|
62
|
+
:class="last2.includes(id) ? 'right-0' : 'left-1/2 -translate-x-1/2'">
|
|
63
|
+
{{icon.title ?? icon.name}}
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
`,
|
|
68
|
+
setup() {
|
|
69
|
+
const tooltip = ref('')
|
|
70
|
+
const last2 = ref(Object.keys($ctx.top).slice(-2))
|
|
71
|
+
return {
|
|
72
|
+
tooltip,
|
|
73
|
+
last2,
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const TopPanel = {
|
|
79
|
+
template: `
|
|
80
|
+
<component v-if="component" :is="component" class="mb-2" />
|
|
81
|
+
`,
|
|
82
|
+
setup() {
|
|
83
|
+
/**@type {AppContext} */
|
|
84
|
+
const ctx = inject('ctx')
|
|
85
|
+
const component = computed(() => ctx.component(ctx.layout.top))
|
|
86
|
+
return {
|
|
87
|
+
component,
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
2
91
|
|
|
3
92
|
export default {
|
|
4
93
|
components: {
|
|
5
|
-
|
|
94
|
+
LeftBar,
|
|
95
|
+
LeftPanel,
|
|
96
|
+
TopBar,
|
|
97
|
+
TopPanel,
|
|
98
|
+
},
|
|
99
|
+
setup() {
|
|
100
|
+
const router = useRouter()
|
|
101
|
+
const route = useRoute()
|
|
102
|
+
|
|
103
|
+
/**@type {AppContext} */
|
|
104
|
+
const ctx = inject('ctx')
|
|
105
|
+
const ai = ctx.ai
|
|
106
|
+
const isMobile = ref(false)
|
|
107
|
+
const modal = ref()
|
|
108
|
+
|
|
109
|
+
const checkMobile = () => {
|
|
110
|
+
//const wasMobile = isMobile.value
|
|
111
|
+
isMobile.value = window.innerWidth < 640 // sm breakpoint
|
|
112
|
+
|
|
113
|
+
//console.log('checkMobile', wasMobile, isMobile.value)
|
|
114
|
+
// Only auto-adjust sidebar state when transitioning between mobile/desktop
|
|
115
|
+
if (isMobile.value) {
|
|
116
|
+
ctx.toggleLayout('left', false)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
onMounted(() => {
|
|
121
|
+
checkMobile()
|
|
122
|
+
window.addEventListener('resize', checkMobile)
|
|
123
|
+
if (route.query.open) {
|
|
124
|
+
modal.value = ctx.openModal(route.query.open)
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
onUnmounted(() => {
|
|
129
|
+
window.removeEventListener('resize', checkMobile)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
function closeModal() {
|
|
133
|
+
ctx.closeModal(route.query.open)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
watch(() => route.query.open, (newVal) => {
|
|
137
|
+
modal.value = ctx.modalComponents[newVal]
|
|
138
|
+
console.log('open', newVal, modal.value)
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
watch(() => ctx.state.selectedModel, (newVal) => {
|
|
142
|
+
ctx.chat.setSelectedModel(ctx.chat.getModel(newVal))
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
return { ai, modal, isMobile, closeModal }
|
|
6
146
|
},
|
|
7
147
|
template: `
|
|
8
|
-
<div class="flex h-screen
|
|
9
|
-
<!--
|
|
10
|
-
<div
|
|
11
|
-
|
|
148
|
+
<div class="flex h-screen">
|
|
149
|
+
<!-- Mobile Overlay -->
|
|
150
|
+
<div v-if="isMobile && $ctx.layoutVisible('left') && $ai.hasAccess"
|
|
151
|
+
@click="$ctx.toggleLayout('left')"
|
|
152
|
+
:class="$ctx.cls('mobile-overlay', 'fixed inset-0 bg-black/50 z-40 lg:hidden')"
|
|
153
|
+
></div>
|
|
154
|
+
|
|
155
|
+
<div v-if="$ai.hasAccess" id="sidebar" :class="$ctx.cls('sidebar', 'z-100 relative flex bg-gray-50 dark:bg-gray-800')">
|
|
156
|
+
<LeftBar id="left-bar" />
|
|
157
|
+
<LeftPanel id="left-panel"
|
|
158
|
+
v-if="$ai.hasAccess && $ctx.layoutVisible('left')"
|
|
159
|
+
:class="[
|
|
160
|
+
'transition-transform duration-300 ease-in-out z-50',
|
|
161
|
+
'w-72 xl:w-80 flex-shrink-0',
|
|
162
|
+
'lg:relative',
|
|
163
|
+
'fixed inset-y-0 left-[2.25rem] lg:left-0',
|
|
164
|
+
'bg-gray-50 dark:bg-gray-800'
|
|
165
|
+
]"
|
|
166
|
+
/>
|
|
12
167
|
</div>
|
|
13
168
|
|
|
14
169
|
<!-- Main Area -->
|
|
15
|
-
<div class="flex-1 flex flex-col">
|
|
16
|
-
<
|
|
170
|
+
<div id="main" :class="$ctx.cls('main', 'flex-1 flex flex-col')">
|
|
171
|
+
<div id="main-inner" :class="$ctx.cls('main-inner', 'flex flex-col h-full w-full overflow-hidden')">
|
|
172
|
+
<div v-if="$ai.hasAccess" id="header" :class="$ctx.cls('header', 'py-1 pr-1 flex items-center justify-between shrink-0')">
|
|
173
|
+
<div>
|
|
174
|
+
<ModelSelector :models="$state.models" v-model="$state.selectedModel" />
|
|
175
|
+
</div>
|
|
176
|
+
<TopBar id="top-bar" />
|
|
177
|
+
</div>
|
|
178
|
+
<TopPanel v-if="$ai.hasAccess" id="top-panel" :class="$ctx.cls('top-panel', 'shrink-0')" />
|
|
179
|
+
<div id="page" :class="$ctx.cls('page', 'flex-1 overflow-y-auto min-h-0 flex flex-col')">
|
|
180
|
+
<RouterView class="h-full" />
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
17
183
|
</div>
|
|
184
|
+
|
|
185
|
+
<component v-if="modal" :is="modal" :class="$ctx.cls('modal', '!z-[200]')" @done="closeModal" />
|
|
18
186
|
</div>
|
|
19
187
|
`,
|
|
20
188
|
}
|
llms/ui/ai.mjs
CHANGED
|
@@ -1,36 +1,102 @@
|
|
|
1
1
|
import { reactive } from "vue"
|
|
2
|
-
import {
|
|
2
|
+
import { ApiResult } from "@servicestack/client"
|
|
3
3
|
|
|
4
4
|
const base = ''
|
|
5
5
|
const headers = { 'Accept': 'application/json' }
|
|
6
6
|
const prefsKey = 'llms.prefs'
|
|
7
7
|
|
|
8
8
|
export const o = {
|
|
9
|
-
version: '
|
|
9
|
+
version: '3.0.18',
|
|
10
10
|
base,
|
|
11
11
|
prefsKey,
|
|
12
12
|
welcome: 'Welcome to llms.py',
|
|
13
13
|
auth: null,
|
|
14
14
|
requiresAuth: false,
|
|
15
|
+
authType: 'apikey', // 'oauth' or 'apikey' - controls which SignIn component to use
|
|
15
16
|
headers,
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
isSidebarOpen: true, // Shared sidebar state (default open for lg+ screens)
|
|
18
|
+
cacheUrlInfo: {},
|
|
19
|
+
|
|
20
|
+
get hasAccess() {
|
|
21
|
+
return !this.requiresAuth || this.auth
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
resolveUrl(url) {
|
|
18
25
|
return url.startsWith('http') || url.startsWith('/v1') ? url : base + url
|
|
19
26
|
},
|
|
20
27
|
get(url, options) {
|
|
21
|
-
return fetch(this.resolveUrl(url), {
|
|
28
|
+
return fetch(this.resolveUrl(url), {
|
|
22
29
|
...options,
|
|
23
30
|
headers: Object.assign({}, this.headers, options?.headers),
|
|
24
31
|
})
|
|
25
32
|
},
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
async getJson(url, options) {
|
|
34
|
+
const res = await this.get(url, options)
|
|
35
|
+
return await this.createJsonResult(res, url)
|
|
36
|
+
},
|
|
37
|
+
async post(url, options) {
|
|
38
|
+
return await fetch(this.resolveUrl(url), {
|
|
28
39
|
method: 'POST',
|
|
29
40
|
...options,
|
|
30
|
-
headers: Object.assign({'Content-Type': 'application/json'}, this.headers, options?.headers),
|
|
41
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, this.headers, options?.headers),
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
async postForm(url, options) {
|
|
45
|
+
return await fetch(this.resolveUrl(url), {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
...options,
|
|
48
|
+
headers: Object.assign({}, options?.headers),
|
|
49
|
+
})
|
|
50
|
+
},
|
|
51
|
+
async postJson(url, options) {
|
|
52
|
+
const res = await this.post(url, options)
|
|
53
|
+
return await this.createJsonResult(res, url)
|
|
54
|
+
},
|
|
55
|
+
async createJsonResult(res, msg = null) {
|
|
56
|
+
let txt = ''
|
|
57
|
+
try {
|
|
58
|
+
txt = await res.text()
|
|
59
|
+
const response = JSON.parse(txt)
|
|
60
|
+
if (response?.responseStatus?.errorCode) {
|
|
61
|
+
return new ApiResult({ error: response.responseStatus })
|
|
62
|
+
}
|
|
63
|
+
if (!res.ok) {
|
|
64
|
+
return new ApiResult({ error: { errorCode: 'Error', message: res.statusText } })
|
|
65
|
+
}
|
|
66
|
+
return new ApiResult({ response })
|
|
67
|
+
} catch (e) {
|
|
68
|
+
console.error('Failed to parse JSON', e, msg, txt)
|
|
69
|
+
const responseStatus = {
|
|
70
|
+
errorCode: 'Error',
|
|
71
|
+
message: `${e.message ?? e}`,
|
|
72
|
+
stackTrace: msg ? `${msg}\n${txt}` : txt,
|
|
73
|
+
}
|
|
74
|
+
return { responseStatus }
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
createErrorStatus({ message, errorCode, stackTrace, errors, meta }) {
|
|
78
|
+
const ret = {
|
|
79
|
+
errorCode: errorCode || 'Error',
|
|
80
|
+
message: message,
|
|
81
|
+
}
|
|
82
|
+
if (stackTrace) {
|
|
83
|
+
ret.stackTrace = stackTrace
|
|
84
|
+
}
|
|
85
|
+
if (errors && Array.isArray(errors)) {
|
|
86
|
+
ret.errors = errors
|
|
87
|
+
}
|
|
88
|
+
if (meta) {
|
|
89
|
+
ret.meta = meta
|
|
90
|
+
}
|
|
91
|
+
return ret
|
|
92
|
+
},
|
|
93
|
+
createErrorResult(e) {
|
|
94
|
+
return new ApiResult({
|
|
95
|
+
error: e.errorCode
|
|
96
|
+
? this.createErrorStatus(e)
|
|
97
|
+
: this.createErrorStatus({ message: `${e.message ?? e}` })
|
|
31
98
|
})
|
|
32
99
|
},
|
|
33
|
-
|
|
34
100
|
async getConfig() {
|
|
35
101
|
return this.get('/config')
|
|
36
102
|
},
|
|
@@ -38,34 +104,57 @@ export const o = {
|
|
|
38
104
|
return this.get('/models')
|
|
39
105
|
},
|
|
40
106
|
async getAuth() {
|
|
41
|
-
return this.requiresAuth
|
|
107
|
+
return this.requiresAuth
|
|
42
108
|
? this.get('/auth')
|
|
43
|
-
: new Promise(resolve => resolve({ json: () => ({ responseStatus: { errorCode: '!requiresAuth' } })}))
|
|
109
|
+
: new Promise(resolve => resolve({ json: () => ({ responseStatus: { errorCode: '!requiresAuth' } }) }))
|
|
44
110
|
},
|
|
45
111
|
get isAdmin() {
|
|
46
112
|
return !this.requiresAuth || this.auth && this.auth.roles?.includes('Admin')
|
|
47
113
|
},
|
|
48
|
-
|
|
114
|
+
|
|
49
115
|
signIn(auth) {
|
|
50
116
|
this.auth = auth
|
|
51
117
|
if (auth?.apiKey) {
|
|
52
118
|
this.headers.Authorization = `Bearer ${auth.apiKey}`
|
|
53
|
-
} else
|
|
119
|
+
} else {
|
|
120
|
+
if (this.headers.Authorization) {
|
|
121
|
+
delete this.headers.Authorization
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
async signOut() {
|
|
126
|
+
try {
|
|
127
|
+
await this.post('/auth/logout')
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error('Logout error:', error)
|
|
130
|
+
}
|
|
131
|
+
this.auth = null
|
|
132
|
+
if (this.headers.Authorization) {
|
|
54
133
|
delete this.headers.Authorization
|
|
55
134
|
}
|
|
56
135
|
},
|
|
57
|
-
async init() {
|
|
136
|
+
async init(ctx) {
|
|
58
137
|
// Load models and prompts
|
|
59
|
-
const
|
|
60
|
-
const [_, configRes, modelsRes, authRes] = await Promise.all([
|
|
61
|
-
initDB(),
|
|
138
|
+
const [configRes, modelsRes, extensionsRes] = await Promise.all([
|
|
62
139
|
this.getConfig(),
|
|
63
140
|
this.getModels(),
|
|
64
|
-
this.
|
|
141
|
+
this.get('/ext'),
|
|
65
142
|
])
|
|
66
143
|
const config = await configRes.json()
|
|
67
144
|
const models = await modelsRes.json()
|
|
68
|
-
const
|
|
145
|
+
const extensions = await extensionsRes.json()
|
|
146
|
+
|
|
147
|
+
// Update auth settings from server config
|
|
148
|
+
if (config.requiresAuth != null) {
|
|
149
|
+
this.requiresAuth = config.requiresAuth
|
|
150
|
+
}
|
|
151
|
+
if (config.authType != null) {
|
|
152
|
+
this.authType = config.authType
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Get auth status
|
|
156
|
+
const authRes = await this.getAuth()
|
|
157
|
+
const auth = this.requiresAuth
|
|
69
158
|
? await authRes.json()
|
|
70
159
|
: null
|
|
71
160
|
if (auth?.responseStatus?.errorCode) {
|
|
@@ -73,9 +162,56 @@ export const o = {
|
|
|
73
162
|
} else {
|
|
74
163
|
this.signIn(auth)
|
|
75
164
|
}
|
|
76
|
-
return { config, models, auth }
|
|
165
|
+
return { config, models, extensions, auth }
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
async uploadFile(file) {
|
|
170
|
+
const formData = new FormData()
|
|
171
|
+
formData.append('file', file)
|
|
172
|
+
const response = await fetch(this.resolveUrl('/upload'), {
|
|
173
|
+
method: 'POST',
|
|
174
|
+
body: formData
|
|
175
|
+
})
|
|
176
|
+
if (!response.ok) {
|
|
177
|
+
throw new Error(`Upload failed: ${response.statusText}`)
|
|
178
|
+
}
|
|
179
|
+
return response.json()
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
getCacheInfo(url) {
|
|
184
|
+
return this.cacheUrlInfo[url]
|
|
185
|
+
},
|
|
186
|
+
async fetchCacheInfos(urls) {
|
|
187
|
+
const infos = {}
|
|
188
|
+
const fetchInfos = []
|
|
189
|
+
for (const url of urls) {
|
|
190
|
+
const info = this.getCacheInfo(url)
|
|
191
|
+
if (info) {
|
|
192
|
+
infos[url] = info
|
|
193
|
+
} else {
|
|
194
|
+
fetchInfos.push(fetch(this.resolveUrl(url + "?info")))
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const responses = await Promise.all(fetchInfos)
|
|
198
|
+
for (let i = 0; i < urls.length; i++) {
|
|
199
|
+
try {
|
|
200
|
+
const info = await responses[i].json()
|
|
201
|
+
this.setCacheInfo(urls[i], info)
|
|
202
|
+
infos[urls[i]] = info
|
|
203
|
+
} catch (e) {
|
|
204
|
+
console.error('Failed to fetch info for', urls[i], e)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return infos
|
|
208
|
+
},
|
|
209
|
+
setCacheInfo(url, info) {
|
|
210
|
+
this.cacheUrlInfo[url] = info
|
|
77
211
|
}
|
|
212
|
+
|
|
78
213
|
}
|
|
79
214
|
|
|
215
|
+
|
|
80
216
|
let ai = reactive(o)
|
|
81
217
|
export default ai
|