Skip to content

Commit

Permalink
✨ feat: Add agent share
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Oct 18, 2023
1 parent c45526a commit 953d7c7
Show file tree
Hide file tree
Showing 34 changed files with 530 additions and 101 deletions.
20 changes: 10 additions & 10 deletions locales/en_US/chat.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"agentDefaultMessage": "Hello, I'm **{{name}}**. You can start chatting with me right away or go to [Assistant Settings](/chat/settings#session={{id}}) to improve my information.",
"agentDefaultMessage": "Hello, I'm **{{name}}**. You can start chatting with me right away or go to [Agent Settings](/chat/settings#session={{id}}) to improve my information.",
"agentDefaultMessageWithSystemRole": "Hello, I'm **{{name}}**, {{systemRole}}. Let's start the conversation!",
"backToBottom": "Go to Latest Messages",
"clearCurrentMessages": "Clear Current Session Messages",
"confirmClearCurrentMessages": "You are about to clear the current session messages. Once cleared, they cannot be recovered. Please confirm your operation.",
"confirmRemoveSessionItemAlert": "You are about to delete this assistant. Once deleted, it cannot be recovered. Please confirm your operation.",
"defaultAgent": "Custom Assistant",
"defaultSession": "Custom Assistant",
"confirmRemoveSessionItemAlert": "You are about to delete this agent. Once deleted, it cannot be recovered. Please confirm your operation.",
"defaultAgent": "Custom Agent",
"defaultSession": "Custom Agent",
"historyRange": "History Range",
"inbox": {
"defaultMessage": "Hello, I'm your intelligent assistant. You can ask me any questions, and I will do my best to answer you. If you need a more professional or customized assistant, you can click on `+` to create a custom assistant.",
"desc": "Activate brain clusters and spark thinking. Your intelligent assistant is here to communicate with you about everything.",
"defaultMessage": "Hello, I'm your intelligent agent. You can ask me any questions, and I will do my best to answer you. If you need a more professional or customized agent, you can click on `+` to create a custom agent.",
"desc": "Activate brain clusters and spark thinking. Your intelligent agent is here to communicate with you about everything.",
"title": "Chat Randomly"
},
"newAgent": "Create New Assistant",
"newAgent": "Create New Agent",
"noDescription": "No description available",
"regenerate": "Regenerate",
"roleAndArchive": "Roles and Archives",
"searchAgentPlaceholder": "Search assistants and conversations...",
"searchAgentPlaceholder": "Search agents and conversations...",
"send": "Send",
"sendPlaceholder": "Enter chat content...",
"shareModal": {
Expand All @@ -29,7 +29,7 @@
"withBackground": "Include Background Image",
"withFooter": "Include Footer",
"withPluginInfo": "Include Plugin Information",
"withSystemRole": "Include Assistant Role Setting"
"withSystemRole": "Include Agent Role Setting"
},
"stop": "Stop",
"temp": "Temporary",
Expand All @@ -50,6 +50,6 @@
"clear": "Clear Translation"
},
"translateTo": "Translate",
"updateAgent": "Update Assistant Information",
"updateAgent": "Update Agent Information",
"warp": "Line Break"
}
7 changes: 7 additions & 0 deletions locales/en_US/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@
},
"title": "Theme Settings"
},
"submitAgentModal": {
"tooltips": "Share to Assistant Market",
"button": "Submit Assistant",
"identifier": "Identifier",
"metaMiss": "Please complete the assistant information before submitting. It should include name, description, and tags.",
"placeholder": "Please enter a unique identifier for the assistant, such as web-development."
},
"tab": {
"agent": "Default Agent",
"common": "Common Settings",
Expand Down
7 changes: 7 additions & 0 deletions locales/ja_JP/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@
},
"title": "テーマ設定"
},
"submitAgentModal": {
"tooltips": "アシスタントマーケットに共有する",
"button": "助手を提出する",
"identifier": "識別子 エージェントの識別子",
"metaMiss": "エージェント情報を入力してから提出してください。名前、説明、およびタグが必要です",
"placeholder": "エージェントの識別子を入力してください。一意である必要があります。例:web-development"
},
"tab": {
"agent": "デフォルトのアシスタント",
"common": "一般設定",
Expand Down
7 changes: 7 additions & 0 deletions locales/ko_KR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@
},
"title": "테마 설정"
},
"submitAgentModal": {
"tooltips": "도우미 마켓에 공유",
"button": "도우미 제출",
"identifier": "식별자 도우미 식별자",
"metaMiss": "도우미 정보를 입력한 후 제출하세요. 이름, 설명 및 태그를 포함해야 합니다.",
"placeholder": "도우미의 식별자를 입력하세요. 고유해야 하며, 예를 들어 web-development과 같은 형식이어야 합니다."
},
"tab": {
"agent": "기본 도우미",
"common": "일반 설정",
Expand Down
3 changes: 2 additions & 1 deletion locales/ru_RU/common.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"about": "Наш Github",
"advanceSettings": "Дополнительные настройки",
"agentDefaultMessage": "Здравствуйте, я **{{name}}**. Вы можете начать общаться со мной прямо сейчас или перейти на [Assistant Settings](/chat/settings#session={{id}}) для моей настройки.",
"agentDefaultMessage": "Здравствуйте, я **{{name}}**. Вы можете начать общаться со мной прямо сейчас или перейти на [Agent Settings](/chat/settings#session={{id}}) для моей настройки.",
"agentMaxToken": "Максимальная длина сессии",
"agentModel": "Модель",
"agentProfile": "Информация о помощнике",
"appInitializing": "LobeChat запускается, пожалуйста, подождите...",
Expand Down
7 changes: 7 additions & 0 deletions locales/ru_RU/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@
},
"title": "Настройки темы"
},
"submitAgentModal": {
"tooltips": "Поделиться на рынке помощников",
"button": "Отправить агента",
"identifier": "Идентификатор агента",
"metaMiss": "Пожалуйста, заполните информацию об агенте перед отправкой. Необходимо указать имя, описание и метки",
"placeholder": "Введите идентификатор агента, который должен быть уникальным, например, web-development"
},
"tab": {
"agent": "Помощник по умолчанию",
"common": "Общие настройки",
Expand Down
7 changes: 7 additions & 0 deletions locales/zh_CN/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@
},
"title": "主题设置"
},
"submitAgentModal": {
"button": "提交助手",
"identifier": "identifier 助手标识符",
"metaMiss": "请补全助手信息后提交,需要包含名称、描述和标签",
"placeholder": "请输入助手的标识符,需要是唯一的,比如 web-development",
"tooltips": "分享到助手市场"
},
"tab": {
"agent": "默认助手",
"common": "通用设置",
Expand Down
7 changes: 7 additions & 0 deletions locales/zh_TW/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@
},
"title": "主題設定"
},
"submitAgentModal": {
"tooltips": "分享到助手市場",
"button": "提交助手",
"identifier": "助手識別符",
"metaMiss": "請補全助手資訊後提交,需要包含名稱、描述和標籤",
"placeholder": "請輸入助手的識別符,需要是唯一的,例如 web-development"
},
"tab": {
"agent": "預設助理",
"common": "通用設定",
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@emoji-mart/data": "^1",
"@emoji-mart/react": "^1",
"@icons-pack/react-simple-icons": "^9",
"@lobehub/chat-plugin-sdk": "^1.17.8",
"@lobehub/chat-plugin-sdk": "latest",
"@lobehub/chat-plugins-gateway": "latest",
"@lobehub/ui": "latest",
"@vercel/analytics": "^1",
Expand All @@ -79,7 +79,7 @@
"antd-style": "^3.5",
"brotli-wasm": "^1",
"chroma-js": "^2",
"copy-to-clipboard": "^3.3.3",
"copy-to-clipboard": "^3",
"dayjs": "^1",
"emoji-mart": "^5",
"fast-deep-equal": "^3",
Expand All @@ -98,6 +98,7 @@
"openai": "^4.10.0",
"polished": "^4",
"posthog-js": "^1",
"query-string": "^8",
"react": "^18",
"react-dom": "^18",
"react-hotkeys-hook": "^4",
Expand Down Expand Up @@ -146,7 +147,7 @@
"eslint": "^8",
"husky": "^8",
"jsdom": "^22",
"lint-staged": "^15.0.0",
"lint-staged": "^15",
"lodash": "^4",
"next-pwa": "^5",
"node-fetch": "^3",
Expand Down
5 changes: 4 additions & 1 deletion scripts/i18nWorkflow/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ export const readJSON = (filePath: string) => {
return JSON.parse(data);
};

export const replaceAssistantToAgent = (text: string) =>
text.replaceAll('assistant', 'agent').replaceAll('Assistant', 'Agent');

export const writeJSON = (filePath: string, data: any) => {
const jsonStr = JSON.stringify(data, null, 2);
writeFileSync(filePath, jsonStr, 'utf8');
writeFileSync(filePath, replaceAssistantToAgent(jsonStr), 'utf8');
};

export const genResourcesContent = (locales: string[]) => {
Expand Down
5 changes: 4 additions & 1 deletion src/app/chat/features/TopicListContent/SystemRole/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import AgentInfo from '@/features/AgentInfo';
import { useSessionChatInit, useSessionStore } from '@/store/session';
import { agentSelectors } from '@/store/session/selectors';

Expand All @@ -15,8 +16,9 @@ const SystemRole = memo(() => {
const [openModal, setOpenModal] = useState(false);
const [editing, setEditing] = useState(false);
const { styles } = useStyles();
const [systemRole, updateAgentConfig] = useSessionStore((s) => [
const [systemRole, meta, updateAgentConfig] = useSessionStore((s) => [
agentSelectors.currentAgentSystemRole(s),
agentSelectors.currentAgentMeta(s),
s.updateAgentConfig,
]);

Expand Down Expand Up @@ -57,6 +59,7 @@ const SystemRole = memo(() => {
<EditableMessage
classNames={{ markdown: styles.prompt }}
editing={editing}
model={{ extra: <AgentInfo meta={meta} style={{ marginBottom: 16 }} /> }}
onChange={(e) => {
updateAgentConfig({ systemRole: e });
}}
Expand Down
13 changes: 0 additions & 13 deletions src/app/chat/settings/(desktop)/Header/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { ChatHeader, ChatHeaderTitle } from '@lobehub/ui';
import { useRouter } from 'next/navigation';
import { ReactNode, memo } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import HeaderContent from '@/app/chat/settings/features/HeaderContent';
import { pathString } from '@/utils/url';

const Header = memo<{ children: ReactNode }>(({ children }) => {
const Header = memo(() => {
const { t } = useTranslation('setting');
const router = useRouter();

return (
<ChatHeader
left={<ChatHeaderTitle title={t('header.session')} />}
onBackClick={() => router.push(pathString('/chat', { hash: location.hash }))}
right={children}
right={<HeaderContent />}
showBackButton
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/chat/settings/(desktop)/layout.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SafeSpacing from '@/components/SafeSpacing';
import { HEADER_HEIGHT } from '@/const/layoutTokens';

import Layout from '../../(desktop)/layout.desktop';
import Header from './Header';
import Header from './features/Header';

export default memo(({ children }: PropsWithChildren) => (
<Layout>
Expand Down
12 changes: 0 additions & 12 deletions src/app/chat/settings/(mobile)/Header.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { MobileNavBar, MobileNavBarTitle } from '@lobehub/ui';
import { useRouter } from 'next/navigation';
import { type ReactNode, memo } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import HeaderContent from '@/app/chat/settings/features/HeaderContent';
import { pathString } from '@/utils/url';

const Header = memo<{ children: ReactNode }>(({ children }) => {
const Header = memo(() => {
const { t } = useTranslation('setting');
const router = useRouter();

return (
<MobileNavBar
center={<MobileNavBarTitle title={t('header.session')} />}
onBackClick={() => router.push(pathString('/chat/mobile', { hash: location.hash }))}
right={children}
right={<HeaderContent />}
showBackButton
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/chat/settings/(mobile)/layout.mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PropsWithChildren, memo } from 'react';

import AppLayoutMobile from '@/layout/AppLayout.mobile';

import Header from './Header';
import Header from './features/Header';

export default memo(({ children }: PropsWithChildren) => (
<AppLayoutMobile navBar={<Header />}>{children}</AppLayoutMobile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { exportSingleAgent, exportSingleSession } from '@/helpers/export';
import { useSessionStore } from '@/store/session';

import SubmitAgentButton from './SubmitAgentButton';

export const HeaderContent = memo<{ mobile?: boolean }>(() => {
const { t } = useTranslation('setting');
const id = useSessionStore((s) => s.activeId);

const { mobile } = useResponsive();

const items = useMemo<MenuProps['items']>(
Expand Down Expand Up @@ -41,8 +44,13 @@ export const HeaderContent = memo<{ mobile?: boolean }>(() => {
const size = mobile ? MOBILE_HEADER_ICON_SIZE : { fontSize: 24 };

return (
<Dropdown arrow={false} menu={{ items }} trigger={['click']}>
<ActionIcon icon={HardDriveDownload} size={size} title={t('export', { ns: 'common' })} />
</Dropdown>
<>
<SubmitAgentButton />
<Dropdown arrow={false} menu={{ items }} trigger={['click']}>
<ActionIcon icon={HardDriveDownload} size={size} title={t('export', { ns: 'common' })} />
</Dropdown>
</>
);
});

export default HeaderContent;
Loading

0 comments on commit 953d7c7

Please sign in to comment.