listpage-next 0.0.147 → 0.0.149
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/Bubble.js +9 -5
- package/dist/features/ChatClient/context/message.d.ts +1 -1
- package/dist/features/ChatClient/context/types.d.ts +2 -0
- package/dist/features/ChatClient/context/useChatContext.d.ts +2 -0
- package/dist/features/ChatClient/context/useChatContext.js +3 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import { useHover } from "ahooks";
|
|
4
4
|
import styled_components from "styled-components";
|
|
@@ -7,8 +7,11 @@ import { Reasoning } from "./Reasoning.js";
|
|
|
7
7
|
import { ReferenceList } from "./ReferenceList.js";
|
|
8
8
|
const Bubble = (props)=>{
|
|
9
9
|
const { content, reasoning_content, extra, feedback, markdownRender, reasoningMarkdownRender = markdownRender, references, suggests, role = 'user', placement = 'user' === role ? 'end' : 'start', showFeedback = (hovered)=>hovered } = props;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const containerRef = useRef(null);
|
|
11
|
+
const feedbackRef = useRef(null);
|
|
12
|
+
const containerHovered = useHover(containerRef);
|
|
13
|
+
const feedbackHovered = useHover(feedbackRef);
|
|
14
|
+
const hovered = containerHovered || feedbackHovered;
|
|
12
15
|
const messageMarkdownEle = markdownRender ? markdownRender(content || '') : /*#__PURE__*/ jsx(Markdown, {
|
|
13
16
|
content: content || ''
|
|
14
17
|
});
|
|
@@ -20,11 +23,11 @@ const Bubble = (props)=>{
|
|
|
20
23
|
}) : /*#__PURE__*/ jsx(AssistantContentWrapper, {
|
|
21
24
|
children: messageMarkdownEle
|
|
22
25
|
});
|
|
23
|
-
return /*#__PURE__*/ jsxs(
|
|
26
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
24
27
|
children: [
|
|
25
28
|
/*#__PURE__*/ jsxs(BubbleContainer, {
|
|
26
29
|
placement: placement,
|
|
27
|
-
ref:
|
|
30
|
+
ref: containerRef,
|
|
28
31
|
children: [
|
|
29
32
|
Boolean(reasoning_content) && /*#__PURE__*/ jsx(Reasoning, {
|
|
30
33
|
thinking: Boolean(!content),
|
|
@@ -38,6 +41,7 @@ const Bubble = (props)=>{
|
|
|
38
41
|
}),
|
|
39
42
|
extra,
|
|
40
43
|
feedback && /*#__PURE__*/ jsx(ToolContainer, {
|
|
44
|
+
ref: feedbackRef,
|
|
41
45
|
children: showFeedback(hovered) && feedback
|
|
42
46
|
}),
|
|
43
47
|
suggests && /*#__PURE__*/ jsx(SuggestContainer, {
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { BaseMessageInfo, Message, SendMessageRequest } from './types';
|
|
3
3
|
export type MessageContextValue<MessageInfo extends BaseMessageInfo = any> = {
|
|
4
4
|
messages: Message<MessageInfo>[];
|
|
5
|
-
appendMessage: (
|
|
5
|
+
appendMessage: (message: Message<MessageInfo>) => void;
|
|
6
6
|
sendMessage: (info: MessageInfo, callback?: (info: MessageInfo) => void) => void;
|
|
7
7
|
setMessages: (messages: Message<MessageInfo>[]) => void;
|
|
8
8
|
isRequesting: boolean;
|
|
@@ -17,3 +17,5 @@ export type SendMessageRequest<MessageInfo extends BaseMessageInfo = any> = (inf
|
|
|
17
17
|
onSuccess: (id: string, info: MessageInfo) => void;
|
|
18
18
|
onError: (id: string, info: MessageInfo) => void;
|
|
19
19
|
}, messages: MessageInfo[]) => Promise<void>;
|
|
20
|
+
export type { MessageContextValue } from './message';
|
|
21
|
+
export type { ChatInstance } from './useChatContext';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare function useChatContext(): {
|
|
2
2
|
messages: import("./types").Message<any>[];
|
|
3
3
|
sendMessage: (info: any, callback?: ((info: any) => void) | undefined) => void;
|
|
4
|
+
appendMessage: (message: import("./types").Message<any>) => void;
|
|
5
|
+
setMessages: (messages: import("./types").Message<any>[]) => void;
|
|
4
6
|
deleteConversation: ((key: string) => void) | undefined;
|
|
5
7
|
updateConversation: ((key: string, item: any) => void) | undefined;
|
|
6
8
|
scrollToBottom: () => void;
|
|
@@ -2,11 +2,13 @@ import { useChatClientContext } from "./client.js";
|
|
|
2
2
|
import { useMessageContext } from "./message.js";
|
|
3
3
|
function useChatContext() {
|
|
4
4
|
const { conversationAction, bubbleListRef } = useChatClientContext();
|
|
5
|
-
const { messages, sendMessage } = useMessageContext();
|
|
5
|
+
const { messages, sendMessage, appendMessage, setMessages } = useMessageContext();
|
|
6
6
|
const { deleteItem, updateItem } = conversationAction ?? {};
|
|
7
7
|
return {
|
|
8
8
|
messages,
|
|
9
9
|
sendMessage,
|
|
10
|
+
appendMessage,
|
|
11
|
+
setMessages,
|
|
10
12
|
deleteConversation: deleteItem,
|
|
11
13
|
updateConversation: updateItem,
|
|
12
14
|
scrollToBottom: ()=>bubbleListRef.current?.scrollToBottom()
|