lemonade-sdk 8.1.2__py3-none-any.whl → 8.1.3__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.
Potentially problematic release.
This version of lemonade-sdk might be problematic. Click here for more details.
- lemonade/tools/oga/utils.py +54 -33
- lemonade/tools/server/llamacpp.py +96 -4
- lemonade/tools/server/serve.py +74 -8
- lemonade/tools/server/static/js/chat.js +735 -0
- lemonade/tools/server/static/js/model-settings.js +162 -0
- lemonade/tools/server/static/js/models.js +865 -0
- lemonade/tools/server/static/js/shared.js +491 -0
- lemonade/tools/server/static/styles.css +652 -26
- lemonade/tools/server/static/webapp.html +145 -1092
- lemonade/tools/server/utils/port.py +3 -2
- lemonade/version.py +1 -1
- {lemonade_sdk-8.1.2.dist-info → lemonade_sdk-8.1.3.dist-info}/METADATA +7 -6
- {lemonade_sdk-8.1.2.dist-info → lemonade_sdk-8.1.3.dist-info}/RECORD +21 -17
- lemonade_server/cli.py +31 -17
- lemonade_server/pydantic_models.py +15 -3
- lemonade_server/server_models.json +9 -3
- {lemonade_sdk-8.1.2.dist-info → lemonade_sdk-8.1.3.dist-info}/WHEEL +0 -0
- {lemonade_sdk-8.1.2.dist-info → lemonade_sdk-8.1.3.dist-info}/entry_points.txt +0 -0
- {lemonade_sdk-8.1.2.dist-info → lemonade_sdk-8.1.3.dist-info}/licenses/LICENSE +0 -0
- {lemonade_sdk-8.1.2.dist-info → lemonade_sdk-8.1.3.dist-info}/licenses/NOTICE.md +0 -0
- {lemonade_sdk-8.1.2.dist-info → lemonade_sdk-8.1.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Model Settings functionality
|
|
2
|
+
|
|
3
|
+
// Model settings state
|
|
4
|
+
let modelSettings = {};
|
|
5
|
+
|
|
6
|
+
// === Model Settings Management ===
|
|
7
|
+
|
|
8
|
+
// Load model settings from localStorage (without DOM access)
|
|
9
|
+
function loadModelSettingsFromStorage() {
|
|
10
|
+
const saved = localStorage.getItem('lemonade_model_settings');
|
|
11
|
+
if (saved) {
|
|
12
|
+
try {
|
|
13
|
+
const savedSettings = JSON.parse(saved);
|
|
14
|
+
modelSettings = { ...modelSettings, ...savedSettings };
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('Error loading saved settings:', error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Load model settings from localStorage and update UI
|
|
22
|
+
function loadModelSettings() {
|
|
23
|
+
// First load from storage
|
|
24
|
+
loadModelSettingsFromStorage();
|
|
25
|
+
|
|
26
|
+
// Update UI - set values only if they exist, otherwise leave placeholder
|
|
27
|
+
const tempInput = document.getElementById('setting-temperature');
|
|
28
|
+
const topKInput = document.getElementById('setting-top-k');
|
|
29
|
+
const topPInput = document.getElementById('setting-top-p');
|
|
30
|
+
const repeatInput = document.getElementById('setting-repeat-penalty');
|
|
31
|
+
|
|
32
|
+
// Check if DOM elements exist
|
|
33
|
+
if (!tempInput || !topKInput || !topPInput || !repeatInput) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Load saved values or leave as placeholder "default"
|
|
38
|
+
if (modelSettings.temperature !== undefined) {
|
|
39
|
+
tempInput.value = modelSettings.temperature;
|
|
40
|
+
}
|
|
41
|
+
if (modelSettings.top_k !== undefined) {
|
|
42
|
+
topKInput.value = modelSettings.top_k;
|
|
43
|
+
}
|
|
44
|
+
if (modelSettings.top_p !== undefined) {
|
|
45
|
+
topPInput.value = modelSettings.top_p;
|
|
46
|
+
}
|
|
47
|
+
if (modelSettings.repeat_penalty !== undefined) {
|
|
48
|
+
repeatInput.value = modelSettings.repeat_penalty;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Auto-save model settings whenever inputs change
|
|
53
|
+
function setupAutoSaveSettings() {
|
|
54
|
+
const inputs = ['setting-temperature', 'setting-top-k', 'setting-top-p', 'setting-repeat-penalty'];
|
|
55
|
+
|
|
56
|
+
inputs.forEach(inputId => {
|
|
57
|
+
const input = document.getElementById(inputId);
|
|
58
|
+
if (input) {
|
|
59
|
+
input.addEventListener('input', function() {
|
|
60
|
+
updateModelSettings();
|
|
61
|
+
});
|
|
62
|
+
input.addEventListener('blur', function() {
|
|
63
|
+
updateModelSettings();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Update model settings from current input values
|
|
70
|
+
function updateModelSettings() {
|
|
71
|
+
const tempInput = document.getElementById('setting-temperature');
|
|
72
|
+
const topKInput = document.getElementById('setting-top-k');
|
|
73
|
+
const topPInput = document.getElementById('setting-top-p');
|
|
74
|
+
const repeatInput = document.getElementById('setting-repeat-penalty');
|
|
75
|
+
|
|
76
|
+
// Check if DOM elements exist (might not be available if DOM isn't ready)
|
|
77
|
+
if (!tempInput || !topKInput || !topPInput || !repeatInput) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Only set values if user has entered something, otherwise use undefined (default)
|
|
82
|
+
modelSettings = {};
|
|
83
|
+
|
|
84
|
+
if (tempInput.value && tempInput.value.trim() !== '') {
|
|
85
|
+
modelSettings.temperature = parseFloat(tempInput.value);
|
|
86
|
+
}
|
|
87
|
+
if (topKInput.value && topKInput.value.trim() !== '') {
|
|
88
|
+
modelSettings.top_k = parseInt(topKInput.value);
|
|
89
|
+
}
|
|
90
|
+
if (topPInput.value && topPInput.value.trim() !== '') {
|
|
91
|
+
modelSettings.top_p = parseFloat(topPInput.value);
|
|
92
|
+
}
|
|
93
|
+
if (repeatInput.value && repeatInput.value.trim() !== '') {
|
|
94
|
+
modelSettings.repeat_penalty = parseFloat(repeatInput.value);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Save to localStorage
|
|
98
|
+
localStorage.setItem('lemonade_model_settings', JSON.stringify(modelSettings));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Reset model settings to defaults (clear all inputs)
|
|
102
|
+
function resetModelSettings() {
|
|
103
|
+
modelSettings = {};
|
|
104
|
+
|
|
105
|
+
// Clear all input values to show placeholders
|
|
106
|
+
document.getElementById('setting-temperature').value = '';
|
|
107
|
+
document.getElementById('setting-top-k').value = '';
|
|
108
|
+
document.getElementById('setting-top-p').value = '';
|
|
109
|
+
document.getElementById('setting-repeat-penalty').value = '';
|
|
110
|
+
|
|
111
|
+
localStorage.removeItem('lemonade_model_settings');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Get current model settings for API requests (only include non-default values)
|
|
115
|
+
function getCurrentModelSettings() {
|
|
116
|
+
// Only update from DOM if the settings elements are available and visible
|
|
117
|
+
// Otherwise, use the settings loaded from localStorage
|
|
118
|
+
const tempInput = document.getElementById('setting-temperature');
|
|
119
|
+
if (tempInput) {
|
|
120
|
+
// DOM elements are available, update from current form state
|
|
121
|
+
updateModelSettings();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Return only the settings that have actual values (not defaults)
|
|
125
|
+
const currentSettings = {};
|
|
126
|
+
if (modelSettings.temperature !== undefined) {
|
|
127
|
+
currentSettings.temperature = modelSettings.temperature;
|
|
128
|
+
}
|
|
129
|
+
if (modelSettings.top_k !== undefined) {
|
|
130
|
+
currentSettings.top_k = modelSettings.top_k;
|
|
131
|
+
}
|
|
132
|
+
if (modelSettings.top_p !== undefined) {
|
|
133
|
+
currentSettings.top_p = modelSettings.top_p;
|
|
134
|
+
}
|
|
135
|
+
if (modelSettings.repeat_penalty !== undefined) {
|
|
136
|
+
currentSettings.repeat_penalty = modelSettings.repeat_penalty;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
console.log('getCurrentModelSettings returning:', currentSettings);
|
|
140
|
+
return currentSettings;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Make functions globally available for external access (like chat.js)
|
|
144
|
+
window.getCurrentModelSettings = getCurrentModelSettings;
|
|
145
|
+
|
|
146
|
+
// Load initial settings from localStorage immediately (without requiring DOM)
|
|
147
|
+
loadModelSettingsFromStorage();
|
|
148
|
+
|
|
149
|
+
// Initialize model settings when DOM is loaded
|
|
150
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
151
|
+
// Set up model settings controls (only reset button now)
|
|
152
|
+
const resetBtn = document.getElementById('reset-settings-btn');
|
|
153
|
+
if (resetBtn) {
|
|
154
|
+
resetBtn.onclick = resetModelSettings;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Load initial model settings
|
|
158
|
+
loadModelSettings();
|
|
159
|
+
|
|
160
|
+
// Set up auto-save for settings
|
|
161
|
+
setupAutoSaveSettings();
|
|
162
|
+
});
|