Skip to content

Commit 5687c0c

Browse files
committed
update: lite size and optimize batch streaming
1 parent 0763811 commit 5687c0c

File tree

8 files changed

+45
-102
lines changed

8 files changed

+45
-102
lines changed

tools/agently_helper/README.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,7 @@ Outputs are written to `tools/agently_helper/dist`.
2828

2929
Notes:
3030
- Target OS must be used to build that OS package.
31-
- Packaged apps can bundle Python under `tools/agently_helper/python` (see `tools/agently_helper/python/README.md`).
32-
- If not bundled, the app will use `PYTHON` or fall back to `python3`/`python`.
33-
34-
### Build Embedded Python (recommended)
35-
36-
Create a bundled venv that includes Agently:
37-
38-
```bash
39-
./tools/agently_helper/scripts/build_python_bundle.sh
40-
```
41-
42-
On Windows (PowerShell):
43-
44-
```powershell
45-
.\tools\agently_helper\scripts\build_python_bundle.ps1
46-
```
31+
- The app uses a user-provided Python interpreter (via Settings) or `PYTHON`, then falls back to `python3`/`python`.
4732

4833
## Usage
4934

tools/agently_helper/README_CN.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,7 @@ npm run dist:linux
2828

2929
说明:
3030
- 需要在目标系统上打包对应的安装包。
31-
- 可将 Python 放在 `tools/agently_helper/python` 内打包(见 `tools/agently_helper/python/README.md`)。
32-
- 若未打包内置 Python,应用会使用 `PYTHON`,否则回退到 `python3`/`python`
33-
34-
### 生成内置 Python(推荐)
35-
36-
创建包含 Agently 的 venv:
37-
38-
```bash
39-
./tools/agently_helper/scripts/build_python_bundle.sh
40-
```
41-
42-
Windows(PowerShell):
43-
44-
```powershell
45-
.\tools\agently_helper\scripts\build_python_bundle.ps1
46-
```
31+
- 应用使用用户在设置中选择的 Python 解释器,或 `PYTHON`,再回退到 `python3`/`python`
4732

4833
## 使用方式
4934

tools/agently_helper/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,10 @@ <h2 data-i18n="Settings">Settings</h2>
548548
/>
549549
</div>
550550
<div class="settings-row">
551-
<label data-i18n="Interpreter Test">Interpreter Test</label>
551+
<label class="label-spacer">Interpreter</label>
552552
<div class="settings-inline">
553-
<button id="pythonTestButton" class="ghost small" data-i18n="Test Interpreter">
554-
Test Interpreter
553+
<button id="pythonInterpreterSaveButton" class="ghost small" data-i18n="Test And Save Interpreter">
554+
Test And Save Interpreter
555555
</button>
556556
<span id="pythonTestStatus" class="status-label"></span>
557557
</div>
@@ -595,7 +595,9 @@ <h2 data-i18n="Settings">Settings</h2>
595595
<div class="action-row">
596596
<button id="modelFieldAddButton" class="ghost small" data-i18n="Add Field">Add Field</button>
597597
<div class="action-right">
598-
<button id="settingsSaveButton" class="primary" data-i18n="Save Settings">Save Settings</button>
598+
<button id="settingsSaveButton" class="primary" data-i18n="Save Model Settings">
599+
Save Model Settings
600+
</button>
599601
</div>
600602
</div>
601603
<div class="settings-divider"></div>

tools/agently_helper/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
"directories": {
3131
"output": "dist"
3232
},
33-
"extraResources": [
34-
{
35-
"from": "python",
36-
"to": "python"
37-
}
38-
],
3933
"files": [
4034
"**/*"
4135
],

tools/agently_helper/renderer.js

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const modelTemplateSelect = document.querySelector("#modelTemplateSelect");
2929
const modelTemplateButton = document.querySelector("#modelTemplateButton");
3030
const pythonInterpreterSelect = document.querySelector("#pythonInterpreterSelect");
3131
const pythonInterpreterInput = document.querySelector("#pythonInterpreterInput");
32-
const pythonTestButton = document.querySelector("#pythonTestButton");
32+
const pythonInterpreterSaveButton = document.querySelector("#pythonInterpreterSaveButton");
3333
const pythonTestStatus = document.querySelector("#pythonTestStatus");
3434
const showApiKeyToggle = document.querySelector("#showApiKeyToggle");
3535
const settingsWizardButton = document.querySelector("#settingsWizardButton");
@@ -130,6 +130,7 @@ let batchOutputRows = [];
130130
let batchCurrentPage = 1;
131131
const batchPageSize = 10;
132132
let batchSelectedIndex = null;
133+
let batchTableRenderTimer = null;
133134
let activeBatchVar = "";
134135

135136
const editorRegistry = new Map();
@@ -454,7 +455,7 @@ const translations = {
454455
Delete: "Delete",
455456
Remove: "Remove",
456457
"Add Field": "Add Field",
457-
"Save Settings": "Save Settings",
458+
"Save Model Settings": "Save Model Settings",
458459
Console: "Console",
459460
Reset: "Reset",
460461
"model name": "model name",
@@ -486,6 +487,7 @@ const translations = {
486487
Testing: "Testing...",
487488
OK: "OK",
488489
"Install Hint": "If your interpreter does not have Agently installed, run:",
490+
"Test And Save Interpreter": "Test And Save Interpreter",
489491
"Reset Settings And Use Wizard": "Reset Settings And Use Wizard",
490492
"Reset Settings Confirm": "This will reset all settings and reopen the wizard. Continue?",
491493
},
@@ -560,7 +562,7 @@ const translations = {
560562
Delete: "删除",
561563
Remove: "移除",
562564
"Add Field": "添加字段",
563-
"Save Settings": "保存设置",
565+
"Save Model Settings": "保存模型设置",
564566
Console: "控制台",
565567
Reset: "重置",
566568
"model name": "模型名称",
@@ -569,8 +571,7 @@ const translations = {
569571
"Python Interpreter": "Python 解释器",
570572
"Custom Path": "自定义路径",
571573
"/usr/bin/python3": "/usr/bin/python3",
572-
"Interpreter Test": "解释器测试",
573-
"Test Interpreter": "测试解释器",
574+
"Test And Save Interpreter": "测试并保存解释器",
574575
"Testing interpreter...": "正在测试解释器...",
575576
"Interpreter OK": "解释器可用",
576577
"Interpreter test failed": "解释器测试失败",
@@ -909,6 +910,7 @@ function switchBatchOutputTab(target) {
909910
batchOutputPanels.forEach((panel) =>
910911
panel.classList.toggle("active", panel.dataset.batchOutputPanel === target),
911912
);
913+
renderBatchDetail();
912914
autoResizeAllOutputs();
913915
const panel = document.querySelector(`[data-batch-output-panel="${target}"] textarea`);
914916
if (panel) {
@@ -920,6 +922,7 @@ function switchBatchPromptTab(target) {
920922
batchPromptPanels.forEach((panel) =>
921923
panel.classList.toggle("active", panel.dataset.batchPromptPanel === target),
922924
);
925+
renderBatchDetail();
923926
autoResizeAllOutputs();
924927
}
925928

@@ -1307,6 +1310,16 @@ function renderBatchTable() {
13071310
renderBatchDetail();
13081311
}
13091312

1313+
function scheduleBatchTableRender() {
1314+
if (batchTableRenderTimer) {
1315+
return;
1316+
}
1317+
batchTableRenderTimer = setTimeout(() => {
1318+
batchTableRenderTimer = null;
1319+
renderBatchTable();
1320+
}, 120);
1321+
}
1322+
13101323
function renderBatchDetail() {
13111324
if (
13121325
!batchDetailTitle ||
@@ -1907,8 +1920,8 @@ if (showApiKeyToggle) {
19071920
});
19081921
}
19091922

1910-
if (pythonTestButton) {
1911-
pythonTestButton.addEventListener("click", async () => {
1923+
if (pythonInterpreterSaveButton) {
1924+
pythonInterpreterSaveButton.addEventListener("click", async () => {
19121925
if (!window.agentlyApi?.testPythonInterpreter) {
19131926
return;
19141927
}
@@ -1917,14 +1930,16 @@ if (pythonTestButton) {
19171930
if (pythonTestStatus) {
19181931
pythonTestStatus.textContent = testingLabel;
19191932
}
1920-
pythonTestButton.disabled = true;
1933+
pythonInterpreterSaveButton.disabled = true;
19211934
const result = await window.agentlyApi.testPythonInterpreter(path);
19221935
if (result?.ok) {
19231936
const okLabel = translations[languageSelect.value]?.["Interpreter OK"] || "Interpreter OK";
1924-
const message = result.version ? `${okLabel}: ${result.version}` : okLabel;
1937+
const message = okLabel;
19251938
if (pythonTestStatus) {
19261939
pythonTestStatus.textContent = message;
19271940
}
1941+
settingsCache.pythonInterpreter = path;
1942+
await saveSettings();
19281943
} else {
19291944
const failedLabel = translations[languageSelect.value]?.["Interpreter test failed"]
19301945
|| "Interpreter test failed";
@@ -1933,7 +1948,7 @@ if (pythonTestButton) {
19331948
pythonTestStatus.textContent = message;
19341949
}
19351950
}
1936-
pythonTestButton.disabled = false;
1951+
pythonInterpreterSaveButton.disabled = false;
19371952
});
19381953
}
19391954

@@ -2198,15 +2213,15 @@ function bindBatchStream() {
21982213
row.promptJson = data.jsonPrompt || "";
21992214
row.promptPython = data.pythonExample || "";
22002215
}
2201-
renderBatchTable();
2216+
scheduleBatchTableRender();
22022217
return;
22032218
}
22042219
if (data.type === "task_start") {
22052220
const row = batchOutputRows.find((item) => item.index === data.index + 1);
22062221
if (row) {
22072222
row.status = "running";
22082223
}
2209-
renderBatchTable();
2224+
scheduleBatchTableRender();
22102225
return;
22112226
}
22122227
if (data.type === "stream") {
@@ -2222,7 +2237,7 @@ function bindBatchStream() {
22222237
if (batchSelectedIndex === data.index + 1) {
22232238
renderBatchDetail();
22242239
}
2225-
renderBatchTable();
2240+
scheduleBatchTableRender();
22262241
return;
22272242
}
22282243
if (data.type === "console") {
@@ -2233,7 +2248,7 @@ function bindBatchStream() {
22332248
if (batchSelectedIndex === data.index + 1) {
22342249
renderBatchDetail();
22352250
}
2236-
renderBatchTable();
2251+
scheduleBatchTableRender();
22372252
return;
22382253
}
22392254
if (data.type === "console_delta") {
@@ -2244,7 +2259,7 @@ function bindBatchStream() {
22442259
if (batchSelectedIndex === data.index + 1) {
22452260
renderBatchDetail();
22462261
}
2247-
renderBatchTable();
2262+
scheduleBatchTableRender();
22482263
return;
22492264
}
22502265
if (data.type === "final") {
@@ -2260,7 +2275,7 @@ function bindBatchStream() {
22602275
if (batchSelectedIndex === data.index + 1) {
22612276
renderBatchDetail();
22622277
}
2263-
renderBatchTable();
2278+
scheduleBatchTableRender();
22642279
return;
22652280
}
22662281
if (data.type === "error") {
@@ -2276,7 +2291,7 @@ function bindBatchStream() {
22762291
if (batchSelectedIndex === data.index + 1) {
22772292
renderBatchDetail();
22782293
}
2279-
renderBatchTable();
2294+
scheduleBatchTableRender();
22802295
return;
22812296
}
22822297
if (data.type === "done") {

tools/agently_helper/scripts/build_python_bundle.ps1

Lines changed: 0 additions & 22 deletions
This file was deleted.

tools/agently_helper/scripts/build_python_bundle.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

tools/agently_helper/styles.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,11 @@ textarea {
704704
flex-wrap: nowrap;
705705
}
706706

707+
.label-spacer {
708+
min-width: 110px;
709+
visibility: hidden;
710+
}
711+
707712
.settings-inline {
708713
display: inline-flex;
709714
align-items: center;

0 commit comments

Comments
 (0)