mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix: fix supervisor group prompt (#11543)
* update content * improve i18n * update i18n * fix group supervisor prompts * update
This commit is contained in:
5
locales/en-US/agentGroup.json
Normal file
5
locales/en-US/agentGroup.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"avatar.sizeExceeded": "Avatar size exceeds limit",
|
||||
"backgroundColor.title": "Background Color",
|
||||
"name.placeholder": "Enter group name"
|
||||
}
|
||||
@@ -288,7 +288,7 @@
|
||||
"shareModal.pdfReady": "PDF is ready",
|
||||
"shareModal.popover.moreOptions": "More share options",
|
||||
"shareModal.popover.privacyWarning.confirm": "I understand, continue",
|
||||
"shareModal.popover.privacyWarning.content": "Please ensure the conversation does not contain any private or sensitive information before sharing. LobeHub is not responsible for any security issues that may arise from sharing.",
|
||||
"shareModal.popover.privacyWarning.content": "Please make sure your conversation doesn't contain any personal or sensitive information. You are responsible for any content you choose to share and its consequences.",
|
||||
"shareModal.popover.privacyWarning.title": "Privacy Notice",
|
||||
"shareModal.popover.title": "Share Topic",
|
||||
"shareModal.popover.visibility": "Visibility",
|
||||
|
||||
5
locales/zh-CN/agentGroup.json
Normal file
5
locales/zh-CN/agentGroup.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"avatar.sizeExceeded": "头像大小超过限制",
|
||||
"backgroundColor.title": "背景颜色",
|
||||
"name.placeholder": "请输入群组名称"
|
||||
}
|
||||
@@ -288,7 +288,7 @@
|
||||
"shareModal.pdfReady": "PDF 已准备就绪",
|
||||
"shareModal.popover.moreOptions": "更多分享方式",
|
||||
"shareModal.popover.privacyWarning.confirm": "我已了解,继续",
|
||||
"shareModal.popover.privacyWarning.content": "分享前请确保对话中不包含任何隐私或敏感信息。因分享而可能产生的任何安全问题,LobeHub 概不负责。",
|
||||
"shareModal.popover.privacyWarning.content": "请确保对话中不含个人隐私或敏感信息,LobeHub 不对任何分享的内容及其产生的后果负责。",
|
||||
"shareModal.popover.privacyWarning.title": "隐私提醒",
|
||||
"shareModal.popover.title": "分享话题",
|
||||
"shareModal.popover.visibility": "可见性",
|
||||
|
||||
@@ -11,7 +11,9 @@ import type { GroupSupervisorContext } from './type';
|
||||
* Replace template variables in system role
|
||||
*/
|
||||
const resolveSystemRole = (ctx: GroupSupervisorContext): string => {
|
||||
return supervisorSystemRole.replace('{{GROUP_TITLE}}', ctx.groupTitle);
|
||||
return supervisorSystemRole
|
||||
.replace('{{GROUP_TITLE}}', ctx.groupTitle)
|
||||
.replace('{{SYSTEM_PROMPT}}', ctx.systemPrompt || '');
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ export const supervisorSystemRole = `You are LobeAI, an intelligent team coordin
|
||||
- Current date: {{date}}
|
||||
</system_context>
|
||||
|
||||
{{SYSTEM_PROMPT}}
|
||||
|
||||
<core_responsibilities>
|
||||
1. **Proactive Group Participation (PRIMARY FOCUS)**
|
||||
|
||||
@@ -21,7 +21,7 @@ import { globalGeneralSelectors } from '@/store/global/selectors';
|
||||
const MAX_AVATAR_SIZE = 1024 * 1024; // 1MB limit for server actions
|
||||
|
||||
const GroupHeader = memo(() => {
|
||||
const { t } = useTranslation(['setting', 'common']);
|
||||
const { t } = useTranslation('agentGroup');
|
||||
const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);
|
||||
|
||||
// Get group meta from agentGroup store
|
||||
@@ -57,7 +57,7 @@ const GroupHeader = memo(() => {
|
||||
const handleAvatarUpload = useCallback(
|
||||
async (file: File) => {
|
||||
if (file.size > MAX_AVATAR_SIZE) {
|
||||
message.error(t('settingAgent.avatar.sizeExceeded', { ns: 'setting' }));
|
||||
message.error(t('avatar.sizeExceeded'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ const GroupHeader = memo(() => {
|
||||
customTabs={[
|
||||
{
|
||||
label: (
|
||||
<Tooltip title={t('settingAgent.backgroundColor.title', { ns: 'setting' })}>
|
||||
<Tooltip title={t('backgroundColor.title')}>
|
||||
<Icon icon={PaletteIcon} size={{ size: 20, strokeWidth: 2.5 }} />
|
||||
</Tooltip>
|
||||
),
|
||||
@@ -164,7 +164,7 @@ const GroupHeader = memo(() => {
|
||||
setLocalTitle(e.target.value);
|
||||
debouncedSaveTitle(e.target.value);
|
||||
}}
|
||||
placeholder={t('settingAgent.name.placeholder', { ns: 'setting' })}
|
||||
placeholder={t('name.placeholder')}
|
||||
style={{
|
||||
fontSize: 36,
|
||||
fontWeight: 600,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Avatar } from '@lobehub/ui';
|
||||
import { Avatar, Icon } from '@lobehub/ui';
|
||||
import { FileTextIcon } from 'lucide-react';
|
||||
import { memo, useCallback, useMemo } from 'react';
|
||||
import { type MouseEvent, memo, useCallback, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import NavItem from '@/features/NavPanel/components/NavItem';
|
||||
@@ -36,25 +36,26 @@ const PageListItem = memo<DocumentItemProps>(({ pageId, className }) => {
|
||||
[pageId, setRenamingPageId],
|
||||
);
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
if (!editing) {
|
||||
selectPage(pageId);
|
||||
}
|
||||
}, [editing, selectPage, pageId]);
|
||||
const handleClick = useCallback(
|
||||
(e: MouseEvent) => {
|
||||
// Skip navigation in current tab when opening in new tab
|
||||
if (e.metaKey || e.ctrlKey) return;
|
||||
if (!editing) {
|
||||
selectPage(pageId);
|
||||
}
|
||||
},
|
||||
[editing, selectPage, pageId],
|
||||
);
|
||||
|
||||
// Icon with emoji support
|
||||
const icon = useMemo(() => {
|
||||
if (emoji) {
|
||||
return <Avatar avatar={emoji} size={28} />;
|
||||
}
|
||||
return FileTextIcon;
|
||||
return <Icon icon={FileTextIcon} size={{ size: 18, strokeWidth: 1.5 }} />;
|
||||
}, [emoji]);
|
||||
|
||||
const dropdownMenu = useDropdownMenu({
|
||||
documentContent: document?.content || undefined,
|
||||
pageId,
|
||||
toggleEditing,
|
||||
});
|
||||
const dropdownMenu = useDropdownMenu({ pageId, toggleEditing });
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -64,6 +65,7 @@ const PageListItem = memo<DocumentItemProps>(({ pageId, className }) => {
|
||||
className={className}
|
||||
contextMenuItems={dropdownMenu}
|
||||
disabled={editing}
|
||||
href={`/page/${pageId}`}
|
||||
icon={icon}
|
||||
key={pageId}
|
||||
onClick={handleClick}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
import { Icon, type MenuProps } from '@lobehub/ui';
|
||||
import { App } from 'antd';
|
||||
import { Copy, CopyPlus, Pencil, Trash2 } from 'lucide-react';
|
||||
import { CopyPlus, Pencil, Trash2 } from 'lucide-react';
|
||||
import { useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { usePageStore } from '@/store/page';
|
||||
|
||||
interface ActionProps {
|
||||
documentContent?: string;
|
||||
pageId: string;
|
||||
toggleEditing: (visible?: boolean) => void;
|
||||
}
|
||||
|
||||
export const useDropdownMenu = ({
|
||||
documentContent,
|
||||
pageId,
|
||||
toggleEditing,
|
||||
}: ActionProps): (() => MenuProps['items']) => {
|
||||
@@ -41,16 +39,6 @@ export const useDropdownMenu = ({
|
||||
});
|
||||
};
|
||||
|
||||
const handleCopy = async () => {
|
||||
if (documentContent) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(documentContent);
|
||||
} catch (error) {
|
||||
console.error('Failed to copy page:', error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleDuplicate = async () => {
|
||||
try {
|
||||
await duplicatePage(pageId);
|
||||
@@ -68,12 +56,12 @@ export const useDropdownMenu = ({
|
||||
label: t('rename'),
|
||||
onClick: () => toggleEditing(true),
|
||||
},
|
||||
{
|
||||
icon: <Icon icon={Copy} />,
|
||||
key: 'copy',
|
||||
label: t('pageList.copyContent', { ns: 'file' }),
|
||||
onClick: handleCopy,
|
||||
},
|
||||
// {
|
||||
// icon: <Icon icon={Copy} />,
|
||||
// key: 'copy',
|
||||
// label: t('pageList.copyContent', { ns: 'file' }),
|
||||
// onClick: handleCopy,
|
||||
// },
|
||||
{
|
||||
icon: <Icon icon={CopyPlus} />,
|
||||
key: 'duplicate',
|
||||
@@ -89,6 +77,6 @@ export const useDropdownMenu = ({
|
||||
onClick: handleDelete,
|
||||
},
|
||||
].filter(Boolean) as MenuProps['items'],
|
||||
[t, toggleEditing, handleCopy, handleDuplicate, handleDelete],
|
||||
[t, toggleEditing, handleDuplicate, handleDelete],
|
||||
);
|
||||
};
|
||||
|
||||
@@ -130,7 +130,6 @@ export const PageEditor: FC<PageEditorProps> = ({
|
||||
<EditorProvider>
|
||||
<PageEditorProvider
|
||||
emoji={emoji}
|
||||
key={pageId}
|
||||
knowledgeBaseId={knowledgeBaseId}
|
||||
onBack={onBack}
|
||||
onDelete={() => deletePage(pageId || '')}
|
||||
|
||||
@@ -40,6 +40,7 @@ const PageExplorer = memo<PageExplorerProps>(({ pageId }) => {
|
||||
return (
|
||||
<PageEditor
|
||||
emoji={emoji}
|
||||
key={pageId}
|
||||
onEmojiChange={handleEmojiChange}
|
||||
onTitleChange={handleTitleChange}
|
||||
pageId={pageId}
|
||||
|
||||
5
src/locales/default/agentGroup.ts
Normal file
5
src/locales/default/agentGroup.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
'avatar.sizeExceeded': 'Avatar size exceeds limit',
|
||||
'backgroundColor.title': 'Background Color',
|
||||
'name.placeholder': 'Enter group name',
|
||||
};
|
||||
@@ -319,7 +319,7 @@ export default {
|
||||
'shareModal.popover.moreOptions': 'More share options',
|
||||
'shareModal.popover.privacyWarning.confirm': 'I understand, continue',
|
||||
'shareModal.popover.privacyWarning.content':
|
||||
'Please ensure the conversation does not contain any private or sensitive information before sharing. LobeHub is not responsible for any security issues that may arise from sharing.',
|
||||
"Please make sure your conversation doesn't contain any personal or sensitive information. You are responsible for any content you choose to share and its consequences.",
|
||||
'shareModal.popover.privacyWarning.title': 'Privacy Notice',
|
||||
'shareModal.popover.title': 'Share Topic',
|
||||
'shareModal.popover.visibility': 'Visibility',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { businessLocales } from '@/business/locales/index';
|
||||
|
||||
import agentGroup from './agentGroup';
|
||||
import auth from './auth';
|
||||
import authError from './authError';
|
||||
import changelog from './changelog';
|
||||
@@ -41,6 +42,7 @@ import ui from './ui';
|
||||
import welcome from './welcome';
|
||||
|
||||
const resources = {
|
||||
agentGroup,
|
||||
auth,
|
||||
authError,
|
||||
changelog,
|
||||
|
||||
@@ -730,7 +730,7 @@ describe('resolveAgentConfig', () => {
|
||||
],
|
||||
groupId: 'group-123',
|
||||
groupTitle: 'Test Group',
|
||||
systemPrompt: 'Custom group system prompt',
|
||||
systemPrompt: 'You are a helpful assistant',
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -193,7 +193,7 @@ export const resolveAgentConfig = (ctx: AgentConfigResolverContext): ResolvedAge
|
||||
availableAgents: groupMembers.map((agent) => ({ id: agent.id, title: agent.title })),
|
||||
groupId: group.id,
|
||||
groupTitle: group.title || 'Group Chat',
|
||||
systemPrompt: group.config?.systemPrompt,
|
||||
systemPrompt: agentConfig.systemRole,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user