Skip to content

Commit ec20b42

Browse files
committed
✨ feat: add ProChat
1 parent 78e6bd7 commit ec20b42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4445
-19
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import ActionIconGroup from '@/ActionIconGroup';
2+
import { RenderAction } from '@/ChatList';
3+
import { useChatListActionsBar } from '@/hooks/useChatListActionsBar';
4+
import { memo } from 'react';
5+
6+
import { ErrorActionsBar } from './Error';
7+
8+
export const AssistantActionsBar: RenderAction = memo(({ text, id, onActionClick, error }) => {
9+
const { regenerate, edit, copy, divider, del } = useChatListActionsBar(text);
10+
11+
if (id === 'default') return;
12+
13+
if (error) return <ErrorActionsBar onActionClick={onActionClick} text={text} />;
14+
15+
return (
16+
<ActionIconGroup
17+
dropdownMenu={[
18+
edit,
19+
copy,
20+
regenerate,
21+
divider,
22+
// TODO: need a translate
23+
divider,
24+
del,
25+
]}
26+
items={[regenerate, copy]}
27+
onActionClick={onActionClick}
28+
type="ghost"
29+
/>
30+
);
31+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import ActionIconGroup from '@/ActionIconGroup';
2+
import { ActionsBarProps } from '@/ChatList/ActionsBar';
3+
import { useChatListActionsBar } from '@/hooks/useChatListActionsBar';
4+
import { memo } from 'react';
5+
6+
export const ErrorActionsBar = memo<ActionsBarProps>(({ text, onActionClick }) => {
7+
const { regenerate, del } = useChatListActionsBar(text);
8+
9+
return <ActionIconGroup items={[regenerate, del]} onActionClick={onActionClick} type="ghost" />;
10+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { useChatListActionsBar } from '@/hooks/useChatListActionsBar';
2+
import { ActionIconGroup, RenderAction } from '@lobehub/ui';
3+
import { memo } from 'react';
4+
5+
export const DefaultActionsBar: RenderAction = memo(({ text, onActionClick }) => {
6+
const { del } = useChatListActionsBar(text);
7+
return (
8+
<ActionIconGroup dropdownMenu={[del]} items={[]} onActionClick={onActionClick} type="ghost" />
9+
);
10+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { useChatListActionsBar } from '@/hooks/useChatListActionsBar';
2+
import { ActionIconGroup, RenderAction } from '@lobehub/ui';
3+
import { memo } from 'react';
4+
5+
export const FunctionActionsBar: RenderAction = memo(({ text, onActionClick }) => {
6+
const { regenerate, divider, del } = useChatListActionsBar(text);
7+
return (
8+
<ActionIconGroup
9+
dropdownMenu={[regenerate, divider, del]}
10+
items={[regenerate]}
11+
onActionClick={onActionClick}
12+
type="ghost"
13+
/>
14+
);
15+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { useChatListActionsBar } from '@/hooks/useChatListActionsBar';
2+
import { ActionIconGroup, RenderAction } from '@lobehub/ui';
3+
import { memo } from 'react';
4+
5+
export const UserActionsBar: RenderAction = memo(({ text, onActionClick }) => {
6+
const { regenerate, edit, copy, divider, del } = useChatListActionsBar(text);
7+
8+
return (
9+
<ActionIconGroup
10+
dropdownMenu={[
11+
edit,
12+
copy,
13+
regenerate,
14+
divider,
15+
// TODO: need a translate
16+
divider,
17+
del,
18+
]}
19+
items={[regenerate, edit]}
20+
onActionClick={onActionClick}
21+
type="ghost"
22+
/>
23+
);
24+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ChatListProps } from '@lobehub/ui';
2+
3+
import { AssistantActionsBar } from './Assistant';
4+
import { DefaultActionsBar } from './Fallback';
5+
import { FunctionActionsBar } from './Function';
6+
import { UserActionsBar } from './User';
7+
8+
export const renderActions: ChatListProps['renderActions'] = {
9+
assistant: AssistantActionsBar,
10+
function: FunctionActionsBar,
11+
system: DefaultActionsBar,
12+
user: UserActionsBar,
13+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Tag from '@/components/Tag';
2+
import { RenderMessageExtra } from '@/index';
3+
4+
import { memo } from 'react';
5+
import { Flexbox } from 'react-layout-kit';
6+
7+
import { useChatStore } from '@/ProChat/store';
8+
import { agentSelectors } from '@/ProChat/store/selectors';
9+
10+
export const AssistantMessageExtra: RenderMessageExtra = memo(({ extra }) => {
11+
const model = useChatStore(agentSelectors.currentAgentModel);
12+
13+
const showModelTag = extra?.fromModel && model !== extra?.fromModel;
14+
const hasTranslate = !!extra?.translate;
15+
16+
const showExtra = showModelTag || hasTranslate;
17+
18+
if (!showExtra) return;
19+
20+
return (
21+
<Flexbox gap={8} style={{ marginTop: 8 }}>
22+
{showModelTag && (
23+
<div>
24+
{/*TODO: need a model icons */}
25+
<Tag>{extra?.fromModel as string}</Tag>
26+
</div>
27+
)}
28+
</Flexbox>
29+
);
30+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { RenderMessageExtra } from '@/index';
2+
import { Divider } from 'antd';
3+
import { memo } from 'react';
4+
import { Flexbox } from 'react-layout-kit';
5+
6+
export const UserMessageExtra: RenderMessageExtra = memo(({ extra }) => {
7+
const hasTranslate = !!extra?.translate;
8+
9+
return (
10+
<Flexbox gap={8} style={{ marginTop: hasTranslate ? 8 : 0 }}>
11+
{extra?.translate && (
12+
<div>
13+
<Divider style={{ margin: '12px 0' }} />
14+
</div>
15+
)}
16+
</Flexbox>
17+
);
18+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ChatListProps } from '@lobehub/ui';
2+
3+
import { AssistantMessageExtra } from './Assistant';
4+
import { UserMessageExtra } from './User';
5+
6+
export const renderMessagesExtra: ChatListProps['renderMessagesExtra'] = {
7+
assistant: AssistantMessageExtra,
8+
user: UserMessageExtra,
9+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { useTheme } from 'antd-style';
2+
3+
const Svg = () => (
4+
<svg viewBox="0 0 32 24" xmlns="http://www.w3.org/2000/svg">
5+
<circle cx="0" cy="12" r="0" transform="translate(8 0)">
6+
<animate
7+
attributeName="r"
8+
begin="0"
9+
calcMode="spline"
10+
dur="1.2s"
11+
keySplines="0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8"
12+
keyTimes="0;0.2;0.7;1"
13+
repeatCount="indefinite"
14+
values="0; 4; 0; 0"
15+
/>
16+
</circle>
17+
<circle cx="0" cy="12" r="0" transform="translate(16 0)">
18+
<animate
19+
attributeName="r"
20+
begin="0.3"
21+
calcMode="spline"
22+
dur="1.2s"
23+
keySplines="0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8"
24+
keyTimes="0;0.2;0.7;1"
25+
repeatCount="indefinite"
26+
values="0; 4; 0; 0"
27+
/>
28+
</circle>
29+
<circle cx="0" cy="12" r="0" transform="translate(24 0)">
30+
<animate
31+
attributeName="r"
32+
begin="0.6"
33+
calcMode="spline"
34+
dur="1.2s"
35+
keySplines="0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8"
36+
keyTimes="0;0.2;0.7;1"
37+
repeatCount="indefinite"
38+
values="0; 4; 0; 0"
39+
/>
40+
</circle>
41+
</svg>
42+
);
43+
44+
const BubblesLoading = () => {
45+
const { colorTextTertiary } = useTheme();
46+
return (
47+
<div style={{ fill: colorTextTertiary, height: 24, width: 32 }}>
48+
<Svg />
49+
</div>
50+
);
51+
};
52+
53+
export default BubblesLoading;

0 commit comments

Comments
 (0)