plain-design 1.0.0-beta.157 → 1.0.0-beta.158
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/package.json
CHANGED
|
@@ -28,6 +28,7 @@ export const AiChatBox = designComponent({
|
|
|
28
28
|
systemContent: { type: String },
|
|
29
29
|
/*手动处理大模型返回的message*/
|
|
30
30
|
handleMessage: { type: Function as PropType<(param: { message: string, userContent: string, chatData?: iAiChatResponse, addHistory: (history: iChatBoxHistory) => void }) => void | iChatBoxHistory | iChatBoxHistory[] | Promise<void | iChatBoxHistory | iChatBoxHistory[]>> },
|
|
31
|
+
handleReceive: { type: Function as PropType<(data: { fullText?: string, chunkText?: string }) => void> },
|
|
31
32
|
inputMinHeight: { type: String, default: '80px' },
|
|
32
33
|
inputMaxHeight: { type: String, default: '225px' },
|
|
33
34
|
},
|
|
@@ -62,15 +63,14 @@ export const AiChatBox = designComponent({
|
|
|
62
63
|
refs.scroll.methods.scrollEnd();
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
|
-
addHistory: async (history: iChatBoxHistory) => {
|
|
66
|
-
state.histories.push(history);
|
|
66
|
+
addHistory: async (...history: iChatBoxHistory[]) => {
|
|
67
|
+
state.histories.push(...history);
|
|
67
68
|
await methods.scrollEnd();
|
|
68
69
|
},
|
|
69
70
|
send: async (userContent: string) => {
|
|
70
71
|
await delay(23);
|
|
71
72
|
state.userContent = '';
|
|
72
|
-
|
|
73
|
-
await methods.scrollEnd();
|
|
73
|
+
await methods.addHistory({ role: 'user', content: userContent, id: uuid() });
|
|
74
74
|
|
|
75
75
|
/*const { message, chatData } = await $ai.chatSystem(userContent, props.systemContent, aiConfig);*/
|
|
76
76
|
const messages: iAiHistory[] = [{ role: 'user', content: userContent }];
|
|
@@ -81,8 +81,9 @@ export const AiChatBox = designComponent({
|
|
|
81
81
|
await $ai.chatStream({
|
|
82
82
|
aiConfig,
|
|
83
83
|
messages,
|
|
84
|
-
onReceiving: ({ fullText }) => {
|
|
84
|
+
onReceiving: ({ fullText, chunkText }) => {
|
|
85
85
|
// console.log('receiving', fullText);
|
|
86
|
+
props.handleReceive?.({ fullText, chunkText });
|
|
86
87
|
if (!chatBoxHistory) {
|
|
87
88
|
state.histories.push({ role: 'assistant', content: '', id: uuid() });
|
|
88
89
|
chatBoxHistory = lastItem(state.histories);
|
|
@@ -108,9 +109,8 @@ export const AiChatBox = designComponent({
|
|
|
108
109
|
});
|
|
109
110
|
|
|
110
111
|
if (newHistory != null) {
|
|
111
|
-
|
|
112
|
+
await methods.addHistory(...toArray(newHistory));
|
|
112
113
|
}
|
|
113
|
-
await methods.scrollEnd();
|
|
114
114
|
|
|
115
115
|
return { message, /*chatData*/ };
|
|
116
116
|
},
|