Nanny7 commited on
Commit
ef50eab
·
1 Parent(s): d37a434

Deploy OpenWebUI update from local

Browse files
config/minimal_ui_patch.js CHANGED
@@ -1,4 +1,31 @@
1
  (() => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  const HIDE_TEXT = new Set([
3
  'Settings',
4
  'Archived Chats',
@@ -18,6 +45,44 @@
18
  return (text || '').replace(/\s+/g, ' ').trim();
19
  }
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  function hide(el) {
22
  if (!el || el.dataset.montaigneHidden === '1') {
23
  return;
@@ -80,6 +145,8 @@
80
  document.querySelectorAll('#temporary-chat-button').forEach(hide);
81
  }
82
 
 
 
83
  const run = () => window.requestAnimationFrame(applyMinimalUi);
84
 
85
  if (document.readyState === 'loading') {
 
1
  (() => {
2
+ const MONTAIGNE_SUGGESTIONS = [
3
+ {
4
+ title: ['What occupies your thoughts', 'most lately?'],
5
+ content: 'What occupies your thoughts most lately?'
6
+ },
7
+ {
8
+ title: ['Which of your habits', 'deserve examination?'],
9
+ content: 'Which of my habits deserve the closest examination, and how might I begin?'
10
+ },
11
+ {
12
+ title: ['What do solitude and', 'conversation each reveal?'],
13
+ content: "What do solitude and conversation each reveal about a person's character?"
14
+ },
15
+ {
16
+ title: ['How have you changed', 'without noticing?'],
17
+ content: 'How can someone recognize the ways they have changed without noticing?'
18
+ },
19
+ {
20
+ title: ['Where does ambition', 'help or mislead you?'],
21
+ content: 'Where does ambition improve a life, and where does it quietly mislead us?'
22
+ },
23
+ {
24
+ title: ['What truth about yourself', 'is hardest to admit?'],
25
+ content: 'What kinds of truths about ourselves are the hardest to admit, and why?'
26
+ }
27
+ ];
28
+
29
  const HIDE_TEXT = new Set([
30
  'Settings',
31
  'Archived Chats',
 
45
  return (text || '').replace(/\s+/g, ' ').trim();
46
  }
47
 
48
+ function installConfigFetchPatch() {
49
+ if (window.__montaigneConfigFetchPatched) {
50
+ return;
51
+ }
52
+
53
+ window.__montaigneConfigFetchPatched = true;
54
+
55
+ const originalFetch = window.fetch.bind(window);
56
+ window.fetch = async (...args) => {
57
+ const response = await originalFetch(...args);
58
+
59
+ try {
60
+ const input = args[0];
61
+ const rawUrl = input instanceof Request ? input.url : String(input);
62
+ const url = new URL(rawUrl, window.location.origin);
63
+
64
+ if (url.pathname !== '/api/config') {
65
+ return response;
66
+ }
67
+
68
+ const payload = await response.clone().json();
69
+ payload.default_prompt_suggestions = MONTAIGNE_SUGGESTIONS;
70
+
71
+ const headers = new Headers(response.headers);
72
+ headers.set('content-type', 'application/json');
73
+ headers.delete('content-length');
74
+
75
+ return new Response(JSON.stringify(payload), {
76
+ status: response.status,
77
+ statusText: response.statusText,
78
+ headers
79
+ });
80
+ } catch (_error) {
81
+ return response;
82
+ }
83
+ };
84
+ }
85
+
86
  function hide(el) {
87
  if (!el || el.dataset.montaigneHidden === '1') {
88
  return;
 
145
  document.querySelectorAll('#temporary-chat-button').forEach(hide);
146
  }
147
 
148
+ installConfigFetchPatch();
149
+
150
  const run = () => window.requestAnimationFrame(applyMinimalUi);
151
 
152
  if (document.readyState === 'loading') {
config/prompt_suggestions.json CHANGED
@@ -5,16 +5,24 @@
5
  "content": "What occupies your thoughts most lately?"
6
  },
7
  {
8
- "title": ["Have you ever changed", "your mind about something important?"],
9
- "content": "Have you ever found yourself changing your mind about something important?"
10
  },
11
  {
12
- "title": ["When you look inward,", "what do you discover?"],
13
- "content": "When you look inward, what do you discover about yourself?"
14
  },
15
  {
16
- "title": ["How do you balance", "action with reflection?"],
17
- "content": "How do you balance action with reflection in your life?"
 
 
 
 
 
 
 
 
18
  }
19
  ]
20
  }
 
5
  "content": "What occupies your thoughts most lately?"
6
  },
7
  {
8
+ "title": ["Which of your habits", "deserve examination?"],
9
+ "content": "Which of my habits deserve the closest examination, and how might I begin?"
10
  },
11
  {
12
+ "title": ["What do solitude and", "conversation each reveal?"],
13
+ "content": "What do solitude and conversation each reveal about a person's character?"
14
  },
15
  {
16
+ "title": ["How have you changed", "without noticing?"],
17
+ "content": "How can someone recognize the ways they have changed without noticing?"
18
+ },
19
+ {
20
+ "title": ["Where does ambition", "help or mislead you?"],
21
+ "content": "Where does ambition improve a life, and where does it quietly mislead us?"
22
+ },
23
+ {
24
+ "title": ["What truth about yourself", "is hardest to admit?"],
25
+ "content": "What kinds of truths about ourselves are the hardest to admit, and why?"
26
  }
27
  ]
28
  }
docker-entrypoint.sh CHANGED
@@ -157,11 +157,13 @@ if [ -f "$MINIMAL_UI_PATCH_FILE" ] && [ -f "/app/build/index.html" ]; then
157
  from pathlib import Path
158
 
159
  index_path = Path('/app/build/index.html')
160
- script_tag = '<script defer src="/montaigne-minimal-ui.js"></script>'
161
  html = index_path.read_text(encoding='utf-8')
162
 
163
  if script_tag not in html:
164
- if '</head>' in html:
 
 
165
  html = html.replace('</head>', f' {script_tag}\n</head>', 1)
166
  elif '</body>' in html:
167
  html = html.replace('</body>', f' {script_tag}\n</body>', 1)
 
157
  from pathlib import Path
158
 
159
  index_path = Path('/app/build/index.html')
160
+ script_tag = '<script src="/montaigne-minimal-ui.js"></script>'
161
  html = index_path.read_text(encoding='utf-8')
162
 
163
  if script_tag not in html:
164
+ if '<script' in html:
165
+ html = html.replace('<script', f'{script_tag}\n<script', 1)
166
+ elif '</head>' in html:
167
  html = html.replace('</head>', f' {script_tag}\n</head>', 1)
168
  elif '</body>' in html:
169
  html = html.replace('</body>', f' {script_tag}\n</body>', 1)