Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
bentwnghk committed Feb 10, 2025
2 parents 5967475 + ae4aa0e commit a15e091
Show file tree
Hide file tree
Showing 53 changed files with 353 additions and 820 deletions.
607 changes: 2 additions & 605 deletions changelog/v1.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/self-hosting/platform/btpanel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ To install aaPanel, go to the [aaPanel](https://www.aapanel.com/new/download.htm

6. After submission, the panel will automatically initialize the application, which will take about `1-3` minutes. It can be accessed after the initialization is completed.

<Callout type="warning">
⚠️ Do not enable any form of cache in the reverse proxy settings of the panel to avoid affecting the normal operation of the service. Read more at https://github.com/lobehub/lobe-chat/discussions/5986
</Callout>

## Visit LobeChat

- If you have set a domain name, please directly enter the domain name in the browser address bar, such as `http://demo.lobechat`, to access the `LobeChat` console.
Expand Down
4 changes: 4 additions & 0 deletions docs/self-hosting/platform/btpanel.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ tags:

5. 提交后面板会自动进行应用初始化,大概需要`1-3`分钟,初始化完成后即可访问。

<Callout type="warning">
⚠️ 请不要在面板的反向代理设置中开启任何形式的缓存,以免影响服务的正常运行。详情请见 https://github.com/lobehub/lobe-chat/discussions/5986
</Callout>

## 访问 Mr.🆖 AI

- 如果您填写域名,请在浏览器输入您的域名访问,如`http://demo.Mr.🆖 AI`,即可访问 `Mr.🆖 AI` 页面。
Expand Down
4 changes: 4 additions & 0 deletions docs/self-hosting/server-database/docker-compose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ The script supports the following deployment modes; please choose the appropriat
proxy_set_header X-Forwarded-Proto $scheme; # Keep the request protocol
}
```

⚠️ If you are using such panel software,
please do not enable any form of caching in the reverse proxy settings of such panel software to avoid affecting the normal operation of the service.
Read more at https://github.com/lobehub/lobe-chat/discussions/5986
</Callout>

### Complete Remaining Configuration in Interactive Script
Expand Down
3 changes: 3 additions & 0 deletions docs/self-hosting/server-database/docker-compose.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ bash <(curl -fsSL https://lobe.li/setup.sh) -l zh_CN
proxy_set_header X-Forwarded-Proto $scheme; # 保留请求协议
}
```

⚠️ 请不要在此类面板软件的反向代理设置中开启任何形式的缓存,以免影响服务的正常运行。
详情请见 https://github.com/lobehub/lobe-chat/discussions/5986
</Callout>

### 在交互式脚本中完成剩余配置
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import useSWR from 'swr';
import urlJoin from 'url-join';

import { assistantService } from '@/services/assistant';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';
import { DiscoverAssistantItem } from '@/types/discover';

const { Paragraph } = Typography;
Expand Down Expand Up @@ -60,7 +60,7 @@ const useStyles = createStyles(({ css, token, responsive }) => ({

const AgentsSuggest = memo<{ mobile?: boolean }>(({ mobile }) => {
const { t } = useTranslation('welcome');
const locale = useUserStore(userGeneralSettingsSelectors.currentLanguage);
const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);
const [sliceStart, setSliceStart] = useState(0);

const { data: assistantList, isLoading } = useSWR(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const DefaultMode = memo(() => {
label: t('defaultList'),
},
].filter(Boolean) as CollapseProps['items'],
[customSessionGroups, pinnedSessions, defaultSessions],
[t, customSessionGroups, pinnedSessions, defaultSessions],
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import { AGENTS_INDEX_GITHUB_ISSUE } from '@/const/url';
import AgentInfo from '@/features/AgentInfo';
import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';
import { useSessionStore } from '@/store/session';
import { sessionMetaSelectors } from '@/store/session/selectors';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';

const SubmitAgentModal = memo<ModalProps>(({ open, onCancel }) => {
const { t } = useTranslation('setting');
const [identifier, setIdentifier] = useState('');
const systemRole = useAgentStore(agentSelectors.currentAgentSystemRole);
const theme = useTheme();
const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
const language = useUserStore((s) => userGeneralSettingsSelectors.currentLanguage(s));
const language = useGlobalStore(globalGeneralSelectors.currentLanguage);

const isMetaPass = Boolean(
meta && meta.title && meta.description && (meta.tags as string[])?.length > 0 && meta.avatar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,34 @@ import { Form, type ItemGroup, SelectWithImg, SliderWithInput } from '@bentwnghk
import { Select } from 'antd';
import isEqual from 'fast-deep-equal';
import { Monitor, Moon, Sun } from 'lucide-react';
import { useRouter } from 'next/navigation';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import { useSyncSettings } from '@/app/[variants]/(main)/settings/hooks/useSyncSettings';
import { FORM_STYLE } from '@/const/layoutTokens';
import { imageUrl } from '@/const/url';
import { Locales, localeOptions } from '@/locales/resources';
import { useGlobalStore } from '@/store/global';
import { useUserStore } from '@/store/user';
import { settingsSelectors, userGeneralSettingsSelectors } from '@/store/user/selectors';
import { switchLang } from '@/utils/client/switchLang';

import { ThemeSwatchesNeutral, ThemeSwatchesPrimary } from './ThemeSwatches';

type SettingItemGroup = ItemGroup;

const Theme = memo(() => {
const { t } = useTranslation('setting');
const router = useRouter();

const [form] = Form.useForm();
const settings = useUserStore(settingsSelectors.currentSettings, isEqual);
const themeMode = useUserStore(userGeneralSettingsSelectors.currentThemeMode);
const [setThemeMode, setSettings] = useUserStore((s) => [s.switchThemeMode, s.setSettings]);

useSyncSettings(form);
const [switchLocale] = useGlobalStore((s) => [s.switchLocale]);

const handleLangChange = (value: Locales) => {
switchLang(value);
router.refresh();
switchLocale(value);
};

const theme: SettingItemGroup = {
Expand Down
4 changes: 2 additions & 2 deletions src/chains/__tests__/summaryAgentName.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Mock, describe, expect, it } from 'vitest';

import { globalHelpers } from '@/store/user/helpers';
import { globalHelpers } from '@/store/global/helpers';

import { chainSummaryAgentName } from '../summaryAgentName';

// Mock the getCurrentLanguage function
vi.mock('@/store/user/helpers', () => ({
vi.mock('@/store/global/helpers', () => ({
globalHelpers: {
getCurrentLanguage: vi.fn(),
},
Expand Down
4 changes: 2 additions & 2 deletions src/chains/__tests__/summaryDescription.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Mock, describe, expect, it, vi } from 'vitest';

import { globalHelpers } from '@/store/user/helpers';
import { globalHelpers } from '@/store/global/helpers';

import { chainSummaryDescription } from '../summaryDescription';

// Mock the globalHelpers.getCurrentLanguage function
vi.mock('@/store/user/helpers', () => ({
vi.mock('@/store/global/helpers', () => ({
globalHelpers: {
getCurrentLanguage: vi.fn(() => 'en-US'),
},
Expand Down
2 changes: 1 addition & 1 deletion src/chains/__tests__/summaryHistory.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Mock, describe, expect, it, vi } from 'vitest';

import { chatHelpers } from '@/store/chat/helpers';
import { globalHelpers } from '@/store/user/helpers';
import { globalHelpers } from '@/store/global/helpers';
import { ChatMessage } from '@/types/message';
import { OpenAIChatMessage } from '@/types/openai/chat';

Expand Down
4 changes: 2 additions & 2 deletions src/chains/__tests__/summaryTags.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Mock, describe, expect, it } from 'vitest';

import { globalHelpers } from '@/store/user/helpers';
import { globalHelpers } from '@/store/global/helpers';

import { chainSummaryTags } from '../summaryTags';

// Mock the getCurrentLanguage function
vi.mock('@/store/user/helpers', () => ({
vi.mock('@/store/global/helpers', () => ({
globalHelpers: {
getCurrentLanguage: vi.fn(),
},
Expand Down
4 changes: 2 additions & 2 deletions src/chains/__tests__/summaryTitle.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Mock, describe, expect, it, vi } from 'vitest';

import { chatHelpers } from '@/store/chat/helpers';
import { globalHelpers } from '@/store/user/helpers';
import { globalHelpers } from '@/store/global/helpers';
import { OpenAIChatMessage } from '@/types/openai/chat';

import { chainSummaryTitle } from '../summaryTitle';

// Mock the getCurrentLanguage function
vi.mock('@/store/user/helpers', () => ({
vi.mock('@/store/global/helpers', () => ({
globalHelpers: {
getCurrentLanguage: vi.fn(),
},
Expand Down
2 changes: 1 addition & 1 deletion src/chains/summaryAgentName.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { globalHelpers } from '@/store/user/helpers';
import { globalHelpers } from '@/store/global/helpers';
import { ChatStreamPayload } from '@/types/openai/chat';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/chains/summaryDescription.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { globalHelpers } from '@/store/user/helpers';
import { globalHelpers } from '@/store/global/helpers';
import { ChatStreamPayload } from '@/types/openai/chat';

export const chainSummaryDescription = (content: string): Partial<ChatStreamPayload> => ({
Expand Down
2 changes: 1 addition & 1 deletion src/chains/summaryTags.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { globalHelpers } from '@/store/user/helpers';
import { globalHelpers } from '@/store/global/helpers';
import { ChatStreamPayload } from '@/types/openai/chat';

export const chainSummaryTags = (content: string): Partial<ChatStreamPayload> => ({
Expand Down
2 changes: 1 addition & 1 deletion src/chains/summaryTitle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { globalHelpers } from '@/store/user/helpers';
import { globalHelpers } from '@/store/global/helpers';
import { ChatStreamPayload, OpenAIChatMessage } from '@/types/openai/chat';

export const chainSummaryTitle = (messages: OpenAIChatMessage[]): Partial<ChatStreamPayload> => {
Expand Down
1 change: 0 additions & 1 deletion src/const/settings/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ import { UserGeneralConfig } from '@/types/user/settings';

export const DEFAULT_COMMON_SETTINGS: UserGeneralConfig = {
fontSize: 14,
language: 'auto',
themeMode: 'auto',
};
6 changes: 3 additions & 3 deletions src/features/AgentSetting/AgentMeta/AutoGenerateAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';

const EmojiPicker = dynamic(() => import('@bentwnghk/ui/es/EmojiPicker'), { ssr: false });

Expand All @@ -24,7 +24,7 @@ const AutoGenerateAvatar = memo<AutoGenerateAvatarProps>(
({ loading, background, value, onChange, onGenerate, canAutoGenerate }) => {
const { t } = useTranslation('common');
const theme = useTheme();
const locale = useUserStore(userGeneralSettingsSelectors.currentLanguage);
const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);

return (
<Flexbox>
Expand Down
8 changes: 4 additions & 4 deletions src/features/AgentSetting/AgentTTS/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';

import { FORM_STYLE } from '@/const/layoutTokens';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';

import { useStore } from '../store';
import { useAgentSyncSettings } from '../useSyncAgemtSettings';
Expand All @@ -23,8 +23,8 @@ const { openaiVoiceOptions, localeOptions } = VoiceList;
const AgentTTS = memo(() => {
const { t } = useTranslation('setting');
const [form] = Form.useForm();
const voiceList = useUserStore((s) => {
const locale = userGeneralSettingsSelectors.currentLanguage(s);
const voiceList = useGlobalStore((s) => {
const locale = globalGeneralSelectors.currentLanguage(s);
return (all?: boolean) => new VoiceList(all ? undefined : locale);
});
const [showAllLocaleVoice, ttsService, updateConfig] = useStore((s) => [
Expand Down
6 changes: 4 additions & 2 deletions src/features/ChatInput/STT/browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/slices/chat';
import { useChatStore } from '@/store/chat';
import { chatSelectors } from '@/store/chat/selectors';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';
import { useUserStore } from '@/store/user';
import { settingsSelectors, userGeneralSettingsSelectors } from '@/store/user/selectors';
import { settingsSelectors } from '@/store/user/selectors';
import { ChatMessageError } from '@/types/message';
import { getMessageError } from '@/utils/fetch';

Expand All @@ -22,7 +24,7 @@ interface STTConfig extends SWRConfiguration {
const useBrowserSTT = (config: STTConfig) => {
const ttsSettings = useUserStore(settingsSelectors.currentTTS, isEqual);
const ttsAgentSettings = useAgentStore(agentSelectors.currentAgentTTS, isEqual);
const locale = useUserStore(userGeneralSettingsSelectors.currentLanguage);
const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);

const autoStop = ttsSettings.sttAutoStop;
const sttLocale =
Expand Down
6 changes: 4 additions & 2 deletions src/features/ChatInput/STT/openai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
import { useChatStore } from '@/store/chat';
import { chatSelectors } from '@/store/chat/slices/message/selectors';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';
import { useUserStore } from '@/store/user';
import { settingsSelectors, userGeneralSettingsSelectors } from '@/store/user/selectors';
import { settingsSelectors } from '@/store/user/selectors';
import { ChatMessageError } from '@/types/message';
import { getMessageError } from '@/utils/fetch';

Expand All @@ -25,7 +27,7 @@ interface STTConfig extends SWRConfiguration {
const useOpenaiSTT = (config: STTConfig) => {
const ttsSettings = useUserStore(settingsSelectors.currentTTS, isEqual);
const ttsAgentSettings = useAgentStore(agentSelectors.currentAgentTTS, isEqual);
const locale = useUserStore(userGeneralSettingsSelectors.currentLanguage);
const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);

const autoStop = ttsSettings.sttAutoStop;
const sttLocale =
Expand Down
6 changes: 3 additions & 3 deletions src/features/Conversation/Extras/TTS/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { Md5 } from 'ts-md5';

import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/slices/chat';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';

import FilePlayer from './FilePlayer';
import InitPlayer, { TTSProps } from './InitPlayer';

const TTS = memo<TTSProps>(
(props) => {
const { file, voice, content, contentMd5 } = props;
const lang = useUserStore(userGeneralSettingsSelectors.currentLanguage);
const lang = useGlobalStore(globalGeneralSelectors.currentLanguage);
const currentVoice = useAgentStore(agentSelectors.currentAgentTTSVoice(lang));

const md5 = useMemo(() => Md5.hashStr(content).toString(), [content]);
Expand Down
6 changes: 3 additions & 3 deletions src/features/PluginDevModal/LocalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import dynamic from 'next/dynamic';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';
import { useToolStore } from '@/store/tool';
import { pluginSelectors } from '@/store/tool/selectors';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';

const EmojiPicker = dynamic(() => import('@bentwnghk/ui/es/EmojiPicker'), { ssr: false });

const LocalForm = memo<{ form: FormInstance; mode?: 'edit' | 'create' }>(({ form, mode }) => {
const isEditMode = mode === 'edit';
const locale = useUserStore(userGeneralSettingsSelectors.currentLanguage);
const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);
const { t } = useTranslation('plugin');

const pluginIds = useToolStore(pluginSelectors.storeAndInstallPluginsIdList);
Expand Down
18 changes: 12 additions & 6 deletions src/features/User/UserPanel/LangButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,35 @@ import { useTranslation } from 'react-i18next';

import Menu, { type MenuProps } from '@/components/Menu';
import { localeOptions } from '@/locales/resources';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';
import { LocaleMode } from '@/types/locale';

const LangButton = memo<{ placement?: PopoverProps['placement'] }>(({ placement = 'right' }) => {
const theme = useTheme();
const [language, switchLocale] = useUserStore((s) => [
userGeneralSettingsSelectors.language(s),

const [language, switchLocale] = useGlobalStore((s) => [
globalGeneralSelectors.language(s),
s.switchLocale,
]);

const handleLangChange = (value: LocaleMode) => {
switchLocale(value);
};

const { t } = useTranslation('setting');

const items: MenuProps['items'] = useMemo(
() => [
{
key: 'auto',
label: t('settingTheme.lang.autoMode'),
onClick: () => switchLocale('auto'),
onClick: () => handleLangChange('auto'),
},
...localeOptions.map((item) => ({
key: item.value,
label: item.label,
onClick: () => switchLocale(item.value),
onClick: () => handleLangChange(item.value),
})),
],
[t],
Expand Down
Loading

0 comments on commit a15e091

Please sign in to comment.