Skip to content

Commit

Permalink
🐛 fix: fix auto avatar (lobehub#2939)
Browse files Browse the repository at this point in the history
* 🐛 fix: fix auto avatar

* 💄 style: add auto avatar

* 🌐 chore: update locale

* ♻️ refactor: add instance for AgentSetting
  • Loading branch information
arvinxx authored Jun 19, 2024
1 parent 53d91e6 commit f40300c
Show file tree
Hide file tree
Showing 42 changed files with 370 additions and 69 deletions.
5 changes: 5 additions & 0 deletions locales/ar/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "نموذج إنشاء بيانات المساعد",
"modelDesc": "يحدد النموذج المستخدم لإنشاء اسم المساعد ووصفه وصورته وعلامته",
"title": "توليد معلومات المساعد تلقائيًا"
},
"title": "مساعد النظام",
"topic": {
"label": "نموذج تسمية الموضوع",
Expand Down
5 changes: 5 additions & 0 deletions locales/bg-BG/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Модел за генериране на помощни метаданни",
"modelDesc": "Модел, определен за генериране на име, описание, профилна снимка и етикети на помощник",
"title": "Автоматично генериране на информация за помощник"
},
"title": "Системен асистент",
"topic": {
"label": "Модел за именуване на теми",
Expand Down
5 changes: 5 additions & 0 deletions locales/de-DE/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Assistentenmetadaten-Generierungsmodell",
"modelDesc": "Das Modell, das zur Generierung von Assistentennamen, -beschreibungen, -avatars und -tags verwendet wird",
"title": "Automatische Generierung von Assistenteninformationen"
},
"title": "Systemassistent",
"topic": {
"label": "Themenbenennungsmodell",
Expand Down
5 changes: 5 additions & 0 deletions locales/en-US/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Assistant Metadata Generation Model",
"modelDesc": "Model designated for generating assistant name, description, avatar, and tags",
"title": "Automatically Generate Assistant Information"
},
"title": "System Assistants",
"topic": {
"label": "Topic Naming Model",
Expand Down
5 changes: 5 additions & 0 deletions locales/es-ES/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Modelo de generación de metadatos de asistente",
"modelDesc": "Modelo designado para generar el nombre, descripción, avatar y etiquetas del asistente",
"title": "Generación automática de información del asistente"
},
"title": "Asistente del sistema",
"topic": {
"label": "Modelo de nombramiento de temas",
Expand Down
5 changes: 5 additions & 0 deletions locales/fr-FR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Modèle de génération de métadonnées d'assistant",
"modelDesc": "Modèle spécifié pour générer le nom, la description, l'avatar et les balises de l'assistant",
"title": "Génération automatique des informations de l'assistant"
},
"title": "Agent système",
"topic": {
"label": "Modèle de nommage des sujets",
Expand Down
5 changes: 5 additions & 0 deletions locales/it-IT/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Modello di generazione metadati assistente",
"modelDesc": "Modello specificato per generare nome, descrizione, avatar e etichetta dell'assistente",
"title": "Genera automaticamente informazioni sull'assistente"
},
"title": "Assistente di sistema",
"topic": {
"label": "Modello di denominazione degli argomenti",
Expand Down
5 changes: 5 additions & 0 deletions locales/ja-JP/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "アシスタントメタデータ生成モデル",
"modelDesc": "アシスタントの名前、説明、アバター、ラベルを生成するために指定されたモデル",
"title": "アシスタント情報の自動生成"
},
"title": "システムアシスタント",
"topic": {
"label": "トピックネーミングモデル",
Expand Down
5 changes: 5 additions & 0 deletions locales/ko-KR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "어시스턴트 메타 생성 모델",
"modelDesc": "어시스턴트 이름, 설명, 프로필 이미지, 레이블을 생성하는 데 사용되는 모델을 지정합니다.",
"title": "어시스턴트 정보 자동 생성"
},
"title": "시스템 도우미",
"topic": {
"label": "주제 명명 모델",
Expand Down
5 changes: 5 additions & 0 deletions locales/nl-NL/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Assistentmetadata-generatiemodel",
"modelDesc": "Model voor het genereren van assistentnaam, beschrijving, profielfoto en labels",
"title": "Automatisch assistentinformatie genereren"
},
"title": "Systeemassistent",
"topic": {
"label": "Onderwerp Naamgevingsmodel",
Expand Down
5 changes: 5 additions & 0 deletions locales/pl-PL/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Model generowania metadanych asystenta",
"modelDesc": "Określa model używany do generowania nazwy, opisu, awatara i etykiety asystenta",
"title": "Automatyczne generowanie informacji o asystencie"
},
"title": "Asystent Systemowy",
"topic": {
"label": "Model nazewnictwa tematów",
Expand Down
5 changes: 5 additions & 0 deletions locales/pt-BR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Modelo de Geração de Metadados do Assistente",
"modelDesc": "Especifica o modelo usado para gerar o nome, descrição, avatar e tags do assistente",
"title": "Geração Automática de Informações do Assistente"
},
"title": "Assistente do Sistema",
"topic": {
"label": "Modelo de Nomeação de Tópicos",
Expand Down
5 changes: 5 additions & 0 deletions locales/ru-RU/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Модель генерации метаданных агента",
"modelDesc": "Модель, используемая для генерации имени агента, описания, аватара и меток",
"title": "Автоматическое создание информации об агенте"
},
"title": "Системный агент",
"topic": {
"label": "Модель именования тем",
Expand Down
5 changes: 5 additions & 0 deletions locales/tr-TR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Asistan Meta Veri Oluşturma Modeli",
"modelDesc": "Asistan adı, açıklaması, avatar ve etiket oluşturmak için belirlenen model",
"title": "Asistan Bilgilerini Otomatik Oluştur"
},
"title": "Sistem Asistanı",
"topic": {
"label": "Konu Adlandırma Modeli",
Expand Down
5 changes: 5 additions & 0 deletions locales/vi-VN/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "Mô hình tạo siêu dữ liệu trợ lý",
"modelDesc": "Xác định mô hình được sử dụng để tạo tên, mô tả, hình đại diện, nhãn cho trợ lý",
"title": "Tự động tạo thông tin trợ lý"
},
"title": "Trợ lý hệ thống",
"topic": {
"label": "Mô hình đặt tên chủ đề",
Expand Down
5 changes: 5 additions & 0 deletions locales/zh-CN/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "助理元数据生成模型",
"modelDesc": "指定用于生成助理名称、描述、头像、标签的模型",
"title": "自动生成助理信息"
},
"title": "系统助手",
"topic": {
"label": "话题命名模型",
Expand Down
5 changes: 5 additions & 0 deletions locales/zh-TW/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
}
},
"systemAgent": {
"agentMeta": {
"label": "助理元數據生成模型",
"modelDesc": "指定用於生成助理名稱、描述、頭像、標籤的模型",
"title": "自動生成助理資訊"
},
"title": "系統助手",
"topic": {
"label": "話題命名模型",
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/chat/(workspace)/@conversation/default.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ChatHydration from '@/components/StoreHydration/ChatHydration';
import Conversation from '@/features/Conversation';
import { isMobileDevice } from '@/utils/responsive';

import ChatHydration from './features/ChatHydration';
import DesktopChatInput from './features/ChatInput/Desktop';
import MobileChatInput from './features/ChatInput/Mobile';

Expand Down
4 changes: 2 additions & 2 deletions src/app/(main)/chat/settings/features/EditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import PageTitle from '@/components/PageTitle';
import AgentSetting from '@/features/AgentSetting';
import { AgentSettings } from '@/features/AgentSetting';
import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
import { useSessionStore } from '@/store/session';
Expand All @@ -26,7 +26,7 @@ const EditPage = memo(() => {
return (
<>
<PageTitle title={t('header.sessionWithName', { name: title })} />
<AgentSetting
<AgentSettings
config={config}
id={id}
meta={meta}
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/settings/agent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import isEqual from 'fast-deep-equal';
import { memo } from 'react';

import { INBOX_SESSION_ID } from '@/const/session';
import AgentSettings from '@/features/AgentSetting';
import { AgentSettings } from '@/features/AgentSetting';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';

Expand Down
58 changes: 58 additions & 0 deletions src/app/(main)/settings/system-agent/features/AgentMeta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use client';

import { Form, type ItemGroup } from '@lobehub/ui';
import { Form as AntForm } from 'antd';
import isEqual from 'fast-deep-equal';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import { FORM_STYLE } from '@/const/layoutTokens';
import ModelSelect from '@/features/ModelSelect';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';

import { useSyncSystemAgent } from './useSync';

type SettingItemGroup = ItemGroup;

const systemAgentKey = 'agentMeta';
const AgentMeta = memo(() => {
const { t } = useTranslation('setting');
const [form] = AntForm.useForm();

const settings = useUserStore(settingsSelectors.currentSystemAgent, isEqual);
const [updateSystemAgent] = useUserStore((s) => [s.updateSystemAgent]);

const systemAgentSettings: SettingItemGroup = {
children: [
{
children: (
<ModelSelect
onChange={(props) => {
updateSystemAgent(systemAgentKey, props);
}}
showAbility={false}
/>
),
desc: t(`systemAgent.${systemAgentKey}.modelDesc`),
label: t(`systemAgent.${systemAgentKey}.label`),
name: [systemAgentKey, 'model'],
},
],
title: t(`systemAgent.${systemAgentKey}.title`),
};

useSyncSystemAgent(form);

return (
<Form
form={form}
initialValues={settings}
items={[systemAgentSettings]}
variant={'pure'}
{...FORM_STYLE}
/>
);
});

export default AgentMeta;
1 change: 1 addition & 0 deletions src/app/(main)/settings/system-agent/features/Topic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const Topic = memo(() => {
onChange={(props) => {
updateSystemAgent('topic', props);
}}
showAbility={false}
/>
),
desc: t('systemAgent.topic.modelDesc'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const Translation = memo(() => {
onChange={(props) => {
updateSystemAgent('translation', props);
}}
showAbility={false}
/>
),
desc: t('systemAgent.translation.modelDesc'),
Expand Down
2 changes: 2 additions & 0 deletions src/app/(main)/settings/system-agent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AgentMeta from './features/AgentMeta';
import Topic from './features/Topic';
import Translation from './features/Translation';

Expand All @@ -6,6 +7,7 @@ const Page = () => {
<>
<Topic />
<Translation />
<AgentMeta />
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/settings/system-agent/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const generateMetadata = async () => {

return metadataModule.generate({
description: t('header.desc'),
title: t('tab.systemAgent'),
title: t('tab.system-agent'),
url: '/settings/system-agent',
});
};
Expand Down
1 change: 1 addition & 0 deletions src/const/settings/systemAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const DEFAULT_SYSTEM_AGENT_ITEM: SystemAgentItem = {
};

export const DEFAULT_SYSTEM_AGENT_CONFIG: UserSystemAgentConfig = {
agentMeta: DEFAULT_SYSTEM_AGENT_ITEM,
topic: DEFAULT_SYSTEM_AGENT_ITEM,
translation: DEFAULT_SYSTEM_AGENT_ITEM,
};
Loading

0 comments on commit f40300c

Please sign in to comment.