listpage-next 0.0.99 → 0.0.101
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/dist/features/ChatClient/components/Bubble/index.d.ts +2 -0
- package/dist/features/ChatClient/components/Bubble/index.js +57 -0
- package/dist/features/ChatClient/components/Bubble/types.d.ts +8 -0
- package/dist/features/ChatClient/components/Bubble/types.js +0 -0
- package/dist/features/ChatClient/components/ChatGuidance/index.js +1 -1
- package/dist/features/ChatClient/components/Reasoning/index.d.ts +5 -0
- package/dist/features/ChatClient/components/Reasoning/index.js +107 -0
- package/dist/features/ChatClient/context/client.d.ts +1 -1
- package/dist/features/ChatClient/context/index.d.ts +1 -0
- package/dist/features/ChatClient/context/index.js +1 -0
- package/dist/features/ChatClient/context/message.d.ts +1 -19
- package/dist/features/ChatClient/context/message.js +3 -3
- package/dist/features/ChatClient/context/types.d.ts +19 -0
- package/dist/features/ChatClient/context/types.js +0 -0
- package/dist/features/ChatClient/context/useChatContext.d.ts +1 -1
- package/dist/features/ChatClient/index.d.ts +5 -2
- package/dist/features/ChatClient/index.js +5 -2
- package/package.json +1 -1
- /package/dist/features/ChatClient/components/{ClientContent → ChatContent}/BubbleList.d.ts +0 -0
- /package/dist/features/ChatClient/components/{ClientContent → ChatContent}/BubbleList.js +0 -0
- /package/dist/features/ChatClient/components/{ClientContent → ChatContent}/Header.d.ts +0 -0
- /package/dist/features/ChatClient/components/{ClientContent → ChatContent}/Header.js +0 -0
- /package/dist/features/ChatClient/components/{ClientContent → ChatContent}/index.d.ts +0 -0
- /package/dist/features/ChatClient/components/{ClientContent → ChatContent}/index.js +0 -0
- /package/dist/features/ChatClient/components/{ClientContent → ChatContent}/styles.d.ts +0 -0
- /package/dist/features/ChatClient/components/{ClientContent → ChatContent}/styles.js +0 -0
- /package/dist/features/ChatClient/components/{Layout → ChatPage}/ChatPage.d.ts +0 -0
- /package/dist/features/ChatClient/components/{Layout → ChatPage}/ChatPage.js +0 -0
- /package/dist/features/ChatClient/components/{Layout → ChatPage}/Sider.d.ts +0 -0
- /package/dist/features/ChatClient/components/{Layout → ChatPage}/Sider.js +0 -0
- /package/dist/features/ChatClient/components/{Layout → ChatPage}/index.d.ts +0 -0
- /package/dist/features/ChatClient/components/{Layout → ChatPage}/index.js +0 -0
- /package/dist/features/ChatClient/components/{Layout → ChatPage}/styles.d.ts +0 -0
- /package/dist/features/ChatClient/components/{Layout → ChatPage}/styles.js +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { useHover } from "ahooks";
|
|
4
|
+
import styled_components from "styled-components";
|
|
5
|
+
const Bubble = (props)=>{
|
|
6
|
+
const { children, feedback, role = "user", placement = 'user' === role ? 'end' : 'start', showFeedback = (hovered)=>hovered } = props;
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
const hovered = useHover(ref);
|
|
9
|
+
const content = "user" === role ? /*#__PURE__*/ jsx(UserContentWrapper, {
|
|
10
|
+
children: children
|
|
11
|
+
}) : /*#__PURE__*/ jsx(AssistantContentWrapper, {
|
|
12
|
+
children: children
|
|
13
|
+
});
|
|
14
|
+
return /*#__PURE__*/ jsxs(BubbleContainer, {
|
|
15
|
+
placement: placement,
|
|
16
|
+
ref: ref,
|
|
17
|
+
children: [
|
|
18
|
+
content,
|
|
19
|
+
/*#__PURE__*/ jsx(ToolContainer, {
|
|
20
|
+
children: showFeedback(hovered) && feedback
|
|
21
|
+
})
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const BubbleContainer = styled_components.div`
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
align-items: ${(props)=>"start" === props.placement ? "flex-start" : "flex-end"};
|
|
29
|
+
margin-top: 16px;
|
|
30
|
+
`;
|
|
31
|
+
const UserContentWrapper = styled_components.div`
|
|
32
|
+
color: #000000d9;
|
|
33
|
+
padding: 9px 16px;
|
|
34
|
+
font-size: 16px;
|
|
35
|
+
line-height: 24px;
|
|
36
|
+
font-weight: 400;
|
|
37
|
+
min-width: 0px;
|
|
38
|
+
font-family: sans-serif;
|
|
39
|
+
|
|
40
|
+
width: fit-content;
|
|
41
|
+
background-color: #0000000a;
|
|
42
|
+
border-radius: 12px;
|
|
43
|
+
max-width: 450px;
|
|
44
|
+
`;
|
|
45
|
+
const AssistantContentWrapper = styled_components.div`
|
|
46
|
+
color: #000000d9;
|
|
47
|
+
padding: 9px 16px;
|
|
48
|
+
font-size: 16px;
|
|
49
|
+
line-height: 24px;
|
|
50
|
+
font-weight: 400;
|
|
51
|
+
min-width: 0px;
|
|
52
|
+
font-family: sans-serif;
|
|
53
|
+
`;
|
|
54
|
+
const ToolContainer = styled_components.div`
|
|
55
|
+
height: 40px;
|
|
56
|
+
`;
|
|
57
|
+
export { Bubble };
|
|
File without changes
|
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import "react";
|
|
3
3
|
import { PureChatSender } from "../ChatSender/index.js";
|
|
4
4
|
import { ChatGuidanceContainer, ChatGuidanceContent, GreetingText, SenderContainer } from "./styles.js";
|
|
5
|
-
import { Header } from "../
|
|
5
|
+
import { Header } from "../ChatContent/Header.js";
|
|
6
6
|
const ChatGuidance = (props)=>{
|
|
7
7
|
const { greetingText, extra, style, placeholder, offset, onSubmit } = props;
|
|
8
8
|
return /*#__PURE__*/ jsxs(ChatGuidanceContainer, {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowsAltOutlined, ShrinkOutlined } from "@ant-design/icons";
|
|
3
|
+
import { useUpdateEffect } from "ahooks";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { styled } from "styled-components";
|
|
6
|
+
const Reasoning = ({ thinking, children })=>{
|
|
7
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
8
|
+
useUpdateEffect(()=>{
|
|
9
|
+
if (!thinking) setCollapsed(true);
|
|
10
|
+
}, [
|
|
11
|
+
thinking
|
|
12
|
+
]);
|
|
13
|
+
return /*#__PURE__*/ jsxs(ReasoningContainer, {
|
|
14
|
+
style: {
|
|
15
|
+
padding: collapsed ? '6px 12px' : '0px 12px 13px 12px',
|
|
16
|
+
backgroundColor: collapsed ? void 0 : '#fff'
|
|
17
|
+
},
|
|
18
|
+
children: [
|
|
19
|
+
/*#__PURE__*/ jsxs(ReasoningHeader, {
|
|
20
|
+
onClick: ()=>setCollapsed(!collapsed),
|
|
21
|
+
style: {
|
|
22
|
+
padding: collapsed ? '0' : '7px 0px',
|
|
23
|
+
height: collapsed ? 42 : 56
|
|
24
|
+
},
|
|
25
|
+
children: [
|
|
26
|
+
/*#__PURE__*/ jsx(ReasoningTitle, {
|
|
27
|
+
children: thinking ? /*#__PURE__*/ jsx(ReasoningTitleAnimation, {
|
|
28
|
+
children: "深度思考中"
|
|
29
|
+
}) : '已完成思考'
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ jsx(ReasoningIcon, {
|
|
32
|
+
children: collapsed ? /*#__PURE__*/ jsx(ArrowsAltOutlined, {}) : /*#__PURE__*/ jsx(ShrinkOutlined, {})
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ jsx(ReasoningContent, {
|
|
37
|
+
style: {
|
|
38
|
+
height: collapsed ? 0 : 'auto'
|
|
39
|
+
},
|
|
40
|
+
children: children
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const ReasoningContainer = styled.div`
|
|
46
|
+
background-color: #fff;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
border: 1px solid #ebebeb;
|
|
49
|
+
border-radius: 12px;
|
|
50
|
+
margin-bottom: 20px;
|
|
51
|
+
transition: height 0.3s ease-in-out;
|
|
52
|
+
&:hover {
|
|
53
|
+
background-color: #0000000a;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
const ReasoningHeader = styled.div`
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
justify-content: space-between;
|
|
60
|
+
`;
|
|
61
|
+
const ReasoningContent = styled.div`
|
|
62
|
+
color: #00000080 !important;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
`;
|
|
65
|
+
const ReasoningTitle = styled.div`
|
|
66
|
+
color: #000c;
|
|
67
|
+
font-size: 14px;
|
|
68
|
+
font-weight: 500;
|
|
69
|
+
`;
|
|
70
|
+
const ReasoningIcon = styled.div`
|
|
71
|
+
align-items: center;
|
|
72
|
+
border: 1px solid #00000014;
|
|
73
|
+
border-radius: 8px;
|
|
74
|
+
display: flex;
|
|
75
|
+
height: 28px;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
padding: 5px 8px;
|
|
78
|
+
width: 28px;
|
|
79
|
+
|
|
80
|
+
&:hover {
|
|
81
|
+
background-color: #0000000a;
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
const ReasoningTitleAnimation = styled.span`
|
|
85
|
+
/* 文字流光动画 */
|
|
86
|
+
@keyframes textShine {
|
|
87
|
+
to {
|
|
88
|
+
background-position: 200% center;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
background: linear-gradient(
|
|
93
|
+
90deg,
|
|
94
|
+
#3b82f6,
|
|
95
|
+
#93c5fd,
|
|
96
|
+
#3b82f6,
|
|
97
|
+
#93c5fd,
|
|
98
|
+
#3b82f6
|
|
99
|
+
);
|
|
100
|
+
background-size: 200% auto;
|
|
101
|
+
color: #000;
|
|
102
|
+
background-clip: text;
|
|
103
|
+
-webkit-background-clip: text;
|
|
104
|
+
-webkit-text-fill-color: transparent;
|
|
105
|
+
animation: textShine 3s linear infinite;
|
|
106
|
+
`;
|
|
107
|
+
export { Reasoning };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { InfiniteListProps, InfiniteListRef, RenderActions } from "../../../components/InfiniteList";
|
|
3
|
-
import { BaseMessageInfo, Message, SendMessageRequest } from "./
|
|
3
|
+
import { BaseMessageInfo, Message, SendMessageRequest } from "./types";
|
|
4
4
|
import { BubbleListRef } from "./useBubbleListRef";
|
|
5
5
|
export type ChatRequest<SessionData = any, MessageInfo extends BaseMessageInfo = any> = {
|
|
6
6
|
getConversations: InfiniteListProps<SessionData>['request'];
|
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
export type BaseMessageInfo = {
|
|
4
|
-
id: string;
|
|
5
|
-
role: string;
|
|
6
|
-
content: string;
|
|
7
|
-
reasoning?: string;
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
};
|
|
10
|
-
export type Message<MessageInfo extends BaseMessageInfo = any> = {
|
|
11
|
-
id: string;
|
|
12
|
-
status: MessageStatus;
|
|
13
|
-
info: MessageInfo;
|
|
14
|
-
};
|
|
2
|
+
import { BaseMessageInfo, Message, SendMessageRequest } from './types';
|
|
15
3
|
export type MessageContextValue<MessageInfo extends BaseMessageInfo = any> = {
|
|
16
4
|
messages: Message<MessageInfo>[];
|
|
17
5
|
sendMessage: (info: MessageInfo, callback?: (info: MessageInfo) => void) => void;
|
|
18
6
|
isRequesting: boolean;
|
|
19
7
|
};
|
|
20
|
-
export type SendMessageRequest<MessageInfo extends BaseMessageInfo = any> = (info: MessageInfo, callbacks: {
|
|
21
|
-
onCreated: (info: MessageInfo) => void;
|
|
22
|
-
onUpdate: (id: string, info: MessageInfo) => void;
|
|
23
|
-
onSuccess: (id: string, info: MessageInfo) => void;
|
|
24
|
-
onError: (id: string, info: MessageInfo) => void;
|
|
25
|
-
}) => Promise<void>;
|
|
26
8
|
export declare const MessageContext: import("react").Context<MessageContextValue<any>>;
|
|
27
9
|
export declare const MessageProvider: <MessageInfo extends BaseMessageInfo = any>({ initialMessages, children, request, }: {
|
|
28
10
|
children: ReactNode;
|
|
@@ -19,7 +19,7 @@ const MessageProvider = ({ initialMessages, children, request })=>{
|
|
|
19
19
|
const createAssistantMessage = useCallback(()=>{
|
|
20
20
|
const message = {
|
|
21
21
|
id: 'placeholder',
|
|
22
|
-
status: '
|
|
22
|
+
status: 'pending',
|
|
23
23
|
info: {
|
|
24
24
|
id: 'placeholder',
|
|
25
25
|
role: 'assistant',
|
|
@@ -31,7 +31,7 @@ const MessageProvider = ({ initialMessages, children, request })=>{
|
|
|
31
31
|
const createUserMessage = useCallback((info)=>{
|
|
32
32
|
const message = {
|
|
33
33
|
id: 'placeholder',
|
|
34
|
-
status: '
|
|
34
|
+
status: 'pending',
|
|
35
35
|
info: {
|
|
36
36
|
...info,
|
|
37
37
|
id: 'placeholder'
|
|
@@ -62,7 +62,7 @@ const MessageProvider = ({ initialMessages, children, request })=>{
|
|
|
62
62
|
const index = messagesRef.current.findIndex((msg)=>msg.id === id);
|
|
63
63
|
if (-1 !== index) {
|
|
64
64
|
const message = messagesRef.current[index];
|
|
65
|
-
message.status = '
|
|
65
|
+
message.status = 'pending';
|
|
66
66
|
message.info = info;
|
|
67
67
|
message.id = info.id;
|
|
68
68
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type MessageStatus = 'pending' | 'success' | 'failed';
|
|
2
|
+
export type BaseMessageInfo = {
|
|
3
|
+
id: string;
|
|
4
|
+
role: string;
|
|
5
|
+
content: string;
|
|
6
|
+
reasoning?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
export type Message<MessageInfo extends BaseMessageInfo = any> = {
|
|
10
|
+
id: string;
|
|
11
|
+
status: MessageStatus;
|
|
12
|
+
info: MessageInfo;
|
|
13
|
+
};
|
|
14
|
+
export type SendMessageRequest<MessageInfo extends BaseMessageInfo = any> = (info: MessageInfo, callbacks: {
|
|
15
|
+
onCreated: (info: MessageInfo) => void;
|
|
16
|
+
onUpdate: (id: string, info: MessageInfo) => void;
|
|
17
|
+
onSuccess: (id: string, info: MessageInfo) => void;
|
|
18
|
+
onError: (id: string, info: MessageInfo) => void;
|
|
19
|
+
}) => Promise<void>;
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function useChatContext(): {
|
|
2
|
-
messages: import("./
|
|
2
|
+
messages: import("./types").Message<any>[];
|
|
3
3
|
sendMessage: (info: any, callback?: ((info: any) => void) | undefined) => void;
|
|
4
4
|
deleteConversation: ((key: string) => void) | undefined;
|
|
5
5
|
updateConversation: ((key: string, item: any) => void) | undefined;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export * from './components/
|
|
1
|
+
export * from './components/ChatPage';
|
|
2
2
|
export * from './components/ChatGuidance';
|
|
3
|
-
export * from './components/
|
|
3
|
+
export * from './components/ChatContent';
|
|
4
|
+
export * from './components/Bubble';
|
|
5
|
+
export * from './components/Reasoning';
|
|
4
6
|
export { useChatContext } from './context/useChatContext';
|
|
7
|
+
export * from './context/types';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { useChatContext } from "./context/useChatContext.js";
|
|
2
|
-
export * from "./components/
|
|
2
|
+
export * from "./components/ChatPage/index.js";
|
|
3
3
|
export * from "./components/ChatGuidance/index.js";
|
|
4
|
-
export * from "./components/
|
|
4
|
+
export * from "./components/ChatContent/index.js";
|
|
5
|
+
export * from "./components/Bubble/index.js";
|
|
6
|
+
export * from "./components/Reasoning/index.js";
|
|
7
|
+
export * from "./context/types.js";
|
|
5
8
|
export { useChatContext };
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|