lemonade-sdk 9.1.1__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 (84) hide show
  1. lemonade/__init__.py +5 -0
  2. lemonade/api.py +180 -0
  3. lemonade/cache.py +92 -0
  4. lemonade/cli.py +173 -0
  5. lemonade/common/__init__.py +0 -0
  6. lemonade/common/build.py +176 -0
  7. lemonade/common/cli_helpers.py +139 -0
  8. lemonade/common/exceptions.py +98 -0
  9. lemonade/common/filesystem.py +368 -0
  10. lemonade/common/inference_engines.py +408 -0
  11. lemonade/common/network.py +93 -0
  12. lemonade/common/printing.py +110 -0
  13. lemonade/common/status.py +471 -0
  14. lemonade/common/system_info.py +1411 -0
  15. lemonade/common/test_helpers.py +28 -0
  16. lemonade/profilers/__init__.py +1 -0
  17. lemonade/profilers/agt_power.py +437 -0
  18. lemonade/profilers/hwinfo_power.py +429 -0
  19. lemonade/profilers/memory_tracker.py +259 -0
  20. lemonade/profilers/profiler.py +58 -0
  21. lemonade/sequence.py +363 -0
  22. lemonade/state.py +159 -0
  23. lemonade/tools/__init__.py +1 -0
  24. lemonade/tools/accuracy.py +432 -0
  25. lemonade/tools/adapter.py +114 -0
  26. lemonade/tools/bench.py +302 -0
  27. lemonade/tools/flm/__init__.py +1 -0
  28. lemonade/tools/flm/utils.py +305 -0
  29. lemonade/tools/huggingface/bench.py +187 -0
  30. lemonade/tools/huggingface/load.py +235 -0
  31. lemonade/tools/huggingface/utils.py +359 -0
  32. lemonade/tools/humaneval.py +264 -0
  33. lemonade/tools/llamacpp/bench.py +255 -0
  34. lemonade/tools/llamacpp/load.py +222 -0
  35. lemonade/tools/llamacpp/utils.py +1260 -0
  36. lemonade/tools/management_tools.py +319 -0
  37. lemonade/tools/mmlu.py +319 -0
  38. lemonade/tools/oga/__init__.py +0 -0
  39. lemonade/tools/oga/bench.py +120 -0
  40. lemonade/tools/oga/load.py +804 -0
  41. lemonade/tools/oga/migration.py +403 -0
  42. lemonade/tools/oga/utils.py +462 -0
  43. lemonade/tools/perplexity.py +147 -0
  44. lemonade/tools/prompt.py +263 -0
  45. lemonade/tools/report/__init__.py +0 -0
  46. lemonade/tools/report/llm_report.py +203 -0
  47. lemonade/tools/report/table.py +899 -0
  48. lemonade/tools/server/__init__.py +0 -0
  49. lemonade/tools/server/flm.py +133 -0
  50. lemonade/tools/server/llamacpp.py +320 -0
  51. lemonade/tools/server/serve.py +2123 -0
  52. lemonade/tools/server/static/favicon.ico +0 -0
  53. lemonade/tools/server/static/index.html +279 -0
  54. lemonade/tools/server/static/js/chat.js +1059 -0
  55. lemonade/tools/server/static/js/model-settings.js +183 -0
  56. lemonade/tools/server/static/js/models.js +1395 -0
  57. lemonade/tools/server/static/js/shared.js +556 -0
  58. lemonade/tools/server/static/logs.html +191 -0
  59. lemonade/tools/server/static/styles.css +2654 -0
  60. lemonade/tools/server/static/webapp.html +321 -0
  61. lemonade/tools/server/tool_calls.py +153 -0
  62. lemonade/tools/server/tray.py +664 -0
  63. lemonade/tools/server/utils/macos_tray.py +226 -0
  64. lemonade/tools/server/utils/port.py +77 -0
  65. lemonade/tools/server/utils/thread.py +85 -0
  66. lemonade/tools/server/utils/windows_tray.py +408 -0
  67. lemonade/tools/server/webapp.py +34 -0
  68. lemonade/tools/server/wrapped_server.py +559 -0
  69. lemonade/tools/tool.py +374 -0
  70. lemonade/version.py +1 -0
  71. lemonade_install/__init__.py +1 -0
  72. lemonade_install/install.py +239 -0
  73. lemonade_sdk-9.1.1.dist-info/METADATA +276 -0
  74. lemonade_sdk-9.1.1.dist-info/RECORD +84 -0
  75. lemonade_sdk-9.1.1.dist-info/WHEEL +5 -0
  76. lemonade_sdk-9.1.1.dist-info/entry_points.txt +5 -0
  77. lemonade_sdk-9.1.1.dist-info/licenses/LICENSE +201 -0
  78. lemonade_sdk-9.1.1.dist-info/licenses/NOTICE.md +47 -0
  79. lemonade_sdk-9.1.1.dist-info/top_level.txt +3 -0
  80. lemonade_server/cli.py +805 -0
  81. lemonade_server/model_manager.py +758 -0
  82. lemonade_server/pydantic_models.py +159 -0
  83. lemonade_server/server_models.json +643 -0
  84. lemonade_server/settings.py +39 -0
@@ -0,0 +1,191 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Server Logs</title>
6
+ <style>
7
+ body {
8
+ font-family: monospace;
9
+ background: #1e1e1e;
10
+ color: #d4d4d4;
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+ #log-container {
15
+ padding: 10px;
16
+ height: 100vh;
17
+ overflow-y: auto;
18
+ white-space: pre-wrap;
19
+ }
20
+ </style>
21
+ </head>
22
+ <body>
23
+ <div id="log-container"></div>
24
+
25
+ <script>
26
+ /**
27
+ * LogStreamer - Backwards-compatible log streaming client
28
+ * Supports both WebSocket (Python server) and SSE (C++ server)
29
+ * Tries WebSocket first, falls back to SSE if unavailable
30
+ */
31
+ class LogStreamer {
32
+ constructor(baseUrl, onMessage, onError = null) {
33
+ this.baseUrl = baseUrl;
34
+ this.onMessage = onMessage;
35
+ this.onError = onError;
36
+ this.connection = null;
37
+ this.type = null; // 'websocket' or 'sse'
38
+ }
39
+
40
+ async connect() {
41
+ // Try WebSocket first (Python server)
42
+ try {
43
+ await this.connectWebSocket();
44
+ console.log('[LogStreamer] Connected via WebSocket');
45
+ return;
46
+ } catch (wsError) {
47
+ console.log('[LogStreamer] WebSocket failed, trying SSE...', wsError);
48
+ }
49
+
50
+ // Fallback to SSE (C++ server)
51
+ try {
52
+ this.connectSSE();
53
+ console.log('[LogStreamer] Connected via SSE');
54
+ } catch (sseError) {
55
+ console.error('[LogStreamer] Both WebSocket and SSE failed', sseError);
56
+ if (this.onError) {
57
+ this.onError(new Error('Unable to connect to log stream'));
58
+ }
59
+ }
60
+ }
61
+
62
+ connectWebSocket() {
63
+ return new Promise((resolve, reject) => {
64
+ const wsUrl = this.baseUrl
65
+ .replace('http://', 'ws://')
66
+ .replace('https://', 'wss://') + '/api/v1/logs/ws';
67
+
68
+ const ws = new WebSocket(wsUrl);
69
+ let connectionTimeout = setTimeout(() => {
70
+ reject(new Error('WebSocket connection timeout'));
71
+ ws.close();
72
+ }, 3000); // 3 second timeout
73
+
74
+ ws.onopen = () => {
75
+ clearTimeout(connectionTimeout);
76
+ this.connection = ws;
77
+ this.type = 'websocket';
78
+ resolve();
79
+ };
80
+
81
+ ws.onmessage = (event) => {
82
+ this.onMessage(event.data);
83
+ };
84
+
85
+ ws.onerror = (error) => {
86
+ clearTimeout(connectionTimeout);
87
+ if (this.onError && this.connection) {
88
+ this.onError(error);
89
+ }
90
+ reject(error);
91
+ };
92
+
93
+ ws.onclose = () => {
94
+ if (this.type === 'websocket') {
95
+ console.log('[LogStreamer] WebSocket closed');
96
+ if (this.onError) {
97
+ this.onError(new Error('WebSocket connection closed'));
98
+ }
99
+ }
100
+ };
101
+ });
102
+ }
103
+
104
+ connectSSE() {
105
+ const sseUrl = this.baseUrl + '/api/v1/logs/stream';
106
+ const eventSource = new EventSource(sseUrl);
107
+
108
+ eventSource.onopen = () => {
109
+ this.connection = eventSource;
110
+ this.type = 'sse';
111
+ };
112
+
113
+ eventSource.onmessage = (event) => {
114
+ this.onMessage(event.data);
115
+ };
116
+
117
+ eventSource.onerror = (error) => {
118
+ console.error('[LogStreamer] SSE error:', error);
119
+ if (this.onError) {
120
+ this.onError(error);
121
+ }
122
+ };
123
+ }
124
+
125
+ disconnect() {
126
+ if (!this.connection) return;
127
+
128
+ if (this.type === 'websocket') {
129
+ this.connection.close();
130
+ } else if (this.type === 'sse') {
131
+ this.connection.close();
132
+ }
133
+
134
+ this.connection = null;
135
+ this.type = null;
136
+ }
137
+
138
+ getConnectionType() {
139
+ return this.type;
140
+ }
141
+ }
142
+
143
+ // Utility functions
144
+ function stripAnsi(str) {
145
+ return str.replace(/\x1B\[[0-9;]*[A-Za-z]/g, '');
146
+ }
147
+
148
+ function isNearBottom() {
149
+ const threshold = 50; // px from bottom
150
+ return logContainer.scrollTop + logContainer.clientHeight >= logContainer.scrollHeight - threshold;
151
+ }
152
+
153
+ // Initialize log streaming
154
+ const logContainer = document.getElementById("log-container");
155
+ const baseUrl = `${location.protocol}//${location.host}`;
156
+
157
+ const logStreamer = new LogStreamer(
158
+ baseUrl,
159
+ (logLine) => {
160
+ // Handle incoming log line
161
+ const line = document.createElement("div");
162
+ line.textContent = stripAnsi(logLine);
163
+ logContainer.appendChild(line);
164
+
165
+ // Only autoscroll if the user is already at (or near) the bottom
166
+ if (isNearBottom()) {
167
+ logContainer.scrollTop = logContainer.scrollHeight;
168
+ }
169
+ },
170
+ (error) => {
171
+ // Handle error
172
+ const msg = document.createElement("div");
173
+ msg.textContent = `[Connection error: ${error.message}]`;
174
+ msg.style.color = "red";
175
+ logContainer.appendChild(msg);
176
+ }
177
+ );
178
+
179
+ // Connect to log stream
180
+ logStreamer.connect();
181
+
182
+ // Show connection type in console
183
+ setTimeout(() => {
184
+ const type = logStreamer.getConnectionType();
185
+ if (type) {
186
+ console.log(`[LogViewer] Connected via ${type === 'websocket' ? 'WebSocket' : 'Server-Sent Events'}`);
187
+ }
188
+ }, 100);
189
+ </script>
190
+ </body>
191
+ </html>