-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsettings.html
346 lines (296 loc) · 13.2 KB
/
settings.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Monadic Chat Settings</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
body {
display: flex;
flex-direction: column;
height: 100vh;
margin: 0;
padding: 0;
color: #333;
background-color: #eeeeee;
overflow: hidden;
}
body, input, textarea, button, select, pre {
font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans CJK JP", "Original Yu Gothic", "Yu Gothic", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Sans Emoji";
}
h1 {
margin: 10px;
font-size: 16px;
font-weight: bold;
}
#settings-container {
flex-grow: 1;
overflow-y: auto;
padding: 0 10px;
height: calc(100vh - 55px);
}
#settings-form {
flex-grow: 1;
display: flex;
flex-direction: column;
margin-bottom: 20px;
}
label {
display: block;
margin-top: 10px;
font-weight: 500;
font-size: 12px;
}
input, select {
width: 100%;
padding: 6px 12px;
margin-top: 5px;
margin-bottom: 5px;
font-size: 13px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
input:focus, select:focus {
outline: none;
border-color: #ffc107;
}
.button-group {
border-top: 1px solid #ccc;
padding: 12px;
background-color: #eeeeee;
}
.button-group button {
background-color: #ffc107;
color: #000;
border: none;
border-radius: 5px;
padding: 5px 10px;
margin-left: 5px;
cursor: pointer;
font-size: 14px;
align-items: center;
height: 26px;
}
.button-group button:hover {
background-color: #e0ac07;
}
button#toggle-visibility {
margin-right: auto;
margin-left: 0;
background-color: #ffc107;
}
button#toggle-visibility:hover {
background-color: #e0ac07;
}
.fa-icon {
margin-right: 5px;
}
#save-message {
display: none;
color: green;
margin-left: 10px;
font-size: 14px;
}
</style>
</head>
<body>
<h1>Monadic Chat <span style="font-weight: normal;">Settings</span></h1>
<div id="settings-container">
<form id="settings-form">
<label for="openai-api-key">OPENAI_API_KEY</label>
<input type="password" id="openai-api-key" name="openai-api-key" spellcheck="false">
<label for="anthropic-api-key">ANTHROPIC_API_KEY</label>
<input type="password" id="anthropic-api-key" name="anthropic-api-key" spellcheck="false">
<label for="cohere-api-key">COHERE_API_KEY</label>
<input type="password" id="cohere-api-key" name="cohere-api-key" spellcheck="false">
<label for="gemini-api-key">GEMINI_API_KEY</label>
<input type="password" id="gemini-api-key" name="gemini-api-key" spellcheck="false">
<label for="mistral-api-key">MISTRAL_API_KEY</label>
<input type="password" id="mistral-api-key" name="mistral-api-key" spellcheck="false">
<label for="xai-api-key">XAI_API_KEY</label>
<input type="password" id="xai-api-key" name="xai-api-key" spellcheck="false">
<label for="perplexity-api-key">PERPLEXITY_API_KEY</label>
<input type="password" id="perplexity-api-key" name="perplexity-api-key" spellcheck="false">
<label for="deepseek-api-key">DEEPSEEK_API_KEY</label>
<input type="password" id="deepseek-api-key" name="deepseek-api-key" spellcheck="false">
<label for="elevenlabs-api-key">ELEVENLABS_API_KEY</label>
<input type="password" id="elevenlabs-api-key" name="elevenlabs-api-key" spellcheck="false">
<label for="tavily-api-key">TAVILY_API_KEY</label>
<input type="password" id="tavily-api-key" name="tavily-api-key" spellcheck="false">
<label for="rouge-theme">Syntax Highlighting Theme</label>
<select id="rouge-theme" name="rouge-theme">
<option disabled>──Dark Themes──</option>
<option value="base16:dark">base16-dark</option>
<option value="github:dark">github-dark</option>
<option value="gruvbox:dark">gruvbox-dark</option>
<option value="colorful:dark">colorful</option>
<option value="molokai:dark">molokai</option>
<option value="monokai:dark">monokai</option>
<option value="monokai_sublime:dark">monokai_sublime</option>
<option value="tulip:dark">tulip</option>
<option value="thankful_eyes:light">thankful_eyes</option>
<option disabled>──Light Themes──</option>
<option value="base16:light">base16-light</option>
<option value="github:light">github-light</option>
<option value="gruvbox:light">gruvbox-light</option>
<option value="bw:light">bw</option>
<option value="igor_pro:light">igor_pro</option>
<option value="magritte:light">magritte</option>
<option value="pastie:light">pastie</option>
</select>
<label for="ai-user-model">AI_USER_MODEL</label>
<select id="ai-user-model" name="ai-user-model">
<option value="gpt-4o-mini">gpt-4o-mini</option>
<option value="gpt-4o">gpt-4o</option>
<option value="o3-mini">o3-mini</option>
<option value="o1-mini">o1-mini</option>
<option value="o1">o1</option>
</select>
<label for="embedding-model">EMBEDDING_MODEL</label>
<select id="embedding-model" name="embedding-model">
<option value="text-embedding-3-small">text-embedding-3-small</option>
<option value="text-embedding-3-large">text-embedding-3-large</option>
</select>
<label for="tts-dict-path">TTS Dictionary File Path</label>
<div style="display: flex; align-items: center;">
<input type="text" id="tts-dict-path" name="tts-dict-path" readonly style="flex: 1; margin-right: 10px;">
<button type="button" id="select-tts-dict">Select File</button>
</div>
<label class="form-check-label" for="extra-logging">Extra Logging</label>
<input class="form-check-inline" style="display:inline; width: 20px; margin-left:0;" type="checkbox" value="" id="extra-logging">
</form>
</div>
<div class="button-group">
<button type="button" id="toggle-visibility"><i class="fas fa-eye fa-icon"></i>Show API Keys</button>
<button type="submit" form="settings-form"><i class="fas fa-save fa-icon"></i>Save</button>
<button type="button" id="cancel"><i class="fas fa-times fa-icon"></i>Close</button>
<span id="save-message">Settings saved</span>
</div>
<script>
const { ipcRenderer } = require('electron');
document.getElementById('settings-form').addEventListener('submit', (event) => {
event.preventDefault();
const ttsDictPath = document.getElementById('tts-dict-path').value;
const data = {
OPENAI_API_KEY: document.getElementById('openai-api-key').value,
ANTHROPIC_API_KEY: document.getElementById('anthropic-api-key').value,
COHERE_API_KEY: document.getElementById('cohere-api-key').value,
GEMINI_API_KEY: document.getElementById('gemini-api-key').value,
MISTRAL_API_KEY: document.getElementById('mistral-api-key').value,
XAI_API_KEY: document.getElementById('xai-api-key').value,
PERPLEXITY_API_KEY: document.getElementById('perplexity-api-key').value,
DEEPSEEK_API_KEY: document.getElementById('deepseek-api-key').value,
ELEVENLABS_API_KEY: document.getElementById('elevenlabs-api-key').value,
TAVILY_API_KEY: document.getElementById('tavily-api-key').value,
ROUGE_THEME: document.getElementById('rouge-theme').value,
AI_USER_MODEL: document.getElementById('ai-user-model').value,
EMBEDDING_MODEL: document.getElementById('embedding-model').value,
TTS_DICT_PATH: ttsDictPath,
EXTRA_LOGGING: document.getElementById('extra-logging').checked
};
ipcRenderer.send('save-settings', data);
// Show the save message
const saveMessage = document.getElementById('save-message');
saveMessage.style.display = 'inline';
// Hide the message after 3 seconds
setTimeout(() => {
saveMessage.style.display = 'none';
}, 3000);
});
document.getElementById('cancel').addEventListener('click', () => {
ipcRenderer.send('close-settings');
});
ipcRenderer.on('request-settings', () => {
ipcRenderer.send('request-settings');
});
ipcRenderer.on('load-settings', (_event, data) => {
document.getElementById('openai-api-key').value = data.OPENAI_API_KEY || '';
document.getElementById('anthropic-api-key').value = data.ANTHROPIC_API_KEY || '';
document.getElementById('cohere-api-key').value = data.COHERE_API_KEY || '';
document.getElementById('gemini-api-key').value = data.GEMINI_API_KEY || '';
document.getElementById('mistral-api-key').value = data.MISTRAL_API_KEY || '';
document.getElementById('xai-api-key').value = data.XAI_API_KEY || '';
document.getElementById('perplexity-api-key').value = data.PERPLEXITY_API_KEY || '';
document.getElementById('deepseek-api-key').value = data.DEEPSEEK_API_KEY || '';
document.getElementById('elevenlabs-api-key').value = data.ELEVENLABS_API_KEY || '';
document.getElementById('tavily-api-key').value = data.TAVILY_API_KEY || '';
document.getElementById('rouge-theme').value = data.ROUGE_THEME || 'monokai:dark';
document.getElementById('ai-user-model').value = data.AI_USER_MODEL || 'gpt-4o';
document.getElementById('embedding-model').value = data.EMBEDDING_MODEL || 'text-embedding-3-small';
document.getElementById('tts-dict-path').value = data.TTS_DICT_PATH || '';
document.getElementById('extra-logging').checked = data.EXTRA_LOGGING == "true" || false;
});
ipcRenderer.send('request-settings');
document.getElementById('select-tts-dict').addEventListener('click', async () => {
const filePath = await ipcRenderer.invoke('select-tts-dict');
document.getElementById('tts-dict-path').value = filePath;
});
// Enable cut/copy/paste/select all shortcuts for all input fields
const inputs = document.querySelectorAll('input');
inputs.forEach(input => {
input.addEventListener('keydown', (e) => {
if (e.ctrlKey || e.metaKey) { // Windows/LinuxのCtrlキーとmacOSのCommandキーの両方に対応
switch (e.key.toLowerCase()) {
case 'a':
e.preventDefault();
e.target.select();
break;
case 'c':
e.preventDefault();
if (e.target.type === 'password') {
const selection = window.getSelection().toString();
if (selection) {
navigator.clipboard.writeText(selection);
}
} else {
document.execCommand('copy');
}
break;
case 'x':
e.preventDefault();
if (e.target.type === 'password') {
const selection = window.getSelection().toString();
if (selection) {
navigator.clipboard.writeText(selection);
e.target.value = e.target.value.replace(selection, '');
}
} else {
document.execCommand('cut');
}
break;
case 'v':
e.preventDefault();
navigator.clipboard.readText().then(text => {
const start = e.target.selectionStart;
const end = e.target.selectionEnd;
e.target.value = e.target.value.slice(0, start) + text + e.target.value.slice(end);
e.target.setSelectionRange(start + text.length, start + text.length);
});
break;
}
}
});
});
let isVisible = false;
const toggleButton = document.getElementById('toggle-visibility');
const apiInputs = document.querySelectorAll('input[type="password"]');
toggleButton.addEventListener('click', () => {
isVisible = !isVisible;
apiInputs.forEach(input => {
input.type = isVisible ? 'text' : 'password';
});
toggleButton.innerHTML = isVisible ?
'<i class="fas fa-eye-slash fa-icon"></i>Hide API Keys' :
'<i class="fas fa-eye fa-icon"></i>Show API Keys';
});
// Set initial state to hidden
apiInputs.forEach(input => {
input.type = 'password';
});
</script>
</body>
</html>