RFC fix, history bugfixes

frdel committed Nov 27, 2024 at 22:01 UTC 969f142af12c01abd9009a8e35e0cbbd225bca8d
7 files changed +155 -116
.github/FUNDING.yml new
+1
@@ -0,0 +1 @@
1 +github: frdel
python/helpers/history.py
+10 -3
@@ -145,7 +145,7 @@ class Topic(Record):
145 for msg, tok, leng, out in large_msgs:
146 trim_to_chars = leng * (msg_max_size / tok)
147 trunc = messages.truncate_dict_by_ratio(
148 - self.history.agent, out["content"], trim_to_chars * 1.15, trim_to_chars * 0.85
148 + self.history.agent, out[0]["content"], trim_to_chars * 1.15, trim_to_chars * 0.85
149 )
150 msg.summary = trunc
151
@@ -367,11 +367,15 @@ class History(Record):
367 return True
368
369 async def compress_bulks(self):
370 + #merge bulks if possible
371 compressed = await self.merge_bulks_by(BULK_MERGE_COUNT)
372 + #remove oldest bulk if necessary
373 + if not compressed:
374 + self.bulks.pop(0)
375 return compressed
376
377 async def merge_bulks_by(self, count: int):
374 - if len(self.bulks) < count:
378 + if len(self.bulks) > 0:
379 return False
380 bulks = await asyncio.gather(
381 *[
@@ -409,7 +413,10 @@ def serialize_output(output: OutputMessage, ai_label="ai", human_label="human"):
413 def serialize_content(content: OutputType) -> str:
414 if isinstance(content, str):
415 return content
412 - return json.dumps(content)
416 + try:
417 + return json.dumps(content)
418 + except Exception as e:
419 + raise e
420
421
422 def group_outputs_abab(outputs: list[OutputMessage]) -> list[OutputMessage]:
python/helpers/rfc.py
+3 -6
@@ -38,7 +38,7 @@ async def call_rfc(
38 call = RFCCall(
39 rfc_input=json.dumps(input), hash=hash_data(json.dumps(input), password)
40 )
41 - result = await _send_json_data(url, json.dumps(call))
41 + result = await _send_json_data(url, call)
42 return result
43
44
@@ -68,7 +68,7 @@ def _get_function(module: str, function_name: str):
68 return func
69
70
71 -async def _send_json_data(url: str, data: str):
71 +async def _send_json_data(url: str, data):
72 async with aiohttp.ClientSession() as session:
73 async with session.post(
74 url,
@@ -76,10 +76,7 @@ async def _send_json_data(url: str, data: str):
76 ) as response:
77 if response.status == 200:
78 result = await response.json()
79 - if result["ok"]:
80 - return result["result"]
81 - else:
82 - raise Exception(result["message"])
79 + return result
80 else:
81 error = await response.text()
82 raise Exception(error)
webui/index.css
+4
@@ -1702,4 +1702,8 @@ input:checked + .slider:before {
1702 -webkit-text-size-adjust: none;
1703 text-size-adjust: none;
1704 }
1705 +}
1706 +
1707 +.invisible{
1708 + visibility:hidden;
1709 }
\ No newline at end of file
webui/index.html
+133 -100
@@ -20,17 +20,19 @@
20 </script>
21
22 <script defer src="https://cdn.jsdelivr.net/npm/@alpinejs/collapse@3.x.x/dist/cdn.min.js"></script>
23 - <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
24 - <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js" type="text/javascript" charset="utf-8"></script>
23 + <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
24
25 +<script src="https://cdn.jsdelivr.net/npm/ace-builds@1.36.5/src-noconflict/ace.js"></script>
26 +<link href="https://cdn.jsdelivr.net/npm/ace-builds@1.36.5/css/ace.min.css" rel="stylesheet">
27 <!-- KaTeX CSS -->
28 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css" crossorigin="anonymous">
29
30 <!-- KaTeX javascript -->
31 <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js" crossorigin="anonymous"></script>
31 - <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js" crossorigin="anonymous"></script>
32 + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js"
33 + crossorigin="anonymous"></script>
34 +
35
33 -
36 <script type="module" src="index.js"></script>
37 <script type="text/javascript" src="js/settings.js"></script>
38 <script type="text/javascript" src="js/file_browser.js"></script>
@@ -72,11 +74,16 @@
74 <button class="config-button" id="newChat" @click="newChat()">New Chat</button>
75 <button class="config-button" id="loadChats" @click="loadChats()">Load Chat</button>
76 <button class="config-button" id="loadChat" @click="saveChat()">Save Chat</button>
75 - <button class="config-button" id="settings"
76 - @click="settingsModalProxy.openModal()"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-5.0 -17.0 110.0 135.0" fill="currentColor" width="24" height="24">
77 - <path d="m52.301 90.102h-4.1016c-3 0-5 0-6.8984-1.3984-1.8984-1.3984-2.5-3.3008-3.5-6.1016l-1.1016-3.6016c-0.19922-0.60156-0.69922-1.1992-1.3984-1.6016l-1.1016-0.60156c-0.60156-0.30078-1.5-0.39844-2.3008-0.19922l-4.3008 1.1992c-3.1016 0.89844-5.1016 1.5-7.3984 0.5-2.3008-0.89844-3.3984-2.8008-5-5.6016l-1.8008-3.1016c-1.5-2.5-2.5-4.3008-2.3008-6.6992 0.19922-2.3984 1.6016-3.8008 3.6016-6.1016l3.8008-4.1992c0.19922-0.19922 0.60156-1.3984 0.60156-2.6016 0-1.1016-0.5-2.3008-0.80078-2.6992l-3.6016-4c-2-2.1992-3.3008-3.6992-3.6016-6.1016-0.19922-2.3984 0.80078-4.1992 2.3008-6.6992l1.8008-3.1016c1.6016-2.8008 2.6992-4.6016 5-5.6016 2.3008-0.89844 4.3008-0.39844 7.3984 0.5l4.3984 1.1992c0.69922 0.10156 1.5 0 2.3008-0.30078l1.1016-0.60156c0.5-0.30078 1-0.89844 1.3008-1.6992l1.1992-3.5c0.89844-2.8008 1.6016-4.6992 3.5-6.1016 1.8984-1.3984 3.8984-1.3984 6.8984-1.3984h4.1016c3 0 5 0 6.8984 1.3984 1.8984 1.3984 2.5 3.1992 3.5 6.1016l1.1992 3.6016c0.19922 0.60156 0.69922 1.1992 1.3984 1.6016l1.1016 0.60156c0.60156 0.30078 1.5 0.39844 2.3008 0.19922l4.3008-1.1992c3.1016-0.89844 5.1016-1.5 7.3984-0.5 2.3008 0.89844 3.3984 2.8008 5 5.5l1.8008 3.1016c1.3984 2.5 2.5 4.3008 2.3008 6.6992-0.19922 2.3984-1.6016 3.8008-3.6016 6.1016l-3.9961 4.4062c-0.19922 0.19922-0.60156 1.3984-0.60156 2.6016 0 1.1016 0.5 2.3008 0.80078 2.6992l3.6016 4c2 2.1992 3.3008 3.6992 3.6016 6.1016 0.19922 2.3984-0.80078 4.1992-2.3008 6.6992l-1.8008 3.1016c-1.6016 2.8008-2.6992 4.6016-5 5.6016-2.3008 0.89844-4.3984 0.39844-7.3984-0.5l-4.3984-1.1992c-0.69922-0.10156-1.5 0-2.3008 0.30078l-1.1016 0.60156c-0.5 0.30078-1 0.89844-1.3008 1.6992l-1.1992 3.5c-0.89844 2.8008-1.6016 4.6992-3.5 6.1016-1.8008 1.293-3.8008 1.293-6.8008 1.293zm-6.6016-7.3008c0.5 0.10156 1.6016 0.10156 2.6016 0.10156h4.1016c1 0 2 0 2.6016-0.10156 0.19922-0.5 0.60156-1.5 0.89844-2.3984l1.1992-3.6016c0.89844-2.3008 2.3984-4.1992 4.3984-5.3984l1.3984-0.80078c2.3984-1.3008 5.1016-1.6016 7.6016-1l4.6016 1.3008c1 0.30078 2.1016 0.60156 2.6992 0.69922 0.30078-0.5 0.89844-1.5 1.3984-2.3984l1.8008-3.1016c0.5-0.80078 1-1.8008 1.1992-2.3008-0.30078-0.39844-1-1.1992-1.6992-2l-3.8008-4.1992c-1.6016-2-2.5-4.8008-2.5-7.3984 0-2.6016 0.89844-5.3984 2.3008-7.3008l3.8984-4.3984c0.69922-0.69922 1.3984-1.5 1.6992-2-0.19922-0.5-0.80078-1.3984-1.1992-2.3008l-1.8984-3.1016c-0.5-0.89844-1.1016-1.8984-1.3984-2.3984-0.60156 0.10156-1.6992 0.39844-2.6992 0.69922l-4.3984 1.3008c-2.6992 0.60156-5.3008 0.30078-7.6016-0.89844l-1.4023-0.80469c-2.1016-1.3984-3.6016-3.1992-4.3984-5.3984l-1.3008-3.8008c-0.30078-0.89844-0.60156-1.8984-0.89844-2.3984-0.5-0.10156-1.6016-0.10156-2.6016-0.10156h-4.1016c-1 0-2 0-2.6016 0.10156-0.19922 0.5-0.60156 1.5-0.89844 2.3984l-1.1992 3.6016c-0.89844 2.3008-2.3984 4.1992-4.3984 5.3984l-1.3984 0.80078c-2.3984 1.3008-5.1016 1.6016-7.6016 1l-4.6016-1.3008c-1-0.30078-2.1016-0.60156-2.6992-0.69922-0.30078 0.5-0.89844 1.5-1.3984 2.3984l-1.8008 3.1016c-0.5 0.80078-1 1.8008-1.1992 2.3008 0.30078 0.39844 1 1.1992 1.6992 2l3.8008 4.1992c1.6016 2 2.5 4.8008 2.5 7.3984 0 2.6016-0.89844 5.3984-2.3008 7.3008l-3.8984 4.3984c-0.69922 0.69922-1.3984 1.5-1.6992 2 0.19922 0.5 0.80078 1.3984 1.1992 2.3008l1.8008 3.1016c0.5 0.89844 1.1016 1.8984 1.3984 2.3984 0.60156-0.10156 1.6992-0.39844 2.6992-0.69922l4.3984-1.1992c2.6992-0.60156 5.3008-0.30078 7.6016 0.89844l1.3984 0.80078c2.1016 1.3008 3.6016 3.1992 4.3984 5.3984l1.3008 3.8008c0.5 0.80078 0.80078 1.8008 1 2.3008z"></path>
78 - <path d="m50.301 66.5c-9 0-16.398-7.3008-16.398-16.398 0-9.1016 7.3008-16.398 16.398-16.398 9.1016 0 16.398 7.3008 16.398 16.398 0 9.0977-7.3984 16.398-16.398 16.398zm0-25.5c-5 0-9.1016 4.1016-9.1016 9.1016s4.1016 9.1016 9.1016 9.1016 9.1016-4.1016 9.1016-9.1016c-0.003906-5-4.1016-9.1016-9.1016-9.1016z"></path>
79 - </svg>Settings</button>
77 + <button class="config-button" id="settings" @click="settingsModalProxy.openModal()"><svg
78 + xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-5.0 -17.0 110.0 135.0"
79 + fill="currentColor" width="24" height="24">
80 + <path
81 + d="m52.301 90.102h-4.1016c-3 0-5 0-6.8984-1.3984-1.8984-1.3984-2.5-3.3008-3.5-6.1016l-1.1016-3.6016c-0.19922-0.60156-0.69922-1.1992-1.3984-1.6016l-1.1016-0.60156c-0.60156-0.30078-1.5-0.39844-2.3008-0.19922l-4.3008 1.1992c-3.1016 0.89844-5.1016 1.5-7.3984 0.5-2.3008-0.89844-3.3984-2.8008-5-5.6016l-1.8008-3.1016c-1.5-2.5-2.5-4.3008-2.3008-6.6992 0.19922-2.3984 1.6016-3.8008 3.6016-6.1016l3.8008-4.1992c0.19922-0.19922 0.60156-1.3984 0.60156-2.6016 0-1.1016-0.5-2.3008-0.80078-2.6992l-3.6016-4c-2-2.1992-3.3008-3.6992-3.6016-6.1016-0.19922-2.3984 0.80078-4.1992 2.3008-6.6992l1.8008-3.1016c1.6016-2.8008 2.6992-4.6016 5-5.6016 2.3008-0.89844 4.3008-0.39844 7.3984 0.5l4.3984 1.1992c0.69922 0.10156 1.5 0 2.3008-0.30078l1.1016-0.60156c0.5-0.30078 1-0.89844 1.3008-1.6992l1.1992-3.5c0.89844-2.8008 1.6016-4.6992 3.5-6.1016 1.8984-1.3984 3.8984-1.3984 6.8984-1.3984h4.1016c3 0 5 0 6.8984 1.3984 1.8984 1.3984 2.5 3.1992 3.5 6.1016l1.1992 3.6016c0.19922 0.60156 0.69922 1.1992 1.3984 1.6016l1.1016 0.60156c0.60156 0.30078 1.5 0.39844 2.3008 0.19922l4.3008-1.1992c3.1016-0.89844 5.1016-1.5 7.3984-0.5 2.3008 0.89844 3.3984 2.8008 5 5.5l1.8008 3.1016c1.3984 2.5 2.5 4.3008 2.3008 6.6992-0.19922 2.3984-1.6016 3.8008-3.6016 6.1016l-3.9961 4.4062c-0.19922 0.19922-0.60156 1.3984-0.60156 2.6016 0 1.1016 0.5 2.3008 0.80078 2.6992l3.6016 4c2 2.1992 3.3008 3.6992 3.6016 6.1016 0.19922 2.3984-0.80078 4.1992-2.3008 6.6992l-1.8008 3.1016c-1.6016 2.8008-2.6992 4.6016-5 5.6016-2.3008 0.89844-4.3984 0.39844-7.3984-0.5l-4.3984-1.1992c-0.69922-0.10156-1.5 0-2.3008 0.30078l-1.1016 0.60156c-0.5 0.30078-1 0.89844-1.3008 1.6992l-1.1992 3.5c-0.89844 2.8008-1.6016 4.6992-3.5 6.1016-1.8008 1.293-3.8008 1.293-6.8008 1.293zm-6.6016-7.3008c0.5 0.10156 1.6016 0.10156 2.6016 0.10156h4.1016c1 0 2 0 2.6016-0.10156 0.19922-0.5 0.60156-1.5 0.89844-2.3984l1.1992-3.6016c0.89844-2.3008 2.3984-4.1992 4.3984-5.3984l1.3984-0.80078c2.3984-1.3008 5.1016-1.6016 7.6016-1l4.6016 1.3008c1 0.30078 2.1016 0.60156 2.6992 0.69922 0.30078-0.5 0.89844-1.5 1.3984-2.3984l1.8008-3.1016c0.5-0.80078 1-1.8008 1.1992-2.3008-0.30078-0.39844-1-1.1992-1.6992-2l-3.8008-4.1992c-1.6016-2-2.5-4.8008-2.5-7.3984 0-2.6016 0.89844-5.3984 2.3008-7.3008l3.8984-4.3984c0.69922-0.69922 1.3984-1.5 1.6992-2-0.19922-0.5-0.80078-1.3984-1.1992-2.3008l-1.8984-3.1016c-0.5-0.89844-1.1016-1.8984-1.3984-2.3984-0.60156 0.10156-1.6992 0.39844-2.6992 0.69922l-4.3984 1.3008c-2.6992 0.60156-5.3008 0.30078-7.6016-0.89844l-1.4023-0.80469c-2.1016-1.3984-3.6016-3.1992-4.3984-5.3984l-1.3008-3.8008c-0.30078-0.89844-0.60156-1.8984-0.89844-2.3984-0.5-0.10156-1.6016-0.10156-2.6016-0.10156h-4.1016c-1 0-2 0-2.6016 0.10156-0.19922 0.5-0.60156 1.5-0.89844 2.3984l-1.1992 3.6016c-0.89844 2.3008-2.3984 4.1992-4.3984 5.3984l-1.3984 0.80078c-2.3984 1.3008-5.1016 1.6016-7.6016 1l-4.6016-1.3008c-1-0.30078-2.1016-0.60156-2.6992-0.69922-0.30078 0.5-0.89844 1.5-1.3984 2.3984l-1.8008 3.1016c-0.5 0.80078-1 1.8008-1.1992 2.3008 0.30078 0.39844 1 1.1992 1.6992 2l3.8008 4.1992c1.6016 2 2.5 4.8008 2.5 7.3984 0 2.6016-0.89844 5.3984-2.3008 7.3008l-3.8984 4.3984c-0.69922 0.69922-1.3984 1.5-1.6992 2 0.19922 0.5 0.80078 1.3984 1.1992 2.3008l1.8008 3.1016c0.5 0.89844 1.1016 1.8984 1.3984 2.3984 0.60156-0.10156 1.6992-0.39844 2.6992-0.69922l4.3984-1.1992c2.6992-0.60156 5.3008-0.30078 7.6016 0.89844l1.3984 0.80078c2.1016 1.3008 3.6016 3.1992 4.3984 5.3984l1.3008 3.8008c0.5 0.80078 0.80078 1.8008 1 2.3008z">
82 + </path>
83 + <path
84 + d="m50.301 66.5c-9 0-16.398-7.3008-16.398-16.398 0-9.1016 7.3008-16.398 16.398-16.398 9.1016 0 16.398 7.3008 16.398 16.398 0 9.0977-7.3984 16.398-16.398 16.398zm0-25.5c-5 0-9.1016 4.1016-9.1016 9.1016s4.1016 9.1016 9.1016 9.1016 9.1016-4.1016 9.1016-9.1016c-0.003906-5-4.1016-9.1016-9.1016-9.1016z">
85 + </path>
86 + </svg>Settings</button>
87 </div>
88 <!-- Chats List -->
89 <div class="config-section" id="chats-section" x-data="{ contexts: [], selected: '' }"
@@ -176,21 +183,15 @@
183 <div class="status-icon" x-data="{ connected: true }">
184 <svg viewBox="0 0 30 30">
185 <!-- Connected State (filled circle) -->
179 - <circle class="connected-circle"
180 - cx="15" cy="15" r="8"
181 - x-bind:fill="connected ? '#00c340' : 'none'"
182 - x-bind:opacity="connected ? 1 : 0"/>
183 -
186 + <circle class="connected-circle" cx="15" cy="15" r="8"
187 + x-bind:fill="connected ? '#00c340' : 'none'" x-bind:opacity="connected ? 1 : 0" />
188 +
189 <!-- Disconnected State (outline circle) -->
185 - <circle class="disconnected-circle"
186 - cx="15" cy="15" r="12"
187 - fill="none"
188 - stroke="#e40138"
189 - stroke-width="3"
190 - x-bind:opacity="connected ? 0 : 1"/>
190 + <circle class="disconnected-circle" cx="15" cy="15" r="12" fill="none" stroke="#e40138"
191 + stroke-width="3" x-bind:opacity="connected ? 0 : 1" />
192 </svg>
192 - </div>
193 - </div>
193 + </div>
194 + </div>
195 <div id="chat-history">
196 </div>
197 <div id="toast" class="toast">
@@ -349,24 +350,44 @@
350 <path stroke-linecap="round" stroke-linejoin="round"
351 d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5m-13.5-9L12 3m0 0 4.5 4.5M12 3v13.5">
352 </path>
352 - </svg><p>Import knowledge</p></button>
353 - <button class="text-button" id="work_dir_browser" @click="fileBrowserModalProxy.openModal()">
354 - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 123.37 92.59">
355 - <path d="m5.72,11.5l-3.93,8.73h119.77s-3.96-8.73-3.96-8.73h-60.03c-1.59,0-2.88-1.29-2.88-2.88V1.75H13.72v6.87c0,1.59-1.29,2.88-2.88,2.88h-5.12Z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="7"></path>
356 - <path d="m6.38,20.23H1.75l7.03,67.03c.11,1.07.55,2.02,1.2,2.69.55.55,1.28.89,2.11.89h97.1c.82,0,1.51-.33,2.05-.87.68-.68,1.13-1.67,1.28-2.79l9.1-66.94H6.38Z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="8"></path>
357 - </svg><p>work_dir Browser</p></button>
358 -
359 - <button class="text-button" id="history_inspect" @click="window.openHistoryModal()">
360 - <svg xmlns="http://www.w3.org/2000/svg" viewBox="5 10 85 85">
361 - <path fill="currentColor" d="m59.572,57.949c-.41,0-.826-.105-1.207-.325l-9.574-5.528c-.749-.432-1.21-1.231-1.21-2.095v-14.923c0-1.336,1.083-2.419,2.419-2.419s2.419,1.083,2.419,2.419v13.526l8.364,4.829c1.157.668,1.554,2.148.886,3.305-.448.776-1.261,1.21-2.097,1.21Zm30.427-7.947c0,10.684-4.161,20.728-11.716,28.283-6.593,6.59-15.325,10.69-24.59,11.544-1.223.113-2.448.169-3.669.169-7.492,0-14.878-2.102-21.22-6.068l-15.356,5.733c-.888.331-1.887.114-2.557-.556s-.887-1.669-.556-2.557l5.733-15.351c-4.613-7.377-6.704-16.165-5.899-24.891.854-9.266,4.954-17.998,11.544-24.588,7.555-7.555,17.6-11.716,28.285-11.716s20.73,4.161,28.285,11.716c7.555,7.555,11.716,17.599,11.716,28.283Zm-15.137-24.861c-13.71-13.71-36.018-13.71-49.728,0-11.846,11.846-13.682,30.526-4.365,44.417.434.647.53,1.464.257,2.194l-4.303,11.523,11.528-4.304c.274-.102.561-.153.846-.153.474,0,.944.139,1.348.41,13.888,9.315,32.568,7.479,44.417-4.365,13.707-13.708,13.706-36.014,0-49.723Zm-24.861-4.13c-15.989,0-28.996,13.006-28.996,28.992s13.008,28.992,28.996,28.992c1.336,0,2.419-1.083,2.419-2.419s-1.083-2.419-2.419-2.419c-13.32,0-24.157-10.835-24.157-24.153s10.837-24.153,24.157-24.153,24.153,10.835,24.153,24.153c0,1.336,1.083,2.419,2.419,2.419s2.419-1.083,2.419-2.419c0-15.986-13.006-28.992-28.992-28.992Zm25.041,33.531c-1.294.347-2.057,1.673-1.71,2.963.343,1.289,1.669,2.057,2.963,1.71,1.289-.343,2.053-1.669,1.71-2.963-.347-1.289-1.673-2.057-2.963-1.71Zm-2.03,6.328c-1.335,0-2.419,1.084-2.419,2.419s1.084,2.419,2.419,2.419,2.419-1.084,2.419-2.419-1.084-2.419-2.419-2.419Zm-3.598,5.587c-1.289-.347-2.615.416-2.963,1.71-.343,1.289.421,2.615,1.71,2.963,1.294.347,2.62-.421,2.963-1.71.347-1.294-.416-2.62-1.71-2.963Zm-4.919,4.462c-1.157-.667-2.638-.27-3.306.887-.667,1.157-.27,2.638.887,3.305,1.157.668,2.638.27,3.306-.887.667-1.157.27-2.638-.887-3.306Zm-9.327,3.04c-.946.946-.946,2.478,0,3.42.942.946,2.473.946,3.42,0,.946-.942.946-2.473,0-3.42-.946-.946-2.478-.946-3.42,0Z"></path>
362 - </svg><p>History</p></button>
363 -
364 - <button class="text-button" id="ctx_window" @click="window.openCtxWindowModal()">
365 - <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="17 15 70 70" fill="currentColor">
366 - <path d="m63 25c1.1016 0 2-0.89844 2-2s-0.89844-2-2-2h-26c-1.1016 0-2 0.89844-2 2s0.89844 2 2 2z"></path>
367 - <path d="m63 79c1.1016 0 2-0.89844 2-2s-0.89844-2-2-2h-26c-1.1016 0-2 0.89844-2 2s0.89844 2 2 2z"></path>
368 - <path d="m68 39h-36c-6.0703 0-11 4.9297-11 11s4.9297 11 11 11h36c6.0703 0 11-4.9297 11-11s-4.9297-11-11-11zm0 18h-36c-3.8594 0-7-3.1406-7-7s3.1406-7 7-7h36c3.8594 0 7 3.1406 7 7s-3.1406 7-7 7z"></path>
369 - </svg><p>Context</p></button>
353 + </svg>
354 + <p>Import knowledge</p>
355 + </button>
356 + <button class="text-button" id="work_dir_browser" @click="fileBrowserModalProxy.openModal()">
357 + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 123.37 92.59">
358 + <path
359 + d="m5.72,11.5l-3.93,8.73h119.77s-3.96-8.73-3.96-8.73h-60.03c-1.59,0-2.88-1.29-2.88-2.88V1.75H13.72v6.87c0,1.59-1.29,2.88-2.88,2.88h-5.12Z"
360 + fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="7"></path>
361 + <path
362 + d="m6.38,20.23H1.75l7.03,67.03c.11,1.07.55,2.02,1.2,2.69.55.55,1.28.89,2.11.89h97.1c.82,0,1.51-.33,2.05-.87.68-.68,1.13-1.67,1.28-2.79l9.1-66.94H6.38Z"
363 + fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="8"></path>
364 + </svg>
365 + <p>work_dir Browser</p>
366 + </button>
367 +
368 + <button class="text-button" id="history_inspect" @click="window.openHistoryModal()">
369 + <svg xmlns="http://www.w3.org/2000/svg" viewBox="5 10 85 85">
370 + <path fill="currentColor"
371 + d="m59.572,57.949c-.41,0-.826-.105-1.207-.325l-9.574-5.528c-.749-.432-1.21-1.231-1.21-2.095v-14.923c0-1.336,1.083-2.419,2.419-2.419s2.419,1.083,2.419,2.419v13.526l8.364,4.829c1.157.668,1.554,2.148.886,3.305-.448.776-1.261,1.21-2.097,1.21Zm30.427-7.947c0,10.684-4.161,20.728-11.716,28.283-6.593,6.59-15.325,10.69-24.59,11.544-1.223.113-2.448.169-3.669.169-7.492,0-14.878-2.102-21.22-6.068l-15.356,5.733c-.888.331-1.887.114-2.557-.556s-.887-1.669-.556-2.557l5.733-15.351c-4.613-7.377-6.704-16.165-5.899-24.891.854-9.266,4.954-17.998,11.544-24.588,7.555-7.555,17.6-11.716,28.285-11.716s20.73,4.161,28.285,11.716c7.555,7.555,11.716,17.599,11.716,28.283Zm-15.137-24.861c-13.71-13.71-36.018-13.71-49.728,0-11.846,11.846-13.682,30.526-4.365,44.417.434.647.53,1.464.257,2.194l-4.303,11.523,11.528-4.304c.274-.102.561-.153.846-.153.474,0,.944.139,1.348.41,13.888,9.315,32.568,7.479,44.417-4.365,13.707-13.708,13.706-36.014,0-49.723Zm-24.861-4.13c-15.989,0-28.996,13.006-28.996,28.992s13.008,28.992,28.996,28.992c1.336,0,2.419-1.083,2.419-2.419s-1.083-2.419-2.419-2.419c-13.32,0-24.157-10.835-24.157-24.153s10.837-24.153,24.157-24.153,24.153,10.835,24.153,24.153c0,1.336,1.083,2.419,2.419,2.419s2.419-1.083,2.419-2.419c0-15.986-13.006-28.992-28.992-28.992Zm25.041,33.531c-1.294.347-2.057,1.673-1.71,2.963.343,1.289,1.669,2.057,2.963,1.71,1.289-.343,2.053-1.669,1.71-2.963-.347-1.289-1.673-2.057-2.963-1.71Zm-2.03,6.328c-1.335,0-2.419,1.084-2.419,2.419s1.084,2.419,2.419,2.419,2.419-1.084,2.419-2.419-1.084-2.419-2.419-2.419Zm-3.598,5.587c-1.289-.347-2.615.416-2.963,1.71-.343,1.289.421,2.615,1.71,2.963,1.294.347,2.62-.421,2.963-1.71.347-1.294-.416-2.62-1.71-2.963Zm-4.919,4.462c-1.157-.667-2.638-.27-3.306.887-.667,1.157-.27,2.638.887,3.305,1.157.668,2.638.27,3.306-.887.667-1.157.27-2.638-.887-3.306Zm-9.327,3.04c-.946.946-.946,2.478,0,3.42.942.946,2.473.946,3.42,0,.946-.942.946-2.473,0-3.42-.946-.946-2.478-.946-3.42,0Z">
372 + </path>
373 + </svg>
374 + <p>History</p>
375 + </button>
376 +
377 + <button class="text-button" id="ctx_window" @click="window.openCtxWindowModal()">
378 + <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="17 15 70 70" fill="currentColor">
379 + <path
380 + d="m63 25c1.1016 0 2-0.89844 2-2s-0.89844-2-2-2h-26c-1.1016 0-2 0.89844-2 2s0.89844 2 2 2z">
381 + </path>
382 + <path
383 + d="m63 79c1.1016 0 2-0.89844 2-2s-0.89844-2-2-2h-26c-1.1016 0-2 0.89844-2 2s0.89844 2 2 2z">
384 + </path>
385 + <path
386 + d="m68 39h-36c-6.0703 0-11 4.9297-11 11s4.9297 11 11 11h36c6.0703 0 11-4.9297 11-11s-4.9297-11-11-11zm0 18h-36c-3.8594 0-7-3.1406-7-7s3.1406-7 7-7h36c3.8594 0 7 3.1406 7 7s-3.1406 7-7 7z">
387 + </path>
388 + </svg>
389 + <p>Context</p>
390 + </button>
391
392 </div>
393 </div>
@@ -374,26 +395,28 @@
395 </div>
396 <div id="settingsModal" x-data="settingsModalProxy">
397 <template x-teleport="body">
377 - <div x-show="isOpen" class="modal-overlay" @click.self="handleCancel()" @keydown.escape.window="handleClose()" x-transition>
398 + <div x-show="isOpen" class="modal-overlay" @click.self="handleCancel()"
399 + @keydown.escape.window="handleClose()" x-transition>
400 <div class="modal-container">
401 <div class="modal-header">
380 - <h2 x-text="settings.title"></h2>
402 + <h2 x-text="settings.title"></h2>
403 <button class="modal-close" @click="handleCancel()">&times;</button>
404 </div>
383 -
405 +
406 <div class="modal-content">
407 <div id="settings-sections">
408 <nav>
387 - <ul>
388 - <template x-for="(section, index) in settings.sections" :key="section.title">
389 - <li>
390 - <a :href="'#section' + (index + 1)">
391 - <img :src="'/public/' + getIconName(section.title) + '.svg'" :alt="section.title">
392 - <span x-text="section.title"></span>
393 - </a>
394 - </li>
395 - </template>
396 - </ul>
409 + <ul>
410 + <template x-for="(section, index) in settings.sections" :key="section.title">
411 + <li>
412 + <a :href="'#section' + (index + 1)">
413 + <img :src="'/public/' + getIconName(section.title) + '.svg'"
414 + :alt="section.title">
415 + <span x-text="section.title"></span>
416 + </a>
417 + </li>
418 + </template>
419 + </ul>
420 </nav>
421 </div>
422 <template x-for="(section, sectionIndex) in settings.sections" :key="sectionIndex">
@@ -488,12 +511,13 @@
511 </div>
512 </template>
513 </div>
491 -
514 +
515 <!-- work_dir Browser Modal -->
516
517 <div id="fileBrowserModal" x-data="fileBrowserModalProxy">
518 <template x-teleport="body">
496 - <div x-show="isOpen" class="modal-overlay" @click.self="handleClose()" @keydown.escape.window="handleClose()" x-transition>
519 + <div x-show="isOpen" class="modal-overlay" @click.self="handleClose()"
520 + @keydown.escape.window="handleClose()" x-transition>
521 <div class="modal-container">
522 <div class="modal-header">
523 <h2 class="modal-title" x-text="browser.title"></h2>
@@ -506,24 +530,24 @@
530 <div x-show="!isLoading">
531 <div class="path-navigator">
532 <!-- Up Button -->
509 - <button class="text-button back-button"
510 - @click="navigateUp()"
511 - aria-label="Navigate Up">
533 + <button class="text-button back-button" @click="navigateUp()" aria-label="Navigate Up">
534 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10.5 15">
513 - <path d="m.75,5.25L5.25.75m0,0l4.5,4.5M5.25.75v13.5" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path>
535 + <path d="m.75,5.25L5.25.75m0,0l4.5,4.5M5.25.75v13.5" fill="none"
536 + stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
537 + stroke-width="1.5"></path>
538 </svg>
515 - Up
539 + Up
540 </button>
517 -
541 +
542 <span class="current-path" x-text="browser.currentPath || 'Current Path: /'"></span>
543 </div>
520 -
544 +
545 <div class="files-list">
546 <!-- Header -->
547 <div class="file-header">
548 <div class="file-cell" @click="toggleSort('name')">
549 Name
526 - <span x-show="browser.sortBy === 'name'"
550 + <span x-show="browser.sortBy === 'name'"
551 x-text="browser.sortDirection === 'asc' ? '↑' : '↓'">
552 </span>
553 </div>
@@ -540,34 +564,44 @@
564 </span>
565 </div>
566 </div>
543 -
567 +
568 <!-- File List -->
569 <template x-if="browser.entries.length">
570 <template x-for="file in sortFiles(browser.entries)" :key="file.path">
571 <div class="file-item" :data-is-dir="file.is_dir">
548 - <div class="file-name" @click="file.is_dir ? navigateToFolder(file.path) : downloadFile(file)">
549 - <img :src="'/public/' + (file.type === 'unknown' ? 'file' : (isArchive(file.name) ? 'archive' : file.type)) + '.svg'" class="file-icon" :alt="file.type">
572 + <div class="file-name"
573 + @click="file.is_dir ? navigateToFolder(file.path) : downloadFile(file)">
574 + <img :src="'/public/' + (file.type === 'unknown' ? 'file' : (isArchive(file.name) ? 'archive' : file.type)) + '.svg'"
575 + class="file-icon" :alt="file.type">
576 <span x-text="file.name"></span>
577 </div>
578 <div class="file-size" x-text="formatFileSize(file.size)"></div>
579 <div class="file-date" x-text="formatDate(file.modified)"></div>
580
581 <div class="file-actions">
556 - <button class="action-button download-button" @click.stop="downloadFile(file)" x-show="!file.is_dir">
582 + <button class="action-button download-button"
583 + @click.stop="downloadFile(file)" x-bind:class="{ 'invisible': file.is_dir }">
584 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.5 19.5">
558 - <path d="m.75,14.25v2.25c0,1.24,1.01,2.25,2.25,2.25h13.5c1.24,0,2.25-1.01,2.25-2.25v-2.25m-4.5-4.5l-4.5,4.5m0,0l-4.5-4.5m4.5,4.5V.75" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path>
585 + <path
586 + d="m.75,14.25v2.25c0,1.24,1.01,2.25,2.25,2.25h13.5c1.24,0,2.25-1.01,2.25-2.25v-2.25m-4.5-4.5l-4.5,4.5m0,0l-4.5-4.5m4.5,4.5V.75"
587 + fill="none" stroke="currentColor" stroke-linecap="round"
588 + stroke-linejoin="round" stroke-width="1.5"></path>
589 </svg>
590 </button>
561 - <button class="delete-button" @click.stop="deleteFile(file)" x-show="!file.is_dir || (file.is_dir &amp;&amp; file.size === 0)">
562 - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15.03 22.53" fill="currentColor">
563 - <path d="m14.55,7.82H4.68L14.09,3.19c.83-.41,1.17-1.42.77-2.25-.41-.83-1.42-1.17-2.25-.77l-3.16,1.55-.15-.31c-.22-.44-.59-.76-1.05-.92-.46-.16-.96-.13-1.39.09l-2.08,1.02c-.9.44-1.28,1.54-.83,2.44l.15.31-3.16,1.55c-.83.41-1.17,1.42-.77,2.25.29.59.89.94,1.51.94.25,0,.5-.06.74-.17l.38-.19s.09.03.14.03h11.14v11.43c0,.76-.62,1.38-1.38,1.38h-.46v-11.28c0-.26-.21-.47-.47-.47s-.47.21-.47.47v11.28h-2.39v-11.28c0-.26-.21-.47-.47-.47s-.47.21-.47.47v11.28h-2.39v-11.28c0-.26-.21-.47-.47-.47s-.47.21-.47.47v11.28h-.46c-.76,0-1.38-.62-1.38-1.38v-9.9c0-.26-.21-.47-.47-.47s-.47.21-.47.47v9.9c0,1.28,1.04,2.32,2.32,2.32h8.55c1.28,0,2.32-1.04,2.32-2.32v-11.91c0-.26-.21-.47-.47-.47ZM5.19,2.46l2.08-1.02c.12-.06.25-.09.39-.09.09,0,.19.02.28.05.22.08.4.23.5.44l.15.31-.19.09-3.46,1.7-.15-.31c-.21-.43-.03-.96.4-1.17Zm-3.19,5.62c-.36.18-.8.03-.98-.33-.18-.36-.03-.8.33-.98l5.8-2.85,2.72-1.34,3.16-1.55c.1-.05.21-.07.32-.07.27,0,.53.15.66.41.09.17.1.37.04.56-.06.18-.19.33-.37.42L2,8.08Z" stroke-width="0"></path>
591 + <button class="delete-button" @click.stop="deleteFile(file)"
592 + x-bind:class="{ 'invisible': file.is_dir && file.size !== 0 }">
593 + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15.03 22.53"
594 + fill="currentColor">
595 + <path
596 + d="m14.55,7.82H4.68L14.09,3.19c.83-.41,1.17-1.42.77-2.25-.41-.83-1.42-1.17-2.25-.77l-3.16,1.55-.15-.31c-.22-.44-.59-.76-1.05-.92-.46-.16-.96-.13-1.39.09l-2.08,1.02c-.9.44-1.28,1.54-.83,2.44l.15.31-3.16,1.55c-.83.41-1.17,1.42-.77,2.25.29.59.89.94,1.51.94.25,0,.5-.06.74-.17l.38-.19s.09.03.14.03h11.14v11.43c0,.76-.62,1.38-1.38,1.38h-.46v-11.28c0-.26-.21-.47-.47-.47s-.47.21-.47.47v11.28h-2.39v-11.28c0-.26-.21-.47-.47-.47s-.47.21-.47.47v11.28h-2.39v-11.28c0-.26-.21-.47-.47-.47s-.47.21-.47.47v11.28h-.46c-.76,0-1.38-.62-1.38-1.38v-9.9c0-.26-.21-.47-.47-.47s-.47.21-.47.47v9.9c0,1.28,1.04,2.32,2.32,2.32h8.55c1.28,0,2.32-1.04,2.32-2.32v-11.91c0-.26-.21-.47-.47-.47ZM5.19,2.46l2.08-1.02c.12-.06.25-.09.39-.09.09,0,.19.02.28.05.22.08.4.23.5.44l.15.31-.19.09-3.46,1.7-.15-.31c-.21-.43-.03-.96.4-1.17Zm-3.19,5.62c-.36.18-.8.03-.98-.33-.18-.36-.03-.8.33-.98l5.8-2.85,2.72-1.34,3.16-1.55c.1-.05.21-.07.32-.07.27,0,.53.15.66.41.09.17.1.37.04.56-.06.18-.19.33-.37.42L2,8.08Z"
597 + stroke-width="0"></path>
598 </svg>
565 - </button>
599 + </button>
600 </div>
601 </div>
602 </template>
603 </template>
570 -
604 +
605 <!-- Empty State -->
606 <template x-if="!browser.entries.length">
607 <div class="no-files">
@@ -579,17 +613,15 @@
613 </div>
614 <div class="modal-footer">
615 <div id="buttons-container">
582 - <label class="btn btn-upload"><svg xmlns="http://www.w3.org/2000/svg"
583 - fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
584 - <path stroke-linecap="round" stroke-linejoin="round"
585 - d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5m-13.5-9L12 3m0 0 4.5 4.5M12 3v13.5">
586 - </path>
587 - </svg>
616 + <label class="btn btn-upload"><svg xmlns="http://www.w3.org/2000/svg" fill="none"
617 + viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
618 + <path stroke-linecap="round" stroke-linejoin="round"
619 + d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5m-13.5-9L12 3m0 0 4.5 4.5M12 3v13.5">
620 + </path>
621 + </svg>
622 Upload Files
589 - <input type="file" multiple=""
590 - accept="all"
591 - @change="handleFileUpload"
592 - style="display: none;">
623 + <input type="file" multiple="" accept="all" @change="handleFileUpload"
624 + style="display: none;">
625 </label>
626 <button class="btn btn-cancel" @click="handleClose()">Close Browser</button>
627 </div>
@@ -598,28 +630,29 @@
630 </template>
631 </div>
632
601 -<!-- generic modal -->
633 + <!-- generic modal -->
634
603 -<div id="genericModal" x-data="genericModalProxy">
604 - <template x-teleport="body">
605 - <div x-show="isOpen" class="modal-overlay" @click.self="handleClose()" @keydown.escape.window="handleClose()" x-transition>
606 - <div class="modal-container">
607 - <div class="modal-header">
608 - <h2 class="modal-title" x-text="title"></h2>
609 - <button class="modal-close" @click="handleClose()">&times;</button>
610 - </div>
611 - <div class="modal-description" x-text="description"></div>
612 - <div class="modal-content" id="viewer">
613 - <div class="html-pre" x-html="html"></div>
614 - </div>
615 - <!-- <div class="modal-footer">
635 + <div id="genericModal" x-data="genericModalProxy">
636 + <template x-teleport="body">
637 + <div x-show="isOpen" class="modal-overlay" @click.self="handleClose()"
638 + @keydown.escape.window="handleClose()" x-transition>
639 + <div class="modal-container">
640 + <div class="modal-header">
641 + <h2 class="modal-title" x-text="title"></h2>
642 + <button class="modal-close" @click="handleClose()">&times;</button>
643 + </div>
644 + <div class="modal-description" x-text="description"></div>
645 + <div class="modal-content" id="viewer">
646 + <div class="html-pre" x-html="html"></div>
647 + </div>
648 + <!-- <div class="modal-footer">
649 <div id="buttons-container">
650 <button class="btn btn-cancel" @click="handleClose()">Close</button>
651 </div>
652 </div> -->
620 - </div>
621 - </template>
622 -</div>
653 + </div>
654 + </template>
655 + </div>
656
657 </body>
658
webui/js/history.js
+4 -2
@@ -4,7 +4,7 @@ export async function openHistoryModal() {
4 const hist = await window.sendJsonData("/history_get", { context: getContext() });
5 const data = JSON.stringify(hist.history, null, 4);
6 const size = hist.tokens
7 - await showEditorModal(data, "json", `History ~${size} tokens`,"Conversation history how the agent can see it. History is compressed to fit into the context window.");
7 + await showEditorModal(data, "json", `History ~${size} tokens`,"Conversation history visible to the LLM. History is compressed to fit into the context window over time.");
8 }
9
10 export async function openCtxWindowModal() {
@@ -28,7 +28,9 @@ async function showEditorModal(data, type = "json", title, description="") {
28
29 const dark = localStorage.getItem('darkMode')
30 if (dark != "false") {
31 - editor.setTheme("ace/theme/monokai");
31 + editor.setTheme("ace/theme/github_dark");
32 + }else{
33 + editor.setTheme("ace/theme/tomorrow");
34 }
35
36 editor.session.setMode("ace/mode/" + type);
webui/js/speech.js
-5
@@ -144,11 +144,6 @@ class MicrophoneInput {
144
145 async initialize() {
146 try {
147 - this.transcriber = await pipeline(
148 - 'automatic-speech-recognition',
149 - `Xenova/whisper-${this.options.modelSize}.${this.options.language}`
150 - );
151 -
147 const stream = await navigator.mediaDevices.getUserMedia({
148 audio: {
149 echoCancellation: true,