@ibiz-template-plugin/ai-chat 0.0.6 → 0.0.9

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.
Files changed (42) hide show
  1. package/dist/index.es.js +2313 -1081
  2. package/dist/index.legacy.js +1 -1
  3. package/dist/polyfills.legacy.js +1 -1
  4. package/dist/style.css +1 -1
  5. package/package.json +5 -3
  6. package/dist/types/app.d.ts +0 -1
  7. package/dist/types/components/chat-container/chat-container.d.ts +0 -98
  8. package/dist/types/components/chat-input/chat-input.d.ts +0 -12
  9. package/dist/types/components/chat-message-item/chat-message-item.d.ts +0 -23
  10. package/dist/types/components/chat-message-item/error-message/error-message.d.ts +0 -22
  11. package/dist/types/components/chat-message-item/markdown-message/markdown-message.d.ts +0 -22
  12. package/dist/types/components/chat-message-item/unknown-message/unknown-message.d.ts +0 -13
  13. package/dist/types/components/chat-message-item/user-message/user-message.d.ts +0 -15
  14. package/dist/types/components/chat-messages/chat-messages.d.ts +0 -12
  15. package/dist/types/components/index.d.ts +0 -1
  16. package/dist/types/constants/index.d.ts +0 -6
  17. package/dist/types/controller/ai-chat/ai-chat.controller.d.ts +0 -99
  18. package/dist/types/controller/chat/chat.controller.d.ts +0 -51
  19. package/dist/types/controller/index.d.ts +0 -2
  20. package/dist/types/entity/chat-message/chat-message.d.ts +0 -28
  21. package/dist/types/entity/index.d.ts +0 -1
  22. package/dist/types/global.d.ts +0 -2
  23. package/dist/types/icons/close-full-screen-svg.d.ts +0 -1
  24. package/dist/types/icons/close-svg.d.ts +0 -1
  25. package/dist/types/icons/copy-svg.d.ts +0 -1
  26. package/dist/types/icons/delete-svg.d.ts +0 -1
  27. package/dist/types/icons/fill-svg.d.ts +0 -1
  28. package/dist/types/icons/full-screen-svg.d.ts +0 -1
  29. package/dist/types/icons/index.d.ts +0 -8
  30. package/dist/types/icons/refresh-svg.d.ts +0 -1
  31. package/dist/types/icons/send-svg.d.ts +0 -1
  32. package/dist/types/index.d.ts +0 -2
  33. package/dist/types/interface/i-chat-container/i-chat-container.d.ts +0 -58
  34. package/dist/types/interface/i-chat-message/i-chat-message.d.ts +0 -83
  35. package/dist/types/interface/i-chat-options/i-chat-options.d.ts +0 -60
  36. package/dist/types/interface/i-message-item-provider/i-message-item-provider.d.ts +0 -18
  37. package/dist/types/interface/i-portal-async-action/i-portal-async-action.d.ts +0 -90
  38. package/dist/types/interface/index.d.ts +0 -4
  39. package/dist/types/main.d.ts +0 -1
  40. package/dist/types/utils/index.d.ts +0 -3
  41. package/dist/types/utils/plugin-static-resource/plugin-static-resource.d.ts +0 -63
  42. package/dist/types/utils/util/util.d.ts +0 -29
@@ -1,22 +0,0 @@
1
- import { IChatMessage } from '../../../interface';
2
- import { AiChatController } from '../../../controller';
3
- export interface ErrorMessageProps {
4
- /**
5
- * 单实例聊天总控
6
- *
7
- * @author chitanda
8
- * @date 2023-10-13 17:10:43
9
- * @type {AiChatController}
10
- */
11
- controller: AiChatController;
12
- message: IChatMessage;
13
- /**
14
- * 内容大小,用于更新绘制
15
- *
16
- * @author chitanda
17
- * @date 2023-10-15 21:10:22
18
- * @type {number}
19
- */
20
- size: number;
21
- }
22
- export declare const ErrorMessage: (props: ErrorMessageProps) => import("preact").JSX.Element;
@@ -1,22 +0,0 @@
1
- import { IChatMessage } from '../../../interface';
2
- import { AiChatController } from '../../../controller';
3
- export interface MarkdownMessageProps {
4
- /**
5
- * 单实例聊天总控
6
- *
7
- * @author chitanda
8
- * @date 2023-10-13 17:10:43
9
- * @type {AiChatController}
10
- */
11
- controller: AiChatController;
12
- message: IChatMessage;
13
- /**
14
- * 内容大小,用于更新绘制
15
- *
16
- * @author chitanda
17
- * @date 2023-10-15 21:10:22
18
- * @type {number}
19
- */
20
- size: number;
21
- }
22
- export declare const MarkdownMessage: (props: MarkdownMessageProps) => import("preact").JSX.Element;
@@ -1,13 +0,0 @@
1
- import { IChatMessage } from '../../../interface';
2
- export interface UnknownMessageProps {
3
- message: IChatMessage;
4
- /**
5
- * 内容大小,用于更新绘制
6
- *
7
- * @author chitanda
8
- * @date 2023-10-15 21:10:22
9
- * @type {number}
10
- */
11
- size: number;
12
- }
13
- export declare const UnknownMessage: (props: UnknownMessageProps) => import("preact").JSX.Element;
@@ -1,15 +0,0 @@
1
- import { IChatMessage } from '../../../interface';
2
- import { AiChatController } from '../../../controller';
3
- export interface UserMessageProps {
4
- controller: AiChatController;
5
- message: IChatMessage;
6
- /**
7
- * 内容大小,用于更新绘制
8
- *
9
- * @author chitanda
10
- * @date 2023-10-15 21:10:22
11
- * @type {number}
12
- */
13
- size: number;
14
- }
15
- export declare const UserMessage: (props: UserMessageProps) => import("preact").JSX.Element;
@@ -1,12 +0,0 @@
1
- import { AiChatController } from '../../controller';
2
- export interface ChatMessageProps {
3
- /**
4
- * 单实例聊天总控
5
- *
6
- * @author chitanda
7
- * @date 2023-10-13 17:10:43
8
- * @type {AiChatController}
9
- */
10
- controller: AiChatController;
11
- }
12
- export declare const ChatMessages: (props: ChatMessageProps) => import("preact").JSX.Element;
@@ -1 +0,0 @@
1
- export { ChatContainer } from './chat-container/chat-container';
@@ -1,6 +0,0 @@
1
- export declare enum AIChatConst {
2
- /**
3
- * 聊天窗口样式缓存
4
- */
5
- STYLE_CACHE = "ai-chat-style-cache"
6
- }
@@ -1,99 +0,0 @@
1
- import { Signal } from '@preact/signals';
2
- import { ChatMessage } from '../../entity';
3
- import { IChatMessage, IChatOptions } from '../../interface';
4
- /**
5
- * 聊天逻辑控制器
6
- *
7
- * @author chitanda
8
- * @date 2023-10-09 15:10:51
9
- * @export
10
- * @class AiChatController
11
- */
12
- export declare class AiChatController {
13
- readonly opts: IChatOptions;
14
- /**
15
- * 聊天记录
16
- *
17
- * @author chitanda
18
- * @date 2023-10-16 16:10:29
19
- * @type {Signal<ChatMessage[]>}
20
- */
21
- readonly messages: Signal<ChatMessage[]>;
22
- /**
23
- * 聊天框输入值
24
- *
25
- * @author chitanda
26
- * @date 2023-10-16 15:10:43
27
- * @type {Signal<string>}
28
- */
29
- readonly input: Signal<string>;
30
- /**
31
- * Creates an instance of AiChatController.
32
- *
33
- * @author chitanda
34
- * @date 2023-10-15 19:10:34
35
- * @param {IChatOptions} opts 聊天配置
36
- */
37
- constructor(opts: IChatOptions);
38
- /**
39
- * 设置聊天框值
40
- *
41
- * @author chitanda
42
- * @date 2023-10-16 16:10:21
43
- * @param {string} input
44
- */
45
- setInput(input: string): void;
46
- /**
47
- * 新增聊天记录
48
- *
49
- * @author chitanda
50
- * @date 2023-10-09 15:10:15
51
- * @param {IMessage} data
52
- */
53
- addMessage(data: IChatMessage): void;
54
- /**
55
- * 替换已经存在的聊天消息
56
- *
57
- * @author chitanda
58
- * @date 2023-10-16 22:10:49
59
- * @param {IChatMessage} data
60
- */
61
- replaceMessage(data: IChatMessage): void;
62
- /**
63
- * 提问
64
- *
65
- * @author chitanda
66
- * @date 2023-10-09 20:10:43
67
- * @return {*} {Promise<void>}
68
- */
69
- question(input: string): Promise<void>;
70
- /**
71
- * 回填选中的消息
72
- *
73
- * @author chitanda
74
- * @date 2023-10-16 18:10:19
75
- * @param {IChatMessage} message
76
- */
77
- backfill(message: IChatMessage): void;
78
- /**
79
- *
80
- * 删除指定消息,如果是用户提问的刷新调用的删除,则需要删除从问题开始到最后的所有记录
81
- * @param {IChatMessage} message
82
- * @param {boolean} [isuser=false]
83
- * @memberof AiChatController
84
- */
85
- deleteMessage(message: IChatMessage): void;
86
- /**
87
- * 刷新当前消息
88
- *
89
- * @memberof AiChatController
90
- */
91
- refreshMessage(message: IChatMessage, isuser?: boolean): Promise<void>;
92
- /**
93
- * 复制消息
94
- *
95
- * @param {IChatMessage} message
96
- * @memberof AiChatController
97
- */
98
- copyMessage(message: IChatMessage): void;
99
- }
@@ -1,51 +0,0 @@
1
- import { AiChatController } from '..';
2
- import { IChatOptions } from '../../interface';
3
- /**
4
- * 聊天器控制器
5
- *
6
- * @author chitanda
7
- * @date 2023-10-13 17:10:47
8
- * @export
9
- * @class ChatController
10
- */
11
- export declare class ChatController {
12
- /**
13
- * 聊天框容器
14
- *
15
- * @author chitanda
16
- * @date 2023-10-13 17:10:03
17
- * @protected
18
- * @type {HTMLDivElement}
19
- */
20
- protected container?: HTMLDivElement;
21
- /**
22
- * 创建聊天窗口(会同时显示出来)
23
- *
24
- * @author chitanda
25
- * @date 2023-10-13 17:10:22
26
- */
27
- create(opts: IChatOptions): AiChatController;
28
- /**
29
- * 隐藏聊天窗口(必须先创建)
30
- *
31
- * @author chitanda
32
- * @date 2023-10-13 17:10:55
33
- */
34
- hidden(): void;
35
- /**
36
- * 显示聊天窗窗口(必须先创建)
37
- *
38
- * @author chitanda
39
- * @date 2023-10-13 17:10:29
40
- */
41
- show(): void;
42
- /**
43
- * 关闭聊天窗口
44
- *
45
- * @author chitanda
46
- * @date 2023-10-13 17:10:10
47
- */
48
- close(): void;
49
- }
50
- declare const chat: ChatController;
51
- export { chat };
@@ -1,2 +0,0 @@
1
- export { AiChatController } from './ai-chat/ai-chat.controller';
2
- export { ChatController, chat } from './chat/chat.controller';
@@ -1,28 +0,0 @@
1
- import { IChatMessage } from '../../interface';
2
- /**
3
- * 消息实体
4
- *
5
- * @author chitanda
6
- * @date 2023-10-09 16:10:45
7
- * @export
8
- * @class ChatMessage
9
- * @implements {IMessage}
10
- */
11
- export declare class ChatMessage implements IChatMessage {
12
- protected msg: IChatMessage;
13
- get messageid(): IChatMessage['messageid'];
14
- get state(): IChatMessage['state'];
15
- get role(): IChatMessage['role'];
16
- get type(): IChatMessage['type'];
17
- get content(): IChatMessage['content'];
18
- get _origin(): IChatMessage;
19
- constructor(msg: IChatMessage);
20
- /**
21
- * 更新消息
22
- *
23
- * @author chitanda
24
- * @date 2023-10-10 17:10:07
25
- * @param {IChatMessage} msg
26
- */
27
- update(msg: IChatMessage): void;
28
- }
@@ -1 +0,0 @@
1
- export { ChatMessage } from './chat-message/chat-message';
@@ -1,2 +0,0 @@
1
- import { PluginStaticResource } from './utils';
2
- export declare const resource: PluginStaticResource;
@@ -1 +0,0 @@
1
- export declare const CloseFullScreenSvg: () => import("preact").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const CloseSvg: () => import("preact").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const CopySvg: () => import("preact").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const DeleteSvg: () => import("preact").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const FillSvg: () => import("preact").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const FullScreenSvg: () => import("preact").JSX.Element;
@@ -1,8 +0,0 @@
1
- export { CloseSvg } from './close-svg';
2
- export { FillSvg } from './fill-svg';
3
- export { SendSvg } from './send-svg';
4
- export { DeleteSvg } from './delete-svg';
5
- export { RefreshSvg } from './refresh-svg';
6
- export { CopySvg } from './copy-svg';
7
- export { FullScreenSvg } from './full-screen-svg';
8
- export { CloseFullScreenSvg } from './close-full-screen-svg';
@@ -1 +0,0 @@
1
- export declare const RefreshSvg: () => import("preact").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const SendSvg: () => import("preact").JSX.Element;
@@ -1,2 +0,0 @@
1
- export { ChatContainer } from './components';
2
- export { chat } from './controller';
@@ -1,58 +0,0 @@
1
- /**
2
- * 聊天窗口呈现配置
3
- *
4
- * @author chitanda
5
- * @date 2023-10-15 19:10:04
6
- * @export
7
- * @interface IChatContainerOptions
8
- */
9
- export interface IChatContainerOptions {
10
- /**
11
- * 窗口 x 坐标
12
- *
13
- * @author chitanda
14
- * @date 2023-10-13 14:10:42
15
- * @type {number}
16
- */
17
- x?: number;
18
- /**
19
- * 窗口 y 坐标
20
- *
21
- * @author chitanda
22
- * @date 2023-10-13 14:10:52
23
- * @type {number}
24
- */
25
- y?: number;
26
- /**
27
- * 窗口宽度
28
- *
29
- * @author chitanda
30
- * @date 2023-10-13 14:10:56
31
- * @type {number}
32
- */
33
- width?: number;
34
- /**
35
- * 窗口高度
36
- *
37
- * @author chitanda
38
- * @date 2023-10-13 14:10:02
39
- * @type {number}
40
- */
41
- height?: number;
42
- /**
43
- * 窗口最小宽度
44
- *
45
- * @author chitanda
46
- * @date 2023-10-13 14:10:11
47
- * @type {number}
48
- */
49
- minWidth?: number;
50
- /**
51
- * 窗口最小高度
52
- *
53
- * @author chitanda
54
- * @date 2023-10-13 14:10:15
55
- * @type {number}
56
- */
57
- minHeight?: number;
58
- }
@@ -1,83 +0,0 @@
1
- import { IPortalAsyncAction } from '../i-portal-async-action/i-portal-async-action';
2
- /**
3
- * AI聊天消息
4
- *
5
- * @author chitanda
6
- * @date 2023-10-10 16:10:29
7
- * @export
8
- * @interface IChatMessage
9
- */
10
- export interface IChatMessage {
11
- /**
12
- * 消息标识
13
- *
14
- * @author chitanda
15
- * @date 2023-09-05 15:09:43
16
- * @type {string}
17
- */
18
- messageid: string;
19
- /**
20
- * 消息名称
21
- *
22
- * @author chitanda
23
- * @date 2023-09-05 15:09:49
24
- * @type {string}
25
- */
26
- messagename?: string;
27
- /**
28
- * 作业状态
29
- *
30
- * @author chitanda
31
- * @date 2023-10-10 15:10:59
32
- * @type {(10 | 20 | 30 | 40)} 未开始 | 执行中 | 已执行 | 执行失败
33
- */
34
- state: 10 | 20 | 30 | 40;
35
- /**
36
- * 消息类型
37
- *
38
- * @author chitanda
39
- * @date 2023-10-10 16:10:21
40
- * @type {string}
41
- */
42
- type: string | 'DEFAULT' | 'ERROR';
43
- /**
44
- * 消息子类型
45
- *
46
- * @author chitanda
47
- * @date 2023-10-10 16:10:00
48
- * @type {string}
49
- */
50
- subtype?: string;
51
- /**
52
- * 消息角色
53
- *
54
- * @author chitanda
55
- * @date 2023-10-10 16:10:32
56
- * @type {('ASSISTANT' | 'USER' | 'SYSTEM')} 助手 | 用户 | 系统
57
- */
58
- role: 'ASSISTANT' | 'USER' | 'SYSTEM';
59
- /**
60
- * 内容摘要
61
- *
62
- * @author chitanda
63
- * @date 2023-09-05 15:09:23
64
- * @type {string}
65
- */
66
- content: string;
67
- /**
68
- * 消息数据
69
- *
70
- * @author chitanda
71
- * @date 2023-09-05 15:09:55
72
- * @type {(IPortalAsyncAction | unknown)}
73
- */
74
- data?: IPortalAsyncAction | unknown;
75
- /**
76
- * 消息路径
77
- *
78
- * @author chitanda
79
- * @date 2023-09-05 15:09:25
80
- * @type {string}
81
- */
82
- url?: string;
83
- }
@@ -1,60 +0,0 @@
1
- import { IChatMessage } from '..';
2
- import { IChatContainerOptions } from '../i-chat-container/i-chat-container';
3
- /**
4
- * 聊天窗口配置参数
5
- *
6
- * @author chitanda
7
- * @date 2023-10-13 17:10:57
8
- * @export
9
- * @interface IChatOptions
10
- */
11
- export interface IChatOptions {
12
- /**
13
- * 聊天窗触发提问回调
14
- *
15
- * @author chitanda
16
- * @date 2023-10-16 14:10:06
17
- * @param {IChatMessage[]} question 提问历史内容(包含当前提问)
18
- * @return {*} {Promise<boolean>} 等待回答,用于显示 loading 并获取最终成功与否
19
- */
20
- question(question: IChatMessage[]): Promise<boolean>;
21
- /**
22
- * 窗口关闭后回调
23
- *
24
- * @author chitanda
25
- * @date 2023-10-15 19:10:25
26
- */
27
- closed?(): void;
28
- /**
29
- * 聊天窗任意位置点击操作
30
- *
31
- * @author chitanda
32
- * @date 2023-10-13 18:10:56
33
- * @param {string} action 操作的行为标识 backfill:回填 question:提问 deletemsg:删除消息 refreshmsg:刷新消息
34
- * @param {T} [params] 传递的参数
35
- * @return {*} {Promise<boolean>} 等待操作,用于显示 loading 并获取最终成功与否
36
- */
37
- action?<T = unknown>(action: 'backfill' | 'question' | 'deletemsg' | 'refreshmsg', params?: T): Promise<boolean>;
38
- /**
39
- * 全屏操作
40
- *
41
- * @param {boolean} target true为打开,false为关闭
42
- * @memberof IChatOptions
43
- */
44
- fullscreen?(target: boolean): void;
45
- /**
46
- * 聊天窗口呈现
47
- *
48
- * @author chitanda
49
- * @date 2023-10-15 19:10:44
50
- * @type {IChatContainerOptions}
51
- */
52
- containerOptions?: IChatContainerOptions;
53
- /**
54
- * 聊天窗口标题
55
- *
56
- * @type {string}
57
- * @memberof IChatOptions
58
- */
59
- caption?: string;
60
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * 项消息绘制适配器
3
- *
4
- * @author chitanda
5
- * @date 2023-10-09 16:10:11
6
- * @export
7
- * @interface IMessageItemProvider
8
- */
9
- export interface IMessageItemProvider {
10
- /**
11
- * 绘制的组件
12
- *
13
- * @author chitanda
14
- * @date 2023-10-09 16:10:38
15
- * @type {*}
16
- */
17
- component: any;
18
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * 异步作业信息
3
- *
4
- * @author chitanda
5
- * @date 2023-09-05 15:09:59
6
- * @export
7
- * @interface IPortalAsyncAction
8
- */
9
- export interface IPortalAsyncAction {
10
- /**
11
- * 会话标识
12
- *
13
- * @author chitanda
14
- * @date 2023-09-05 15:09:57
15
- * @type {string}
16
- */
17
- fulltopictag: string;
18
- /**
19
- * 异步作业类型
20
- *
21
- * @author chitanda
22
- * @date 2023-09-05 15:09:09
23
- * @type {string}
24
- */
25
- actiontype: string;
26
- /**
27
- * 作业状态
28
- *
29
- * @author chitanda
30
- * @date 2023-10-10 15:10:59
31
- * @type {(10 | 20 | 30 | 40)} 未开始 | 执行中 | 已执行 | 执行失败
32
- */
33
- actionstate: 10 | 20 | 30 | 40;
34
- /**
35
- * 异步作业执行结果
36
- *
37
- * @author chitanda
38
- * @date 2023-09-05 15:09:33
39
- * @type {unknown}
40
- */
41
- actionresult?: unknown;
42
- /**
43
- * 步骤信息
44
- *
45
- * @author chitanda
46
- * @date 2023-09-05 15:09:55
47
- * @type {string}
48
- */
49
- stepinfo?: string;
50
- /**
51
- * 异步结果下载路径,目前是留给导出数据使用
52
- *
53
- * @author chitanda
54
- * @date 2023-09-05 15:09:03
55
- * @type {string}
56
- */
57
- asyncresultdownloadurl?: string;
58
- /**
59
- * 预留参数
60
- *
61
- * @author chitanda
62
- * @date 2023-09-05 15:09:32
63
- * @type {unknown}
64
- */
65
- actionparam?: unknown;
66
- /**
67
- *预留参数2
68
- *
69
- * @author chitanda
70
- * @date 2023-09-05 15:09:41
71
- * @type {unknown}
72
- */
73
- actionparam2?: unknown;
74
- /**
75
- *预留参数3
76
- *
77
- * @author chitanda
78
- * @date 2023-09-05 15:09:43
79
- * @type {unknown}
80
- */
81
- actionparam3?: unknown;
82
- /**
83
- *预留参数4
84
- *
85
- * @author chitanda
86
- * @date 2023-09-05 15:09:45
87
- * @type {unknown}
88
- */
89
- actionparam4?: unknown;
90
- }
@@ -1,4 +0,0 @@
1
- export type { IChatMessage } from './i-chat-message/i-chat-message';
2
- export type { IChatOptions } from './i-chat-options/i-chat-options';
3
- export type { IMessageItemProvider } from './i-message-item-provider/i-message-item-provider';
4
- export type { IPortalAsyncAction } from './i-portal-async-action/i-portal-async-action';
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export { Namespace } from '@ibiz-template/scss-utils';
2
- export { PluginStaticResource } from './plugin-static-resource/plugin-static-resource';
3
- export { createUUID } from './util/util';