Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(web-frontend): Modified prompts of referenced models and non-saving issues

openJiuwen-botf7fed281a764
diff --git a/jiuwenswarm/channels/web/frontend/src/components/ConfigPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/ConfigPanel/index.tsx
index a5fd220d63..2ca03cee02 100644
--- a/jiuwenswarm/channels/web/frontend/src/components/ConfigPanel/index.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/components/ConfigPanel/index.tsx
@@ -2519,6 +2519,49 @@ export function ConfigPanel({
[draftModels],
);
+ const agentModelReferencesLost = useMemo(() => {
+ if (!hasModelChanges) return [];
+ const lostReferences: { agentName: string; originalModel: string; newModel: string; changedFields: string[] }[] = [];
+ for (const agent of draftAgents) {
+ const matchedModel = draftModels.find(
+ (m) => m.model_name === agent.model.model
+ && m.model_provider === agent.model.provider
+ && m.api_base === agent.model.api_base
+ );
+ const originalMatched = storeAvailableModels.find(
+ (m) => m.model_name === agent.model.model
+ && m.model_provider === agent.model.provider
+ && m.api_base === agent.model.api_base
+ );
+ if (!matchedModel) {
+ if (originalMatched) {
+ lostReferences.push({
+ agentName: agent.name,
+ originalModel: `${originalMatched.model_name} (${originalMatched.model_provider})`,
+ newModel: agent.model.model ? `${agent.model.model} (${agent.model.provider})` : t('config.model.notSelected'),
+ changedFields: ['model_removed'],
+ });
+ }
+ } else if (originalMatched) {
+ const changedFields: string[] = [];
+ if (matchedModel.api_key !== originalMatched.api_key) changedFields.push('api_key');
+ if (matchedModel.alias !== originalMatched.alias) changedFields.push('alias');
+ if (matchedModel.is_default !== originalMatched.is_default) changedFields.push('is_default');
+ if (matchedModel.temperature !== originalMatched.temperature) changedFields.push('temperature');
+ if (matchedModel.timeout !== originalMatched.timeout) changedFields.push('timeout');
+ if (changedFields.length > 0) {
+ lostReferences.push({
+ agentName: agent.name,
+ originalModel: `${originalMatched.model_name} (${originalMatched.model_provider})`,
+ newModel: `${matchedModel.model_name} (${matchedModel.model_provider}) - ${changedFields.join(', ')} changed`,
+ changedFields,
+ });
+ }
+ }
+ }
+ return lostReferences;
+ }, [hasModelChanges, draftAgents, draftModels, storeAvailableModels, t]);
+
const hasAgentsTeamsValidationError = useMemo(() => {
for (const agent of draftAgents) {
if (!agent.name.trim()) return true;
@@ -2702,7 +2745,7 @@ export function ConfigPanel({
<button
type="button"
onClick={() => void handleSaveAndRestart()}
- disabled={!hasChanges || saving || hasMissingRequiredModelFields || hasMissingModelApiKey || hasMissingModelApiBase || hasAgentsTeamsValidationError || (isProcessing && mode !== 'team')}
+ disabled={!hasChanges || saving || hasMissingRequiredModelFields || hasMissingModelApiKey || hasMissingModelApiBase || hasAgentsTeamsValidationError || agentModelReferencesLost.length > 0 || (isProcessing && mode !== 'team')}
className="btn primary !px-3 !py-1.5 disabled:opacity-50 disabled:cursor-not-allowed"
>
{saving ? t('common.saving') : t('common.save')}
@@ -2729,6 +2772,11 @@ export function ConfigPanel({
{t('config.agentsTeamsValidationError')}
</div>
) : null}
+ {!error && agentModelReferencesLost.length > 0 ? (
+ <div className="mb-4 rounded-md border border-amber-500 bg-amber-50 dark:bg-amber-900/20 px-3 py-2 text-sm text-amber-700 dark:text-amber-300">
+ {t('config.model.referenceLostWarning')}: {agentModelReferencesLost.map((r) => r.agentName).join(', ')}
+ </div>
+ ) : null}
{!groups.length ? (
<div className="text-sm text-text-muted flex-1 min-h-0">
@@ -3061,6 +3109,7 @@ export function ConfigPanel({
</div>
</div>
)}
+
</div>
);
}
diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json
index 0a04727e83..6af84d82fd 100644
--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json
+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json
@@ -571,7 +571,9 @@
"referencedBy": "Referenced by {{count}} Agent(s)",
"deleteConfirmTitle": "Delete Model?",
"deleteConfirmMessage": "Are you sure you want to delete model \"{{modelName}}\"?",
- "deleteConfirmMessageSimple": "Model \"{{modelName}}\" is referenced by {{count}} Agent(s). After deletion, related Agents will no longer be able to use this model."
+ "deleteConfirmMessageSimple": "Model \"{{modelName}}\" is referenced by {{count}} Agent(s). After deletion, related Agents will no longer be able to use this model.",
+ "referenceLostWarning": "Model Reference Lost Warning",
+ "notSelected": "No model selected"
},
"agentList": {
"addAgent": "Add Agent",
diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json
index 9378865c7c..72158ebdf5 100644
--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json
+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json
@@ -570,7 +570,9 @@
"referencedBy": "被 {{count}} 个 Agent 引用",
"deleteConfirmTitle": "确认删除模型?",
"deleteConfirmMessage": "确定要删除模型 \"{{modelName}}\" 吗?",
- "deleteConfirmMessageSimple": "模型 \"{{modelName}}\" 正在被 {{count}} 个 Agent 引用,删除后相关 Agent 将无法使用该模型。"
+ "deleteConfirmMessageSimple": "模型 \"{{modelName}}\" 正在被 {{count}} 个 Agent 引用,删除后相关 Agent 将无法使用该模型。",
+ "referenceLostWarning": "Agent引用模型丢失警告",
+ "notSelected": "未选择模型"
},
"agentList": {
"addAgent": "添加Agent",