Skip to content

Commit b9cc042

Browse files
authored
🎨 Embedding related Style improvement and minor bug fix
2 parents 1d88438 + 8eb9849 commit b9cc042

File tree

5 files changed

+46
-30
lines changed

5 files changed

+46
-30
lines changed

frontend/app/[locale]/setup/agents/components/tool/ToolPool.tsx

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useState, useEffect, useMemo, useCallback, memo } from "react";
44
import { useTranslation } from "react-i18next";
55

6-
import { Button, App, Tabs, Tooltip } from "antd";
6+
import { Button, App, Tabs } from "antd";
77
import {
88
SettingOutlined,
99
LoadingOutlined,
@@ -13,7 +13,7 @@ import {
1313

1414
import { TOOL_SOURCE_TYPES } from "@/const/agentConfig";
1515
import {
16-
Tooltip as CustomTooltip,
16+
Tooltip,
1717
TooltipTrigger,
1818
TooltipContent,
1919
} from "@/components/ui/tooltip";
@@ -151,6 +151,7 @@ function ToolPool({
151151
const embeddingBlocked =
152152
tool.name === "knowledge_base_search" && !isEmbeddingConfigured;
153153
if (embeddingBlocked) {
154+
message.warning(t("embedding.agentToolDisableTooltip.content"));
154155
return;
155156
}
156157

@@ -387,10 +388,6 @@ function ToolPool({
387388
const isEffectivelyAvailable = isAvailable && !isEmbeddingBlocked;
388389
const isDisabled = localIsGenerating || !isEditingMode || isGeneratingAgent; // Disable only during generation or view-only
389390

390-
const kbUnavailableTip = isEmbeddingBlocked
391-
? "您尚未配置 Embedding 模型,无法使用依赖向量化能力的 Agent 工具。"
392-
: undefined;
393-
394391
const item = (
395392
<div
396393
className={`border-2 rounded-md p-2 flex items-center transition-all duration-300 ease-in-out min-h-[45px] shadow-sm ${
@@ -410,20 +407,25 @@ function ToolPool({
410407
}`}
411408
onClick={(e) => {
412409
if (isDisabled) {
410+
if (!isEditingMode) {
411+
message.warning(t("toolPool.message.viewOnlyMode"));
412+
}
413413
return;
414414
}
415415
if (!isEffectivelyAvailable && !isSelected) {
416-
if (!isEmbeddingBlocked) {
417-
message.warning(t("toolPool.message.unavailable"));
418-
}
416+
message.warning(
417+
isEmbeddingBlocked
418+
? t("embedding.agentToolDisableTooltip.content")
419+
: t("toolPool.message.unavailable")
420+
);
419421
return;
420422
}
421423
handleToolSelect(tool, !isSelected, e);
422424
}}
423425
>
424426
{/* Tool name left */}
425427
<div className="flex-1 overflow-hidden">
426-
<div
428+
<div
427429
className={`font-medium text-sm truncate transition-colors duration-300 ${
428430
!isEffectivelyAvailable && !isSelected ? "text-gray-400" : ""
429431
}`}
@@ -437,8 +439,7 @@ function ToolPool({
437439
}}
438440
>
439441
{tool.name}
440-
</div>
441-
442+
</div>
442443
</div>
443444
{/* Settings button right - Tag removed */}
444445
<div className="flex items-center gap-2 ml-2">
@@ -454,9 +455,11 @@ function ToolPool({
454455
message.warning(t("toolPool.message.viewOnlyMode"));
455456
return;
456457
} else {
457-
if (!isEmbeddingBlocked) {
458-
message.warning(t("toolPool.message.unavailable"));
459-
}
458+
message.warning(
459+
isEmbeddingBlocked
460+
? t("embedding.agentToolDisableTooltip.content")
461+
: t("toolPool.message.unavailable")
462+
);
460463
}
461464
return;
462465
}
@@ -480,13 +483,7 @@ function ToolPool({
480483
</div>
481484
);
482485

483-
return kbUnavailableTip ? (
484-
<Tooltip title={kbUnavailableTip} placement="top">
485-
{item}
486-
</Tooltip>
487-
) : (
488-
item
489-
);
486+
return item;
490487
});
491488

492489
// Generate Tabs configuration

frontend/app/[locale]/setup/knowledges/config.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ function DataConfig({ isActive }: DataConfigProps) {
789789
<div className="flex items-center">
790790
<WarningFilled className="text-yellow-500 mt-1 mr-2 text-3xl" />
791791
<div className="ml-3 mt-2">
792-
<div className="text-base text-gray-800 font-semibold whitespace-nowrap">
792+
<div className="text-base text-gray-800 font-semibold">
793793
{t("embedding.knowledgeBaseDisabledWarningModal.title")}
794794
</div>
795795
</div>

frontend/app/[locale]/setup/models/page.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import {motion} from "framer-motion";
1010
import {useAuth} from "@/hooks/useAuth";
1111
import modelEngineService from "@/services/modelEngineService";
1212
import {configStore} from "@/lib/config";
13+
import { configService } from "@/services/configService";
1314
import {
1415
CONNECTION_STATUS,
1516
ConnectionStatus,
16-
MODEL_STATUS
17+
MODEL_STATUS,
1718
} from "@/const/modelConfig";
1819
import log from "@/lib/logger";
1920

@@ -72,6 +73,20 @@ export default function ModelSetupPage() {
7273
}
7374
};
7475

76+
// Centralized behavior: save current config and navigate to next page
77+
const saveAndNavigateNext = async () => {
78+
try {
79+
const currentConfig = configStore.getConfig();
80+
const ok = await configService.saveConfigToBackend(currentConfig as any);
81+
if (!ok) {
82+
message.error(t("setup.page.error.saveConfig"));
83+
}
84+
} catch (e) {
85+
message.error(t("setup.page.error.saveConfig"));
86+
}
87+
router.push("/setup/knowledges");
88+
};
89+
7590
// Handle next button click
7691
const handleNext = async () => {
7792
try {
@@ -116,7 +131,7 @@ export default function ModelSetupPage() {
116131
return;
117132
}
118133

119-
router.push("/setup/knowledges");
134+
await saveAndNavigateNext();
120135
} catch (error) {
121136
log.error(t("setup.page.error.systemError"), error);
122137
message.error(t("setup.page.error.systemError"));
@@ -127,7 +142,7 @@ export default function ModelSetupPage() {
127142
setEmbeddingModalOpen(false);
128143
if (pendingJump) {
129144
setPendingJump(false);
130-
router.push("/setup/knowledges");
145+
await saveAndNavigateNext();
131146
}
132147
};
133148

@@ -163,7 +178,7 @@ export default function ModelSetupPage() {
163178
} catch (e) {
164179
message.error(t("setup.page.error.saveConfig"));
165180
}
166-
router.push("/setup/knowledges");
181+
await saveAndNavigateNext();
167182
}
168183
};
169184

@@ -210,7 +225,9 @@ export default function ModelSetupPage() {
210225
>
211226
<AppModelConfig
212227
onSelectedModelsChange={(selected) => setLiveSelectedModels(selected)}
213-
onEmbeddingConnectivityChange={(status) => setEmbeddingConnectivity(status)}
228+
onEmbeddingConnectivityChange={(status) =>
229+
setEmbeddingConnectivity(status)
230+
}
214231
forwardedRef={modelConfigSectionRef}
215232
/>
216233
</motion.div>

frontend/public/locales/en/common.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,13 +849,14 @@
849849
"embedding.modifyWarningModal.content": "You are attempting to modify an active Embedding model configuration. This will temporarily disable files previously cleaned with that model, created knowledge bases, and generated memory entries.",
850850
"embedding.modifyWarningModal.ok_proceed": "Modify now",
851851
"embedding.modifyWarningModal.cancel": "Cancel",
852-
"embedding.knowledgeBaseDisabledWarningModal.title": "You have not configured an Embedding model, so knowledge base related features are currently unavailable.",
852+
"embedding.knowledgeBaseDisabledWarningModal.title": "You have not configured an Embedding model. Knowledge base features are temporarily disabled.",
853853
"embedding.knowledgeBaseAutoDeselectModal.title": "Automatically Remove Incompatible Knowledge Bases",
854854
"embedding.knowledgeBaseAutoDeselectModal.content": "Due to your change of the Embedding configuration, the incompatible knowledge bases have been automatically removed.",
855855
"embedding.agentToolAutoDeselectModal.title": "Automatically Remove Unavailable Agent Tools",
856856
"embedding.agentToolAutoDeselectModal.content": "Due to not configuring the Embedding model, the unavailable agent tools have been automatically removed.",
857+
"embedding.agentToolDisableTooltip.content": "You have not configured the Embedding model. This agent tool is disabled.",
857858
"embedding.chatMemoryWarningModal.title": "Embedding Model Not Configured",
858-
"embedding.chatMemoryWarningModal.content": "You have not configured the Embedding model, so the memory function is currently unavailable.",
859+
"embedding.chatMemoryWarningModal.content": "You have not configured the Embedding model. Memory functions are temporarily disabled.",
859860
"embedding.chatMemoryWarningModal.tip": "Please contact your tenant administrator for configuration.",
860861
"embedding.chatMemoryWarningModal.ok_config": "Configuration",
861862
"embedding.chatMemoryWarningModal.ok": "Cancel",

frontend/public/locales/zh/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@
854854
"embedding.knowledgeBaseAutoDeselectModal.content": "由于您已修改向量化模型配置,已自动取消选中不兼容的知识库。",
855855
"embedding.agentToolAutoDeselectModal.title": "自动移除无法使用的 Agent 工具",
856856
"embedding.agentToolAutoDeselectModal.content": "由于您尚未配置向量化模型,已自动取消选中无法使用的 Agent 工具。",
857+
"embedding.agentToolDisableTooltip.content": "您尚未配置向量化模型,无法使用依赖向量化能力的 Agent 工具",
857858
"embedding.chatMemoryWarningModal.title": "向量化模型未配置",
858859
"embedding.chatMemoryWarningModal.content": "您尚未配置向量化模型,暂时无法使用记忆功能。",
859860
"embedding.chatMemoryWarningModal.tip": "建议您联系您的租户管理员进行配置。",

0 commit comments

Comments
 (0)