@lobehub/chat 0.101.5 → 0.101.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.101.6](https://github.com/lobehub/lobe-chat/compare/v0.101.5...v0.101.6)
6
+
7
+ <sup>Released on **2023-11-17**</sup>
8
+
9
+ #### 💄 Styles
10
+
11
+ - **misc**: Add config to renderErrorMessages, Use new Alert ui.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Styles
19
+
20
+ - **misc**: Add config to renderErrorMessages ([75b6b40](https://github.com/lobehub/lobe-chat/commit/75b6b40))
21
+ - **misc**: Use new Alert ui ([cf845a7](https://github.com/lobehub/lobe-chat/commit/cf845a7))
22
+
23
+ </details>
24
+
25
+ <div align="right">
26
+
27
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
28
+
29
+ </div>
30
+
5
31
  ### [Version 0.101.5](https://github.com/lobehub/lobe-chat/compare/v0.101.4...v0.101.5)
6
32
 
7
33
  <sup>Released on **2023-11-17**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.101.5",
3
+ "version": "0.101.6",
4
4
  "description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -16,7 +16,7 @@ enum Tab {
16
16
  Password = 'password',
17
17
  }
18
18
 
19
- const InvalidAccess: RenderErrorMessage = memo(({ id }) => {
19
+ const InvalidAccess: RenderErrorMessage['Render'] = memo(({ id }) => {
20
20
  const { t } = useTranslation('error');
21
21
  const [mode, setMode] = useState<Tab>(Tab.Password);
22
22
  const [password, setSettings] = useGlobalStore((s) => [s.settings.password, s.setSettings]);
@@ -4,7 +4,7 @@ import { memo } from 'react';
4
4
  import APIKeyForm from './ApiKeyForm';
5
5
  import { ErrorActionContainer } from './style';
6
6
 
7
- const OpenAPIKey: RenderErrorMessage = memo(({ id }) => (
7
+ const OpenAPIKey: RenderErrorMessage['Render'] = memo(({ id }) => (
8
8
  <ErrorActionContainer>
9
9
  <APIKeyForm id={id} />
10
10
  </ErrorActionContainer>
@@ -3,7 +3,6 @@ import { memo } from 'react';
3
3
  import { Flexbox } from 'react-layout-kit';
4
4
 
5
5
  import OpenAPIKey from './OpenAPIKey';
6
- import { useStyles } from './style';
7
6
 
8
7
  interface OpenAIError {
9
8
  code: 'invalid_api_key' | string;
@@ -16,18 +15,20 @@ interface OpenAIErrorResponse {
16
15
  error: OpenAIError;
17
16
  }
18
17
 
19
- const OpenAiBizError: RenderErrorMessage = memo(({ error, id, ...props }) => {
20
- const { styles } = useStyles();
21
-
18
+ const OpenAiBizError: RenderErrorMessage['Render'] = memo(({ error, id, ...props }) => {
22
19
  const errorBody: OpenAIErrorResponse = (error as any)?.body;
23
20
 
24
21
  const errorCode = errorBody.error?.code;
25
22
 
26
- if (errorCode === 'invalid_api_key') return <OpenAPIKey error={error} id={id} {...props} />;
23
+ if (errorCode === 'invalid_api_key')
24
+ // @ts-ignore
25
+ return <OpenAPIKey error={error} id={id} {...props} />;
27
26
 
28
27
  return (
29
- <Flexbox className={styles.container} style={{ maxWidth: 600 }}>
30
- <Highlighter language={'json'}>{JSON.stringify(errorBody, null, 2)}</Highlighter>
28
+ <Flexbox style={{ maxWidth: 600 }}>
29
+ <Highlighter copyButtonSize={'small'} language={'json'}>
30
+ {JSON.stringify(errorBody, null, 2)}
31
+ </Highlighter>
31
32
  </Flexbox>
32
33
  );
33
34
  });
@@ -2,8 +2,6 @@ import { Highlighter, RenderErrorMessage } from '@lobehub/ui';
2
2
  import { memo } from 'react';
3
3
  import { Flexbox } from 'react-layout-kit';
4
4
 
5
- import { useStyles } from '../style';
6
-
7
5
  interface OpenAIError {
8
6
  code: 'invalid_api_key' | string;
9
7
  message: string;
@@ -15,13 +13,14 @@ interface OpenAIErrorResponse {
15
13
  error: OpenAIError;
16
14
  }
17
15
 
18
- const PluginError: RenderErrorMessage = memo(({ error, id }) => {
19
- const { styles } = useStyles();
16
+ const PluginError: RenderErrorMessage['Render'] = memo(({ error, id }) => {
20
17
  const errorBody: OpenAIErrorResponse = (error as any)?.body;
21
18
 
22
19
  return (
23
- <Flexbox className={styles.container} id={id} style={{ maxWidth: 600 }}>
24
- <Highlighter language={'json'}>{JSON.stringify(errorBody, null, 2)}</Highlighter>
20
+ <Flexbox id={id} style={{ maxWidth: 600 }}>
21
+ <Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
22
+ {JSON.stringify(errorBody, null, 2)}
23
+ </Highlighter>
25
24
  </Flexbox>
26
25
  );
27
26
  });
@@ -12,7 +12,7 @@ import { useSessionStore } from '@/store/session';
12
12
 
13
13
  import { ErrorActionContainer, useStyles } from '../style';
14
14
 
15
- const PluginSettings: RenderErrorMessage = memo(({ id, plugin }) => {
15
+ const PluginSettings: RenderErrorMessage['Render'] = memo(({ id, plugin }) => {
16
16
  const { styles } = useStyles();
17
17
  const { t } = useTranslation('error');
18
18
  const theme = useTheme();
@@ -10,17 +10,63 @@ import PluginError from './Plugin/PluginError';
10
10
  import PluginSettings from './Plugin/PluginSettings';
11
11
 
12
12
  export const renderErrorMessages: ChatListProps['renderErrorMessages'] = {
13
- [PluginErrorType.PluginMarketIndexNotFound]: PluginError,
14
- [PluginErrorType.PluginMarketIndexInvalid]: PluginError,
15
- [PluginErrorType.PluginMetaInvalid]: PluginError,
16
- [PluginErrorType.PluginMetaNotFound]: PluginError,
17
- [PluginErrorType.PluginManifestInvalid]: PluginError,
18
- [PluginErrorType.PluginManifestNotFound]: PluginError,
19
- [PluginErrorType.PluginApiNotFound]: PluginError,
20
- [PluginErrorType.PluginApiParamsError]: PluginError,
21
- [PluginErrorType.PluginServerError]: PluginError,
22
- [PluginErrorType.PluginSettingsInvalid]: PluginSettings,
23
- [ChatErrorType.InvalidAccessCode]: InvalidAccess,
24
- [ChatErrorType.NoAPIKey]: OpenAPIKey,
25
- [ChatErrorType.OpenAIBizError]: OpenAiBizError,
13
+ [PluginErrorType.PluginMarketIndexNotFound]: {
14
+ Render: PluginError,
15
+ },
16
+ [PluginErrorType.PluginMarketIndexInvalid]: {
17
+ Render: PluginError,
18
+ },
19
+ [PluginErrorType.PluginMetaInvalid]: {
20
+ Render: PluginError,
21
+ },
22
+ [PluginErrorType.PluginMetaNotFound]: {
23
+ Render: PluginError,
24
+ },
25
+ [PluginErrorType.PluginManifestInvalid]: {
26
+ Render: PluginError,
27
+ },
28
+ [PluginErrorType.PluginManifestNotFound]: {
29
+ Render: PluginError,
30
+ },
31
+ [PluginErrorType.PluginApiNotFound]: {
32
+ Render: PluginError,
33
+ },
34
+ [PluginErrorType.PluginApiParamsError]: {
35
+ Render: PluginError,
36
+ },
37
+ [PluginErrorType.PluginServerError]: {
38
+ Render: PluginError,
39
+ },
40
+ [PluginErrorType.PluginSettingsInvalid]: {
41
+ Render: PluginSettings,
42
+ config: {
43
+ extraDefaultExpand: true,
44
+ extraIsolate: true,
45
+ type: 'warning',
46
+ },
47
+ },
48
+ [ChatErrorType.InvalidAccessCode]: {
49
+ Render: InvalidAccess,
50
+ config: {
51
+ extraDefaultExpand: true,
52
+ extraIsolate: true,
53
+ type: 'warning',
54
+ },
55
+ },
56
+ [ChatErrorType.NoAPIKey]: {
57
+ Render: OpenAPIKey,
58
+ config: {
59
+ extraDefaultExpand: true,
60
+ extraIsolate: true,
61
+ type: 'warning',
62
+ },
63
+ },
64
+ [ChatErrorType.OpenAIBizError]: {
65
+ Render: OpenAiBizError,
66
+ config: {
67
+ extraDefaultExpand: true,
68
+ extraIsolate: true,
69
+ type: 'warning',
70
+ },
71
+ },
26
72
  };
@@ -5,6 +5,7 @@ import { Center, Flexbox } from 'react-layout-kit';
5
5
 
6
6
  export const useStyles = createStyles(({ css, token }) => ({
7
7
  container: css`
8
+ color: ${token.colorText};
8
9
  background: ${token.colorBgContainer};
9
10
  border: 1px solid ${token.colorSplit};
10
11
  border-radius: 8px;
@@ -1,4 +1,5 @@
1
- import { Alert, Button, Divider, Input } from 'antd';
1
+ import { Alert } from '@lobehub/ui';
2
+ import { Button, Divider, Input } from 'antd';
2
3
  import { useTheme } from 'antd-style';
3
4
  import isEqual from 'fast-deep-equal';
4
5
  import { kebabCase } from 'lodash-es';
@@ -1,4 +1,5 @@
1
- import { Alert, Button } from 'antd';
1
+ import { Alert } from '@lobehub/ui';
2
+ import { Button } from 'antd';
2
3
  import Link from 'next/link';
3
4
  import { memo } from 'react';
4
5
  import { useTranslation } from 'react-i18next';
@@ -1,6 +1,6 @@
1
1
  import { CheckCircleFilled } from '@ant-design/icons';
2
- import { Highlighter } from '@lobehub/ui';
3
- import { Alert, Button } from 'antd';
2
+ import { Alert, Highlighter } from '@lobehub/ui';
3
+ import { Button } from 'antd';
4
4
  import { useTheme } from 'antd-style';
5
5
  import { memo, useState } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
@@ -72,10 +72,19 @@ const Checker = memo<CheckerProps>(({ checkModel }) => {
72
72
 
73
73
  {error && (
74
74
  <Flexbox gap={8}>
75
- <Alert banner message={error.message} showIcon type={'error'}></Alert>
76
- <Flexbox style={{ maxWidth: 600 }}>
77
- <Highlighter language={'json'}>{JSON.stringify(error.body, null, 2)}</Highlighter>
78
- </Flexbox>
75
+ <Alert
76
+ banner
77
+ extra={
78
+ <Flexbox style={{ maxWidth: 600 }}>
79
+ <Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
80
+ {JSON.stringify(error.body, null, 2)}
81
+ </Highlighter>
82
+ </Flexbox>
83
+ }
84
+ message={error.message}
85
+ showIcon
86
+ type={'error'}
87
+ />
79
88
  </Flexbox>
80
89
  )}
81
90
  </Flexbox>
@@ -1,5 +1,4 @@
1
- import { Form, Input, Modal } from '@lobehub/ui';
2
- import { Alert } from 'antd';
1
+ import { Alert, Form, Input, Modal } from '@lobehub/ui';
3
2
  import { memo } from 'react';
4
3
  import { useTranslation } from 'react-i18next';
5
4
  import { Flexbox } from 'react-layout-kit';
@@ -1,5 +1,5 @@
1
- import { Modal } from '@lobehub/ui';
2
- import { Alert, App, Button, Form, Popconfirm } from 'antd';
1
+ import { Alert, Modal } from '@lobehub/ui';
2
+ import { App, Button, Form, Popconfirm } from 'antd';
3
3
  import { useResponsive } from 'antd-style';
4
4
  import { memo, useEffect, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';