@ibiz-template-plugin/ai-chat 0.0.29 → 0.0.31
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/index.es.js +2927 -2441
- package/dist/index.legacy.js +1 -1
- package/dist/polyfills.legacy.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/app.d.ts +1 -0
- package/dist/types/components/chat-back-bottom/chat-back-bottom.d.ts +1 -0
- package/dist/types/components/chat-container/chat-container.d.ts +4 -3
- package/dist/types/components/chat-input/chat-input.d.ts +2 -1
- package/dist/types/components/chat-input-material/chat-input-material.d.ts +1 -0
- package/dist/types/components/chat-input-material-item/chat-input-material-item.d.ts +1 -0
- package/dist/types/components/chat-input-material-item/common-material/common-material.d.ts +1 -0
- package/dist/types/components/chat-input-material-item/ossfile-material/ossfile-material.d.ts +1 -0
- package/dist/types/components/chat-message-item/chat-message-item.d.ts +1 -0
- package/dist/types/components/chat-message-item/error-message/error-message.d.ts +1 -0
- package/dist/types/components/chat-message-item/markdown-message/markdown-message.d.ts +1 -0
- package/dist/types/components/chat-message-item/unknown-message/unknown-message.d.ts +1 -0
- package/dist/types/components/chat-message-item/user-message/user-message.d.ts +1 -0
- package/dist/types/components/chat-messages/chat-messages.d.ts +1 -0
- package/dist/types/components/chat-minimize/chat-minimize.d.ts +1 -0
- package/dist/types/components/chat-search/chat-search.d.ts +1 -0
- package/dist/types/components/chat-suggestions/chat-suggestions.d.ts +1 -0
- package/dist/types/components/chat-thought-chain/chat-thought-chain.d.ts +1 -0
- package/dist/types/components/chat-tool-call/chat-tool-call.d.ts +11 -0
- package/dist/types/components/chat-tool-call-item/chat-tool-call-item.d.ts +11 -0
- package/dist/types/components/chat-toolbar/chat-toolbar-item/chat-toolbar-item.d.ts +1 -0
- package/dist/types/components/chat-toolbar/chat-toolbar.d.ts +1 -0
- package/dist/types/components/chat-topic-item/chat-topic-item.d.ts +1 -0
- package/dist/types/components/chat-topics/chat-topics.d.ts +1 -0
- package/dist/types/components/popup/popup.d.ts +6 -5
- package/dist/types/controller/ai-chat/ai-chat.controller.d.ts +9 -12
- package/dist/types/controller/ai-material/ai-material-factory.d.ts +1 -0
- package/dist/types/controller/ai-material/common-helper.d.ts +1 -0
- package/dist/types/controller/ai-material/file-helper.d.ts +1 -0
- package/dist/types/controller/ai-material/material-helper.d.ts +1 -0
- package/dist/types/controller/ai-topic/ai-topic.controller.d.ts +1 -0
- package/dist/types/controller/chat/chat.controller.d.ts +1 -0
- package/dist/types/entity/chart-material/chart-material.d.ts +1 -0
- package/dist/types/entity/chart-topic/chart-topic.d.ts +1 -0
- package/dist/types/entity/chat-message/chat-message.d.ts +20 -0
- package/dist/types/entity/chat-suggestion/chat-suggestion.d.ts +1 -0
- package/dist/types/global.d.ts +1 -0
- package/dist/types/icons/more-svg.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/interface/i-chat-message/i-chat-message.d.ts +8 -0
- package/dist/types/interface/i-chat-options/i-chat-options.d.ts +15 -0
- package/dist/types/interface/i-chat-tool-call/i-chat-tool-call.d.ts +39 -0
- package/dist/types/interface/i-chat-toolbar-item/i-chat-toolbar-item.d.ts +1 -0
- package/dist/types/interface/i-container-options/i-container-options.d.ts +1 -0
- package/dist/types/interface/i-topic-options/i-topic-options.d.ts +1 -0
- package/dist/types/interface/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/util/chat-suggestion-parser.d.ts +1 -0
- package/dist/types/utils/util/chat-tool-call-parser.d.ts +17 -0
- package/dist/types/utils/util/file-uploader.d.ts +1 -0
- package/dist/types/utils/util/material-resource-parser.d.ts +1 -0
- package/package.json +2 -1
|
@@ -2,6 +2,7 @@ import { Component } from 'preact';
|
|
|
2
2
|
import { Namespace } from '../../utils';
|
|
3
3
|
import { AiChatController, AiTopicController } from '../../controller';
|
|
4
4
|
import { IChatToolbarItem, IChatContainerOptions } from '../../interface';
|
|
5
|
+
|
|
5
6
|
export interface ChatContainerProps {
|
|
6
7
|
/**
|
|
7
8
|
* 呈现模式
|
|
@@ -113,7 +114,7 @@ interface ContainerContext {
|
|
|
113
114
|
enableBackFill: boolean;
|
|
114
115
|
newTopic: Function;
|
|
115
116
|
}
|
|
116
|
-
export declare const ContainerContext: import(
|
|
117
|
+
export declare const ContainerContext: import('preact').Context<ContainerContext>;
|
|
117
118
|
/**
|
|
118
119
|
* 聊天窗口容器,可拖拽,可缩放
|
|
119
120
|
*
|
|
@@ -126,8 +127,8 @@ export declare const ContainerContext: import("preact").Context<ContainerContext
|
|
|
126
127
|
export declare class ChatContainer extends Component<ChatContainerProps, ChatContainerState> {
|
|
127
128
|
constructor(props: ChatContainerProps | undefined);
|
|
128
129
|
ns: Namespace;
|
|
129
|
-
containerRef: import(
|
|
130
|
-
dragHandle: import(
|
|
130
|
+
containerRef: import('preact').RefObject<HTMLDivElement>;
|
|
131
|
+
dragHandle: import('preact').RefObject<HTMLDivElement>;
|
|
131
132
|
/**
|
|
132
133
|
* 窗口样式数据
|
|
133
134
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AiChatController } from '../../controller';
|
|
2
2
|
import { IChatToolbarItem } from '../../interface';
|
|
3
|
+
|
|
3
4
|
export interface ChatInputProps {
|
|
4
5
|
/**
|
|
5
6
|
* 单实例聊天总控
|
|
@@ -18,4 +19,4 @@ export interface ChatInputProps {
|
|
|
18
19
|
*/
|
|
19
20
|
questionToolbarItems?: IChatToolbarItem[];
|
|
20
21
|
}
|
|
21
|
-
export declare const ChatInput: (props: ChatInputProps) => import("preact
|
|
22
|
+
export declare const ChatInput: (props: ChatInputProps) => import("preact").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IChatToolCall } from '../../interface';
|
|
2
|
+
|
|
3
|
+
export interface ChatToolCallProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 工具调用集合
|
|
6
|
+
* @type {IChatToolCall[]}
|
|
7
|
+
* @memberof ChatToolCallProps
|
|
8
|
+
*/
|
|
9
|
+
items: IChatToolCall[];
|
|
10
|
+
}
|
|
11
|
+
export declare const ChatToolCall: (props: ChatToolCallProps) => import("preact").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IChatToolCall } from '../../interface';
|
|
2
|
+
|
|
3
|
+
export interface ChatToolCallItemProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 工具调用
|
|
6
|
+
* @type {IChatToolCall}
|
|
7
|
+
* @memberof ChatToolCallItemProps
|
|
8
|
+
*/
|
|
9
|
+
item: IChatToolCall;
|
|
10
|
+
}
|
|
11
|
+
export declare const ChatToolCallItem: (props: ChatToolCallItemProps) => import("preact").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VNode } from 'preact';
|
|
2
|
+
|
|
2
3
|
type Position = 'top' | 'bottom' | 'left' | 'right' | 'top-left';
|
|
3
4
|
interface ActionItem {
|
|
4
5
|
id: string;
|
|
@@ -7,11 +8,11 @@ interface ActionItem {
|
|
|
7
8
|
}
|
|
8
9
|
export declare const Popup: ({ children, actions, content, position, isOpen: isOpenProp, onToggleOpen, onAction, }: {
|
|
9
10
|
children: import('preact').ComponentChildren;
|
|
10
|
-
actions?: ActionItem[]
|
|
11
|
+
actions?: ActionItem[];
|
|
11
12
|
content?: import('preact').ComponentChildren;
|
|
12
|
-
position?: Position
|
|
13
|
-
isOpen?: boolean
|
|
14
|
-
onToggleOpen?: (
|
|
15
|
-
onAction?: (
|
|
13
|
+
position?: Position;
|
|
14
|
+
isOpen?: boolean;
|
|
15
|
+
onToggleOpen?: (isOpen: boolean) => void;
|
|
16
|
+
onAction?: (actionId: string, event: MouseEvent) => void;
|
|
16
17
|
}) => import("preact").JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Signal } from '@preact/signals';
|
|
2
2
|
import { ChatMessage } from '../../entity';
|
|
3
|
-
import {
|
|
3
|
+
import { ITopic, IMaterial, IChatMessage, IChatOptions, IChatSuggestion } from '../../interface';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* 聊天逻辑控制器
|
|
6
7
|
*
|
|
@@ -89,17 +90,6 @@ export declare class AiChatController {
|
|
|
89
90
|
* @memberof AiChatController
|
|
90
91
|
*/
|
|
91
92
|
chatSessionid: string;
|
|
92
|
-
/**
|
|
93
|
-
* 聊天窗触发提问回调
|
|
94
|
-
*
|
|
95
|
-
* @author tony001
|
|
96
|
-
* @date 2025-02-24 14:02:51
|
|
97
|
-
* @param {object} context
|
|
98
|
-
* @param {object} params
|
|
99
|
-
* @param {object} otherParams
|
|
100
|
-
* @param {IChatMessage[]} question 提问历史内容(包含当前提问)
|
|
101
|
-
* @return {*} {Promise<boolean>} 等待回答
|
|
102
|
-
|
|
103
93
|
/**
|
|
104
94
|
* Creates an instance of AiChatController.
|
|
105
95
|
*
|
|
@@ -173,6 +163,13 @@ export declare class AiChatController {
|
|
|
173
163
|
* @return {*} {string}
|
|
174
164
|
*/
|
|
175
165
|
stringlyMaterialResource(): string;
|
|
166
|
+
/**
|
|
167
|
+
* @description 获取当前会话的消息集合
|
|
168
|
+
* @private
|
|
169
|
+
* @returns {*} {IChatMessage[]}
|
|
170
|
+
* @memberof AiChatController
|
|
171
|
+
*/
|
|
172
|
+
private getMessages;
|
|
176
173
|
/**
|
|
177
174
|
* 提问
|
|
178
175
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AiChatController } from '../ai-chat/ai-chat.controller';
|
|
2
2
|
import { CommonHelper } from './common-helper';
|
|
3
3
|
import { FileHelper } from './file-helper';
|
|
4
|
+
|
|
4
5
|
export declare class AIMaterialFactory {
|
|
5
6
|
static getMaterialHelper(type: string, aiChat: AiChatController): CommonHelper | FileHelper;
|
|
6
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IChatMessage } from '../../interface';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* 消息实体
|
|
4
5
|
*
|
|
@@ -10,6 +11,14 @@ import { IChatMessage } from '../../interface';
|
|
|
10
11
|
*/
|
|
11
12
|
export declare class ChatMessage implements IChatMessage {
|
|
12
13
|
protected msg: IChatMessage;
|
|
14
|
+
toolcalls: IChatMessage['toolcalls'];
|
|
15
|
+
/**
|
|
16
|
+
* @description 消息的所有原始内容
|
|
17
|
+
* - 用于维护工具调用消息数据
|
|
18
|
+
* @type {string}
|
|
19
|
+
* @memberof ChatMessage
|
|
20
|
+
*/
|
|
21
|
+
allcontent: string;
|
|
13
22
|
get messageid(): IChatMessage['messageid'];
|
|
14
23
|
get state(): IChatMessage['state'];
|
|
15
24
|
get role(): IChatMessage['role'];
|
|
@@ -28,6 +37,12 @@ export declare class ChatMessage implements IChatMessage {
|
|
|
28
37
|
* @param {IChatMessage} msg
|
|
29
38
|
*/
|
|
30
39
|
update(msg: IChatMessage): void;
|
|
40
|
+
/**
|
|
41
|
+
* @description 替换消息
|
|
42
|
+
* @param {IChatMessage} msg
|
|
43
|
+
* @memberof ChatMessage
|
|
44
|
+
*/
|
|
45
|
+
replace(msg: IChatMessage): void;
|
|
31
46
|
/**
|
|
32
47
|
* 更新消息完成状态
|
|
33
48
|
*
|
|
@@ -36,4 +51,9 @@ export declare class ChatMessage implements IChatMessage {
|
|
|
36
51
|
* @param {boolean} completed
|
|
37
52
|
*/
|
|
38
53
|
updateCompleted(completed: boolean): void;
|
|
54
|
+
/**
|
|
55
|
+
* @description 计算工具调用
|
|
56
|
+
* @memberof ChatMessage
|
|
57
|
+
*/
|
|
58
|
+
computeToolCalls(): void;
|
|
39
59
|
}
|
package/dist/types/global.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { IChatSuggestion } from '../i-chat-suggestion/i-chat-suggestion';
|
|
2
|
+
import { IChatToolCall } from '../i-chat-tool-call/i-chat-tool-call';
|
|
2
3
|
import { IPortalAsyncAction } from '../i-portal-async-action/i-portal-async-action';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* AI聊天消息
|
|
5
7
|
*
|
|
@@ -105,4 +107,10 @@ export interface IChatMessage {
|
|
|
105
107
|
* @type {IChatSuggestion[]}
|
|
106
108
|
*/
|
|
107
109
|
suggestions?: IChatSuggestion[];
|
|
110
|
+
/**
|
|
111
|
+
* @description 工具调用集合
|
|
112
|
+
* @type {IChatToolCall[]}
|
|
113
|
+
* @memberof IChatMessage
|
|
114
|
+
*/
|
|
115
|
+
toolcalls?: IChatToolCall[];
|
|
108
116
|
}
|
|
@@ -3,6 +3,7 @@ import { IChatMessage } from '../i-chat-message/i-chat-message';
|
|
|
3
3
|
import { IChatToolbarItem } from '../i-chat-toolbar-item/i-chat-toolbar-item';
|
|
4
4
|
import { FileUploaderOptions } from '../i-file-uploader-options/i-file-uploader-options';
|
|
5
5
|
import { ITopic } from '../i-topic-options/i-topic-options';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* 聊天数据
|
|
8
9
|
*
|
|
@@ -43,6 +44,20 @@ export interface IChat {
|
|
|
43
44
|
* @type {string}
|
|
44
45
|
*/
|
|
45
46
|
appDataEntityId: string;
|
|
47
|
+
/**
|
|
48
|
+
* @description 自动提问
|
|
49
|
+
* - 历史数据最后一个项是user时是否自动提问,默认开启
|
|
50
|
+
* @type {boolean}
|
|
51
|
+
* @memberof IChat
|
|
52
|
+
*/
|
|
53
|
+
autoQuestion?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* @description 是否自动回填
|
|
56
|
+
* - AI回答完成之后是否触发回填,默认关闭
|
|
57
|
+
* @type {boolean}
|
|
58
|
+
* @memberof IChat
|
|
59
|
+
*/
|
|
60
|
+
autoFill?: boolean;
|
|
46
61
|
/**
|
|
47
62
|
* 传入对象参数(如果外部传入,在请求历史记录,需要附加当前参数)
|
|
48
63
|
*
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 工具调用
|
|
3
|
+
* @export
|
|
4
|
+
* @interface IChatToolCall
|
|
5
|
+
*/
|
|
6
|
+
export interface IChatToolCall {
|
|
7
|
+
/**
|
|
8
|
+
* @description 工具名称
|
|
9
|
+
* @type {string}
|
|
10
|
+
* @memberof IChatToolCall
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* @description 参数
|
|
15
|
+
* @type {{
|
|
16
|
+
* type: string;
|
|
17
|
+
* id: string;
|
|
18
|
+
* desc: string;
|
|
19
|
+
* }}
|
|
20
|
+
* @memberof IChatToolCall
|
|
21
|
+
*/
|
|
22
|
+
parameters: {
|
|
23
|
+
type: string;
|
|
24
|
+
id: string;
|
|
25
|
+
desc: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @description 是否错误
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
* @memberof IChatToolCall
|
|
31
|
+
*/
|
|
32
|
+
error: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* @description 错误原因
|
|
35
|
+
* @type {string}
|
|
36
|
+
* @memberof IChatToolCall
|
|
37
|
+
*/
|
|
38
|
+
result?: string;
|
|
39
|
+
}
|
|
@@ -10,3 +10,4 @@ export type { IMaterial } from './i-material/i-material';
|
|
|
10
10
|
export type { FileUploaderOptions } from './i-file-uploader-options/i-file-uploader-options';
|
|
11
11
|
export type { IChatContainerOptions } from './i-chat-container/i-chat-container';
|
|
12
12
|
export type { IChatSuggestion } from './i-chat-suggestion/i-chat-suggestion';
|
|
13
|
+
export type { IChatToolCall } from './i-chat-tool-call/i-chat-tool-call';
|
|
@@ -7,3 +7,4 @@ export { MaterialResourceParser } from './util/material-resource-parser';
|
|
|
7
7
|
export { ChatSuggestionParser } from './util/chat-suggestion-parser';
|
|
8
8
|
export { isWithinBounds, limitDraggable } from './util/drag-util';
|
|
9
9
|
export { generateHashWithText } from './util/text-hash-util';
|
|
10
|
+
export { ChatToolCallParser } from './util/chat-tool-call-parser';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IChatToolCall } from '../../interface';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description 工具调用解析器
|
|
5
|
+
* @export
|
|
6
|
+
* @class ChatToolCallParser
|
|
7
|
+
*/
|
|
8
|
+
export declare class ChatToolCallParser {
|
|
9
|
+
/**
|
|
10
|
+
* @description 解析工具调用
|
|
11
|
+
* @static
|
|
12
|
+
* @param {string} toolCallString
|
|
13
|
+
* @returns {*} {IChatToolCall[]}
|
|
14
|
+
* @memberof ChatToolCallParser
|
|
15
|
+
*/
|
|
16
|
+
static parse(toolCallString: string): IChatToolCall[];
|
|
17
|
+
}
|
package/package.json
CHANGED