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.
Files changed (39) hide show
  1. llms/__pycache__/__init__.cpython-312.pyc +0 -0
  2. llms/__pycache__/__init__.cpython-313.pyc +0 -0
  3. llms/__pycache__/__init__.cpython-314.pyc +0 -0
  4. llms/__pycache__/__main__.cpython-312.pyc +0 -0
  5. llms/__pycache__/__main__.cpython-314.pyc +0 -0
  6. llms/__pycache__/llms.cpython-312.pyc +0 -0
  7. llms/__pycache__/main.cpython-312.pyc +0 -0
  8. llms/__pycache__/main.cpython-313.pyc +0 -0
  9. llms/__pycache__/main.cpython-314.pyc +0 -0
  10. llms/__pycache__/plugins.cpython-314.pyc +0 -0
  11. llms/index.html +25 -56
  12. llms/llms.json +2 -2
  13. llms/main.py +452 -93
  14. llms/providers.json +1 -1
  15. llms/ui/App.mjs +25 -4
  16. llms/ui/Avatar.mjs +3 -2
  17. llms/ui/ChatPrompt.mjs +43 -52
  18. llms/ui/Main.mjs +87 -98
  19. llms/ui/OAuthSignIn.mjs +2 -33
  20. llms/ui/ProviderStatus.mjs +7 -8
  21. llms/ui/Recents.mjs +10 -9
  22. llms/ui/Sidebar.mjs +2 -1
  23. llms/ui/SignIn.mjs +7 -6
  24. llms/ui/ai.mjs +9 -41
  25. llms/ui/app.css +137 -138
  26. llms/ui/index.mjs +213 -0
  27. llms/ui/{ModelSelector.mjs → model-selector.mjs} +193 -200
  28. llms/ui/tailwind.input.css +441 -79
  29. llms/ui/threadStore.mjs +17 -6
  30. llms/ui/utils.mjs +1 -0
  31. {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/METADATA +1 -1
  32. llms_py-3.0.0b2.dist-info/RECORD +58 -0
  33. llms/ui/SystemPromptEditor.mjs +0 -31
  34. llms/ui/SystemPromptSelector.mjs +0 -56
  35. llms_py-3.0.0b1.dist-info/RECORD +0 -49
  36. {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/WHEEL +0 -0
  37. {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/entry_points.txt +0 -0
  38. {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/licenses/LICENSE +0 -0
  39. {llms_py-3.0.0b1.dist-info → llms_py-3.0.0b2.dist-info}/top_level.txt +0 -0
llms/ui/Recents.mjs CHANGED
@@ -4,7 +4,7 @@ import { useThreadStore } from './threadStore.mjs'
4
4
  import { renderMarkdown } from './markdown.mjs'
5
5
 
6
6
  const RecentResults = {
7
- template:`
7
+ template: `
8
8
  <div class="flex-1 overflow-y-auto" @scroll="onScroll">
9
9
  <div class="mx-auto max-w-6xl px-4 py-4">
10
10
  <div class="text-sm text-gray-600 dark:text-gray-400 mb-3" v-if="threads.length">
@@ -46,9 +46,10 @@ const RecentResults = {
46
46
  q: String
47
47
  },
48
48
  setup(props) {
49
- const ai = inject('ai')
49
+ const ctx = inject('ctx')
50
+ const ai = ctx.ai
51
+ const config = ctx.state.config
50
52
  const router = useRouter()
51
- const config = inject('config')
52
53
  const { threads, loadThreads } = useThreadStore()
53
54
  let defaultVisibleCount = 25
54
55
  const visibleCount = ref(defaultVisibleCount)
@@ -106,19 +107,19 @@ const RecentResults = {
106
107
  const snippet = (t) => {
107
108
  const highlight = (s) => clean(s).replace(new RegExp(`(${query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi'), `<mark>$1</mark>`)
108
109
  const query = normalized(props.q)
109
- if (!query) return (t.messages && t.messages.length) ? highlight(t.messages[t.messages.length-1].content) : ''
110
+ if (!query) return (t.messages && t.messages.length) ? highlight(t.messages[t.messages.length - 1].content) : ''
110
111
  if (normalized(t.title).includes(query)) return highlight(t.title)
111
- if (Array.isArray(t.messages)){
112
- for (const m of t.messages){
112
+ if (Array.isArray(t.messages)) {
113
+ for (const m of t.messages) {
113
114
  const c = normalized(m?.content)
114
- if (c.includes(query)){
115
+ if (c.includes(query)) {
115
116
  // return small excerpt around first match
116
117
  const idx = c.indexOf(query)
117
118
  const orig = (m?.content || '')
118
119
  const start = Math.max(0, idx - 40)
119
120
  const end = Math.min(orig.length, idx + query.length + 60)
120
- const prefix = start>0 ? '…' : ''
121
- const suffix = end<orig.length ? '…' : ''
121
+ const prefix = start > 0 ? '…' : ''
122
+ const suffix = end < orig.length ? '…' : ''
122
123
  const snippet = prefix + orig.slice(start, end) + suffix
123
124
  // return snippet
124
125
  return highlight(snippet)
llms/ui/Sidebar.mjs CHANGED
@@ -189,7 +189,8 @@ const Sidebar = {
189
189
  `,
190
190
  emits: ['thread-selected', 'toggle-sidebar'],
191
191
  setup(props, { emit }) {
192
- const ai = inject('ai')
192
+ const ctx = inject('ctx')
193
+ const ai = ctx.ai
193
194
  const router = useRouter()
194
195
  const threadStore = useThreadStore()
195
196
  const {
llms/ui/SignIn.mjs CHANGED
@@ -32,12 +32,13 @@ export default {
32
32
  `,
33
33
  emits: ['done'],
34
34
  setup(props, { emit }) {
35
- const ai = inject('ai')
35
+ const ctx = inject('ctx')
36
+ const ai = ctx.ai
36
37
  const apiKey = ref('')
37
38
  const errorSummary = ref()
38
39
  async function submit() {
39
40
  const r = await ai.get('/auth', {
40
- headers: {
41
+ headers: {
41
42
  'Authorization': `Bearer ${apiKey.value}`
42
43
  },
43
44
  })
@@ -48,13 +49,13 @@ export default {
48
49
  json.apiKey = apiKey.value
49
50
  emit('done', json)
50
51
  } else {
51
- errorSummary.value = json.responseStatus || {
52
- errorCode: "Unauthorized",
53
- message: 'Invalid API Key'
52
+ errorSummary.value = json.responseStatus || {
53
+ errorCode: "Unauthorized",
54
+ message: 'Invalid API Key'
54
55
  }
55
56
  }
56
57
  }
57
-
58
+
58
59
  return {
59
60
  apiKey,
60
61
  submit,
llms/ui/ai.mjs CHANGED
@@ -6,7 +6,7 @@ const headers = { 'Accept': 'application/json' }
6
6
  const prefsKey = 'llms.prefs'
7
7
 
8
8
  export const o = {
9
- version: '3.0.0b1',
9
+ version: '3.0.0b2',
10
10
  base,
11
11
  prefsKey,
12
12
  welcome: 'Welcome to llms.py',
@@ -16,6 +16,10 @@ export const o = {
16
16
  headers,
17
17
  isSidebarOpen: true, // Shared sidebar state (default open for lg+ screens)
18
18
 
19
+ get hasAccess() {
20
+ return !this.requiresAuth || this.auth
21
+ },
22
+
19
23
  resolveUrl(url) {
20
24
  return url.startsWith('http') || url.startsWith('/v1') ? url : base + url
21
25
  },
@@ -52,39 +56,22 @@ export const o = {
52
56
  this.auth = auth
53
57
  if (auth?.apiKey) {
54
58
  this.headers.Authorization = `Bearer ${auth.apiKey}`
55
- //localStorage.setItem('llms:auth', JSON.stringify({ apiKey: auth.apiKey }))
56
- } else if (auth?.sessionToken) {
57
- this.headers['X-Session-Token'] = auth.sessionToken
58
- localStorage.setItem('llms:auth', JSON.stringify({ sessionToken: auth.sessionToken }))
59
59
  } else {
60
60
  if (this.headers.Authorization) {
61
61
  delete this.headers.Authorization
62
62
  }
63
- if (this.headers['X-Session-Token']) {
64
- delete this.headers['X-Session-Token']
65
- }
66
63
  }
67
64
  },
68
65
  async signOut() {
69
- if (this.auth?.sessionToken) {
70
- // Call logout endpoint for OAuth sessions
71
- try {
72
- await this.post('/auth/logout', {
73
- headers: {
74
- 'X-Session-Token': this.auth.sessionToken
75
- }
76
- })
77
- } catch (error) {
78
- console.error('Logout error:', error)
79
- }
66
+ try {
67
+ await this.post('/auth/logout')
68
+ } catch (error) {
69
+ console.error('Logout error:', error)
80
70
  }
81
71
  this.auth = null
82
72
  if (this.headers.Authorization) {
83
73
  delete this.headers.Authorization
84
74
  }
85
- if (this.headers['X-Session-Token']) {
86
- delete this.headers['X-Session-Token']
87
- }
88
75
  localStorage.removeItem('llms:auth')
89
76
  },
90
77
  async init() {
@@ -106,25 +93,6 @@ export const o = {
106
93
  this.authType = config.authType
107
94
  }
108
95
 
109
- // Try to restore session from localStorage
110
- if (this.requiresAuth) {
111
- const storedAuth = localStorage.getItem('llms:auth')
112
- if (storedAuth) {
113
- try {
114
- const authData = JSON.parse(storedAuth)
115
- if (authData.sessionToken) {
116
- this.headers['X-Session-Token'] = authData.sessionToken
117
- }
118
- // else if (authData.apiKey) {
119
- // this.headers.Authorization = `Bearer ${authData.apiKey}`
120
- // }
121
- } catch (e) {
122
- console.error('Failed to restore auth from localStorage:', e)
123
- localStorage.removeItem('llms:auth')
124
- }
125
- }
126
- }
127
-
128
96
  // Get auth status
129
97
  const authRes = await this.getAuth()
130
98
  const auth = this.requiresAuth